コード例 #1
0
ファイル: icc_runner.py プロジェクト: wpfu/cmos_linux
 def __init__(self, icc_dic):
     if not shutil.which("icc_shell"):
         raise Exception("icc is not loaded")
     self.icc_dic = icc_dic
     ced, _ = env_booter.EnvBooter().boot_env()
     src_dir = (
         os.path.abspath(os.path.expandvars(self.icc_dic["src"])) if self.icc_dic["src"] else
         f"{ced['FLOW_ICC']}{os.sep}src")
     time_str = ced['TIME'].strftime('%Y_%m_%d_%H_%M_%S')
     icct_dir = f"{ced['FLOW_ICC']}{os.sep}icc_{os.path.basename(src_dir)}_{time_str}"
     icc_dic_dir = os.path.abspath(os.path.expandvars(self.icc_dic["dir"]))
     if self.icc_dic["dir"]:
         if not os.path.isdir(icc_dic_dir):
             raise Exception(f"the input dir {icc_dic_dir} is NA.")
         icct_dir = icc_dic_dir
     if not self.icc_dic["dir"]:
         shutil.copytree(src_dir, icct_dir)
     self.icc_cfg_dic = pcom.gen_cfg([f"{icct_dir}{os.sep}icc.cfg"])
     self.stage_lst = self.icc_cfg_dic.options("icc_stage")
     logs_dir = f"{icct_dir}{os.sep}logs"
     self.dir_f_dic = {
         "icct_dir": icct_dir,
         "src_dir": src_dir,
         "logs_dir": logs_dir,
         "err_rpt": f"{logs_dir}{os.sep}err.rpt",
         "warn_rpt": f"{logs_dir}{os.sep}warning_rpt",
         "time": time_str}
コード例 #2
0
 def __init__(self, leda_dic):
     if not shutil.which("leda"):
         raise Exception("leda is not loaded")
     self.leda_dic = leda_dic
     self.ced, self.cfg_dic = ced, _ = env_booter.EnvBooter().boot_env()
     src_dir = (os.path.abspath(os.path.expandvars(leda_dic["leda_src"])) if
                leda_dic["leda_src"] else f"{ced['FLOW_LEDA']}{os.sep}src")
     leda_cfg_file = f"{src_dir}{os.sep}leda.cfg"
     if not os.path.isfile(leda_cfg_file):
         raise Exception(f"the leda cfg file {leda_cfg_file} is NA.")
     self.leda_cfg = pcom.gen_cfg([leda_cfg_file])
     leda_time_dir = (
         f"{ced['FLOW_LEDA']}{os.sep}{os.path.basename(src_dir)}__{leda_dic['leda_top']}__"
         f"{ced['TIME'].strftime('%Y_%m_%d_%H_%M_%S')}")
     self.df_dic = {
         "src_dir": src_dir,
         "time_dir": leda_time_dir,
         "log_dir": f"{leda_time_dir}{os.sep}leda_logs",
         "log": f"{leda_time_dir}{os.sep}leda_logs{os.sep}leda.log",
         "flist_file": f"{leda_time_dir}{os.sep}leda.flist",
         "tcl": f"{leda_time_dir}{os.sep}leda.tcl",
         "bbox_file": f"{src_dir}{os.sep}bbox_file",
         "rule_dir": f"{src_dir}{os.sep}leda_rule",
         "waiver_dir": f"{src_dir}{os.sep}leda_waiver"
     }
コード例 #3
0
ファイル: dc_runner.py プロジェクト: wpfu/cmos_linux
 def __init__(self, dc_dic):
     if not shutil.which("dc_shell"):
         raise Exception("dc is not loaded")
     self.ced, _ = ced, _ = env_booter.EnvBooter().boot_env()
     self.dc_dic = dc_dic
     dc_pre_str = "dct" if dc_dic["topo"] else "dc"
     self.src_dir = src_dir = (
         os.path.abspath(os.path.expandvars(self.dc_dic["src"]))
         if self.dc_dic["src"] else f"{ced['FLOW_DC']}{os.sep}src")
     self.dc_cfg_dic = dc_cfg_dic = pcom.gen_cfg([f"{src_dir}{os.sep}dc.cfg"])
     for base_key, base_value in self.dc_cfg_dic["base_args"].items():
         os.environ[base_key] = base_value
         self.ced[base_key] = base_value
     dc_time_dir = (
         f"{ced['FLOW_DC']}{os.sep}{dc_pre_str}_{os.path.basename(src_dir)}_"
         f"{dc_cfg_dic['base_args']['DESIGN_NAME']}_"
         f"{ced['TIME'].strftime('%Y_%m_%d_%H_%M_%S')}")
     dc_dic_dir = os.path.abspath(os.path.expandvars(self.dc_dic["dir"]))
     if self.dc_dic["dir"]:
         if not os.path.isdir(dc_dic_dir):
             raise Exception(f"the input dir {dc_dic_dir} is NA.")
         dc_time_dir = dc_dic_dir
     os.makedirs(dc_time_dir, exist_ok=True)
     self.dir_dic = {
         "dc_time_dir": dc_time_dir,
         "reports_dir": f"{dc_time_dir}{os.sep}reports",
         "results_dir": f"{dc_time_dir}{os.sep}results",
         "tcl_dir": f"{dc_time_dir}{os.sep}tcl"}
