コード例 #1
0
    def run_synplify_flow(self, src_files, kwargs):
        if not self.run_synthesis:
            return
        kwargs["source_files"] = self.get_synp_source_files(src_files)
        if self.inc_path:
            _inc_path = xTools.to_abs_list(self.inc_path, self.src_design)
        else:
            _inc_path = list()
        _inc_path.append(xTools.win2unix(os.getcwd()))
        kwargs["search_path"] = "{%s}" % ";".join(_inc_path)
        if self.top_module:
            _tm = 'set_option -top_module "%s"' % self.top_module
        else:
            _tm = ''
        kwargs["top_module"] = _tm

        prj_template = os.path.join(self.conf, "synthesis", "run_synplify.prj")
        if xTools.not_exists(prj_template, "Synplify Project Template"):
            return 1
        synplify_prj_file = "run_synplify.prj"
        xTools.generate_file(synplify_prj_file, prj_template, kwargs)

        synplify_cmd = 'synpwrap -prj "%s"' % synplify_prj_file
        sts = xTools.run_command(synplify_cmd, "my_run_synplify.log",
                                 "my_run_synplify.time")
        return sts
コード例 #2
0
def compile_library(*args):
    diamond_path, hdl_type, family, sim_name, sim_bin_path = args
    family = family.lower()  # change case due to Linux platform
    cae_path = os.path.join(diamond_path, "cae_library")
    lib_file_dict = get_lib_file_dict(cae_path, hdl_type, family)
    compile_bat_file = "Compile_%s.bat" % sim_name
    bat_lines = list()
    vlib_cmd = "%s/vlib" % sim_bin_path
    vcom_cmd = "%s/vcom" % sim_bin_path
    vlog_cmd = "%s/vlog" % sim_bin_path
    vhdl_files = lib_file_dict.get("vhdl")
    verilog_files = lib_file_dict.get("verilog")
    bat_lines.append("%s/vmap -del %s" % (sim_bin_path, sim_name))
    if vhdl_files:
        bat_lines.append("%s %s" % (vlib_cmd, sim_name))
        bat_lines += vcom_vlog_file_lines(vhdl_files, vcom_cmd, vlog_cmd,
                                          sim_name)
    elif verilog_files:
        bat_lines.append("%s %s" % (vlib_cmd, sim_name))
        bat_lines += vcom_vlog_file_lines(verilog_files, vcom_cmd, vlog_cmd,
                                          sim_name)
    xTools.write_file(compile_bat_file, bat_lines)
    on_win, os_name = xTools.get_os_name()
    if not on_win:
        compile_bat_file = "sh %s" % compile_bat_file
    sts = xTools.run_command(compile_bat_file, "%s.log" % sim_name,
                             "%s.time" % sim_name)
    return sts
コード例 #3
0
    def run_test_process(self):
        # synthesize flow
        if self.synthesis == "synplify":
            template_file = os.path.join(self.conf, "ice_synthesis",
                                         "run_synplify.prj")
            prj_file = "run_synplify.prj"
        else:
            template_file = os.path.join(self.conf, "ice_synthesis",
                                         "run_lse.synproj")
            prj_file = "run_lse.synproj"
        if xTools.not_exists(template_file, "Template file"):
            return 1
        xTools.generate_file(prj_file, template_file, self.kwargs)

        if self.synthesis == "synplify":
            syn_cmd = "%s -prj %s" % (self.synpwrap_exe, prj_file)
        else:
            syn_cmd = "%s -f %s" % (self.lse_exe, prj_file)

        sts = xTools.run_command(syn_cmd, "run_synthesis.log",
                                 "run_synthesis.time")
        if sts:
            return 1

        for command in ("edifparser", "sbtplacer", "packer_drc", "packer",
                        "sbrouter", "netlister", "sbtimer", "bitmap"):
            sts = self.runit.run_flow(command, self.kwargs)
            if sts:
                return sts
