def merge_conf_options(self):
        '''
        get the conf file setting, and merge them with command options
        '''
        _conf = self.scripts_options.get("conf")
        if not _conf:
            _conf = os.path.join(os.path.dirname(sys.argv[0]), "..", "conf")
        if os.path.isdir(_conf):
            pass
        else:
            if xTools.not_exists(_conf, "Default Configuration Path"):
                return 1
        _conf = os.path.abspath(_conf)

        self.scripts_options["conf"] = _conf

        conf_files = glob.glob(os.path.join(_conf, "*.ini"))
        if not conf_files:
            xTools.say_it("-Error. Not found any ini file under %s" % _conf)
            return 1
        sts, conf_options = xTools.get_conf_options(conf_files)
        if sts:
            return 1
        self._merge_options(conf_options)
        xTools.say_it(self.scripts_options,
                      "Merge User/Default Configuration Options", self.debug)
Beispiel #2
0
 def get_conf_options(self):
     self.conf_options = dict()
     if self.conf:
         ini_files = glob.glob(os.path.join(self.conf, "*.ini"))
         if ini_files:
             sts, self.conf_options = xTools.get_conf_options(ini_files)
             if sts:
                 return 1
         else:
             xTools.say_it("Warning. No ini file found in %s" % self.conf)
 def merge_file_options(self):
     user_file = self.scripts_options.get("file")
     if not user_file:
         return
     elif user_file:
         if xTools.not_exists(user_file, "User Configuration File"):
             return 1
     sts, file_options = xTools.get_conf_options(user_file)
     if sts:
         return 1
     self._merge_options(file_options)
     xTools.say_it(self.scripts_options, "Merge User Configuration Options",
                   self.debug)
    def process(self):
        sts, qas_options = xTools.get_conf_options(self.qas_file,
                                                   key_lower=False)
        if sts:
            return 1
        self.case_info = qas_options.get(self.case_info_name)
        if not self.case_info:
            xTools.say_it("Error. No [%s] in %s" %
                          (self.case_info_name, self.qas_file))
            return 1
        xTools.say_it(self.case_info, "[%s]" % self.case_info_name, self.debug)

        if self.parse_file_list():
            return 1
    def merge_local_options(self):
        if self.scuba_type:
            big_version, small_version = xLattice.get_diamond_version()
            xml_file = os.path.join(
                self.conf,
                "DiamondDevFile_%s%s.xml" % (big_version, small_version))
            my_convert = xConvert.ConvertScubaCase(self.src_design,
                                                   self.devkit, xml_file,
                                                   self.scuba_type,
                                                   self.scripts_options)
            sts = my_convert.process()
            if sts:
                return 1
            if self.scuba_only:
                return 1
        if self.info_file_name:
            t = os.path.join(self.src_design, self.info_file_name)
            if xTools.not_exists(t, "user specified info file"):
                return 1
            info_file = [t]
            len_info_file = 1
        else:
            info_file = glob.glob(os.path.join(self.src_design, "*.info"))
            len_info_file = len(info_file)
            if len_info_file > 1:
                xTools.say_it("-Error. Found %d info file under %s" %
                              (len_info_file, self.src_design))
                return 1

        if self.run_ice:
            if not len_info_file:  # read the project file directly
                ice_prj_files = glob.glob(
                    os.path.join(self.src_design, "par", "*.project"))
                if not ice_prj_files:
                    ice_prj_files = glob.glob(
                        os.path.join(self.src_design, "synthesis", "*",
                                     "*.project"))
                if not ice_prj_files:
                    ice_prj_files = glob.glob(
                        os.path.join(self.src_design, "project", "*", "*",
                                     "*.project"))
                if xTools.check_file_number(ice_prj_files,
                                            "iCEcube2 project file"):
                    return 1
                local_options = self.get_ice_project_options(ice_prj_files[0])
                self._merge_options(local_options)
                self.scripts_options["same_ldf_dir"] = os.path.dirname(
                    ice_prj_files[0])
                self.scripts_options["use_ice_prj"] = 1

            else:
                sts, info_dict = xTools.get_conf_options(info_file)
                if sts:
                    return 1
                qa_info_dict = info_dict.get("qa")
                if qa_info_dict:
                    project_file = qa_info_dict.get("project_file")
                else:
                    project_file = ""

                if project_file:
                    local_options = self.get_ice_project_options(project_file)
                    self.scripts_options["same_ldf_dir"] = os.path.dirname(
                        project_file)
                    self.scripts_options["use_ice_prj"] = 1
                    self._merge_options(local_options)
                else:
                    self.scripts_options["same_ldf_dir"] = os.path.dirname(
                        info_file[0])
                    self._merge_options(info_dict)

        else:
            if not len_info_file:  # No info file found
                ldf_file = glob.glob(
                    os.path.join(self.src_design, "par", "*.ldf"))
                if not ldf_file:
                    ldf_file = glob.glob(os.path.join(self.src_design,
                                                      "*.ldf"))
                if xTools.check_file_number(ldf_file, "Diamond Project File"):
                    return 1
                self.scripts_options["ldf_file"] = ldf_file[0]
                others_path = os.path.join(self.src_design, "others")
                if os.path.isdir(others_path):
                    self.scripts_options["others_path"] = "./others"
            else:
                sts, local_options = xTools.get_conf_options(info_file)
                if sts:
                    return 1
                real_info_file = info_file[0]
                if xTools.get_fname(real_info_file) == "_qas":
                    new_local_options = qas.get_local_bqs_options(
                        self.conf, local_options, self.src_design)
                    if not new_local_options:
                        xTools.say_it(
                            "-Error. can not get the local info options from _qas.info file"
                        )
                        return 1
                    self._merge_options(new_local_options)
                    # self.generate_check_conf_file(real_info_file)
                else:
                    self._merge_options(local_options)
        xTools.say_it(self.scripts_options, "Final Options", self.debug)