コード例 #4
0
ファイル: dc_runner.py プロジェクト: wpfu/cmos_linux
 def proc_dc(self):
     """to process and kick off dc flow"""
     if self.dc_dic["gen_tcl"]:
         self.gen_dir_dic()
         LOG.info("generating the tcl&sdc files from templates")
         dc_temp_dir = f"{self.src_dir}{os.sep}dc_template"
         for tcl_name in self.dc_cfg_dic.sections():
             if tcl_name == "base_args" or tcl_name == "set_args":
                 pcom.ren_tempfile(
                     f"{dc_temp_dir}{os.sep}set_args.tcl",
                     f"{self.dir_dic['tcl_dir']}{os.sep}set_args.tcl",
                     {"base_arg_dic": self.dc_cfg_dic["base_args"],
                      "set_arg_dic": self.dc_cfg_dic["set_args"]})
             else:
                 tn_str = tcl_name.replace('__', '.')
                 pcom.ren_tempfile(
                     f"{dc_temp_dir}{os.sep}{tn_str}",
                     f"{self.dir_dic['tcl_dir']}{os.sep}{tn_str}",
                     {"dc_dic":self.dc_cfg_dic})
     if self.dc_dic["run"]:
         dc_topo_str = (
             f"cd {self.dir_dic['dc_time_dir']} && "
             f"dc_shell {'-topo' if self.dc_dic['topo'] else ''} "
             f"-f {self.dir_dic['tcl_dir']}{os.sep}dc.tcl "
             f"-output_log_file {self.dir_dic['dc_time_dir']}{os.sep}dc.log ")
         try:
             proc = subprocess.Popen(dc_topo_str, shell=True)
             while proc.poll() is None:
                 time.sleep(180)
                 dc_log_parser.DcLogParser(self.ced, self.dc_cfg_dic).parse_log()
             dc_log_parser.DcLogParser(self.ced, self.dc_cfg_dic).parse_log()
         except KeyboardInterrupt:
             dc_log_parser.DcLogParser(self.ced, self.dc_cfg_dic).parse_log()
             proc.kill()
         if self.dc_dic["tm_flg"]:
             tm_rpt = os.path.join(self.dir_dic["reports_dir"], pcom.rd_cfg(
                 self.dc_cfg_dic, "set_args", "DCRM_FINAL_TIMING_REPORT", True))
             tm_log_parser.TmParser(
                 {"dt_file": tm_rpt, "level": self.dc_dic["tm_level"]}).parse_tm_log()
         if self.dc_dic["formality"]:
             if not shutil.which("fm_shell"):
                 raise Exception("fm is not loaded")
             LOG.info("updating the fm_dic and running formality")
             fm_cfg_dic = pcom.gen_cfg([f"{self.src_dir}{os.sep}fm.cfg"])
             fm_cfg_dic["fm"]["imp_filelist"] = os.linesep.join(
                 pcom.find_iter(self.dir_dic["results_dir"], "*.syn.v"))
             fm_cfg_dic["fm"]["set_svf"] = os.linesep.join(
                 pcom.find_iter(self.dir_dic["results_dir"], "*.syn.svf"))
             fm_cfg_dic["fm"]["DESIGN_NAME"] = pcom.rd_cfg(
                 self.dc_cfg_dic, "base_args", "DESIGN_NAME", True)
             fm_cfg_dic["fm"]["ref_filelist"] = pcom.rd_cfg(
                 self.dc_cfg_dic, "set_args", "rtl_files", True)
             fm_cfg_dic["fm"]["fm_top_dir"] = self.dir_dic["dc_time_dir"]
             fm_cfg_dic["fm"]["fm_src_dir"] = self.src_dir
             fm_runner.proc_fm(self.ced, fm_cfg_dic)