コード例 #4
0
    def run_lse_flow(self, src_files, kwargs):
        synthesis_cmd = self.section_cmd.get("synthesis")
        new_src_files = self.get_lse_source_files(src_files)
        if not self.run_synthesis:
            return
        if synthesis_cmd:
            sts, lse_cmd = xTools.get_cmd(synthesis_cmd,
                                          dict(src_files=new_src_files))
            if sts:
                return 1
            # sometimes the user do NOT use -f for specify the source files
            lse_cmd = re.sub("\s+", " ", lse_cmd)
            sts = xTools.run_command(lse_cmd, "my_run_lse.log",
                                     "my_run_lse.time")
            return sts
        # ---------------------
        if not self.synp_goal:
            self.synp_goal = "Timing"
        else:
            self.synp_goal = self.synp_goal.capitalize()
        kwargs["goal"] = self.synp_goal

        _tm = ""
        if self.top_module:
            _tm = "-top %s" % self.top_module
        kwargs["top_module"] = _tm

        if self.inc_path:
            _inc_path = xTools.to_abs_list(self.inc_path, self.src_design)
        else:
            _inc_path = list()
        _inc_path.append(xTools.win2unix(os.getcwd()))
        kwargs["search_path"] = '"%s"' % '" '.join(_inc_path)
        kwargs["source_files"] = new_src_files

        synproj_template = os.path.join(self.conf, "synthesis",
                                        "run_lse.synproj")
        if xTools.not_exists(synproj_template, "LSE Project Template"):
            return 1
        lse_synproj_file = "run_lse.synproj"
        xTools.generate_file(lse_synproj_file, synproj_template, kwargs)

        lse_cmd = "synthesis -f %s" % lse_synproj_file
        sts = xTools.run_command(lse_cmd, "my_run_lse.log", "my_run_lse.time")
        return sts
コード例 #5
0
def create_diamond_dev_xml(xml_file):
    if os.path.isfile(xml_file):
        return
    create_cmd = "createdevfile -file %s" % xml_file
    sts = xTools.run_command(create_cmd, "create_dev_xml.log",
                             "create_dev_xml.time")
    if sts:
        # ------ copy the default xml file
        sts = xTools.wrap_cp_file("default.xml", xml_file)
    return sts
コード例 #6
0
 def run_flow(self, cmd_name, cmd_args, seed_number=0):
     cmd_template = self.template_dict.get(cmd_name)
     if not cmd_template:
         cmd_template = self.default_tmpl.get(cmd_name)
     if not cmd_template:
         xTools.say_it("- Error. Not support %s" % cmd_name)
         return 1
     sts, cmd = xTools.get_cmd(cmd_template, cmd_args)
     if sts:
         return 1
     if cmd_name == "par":
         if seed_number:
             cmd = re.sub("-t\s+\d+", "-t %d" % seed_number, cmd)
     return xTools.run_command(cmd, self.log_file, self.time_file)