Beispiel #6
0
    def flatten_options(self):
        foundry_path = os.getenv("FOUNDRY")
        if xTools.not_exists(foundry_path, "Foundry Path"):
            return 1

        self.src_design = self.flow_options.get("src_design")
        self.dst_design = self.flow_options.get("dst_design")
        self.synthesis = self.flow_options.get("synthesis")
        if not self.synthesis:
            self.synthesis = "synplify"

        self.sim_rtl = xTools.get_true(self.flow_options, "sim_rtl")
        self.sim_syn_vlg = xTools.get_true(self.flow_options, "sim_syn_vlg")
        self.sim_syn_vhd = xTools.get_true(self.flow_options, "sim_syn_vhd")

        self.sim_map_vlg = xTools.get_true(self.flow_options, "sim_map_vlg")
        self.sim_map_vhd = xTools.get_true(self.flow_options, "sim_map_vhd")
        self.sim_par_vlg = xTools.get_true(self.flow_options, "sim_par_vlg")
        self.sim_par_vhd = xTools.get_true(self.flow_options, "sim_par_vhd")
        self.sim_all = xTools.get_true(self.flow_options, "sim_all")
        self.simrel_path = self.flow_options.get("simrel_path")
        self.run_simrel = self.flow_options.get("run_simrel")
        self.pmi = xTools.get_true(self.flow_options, "pmi")
        self.lst_precision = self.flow_options.get("lst_precision")
        if self.sim_all:
            self.sim_rtl = self.sim_map_vhd = self.sim_map_vlg = self.sim_par_vhd = self.sim_par_vlg = 1
            self.sim_syn_vlg = 1
        if self.sim_syn_vlg:
            self.sim_syn_vhd = 0
        others_path = self.flow_options.get("others_path")
        if others_path:
            others_path = os.path.join(self.src_design, others_path)
            if os.path.isdir(others_path):
                self.others_path = others_path
        else:
            self.others_path = ""

        sim_section = self.flow_options.get("sim")
        if not sim_section:
            xTools.say_it("-Error. Not any simulation settings found.")
            return 1
        self.dev_lib = sim_section.get("dev_lib")
        self.pri_lib = sim_section.get("pri_lib")
        self.src_lib = sim_section.get("src_lib")

        diamond = os.path.dirname(foundry_path)
        self.diamond = diamond = xTools.win2unix(diamond)
        if self.pri_lib:
            self.pri_lib = re.sub('\$diamond', diamond,
                                  xTools.win2unix(self.pri_lib, 0))
        else:
            self.pri_lib = "work"
        if self.src_lib:
            self.src_lib = re.sub('\$diamond', diamond,
                                  xTools.win2unix(self.src_lib, 0))
        else:
            self.src_lib = ""

        self.tb_file = sim_section.get("tb_file")
        self.tb_vector = sim_section.get("tb_vector")
        self.sim_top = sim_section.get("sim_top")
        if not self.sim_top:
            self.sim_top = "sim_top"
        self.src_top_module = sim_section.get("src_top_module")
        if not self.src_top_module:
            self.src_top_module = self.sim_top
        self.uut_name = sim_section.get("uut_name")
        self.resolution = sim_section.get("resolution")
        if not self.uut_name:
            self.uut_name = "UUT"
        self.sim_time = sim_section.get("sim_time")
        self.do_msim = sim_section.get("do_msim")
        self.do_qsim = sim_section.get("do_qsim")
        self.do_ahdl = sim_section.get("do_asim")
        self.do_riviera = sim_section.get("do_rsim")

        _conf = self.flow_options.get("conf")
        if not self.do_msim:
            self.do_msim = os.path.join(_conf, "sim", "msim_do.template")
        if not self.do_qsim:
            self.do_qsim = os.path.join(_conf, "sim", "qsim_do.template")
        if not self.do_riviera:
            self.do_riviera = os.path.join(_conf, "sim", "rsim_do.template")
        if not self.do_ahdl:
            if self.pmi:
                self.do_ahdl = os.path.join(_conf, "sim", "pmi_ahdl.template")
            else:
                self.do_ahdl = os.path.join(_conf, "sim", "ahdl_do.template")

        self.run_modelsim = xTools.get_true(self.flow_options, "run_modelsim")
        self.run_questasim = xTools.get_true(self.flow_options,
                                             "run_questasim")
        self.run_riviera = xTools.get_true(self.flow_options, "run_riviera")

        if self.run_modelsim:
            self.do_template = self.do_msim
            self.sim_vendor_name = "Modelsim"
        elif self.run_questasim:
            self.do_template = self.do_qsim
            self.sim_vendor_name = "QuestaSim"
        elif self.run_riviera:
            self.do_template = self.do_riviera
            self.sim_vendor_name = "Riviera"
        else:
            self.do_template = self.do_ahdl
            self.sim_vendor_name = "Active"
        if not os.path.isfile(self.do_template):
            self.do_template = xTools.get_abs_path(self.do_template,
                                                   self.src_design)
        if xTools.not_exists(self.do_template, "DO Template File"):
            return 1

        bali_node = self.final_ldf_dict.get("bali")
        impl_node = self.final_ldf_dict.get("impl")
        # -------------
        # Fix bugs for getting impl name
        #<BaliProject version="3.2" title="top" device="LFE5UM-85F-6MG285C" default_implementation="DV100V1">
        #<Options/>
        # <Implementation title="DV100V1" dir="Video" description="Video" synthesis="synplify" default_strategy="Video_timing">

        self.impl_name = bali_node.get("default_implementation")
        self.impl_dir = impl_node.get("dir")
        if not self.impl_dir:
            self.impl_dir = self.impl_name
        #

        self.project_name = bali_node.get("title")

        #
        device = bali_node.get("device")
        big_version, small_version = xLattice.get_diamond_version()
        xml_file = os.path.join(
            _conf, "DiamondDevFile_%s%s.xml" % (big_version, small_version))
        self.devkit_parser = xLatticeDev.DevkitParser(xml_file)
        if self.devkit_parser.process():
            return 1
        std_devkit = self.devkit_parser.get_std_devkit(device)
        if not std_devkit:
            xTools.say_it("Error. Unknown device %s" % device)
            return 1
        family_name = std_devkit.get("family")
        conf_file = os.path.join(_conf, "sim", "map_lib.ini")
        if xTools.not_exists(conf_file, "Simulation Library Pairs File"):
            return 1
        sts, raw_lib_dict = xTools.get_conf_options(conf_file)
        if sts:
            return 1
        my_dict = raw_lib_dict.get("family_map_sim_lib")
        fam_lower = family_name.lower()
        map_lib_name = my_dict.get(fam_lower)
        if not map_lib_name:
            map_lib_name = fam_lower
            xTools.say_it("Message: Use map lib name: %s" % fam_lower)

        if self.dev_lib:
            map_lib_name = self.dev_lib
            map_lib_name = re.sub("ovi_", "", map_lib_name)
        else:
            if self.run_modelsim or self.run_questasim or self.run_riviera:
                self.create_dev_lib(map_lib_name)
            else:
                self.dev_lib = os.path.join(foundry_path, "..", "active-hdl",
                                            "Vlib", "ovi_" + map_lib_name,
                                            "ovi_" + map_lib_name + ".lib")
        self.dev_lib = os.path.abspath(self.dev_lib)

        # self.pri_lib = "work"

        self.do_args = dict()
        self.do_args["sim_top"] = self.sim_top
        self.do_args["src_top_module"] = self.src_top_module
        self.do_args["uut_name"] = self.uut_name
        self.do_args["lib_name"] = "ovi_" + map_lib_name
        self.do_args["dev_name"] = map_lib_name
        self.do_args["diamond"] = os.path.dirname(
            foundry_path
        )  # On Linux, ENV-KEY FOUNDRY and foundry are different
        if self.resolution:
            self.do_args["resolution"] = "-t %s" % self.resolution
        else:
            self.do_args["resolution"] = ""

        if self.sim_time:
            _sim_time = self.sim_time
        else:
            _sim_time = "10 us"
        self.do_args["sim_time"] = _sim_time
    def prepare_kwargs(self):
        self.conf = self.flow_options.get("conf")
        same_ldf_dir = self.flow_options.get("same_ldf_dir")
        use_ice_prj = self.flow_options.get("use_ice_prj")
        self.kwargs = dict()
        if use_ice_prj:
            _project = self.flow_options.get("Project")

            implmnt_path = _project.get("Implementations")
            if not implmnt_path:
                xTools.say_it(
                    "-Error. Not found Implementations in project file")
                return 1

            self.kwargs["ProjectName"] = _project.get("ProjectName",
                                                      "DEF_PRJ_NAME")
            self.kwargs["implmnt_path"] = implmnt_path

            _src_files = _project.get("ProjectVFiles")
            _sdc_file = _project.get("ProjectCFiles")
            if _sdc_file:
                _sdc_file = xTools.get_relative_path(_sdc_file, same_ldf_dir)
            sdc_file = self.flow_options.get("sdc_file")
            ldc_file = self.flow_options.get("ldc_file")
            if sdc_file:
                sdc_file = xTools.get_relative_path(sdc_file, same_ldf_dir)
            if ldc_file:
                ldc_file = xTools.get_relative_path(ldc_file, same_ldf_dir)

            _src_files = re.split(",", _src_files)

            _src_files = [re.sub("=\w+", "", item) for item in _src_files]
            _src_files = [[xTools.get_relative_path(item, same_ldf_dir)]
                          for item in _src_files]

            #####################
            _implmnt = self.flow_options.get(implmnt_path)
            if not _implmnt:
                xTools.say_it("Error. Not found section: %s" % implmnt_path)
                return 1

            self.kwargs["DeviceFamily"] = _implmnt.get("DeviceFamily")
            self.kwargs["Device"] = _implmnt.get("Device")
            self.kwargs["DevicePackage"] = _implmnt.get("DevicePackage")

        else:
            _devkit = self.flow_options.get("devkit")
            _top_name = self.flow_options.get("top_module")
            _src_files = self.flow_options.get("src_files")
            _sdc_file = ""
            for item in _src_files:
                fext = xTools.get_fext_lower(item)
                if fext == ".sdc":
                    _sdc_file = item
                    break
            sdc_file = self.flow_options.get("sdc_file")
            ldc_file = self.flow_options.get("ldc_file")
            if sdc_file:
                sdc_file = xTools.get_relative_path(sdc_file, same_ldf_dir)
            if ldc_file:
                ldc_file = xTools.get_relative_path(ldc_file, same_ldf_dir)
            _src_files = [[xTools.get_relative_path(item, same_ldf_dir)]
                          for item in _src_files]

            implmnt_path = _top_name + "_Implmnt"
            _implmnt = dict()
            self.kwargs["ProjectName"] = _top_name
            self.kwargs["implmnt_path"] = implmnt_path
            self.kwargs["source_files"] = _src_files
            _dev_list = re.split("\s*,\s*", _devkit)

            self.kwargs["DeviceFamily"], self.kwargs["Device"], self.kwargs[
                "DevicePackage"] = _dev_list

        # --------------
        self.synthesis = self.flow_options.get("synthesis")

        if not self.synthesis:
            self.synthesis = "synplify"
        if self.synthesis == "synplify":
            _source_files = super_run.get_synp_source_files(_src_files)

            if sdc_file:
                kk = sdc_file
            elif _sdc_file:
                kk = _sdc_file
            else:
                kk = ""
            if kk:
                sdc_file = "add_file -constraint %s" % kk
            else:
                sdc_file = ""
        else:
            _source_files = super_run.get_lse_source_files(_src_files)
            if ldc_file:
                sdc_file = "-sdc %s" % ldc_file
            else:
                sdc_file = ""
        self.kwargs["source_files"] = _source_files
        self.kwargs["sdc_file"] = sdc_file
        # --------------

        _goal = self.flow_options.get("goal")
        _frequency = self.flow_options.get("frequency")
        if not _frequency:
            if self.synthesis == "lse":
                _frequency = 200
            else:
                _frequency = "Auto"
        _mixed_drivers = xTools.get_true(self.flow_options, "mixed_drivers")
        if _mixed_drivers:
            _mixed_drivers = "-resolve_mixed_drivers 1"  # For LSE
        else:
            _mixed_drivers = ""
        self.kwargs["mixed_drivers"] = _mixed_drivers
        if not _goal:
            _goal = "Timing"
        self.kwargs["goal"] = _goal
        self.kwargs["frequency"] = _frequency
        _DesignCell = _implmnt.get("DesignCell")
        if not _DesignCell:
            _DesignCell = self.kwargs["ProjectName"]
        self.kwargs["DesignCell"] = _DesignCell
        self.kwargs["cwd"] = xTools.win2unix(os.getcwd())
        self.kwargs["ice_opt_path"] = self.ice_opt_path
        ice_map_file = os.path.join(self.conf, "ice_synthesis", "ice.map")
        sts, ice_map_options = xTools.get_conf_options(ice_map_file,
                                                       key_lower=False)
        if sts:
            return sts

        _family = ice_map_options.get(self.kwargs.get("DeviceFamily"))
        if not _family:
            xTools.say_it("Warning. Not support Family: %s" %
                          self.kwargs.get("DeviceFamily"))
            return 1
        dev_lib = _family.get(self.kwargs.get("Device"))
        if not dev_lib:
            xTools.say_it("Warning. Not support %s" %
                          self.kwargs.get("Device"))
            return 1
        dev, lib = re.split("\s*,\s*", dev_lib)

        self.kwargs["dev_file"] = os.path.abspath(
            os.path.join(self.ice_root_path, "sbt_backend", "devices", dev))
        self.kwargs["lib_file"] = xTools.win2unix(
            os.path.join(self.ice_root_path, "sbt_backend", "devices", lib))

        # create dir
        _sbt_path = os.path.join(os.getcwd(), implmnt_path, "sbt")
        for item in ("bitmap", "gui", "netlister", "packer", "placer",
                     "router", "simulation_netlist", "timer"):
            tt = os.path.join(_sbt_path, "outputs", item)
            xTools.wrap_md(tt, "ice results path")

        for item in ("netlist", "sds"):
            tt = os.path.join(_sbt_path, "outputs", item)
            xTools.wrap_md(tt, "ice results path")
        self.kwargs["sdc_translator"] = os.path.abspath(
            os.path.join(self.ice_root_path,
                         r"sbt_backend\bin\sdc_translator.tcl"))

        info_line = "%s%s-%s" % (self.kwargs["DeviceFamily"],
                                 self.kwargs["Device"],
                                 self.kwargs["DevicePackage"])
        xTools.append_file(
            os.path.join(_sbt_path, "outputs", "device_info.txt"), info_line,
            False)

        tool_options = self.flow_options.get("tool options", dict())
        _BitmapInitRamBank = tool_options.get("BitmapInitRamBank")
        if not _BitmapInitRamBank:
            _BitmapInitRamBank = "1111"
        self.kwargs["BitmapInitRamBank"] = _BitmapInitRamBank