コード例 #5
0
ファイル: env_booter.py プロジェクト: wpfu/cmos_linux
 def module_env(self, sim_module):
     """to boot verification module level environments used only by pj"""
     self.boot_env()
     self.ced["MODULE"] = os.environ["MODULE"] = sim_module
     self.ced["PROJ_MODULE"] = os.environ["PROJ_MODULE"] = find_module_dir(
         self.ced, self.cfg_dic, sim_module)
     for env_key, env_value in (self.cfg_dic["proj"]["module_env"]
                                if "module_env" in self.cfg_dic["proj"] else
                                {}).items():
         os.environ[env_key] = os.path.expandvars(env_value)
         self.ced[env_key] = os.path.expandvars(env_value)
     c_cfg = f"{self.ced['MODULE_CONFIG']}{os.sep}c.cfg"
     if not os.path.isfile(c_cfg):
         c_cfg = ""
     self.cfg_dic["c"] = pcom.gen_cfg([c_cfg])
     simv_cfg = f"{self.ced['MODULE_CONFIG']}{os.sep}simv.cfg"
     if not os.path.isfile(simv_cfg):
         raise Exception(f"simv config file {simv_cfg} is NA")
     self.cfg_dic["simv"] = pcom.gen_cfg([simv_cfg])
     case_cfg = f"{self.ced['MODULE_CONFIG']}{os.sep}case.cfg"
     if not os.path.isfile(case_cfg):
         raise Exception(f"case config file {case_cfg} is NA")
     case_cfg_lst = [case_cfg]
     for cfg_file in pcom.find_iter(self.ced["MODULE_CONFIG"],
                                    "case_*.cfg"):
         LOG.info("more case config file %s", cfg_file)
         case_cfg_lst.append(cfg_file)
     case_cfg_lst.reverse()
     self.cfg_dic["case"] = pcom.gen_cfg(case_cfg_lst)
     c_module_env = copy.copy(self.cfg_dic["proj"]["env_c"] if "env_c" in
                              self.cfg_dic["proj"] else {})
     simv_module_env = copy.copy(self.cfg_dic["proj"]["env_simv"] if
                                 "env_simv" in self.cfg_dic["proj"] else {})
     case_module_env = copy.copy(self.cfg_dic["proj"]["env_case"] if
                                 "env_case" in self.cfg_dic["proj"] else {})
     c_module_env.update(self.cfg_dic["c"]["DEFAULT"])
     simv_module_env.update(self.cfg_dic["simv"]["DEFAULT"])
     case_module_env.update(self.cfg_dic["case"]["DEFAULT"])
     self.cfg_dic["c"]["DEFAULT"] = c_module_env
     self.cfg_dic["simv"]["DEFAULT"] = simv_module_env
     self.cfg_dic["case"]["DEFAULT"] = case_module_env
     return self.ced, self.cfg_dic
コード例 #6
0
 def test_gen_cfg(self):
     """test case"""
     cfg = pcom.gen_cfg([self.tmp_cfg1_file, self.tmp_cfg2_file])
     self.assertEqual(cfg["section1"]["key1"], "val1, val2")
     self.assertEqual(cfg["section1"]["key2"], f"val3,{os.linesep}val4")
     self.assertEqual(cfg["section2"]["key3"], f"val5{os.linesep}val6")
     self.assertEqual(cfg["section2"]["key4"], "val7=val8")
     self.assertEqual(cfg["section3"]["key5"], "")
     self.assertNotIn("key6", cfg["section3"])
     self.assertEqual(cfg["section3"]["key7"], "val9")
     self.assertEqual(cfg["section3"]["key8"], None)
     self.assertEqual(cfg["section4"]["key9"],
                      """`~!@#$%^&*()-_=+[{]}|;:'",<.>/?""")