コード例 #7
0
    def _run_simulation(self, sim_path, source_files, user_options):
        if xTools.wrap_md(sim_path, "Simulation Path"):
            return 1

        _recov = xTools.ChangeDir(sim_path)
        if self.copy_tb_files(""):
            _recov.comeback()
            return 1
        use_source_do_file = 0
        if not user_options:  # rtl simulation
            if self.others_path:
                self.copy_other_files()
            src_lines = xTools.get_content_in_start_end(
                self.do_template, self.p_src_start, self.p_src_end)
            for src in src_lines:
                if re.search("(vlog|vcom)", src):
                    use_source_do_file = 1

        do_lines = list()
        need_remove_ovi = 0
        if use_source_do_file:  # modify do file and use it!
            start_source = 0
            start_tb = 0
            for line in open(self.do_template):
                line = line.rstrip()
                m_src_start = self.p_src_start.search(line)
                m_src_end = self.p_src_end.search(line)
                m_tb_start = self.p_tb_start.search(line)
                m_tb_end = self.p_tb_end.search(line)
                if not start_source:
                    start_source = m_src_start
                if m_src_end:
                    start_source = 0

                if not start_tb:
                    start_tb = m_tb_start
                if m_tb_end:
                    start_tb = 0

                if not (start_source or start_tb):
                    do_lines.append(line)
                elif start_source or start_tb:
                    new_line = get_new_real_path(self.do_template, line)
                    if start_source:
                        line_list = re.split("\s+", line.strip())
                        if line_list[0] in ("vlog", "vcom"):
                            hdl_file = line_list[-1]
                            real_hdl_file = xTools.get_relative_path(
                                hdl_file, os.getcwd())
                            if not os.path.isfile(real_hdl_file):
                                real_hdl_file = xTools.get_relative_path(
                                    hdl_file, os.path.join("../../sim"))
                            if not os.path.isfile(real_hdl_file):
                                pass
                            else:
                                modified, real_hdl_file = get_real_hdl_file(
                                    real_hdl_file, self.run_scuba)
                                cur_fext = xTools.get_fext_lower(real_hdl_file)
                                if modified:
                                    if cur_fext == ".vhd":
                                        line_list = ["vcom", ""]
                                    else:
                                        line_list = ["vlog", ""]
                                line_list[-1] = real_hdl_file
                                if not need_remove_ovi:
                                    if xTools.get_fext_lower(
                                            real_hdl_file) in (".vho", ".vhd",
                                                               ".vhdl"):
                                        need_remove_ovi = 1
                                new_line = " ".join(line_list)
                    do_lines.append(new_line)
        else:
            start_source = start_tb = 0
            for line in open(self.do_template):
                line = line.rstrip()
                if re.search("%", line):
                    line = line % self.do_args
                    do_lines.append(line)
                    continue
                if start_source:
                    if self.p_src_end.search(line):
                        if not user_options:  # RTL simulation
                            source_files = [
                                xTools.get_relative_path(
                                    item, self.dst_design)
                                for item in source_files
                            ]
                        v_v_line = self.add_vlog_vcom_lines(source_files)
                        if not v_v_line:
                            xTools.say_it(
                                "Error. Not any source files for running %s" %
                                sim_path)
                            xTools.say_it("")
                            _recov.comeback()
                            return 1
                        need_remove_ovi = self.use_vhd
                        do_lines += v_v_line[:]
                        start_source = 0
                        do_lines.append(line)
                    continue
                else:
                    start_source = self.p_src_start.search(line)
                    if start_source:
                        do_lines.append(line)
                        continue

                if start_tb:
                    if self.p_tb_end.search(line):
                        _kk = self.use_vhd
                        v_v_line = self.add_vlog_vcom_lines(
                            self.final_tb_files, add_tb=1)
                        self.use_vhd = _kk
                        do_lines += v_v_line[:]
                        start_tb = 0
                        do_lines.append(line)
                    continue
                else:
                    start_tb = self.p_tb_start.search(line)
                    if start_tb:
                        do_lines.append(line)
                        continue
                do_lines.append(line)
        do_file = "do_%s.do" % sim_path

        new_do_lines = list()
        lib_name = xTools.get_fname(self.dev_lib)
        if need_remove_ovi:
            lib_name = re.sub("ovi_", "", lib_name)

        p1 = re.compile("vmap\s+(\S+)\s+(\$dev_lib)")
        p2 = ""
        tmp_lib_name = ""
        for _ in do_lines:
            if p1:
                m1 = p1.search(_)
                if m1:
                    p1 = ""
                    p2 = re.compile("vsim.+\s+-L\s+%s" % m1.group(1))
                    tmp_lib_name = m1.group(1)
                    _ = "vmap %s %s" % (lib_name, m1.group(2))
            elif p2:
                m2 = p2.search(_)
                if m2:
                    p2 = ""
                    _ = re.sub("-L\s+%s" % tmp_lib_name, "-L %s" % lib_name, _)
            new_do_lines.append(_)
        xTools.write_file(do_file, new_do_lines)
        utils.update_simulation_do_file(self.sim_vendor_name, do_file,
                                        self.lst_precision)

        args = "%s %s %s cmd %s %s" % (do_file, self.dev_lib, self.pri_lib,
                                       self.diamond, self.src_lib)

        if self.run_modelsim or self.run_questasim:
            sim_cmd = '%s/vsim -l sim_log.txt -c -do "do %s"' % (
                self.sim_vendor_bin, args)
        else:
            sim_cmd = "%s/vsimsa -l sim_log.txt -do %s" % (self.sim_vendor_bin,
                                                           args)
        sim_cmd = xTools.win2unix(sim_cmd, 0)
        if need_remove_ovi:
            sim_cmd = re.sub("ovi_", "", sim_cmd)
        # /*
        #  * If license not found, will launch again in 10 times.
        #  */
        log_file = "run_%s.log" % sim_path
        time_file = "run_%s.time" % sim_path
        sts = 0
        for i in range(10):
            if xTools.remove_dir_without_error(log_file):
                _recov.comeback()
                return 1
            sts = xTools.run_command(sim_cmd, log_file, time_file)
            if sts:
                if xTools.simple_parser(
                        log_file,
                    [re.compile("Unable to checkout a license")]):
                    xTools.say_it(
                        "Warning. No licence for running simulation. waiting ..."
                    )
                    time.sleep(i * 10)
                else:
                    break
            else:
                break
        dump_vcd_file()

        _recov.comeback()
        return sts