コード例 #7
0
def proc_cdc(cdc_src):
    """to process cdc flow"""
    if not shutil.which("vlog"):
        raise Exception("qsim is not loaded")
    if not shutil.which("qverify"):
        raise Exception("formal is not loaded")
    ced, _ = env_booter.EnvBooter().boot_env()
    cdc_src_dir = (os.path.abspath(os.path.expandvars(cdc_src))
                   if cdc_src else f"{ced['FLOW_CDC']}{os.sep}src")
    cdc_cfg_dic = pcom.gen_cfg([f"{cdc_src_dir}{os.sep}cdc.cfg"])
    wv_cfg_dic = pcom.gen_cfg([f"{cdc_src_dir}{os.sep}waiver.cfg"])
    cdc_flist = pcom.rd_cfg(cdc_cfg_dic, "cdc", "design_flist")
    top = pcom.rd_cfg(cdc_cfg_dic, "cdc", "design_top")
    if not cdc_flist or not top:
        raise Exception(f"no cdc filelist or top name found in cfg")
    cdc_time_dir = (
        f"{ced['FLOW_CDC']}{os.sep}cdc_{os.path.basename(cdc_src_dir)}_"
        f"{top[0]}_{ced['TIME'].strftime('%Y_%m_%d_%H_%M_%S')}")
    os.makedirs(cdc_time_dir, exist_ok=True)
    pcom.ren_tempfile(f"{cdc_src_dir}{os.sep}template{os.sep}cdc.tcl",
                      f"{cdc_time_dir}{os.sep}cdc.tcl", cdc_cfg_dic["cdc"])
    compiler_err_pat = re.compile("|".join(
        [re.escape(cc) for cc in pcom.rd_cfg(cdc_cfg_dic, "cdc", "err_str")]))
    run_compiler(cdc_time_dir, cdc_flist, compiler_err_pat)
    if not os.path.isfile(f"{cdc_time_dir}{os.sep}failed"):
        cdc_str = (f"cd {cdc_time_dir} && "
                   f"qverify -c -do {cdc_time_dir}{os.sep}cdc.tcl "
                   f"-od {cdc_time_dir}{os.sep}Output_Results")
        subprocess.run(cdc_str, shell=True)
    dtl_rpt = f"{cdc_time_dir}{os.sep}Output_Results{os.sep}cdc_detail.rpt"
    if not os.path.isfile(dtl_rpt):
        raise Exception(f"report file {dtl_rpt} is not existed")
    result_lst = gen_post_wv(dtl_rpt, wv_cfg_dic)
    if result_lst:
        with open(f"{cdc_time_dir}{os.sep}post_waiver.rpt", "w") as pwr:
            for wv_rule in result_lst:
                pwr.write(wv_rule + os.linesep)
        LOG.warning(
            "post waived violations exists, please check post_waiver.rpt file")
コード例 #8
0
ファイル: env_booter.py プロジェクト: wpfu/cmos_linux
 def boot_env(self):
     """to boot top environments used only by pj"""
     os.environ["PROJ_ROOT"] = find_proj_root(os.getcwd())
     self.ced = {
         "PROJ_ROOT": os.environ["PROJ_ROOT"],
         "TIME": dt.datetime.now(),
         "USER_NAME": os.environ["USER"]
     }
     proj_cfg = os.path.expandvars("$PROJ_ROOT/share/config/proj.cfg")
     if not os.path.isfile(proj_cfg):
         raise Exception(f"proj config file {proj_cfg} is NA")
     self.cfg_dic = {"proj": pcom.gen_cfg([proj_cfg])}
     for env_key, env_value in (self.cfg_dic["proj"]["boot_env"]
                                if "boot_env" in self.cfg_dic["proj"] else
                                {}).items():
         os.environ[env_key] = os.path.expandvars(env_value)
         self.ced[env_key] = os.path.expandvars(env_value)
     return self.ced, self.cfg_dic
コード例 #9
0
def run_fm(args):
    """to run fm sub cmd"""
    if args.fm_ref_file and args.fm_imp_file:
        if not shutil.which("fm_shell"):
            raise Exception("fm is not loaded")
        ced, _ = env_booter.EnvBooter().boot_env()
        fm_src_dir = (os.path.abspath(os.path.expandvars(args.fm_src))
                      if args.fm_src else f"{ced['FLOW_FM']}{os.sep}src")
        fm_cfg_dic = pcom.gen_cfg([f"{fm_src_dir}{os.sep}fm.cfg"])
        LOG.info("gegerating ref related file and flag")
        ref_netlist_flag, ref_files = gen_fmfile(args.fm_ref_file)
        fm_cfg_dic["fm"]["ref_netlist_flag"] = str(ref_netlist_flag)
        fm_cfg_dic["fm"]["ref_filelist"] = ref_files
        LOG.info("gegerating imp related file and flag")
        imp_netlist_flag, imp_files = gen_fmfile(args.fm_imp_file)
        fm_cfg_dic["fm"]["imp_netlist_flag"] = str(imp_netlist_flag)
        fm_cfg_dic["fm"]["imp_filelist"] = imp_files
        fm_cfg_dic["fm"]["fm_top_dir"] = ced["FLOW_FM"]
        fm_cfg_dic["fm"]["fm_src_dir"] = fm_src_dir
        proc_fm(ced, fm_cfg_dic)
    else:
        raise Exception("missing main arguments")