• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tools.write_to_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中migen.build.tools.write_to_file函数的典型用法代码示例。如果您正苦于以下问题:Python write_to_file函数的具体用法?Python write_to_file怎么用?Python write_to_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了write_to_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: build

    def build(
        self,
        platform,
        fragment,
        build_dir="build",
        build_name="top",
        toolchain_path="/opt/Xilinx/Vivado",
        source=True,
        run=True,
    ):
        os.makedirs(build_dir, exist_ok=True)
        cwd = os.getcwd()
        os.chdir(build_dir)

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)
        self._convert_clocks(platform)
        v_output = platform.get_verilog(fragment)
        named_sc, named_pc = platform.resolve_signals(v_output.ns)
        v_file = build_name + ".v"
        v_output.write(v_file)
        sources = platform.sources | {(v_file, "verilog", "work")}
        self._build_batch(platform, sources, build_name)
        tools.write_to_file(build_name + ".xdc", _build_xdc(named_sc, named_pc))
        if run:
            _run_vivado(build_name, toolchain_path, source)

        os.chdir(cwd)

        return v_output.ns
开发者ID:m-labs,项目名称:migen,代码行数:31,代码来源:vivado.py


示例2: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
              toolchain_path=None, source=True, run=True, ver=None, **kwargs):
        if toolchain_path is None:
            if sys.platform == "win32":
                toolchain_path = "C:\\lscc\\diamond"
            elif sys.platform == "cygwin":
                toolchain_path = "/cygdrive/c/lscc/diamond"
            else:
                toolchain_path = "/usr/local/diamond"

        os.makedirs(build_dir, exist_ok=True)
        cwd = os.getcwd()
        os.chdir(build_dir)

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)

        v_output = platform.get_verilog(fragment, name=build_name, **kwargs)
        named_sc, named_pc = platform.resolve_signals(v_output.ns)
        v_file = build_name + ".v"
        v_output.write(v_file)
        sources = platform.sources | {(v_file, "verilog", "work")}
        _build_files(platform.device, sources, platform.verilog_include_paths, build_name)

        tools.write_to_file(build_name + ".lpf", _build_lpf(named_sc, named_pc))

        script = _build_script(build_name, platform.device, toolchain_path,
                               source, ver)
        if run:
            _run_script(script)

        os.chdir(cwd)

        return v_output.ns
开发者ID:m-labs,项目名称:migen,代码行数:35,代码来源:diamond.py


示例3: _build_batch

    def _build_batch(self, platform, sources, build_name):
        tcl = []
        for filename, language, library in sources:
            filename_tcl = "{" + filename + "}"
            tcl.append("add_files " + filename_tcl)
            tcl.append("set_property library {} [get_files {}]"
                       .format(library, filename_tcl))

        tcl.append("read_xdc {}.xdc".format(build_name))
        tcl.extend(c.format(build_name=build_name) for c in self.pre_synthesis_commands)
        tcl.append("synth_design -top top -part {} -include_dirs {{{}}}".format(platform.device, " ".join(platform.verilog_include_paths)))
        tcl.append("report_utilization -hierarchical -file {}_utilization_hierarchical_synth.rpt".format(build_name))
        tcl.append("report_utilization -file {}_utilization_synth.rpt".format(build_name))
        tcl.append("place_design")
        if self.with_phys_opt:
            tcl.append("phys_opt_design -directive AddRetime")
        tcl.append("report_utilization -hierarchical -file {}_utilization_hierarchical_place.rpt".format(build_name))
        tcl.append("report_utilization -file {}_utilization_place.rpt".format(build_name))
        tcl.append("report_io -file {}_io.rpt".format(build_name))
        tcl.append("report_control_sets -verbose -file {}_control_sets.rpt".format(build_name))
        tcl.append("report_clock_utilization -file {}_clock_utilization.rpt".format(build_name))
        tcl.append("route_design")
        tcl.append("report_route_status -file {}_route_status.rpt".format(build_name))
        tcl.append("report_drc -file {}_drc.rpt".format(build_name))
        tcl.append("report_timing_summary -max_paths 10 -file {}_timing.rpt".format(build_name))
        tcl.append("report_power -file {}_power.rpt".format(build_name))
        for bitstream_command in self.bitstream_commands:
            tcl.append(bitstream_command.format(build_name=build_name))
        tcl.append("write_bitstream -force {}.bit ".format(build_name))
        for additional_command in self.additional_commands:
            tcl.append(additional_command.format(build_name=build_name))
        tcl.append("quit")
        tools.write_to_file(build_name + ".tcl", "\n".join(tcl))
开发者ID:32bitmicro,项目名称:migen,代码行数:33,代码来源:vivado.py


示例4: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
              toolchain_path="/opt/Diamond", run=True):
        tools.mkdir_noerror(build_dir)
        cwd = os.getcwd()
        os.chdir(build_dir)

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)

        v_output = platform.get_verilog(fragment)
        named_sc, named_pc = platform.resolve_signals(v_output.ns)
        v_file = build_name + ".v"
        v_output.write(v_file)
        sources = platform.sources | {(v_file, "verilog", "work")}
        _build_files(platform.device, sources, platform.verilog_include_paths, build_name)

        tools.write_to_file(build_name + ".lpf", _build_lpf(named_sc, named_pc))

        if run:
            _run_diamond(build_name, toolchain_path)

        os.chdir(cwd)

        return v_output.ns
开发者ID:32bitmicro,项目名称:migen,代码行数:25,代码来源:diamond.py


示例5: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
              toolchain_path="/opt/Xilinx/Vivado", source=True, run=True,
              **kwargs):
        os.makedirs(build_dir, exist_ok=True)

        hdl = kwargs.get("hdl", "verilog")

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)
        self._convert_clocks(platform)
        self._constrain(platform)
        output = platform.get_hdl(fragment, hdl=hdl, **kwargs)
        named_sc, named_pc = platform.resolve_signals(output.ns)
        hdl_file = "{}.{}".format(build_name, "v" if hdl == "verilog" else "vhd")
        with ChdirContext(build_dir):
            output.write(hdl_file)
            sources = platform.sources | {(
                hdl_file, "verilog" if hdl == "verilog" else "vhdl", "work")}
            self._build_batch(platform, sources, platform.edifs, platform.ips, build_name)
            tools.write_to_file(build_name + ".xdc", _build_xdc(named_sc, named_pc))
            if run:
                _run_vivado(build_name, toolchain_path, source)

        return output.ns
开发者ID:peteut,项目名称:migen,代码行数:25,代码来源:vivado.py


示例6: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
        run=True):
        tools.mkdir_noerror(build_dir)
        cwd = os.getcwd()
        os.chdir(build_dir)

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)

        v_output = platform.get_verilog(fragment)
        named_sc, named_pc = platform.resolve_signals(v_output.ns)
        v_file = build_name + ".v"
        v_output.write(v_file)
        sources = platform.sources | {(v_file, "verilog", "work")}
        _build_yosys(platform.device, sources, platform.verilog_include_paths, build_name)

        tools.write_to_file(build_name + ".pcf", _build_pcf(named_sc, named_pc))
        if run:
            (family, size, package) = self.parse_device_string(platform.device)
            new_pnr_opts = self.pnr_opt + " -d " + size + " -P " + package
            _run_icestorm(build_name, False, self.yosys_opt, new_pnr_opts,
                self.icepack_opt)

        os.chdir(cwd)

        return v_output.ns
开发者ID:wzab,项目名称:migen,代码行数:27,代码来源:icestorm.py


示例7: _run_icestorm

def _run_icestorm(build_name, source, yosys_opt, pnr_opt,
                  icetime_opt, icepack_opt):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source_cmd = "call "
        script_ext = ".bat"
        shell = ["cmd", "/c"]
        build_script_contents = "@echo off\nrem Autogenerated by Migen\n"
        fail_stmt = " || exit /b"
    else:
        source_cmd = "source "
        script_ext = ".sh"
        shell = ["bash"]
        build_script_contents = "# Autogenerated by Migen\nset -e\n"
        fail_stmt = ""

    build_script_contents += """
yosys {yosys_opt} -l {build_name}.rpt {build_name}.ys{fail_stmt}
arachne-pnr {pnr_opt} -p {build_name}.pcf {build_name}.blif -o {build_name}.txt{fail_stmt}
icetime {icetime_opt} -t -p {build_name}.pcf -r {build_name}.tim {build_name}.txt{fail_stmt}
icepack {icepack_opt} {build_name}.txt {build_name}.bin{fail_stmt}
"""
    build_script_contents = build_script_contents.format(
        build_name=build_name,
        yosys_opt=yosys_opt, pnr_opt=pnr_opt, icepack_opt=icepack_opt,
        icetime_opt=icetime_opt, fail_stmt=fail_stmt)
    build_script_file = "build_" + build_name + script_ext
    tools.write_to_file(build_script_file, build_script_contents,
                        force_unix=False)
    command = shell + [build_script_file]
    r = subprocess.call(command)
    if r != 0:
        raise OSError("Subprocess failed")
开发者ID:cyrozap,项目名称:migen,代码行数:32,代码来源:icestorm.py


示例8: _run_icestorm

def _run_icestorm(source, build_template, build_name, pnr_pkg_opts,
                  icetime_pkg_opts, icetime_constraint):
    if sys.platform == "win32" or sys.platform == "cygwin":
        script_ext = ".bat"
        shell = ["cmd", "/c"]
        build_script_contents = "@echo off\nrem Autogenerated by Migen\n\n"
        fail_stmt = " || exit /b"
    else:
        script_ext = ".sh"
        shell = ["bash"]
        build_script_contents = "# Autogenerated by Migen\nset -e\n\n"
        fail_stmt = ""

    for s in build_template:
        s_fail = s + "{fail_stmt}\n"  # Required so Windows scripts fail early.
        build_script_contents += s_fail.format(build_name=build_name,
                                               pnr_pkg_opts=pnr_pkg_opts,
                                               icetime_pkg_opts=icetime_pkg_opts,
                                               icetime_constraint=icetime_constraint,
                                               fail_stmt=fail_stmt)

    build_script_file = "build_" + build_name + script_ext
    tools.write_to_file(build_script_file, build_script_contents,
                        force_unix=False)
    command = shell + [build_script_file]
    r = subprocess.call(command)
    if r != 0:
        raise OSError("Subprocess failed")
开发者ID:alangman,项目名称:migen,代码行数:28,代码来源:icestorm.py


示例9: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
              run=True):
        os.makedirs(build_dir, exist_ok=True)
        cwd = os.getcwd()
        os.chdir(build_dir)

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)

        v_output = platform.get_verilog(fragment)
        named_sc, named_pc = platform.resolve_signals(v_output.ns)
        v_file = build_name + ".v"
        v_output.write(v_file)
        sources = platform.sources | {(v_file, "verilog", "work")}
        _build_yosys(platform.device, sources, platform.verilog_include_paths,
                     build_name)

        tools.write_to_file(build_name + ".pcf",
                            _build_pcf(named_sc, named_pc))
        if run:
            (family, size, package) = self.parse_device_string(platform.device)
            pnr_opt = self.pnr_opt + " -d " + size + " -P " + package
            # TODO: PNR will probably eventually support LP devices.
            icetime_opt = self.icetime_opt + " -P " + package + \
                " -d " + "hx" + size + " -c " + \
                str(max(self.freq_constraints.values(), default=0.0))
            _run_icestorm(build_name, False, self.yosys_opt, pnr_opt,
                          icetime_opt, self.icepack_opt)

        os.chdir(cwd)

        return v_output.ns
开发者ID:cyrozap,项目名称:migen,代码行数:33,代码来源:icestorm.py


示例10: _run_sim

def _run_sim(build_name):
    run_script_contents = """obj_dir/Vdut
"""
    run_script_file = "run_" + build_name + ".sh"
    tools.write_to_file(run_script_file, run_script_contents, force_unix=True)
    r = subprocess.call(["bash", run_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
开发者ID:32bitmicro,项目名称:migen,代码行数:8,代码来源:verilator.py


示例11: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
            toolchain_path=None, source=None, run=True, mode="xst"):
        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        if toolchain_path is None:
            if sys.platform == "win32":
                toolchain_path = "C:\\Xilinx"
            elif sys.platform == "cygwin":
                toolchain_path = "/cygdrive/c/Xilinx"
            else:
                toolchain_path = "/opt/Xilinx"
        if source is None:
            source = sys.platform != "win32"

        platform.finalize(fragment)
        ngdbuild_opt = self.ngdbuild_opt
        vns = None

        tools.mkdir_noerror(build_dir)
        cwd = os.getcwd()
        os.chdir(build_dir)
        try:
            if mode == "xst" or mode == "yosys":
                v_output = platform.get_verilog(fragment)
                vns = v_output.ns
                named_sc, named_pc = platform.resolve_signals(vns)
                v_file = build_name + ".v"
                v_output.write(v_file)
                sources = platform.sources | {(v_file, "verilog", "work")}
                if mode == "xst":
                    _build_xst_files(platform.device, sources, platform.verilog_include_paths, build_name, self.xst_opt)
                    isemode = "xst"
                else:
                    _run_yosys(platform.device, sources, platform.verilog_include_paths, build_name)
                    isemode = "edif"
                    ngdbuild_opt += "-p " + platform.device

            if mode == "mist":
                from mist import synthesize
                synthesize(fragment, platform.constraint_manager.get_io_signals())

            if mode == "edif" or mode == "mist":
                e_output = platform.get_edif(fragment)
                vns = e_output.ns
                named_sc, named_pc = platform.resolve_signals(vns)
                e_file = build_name + ".edif"
                e_output.write(e_file)
                isemode = "edif"

            tools.write_to_file(build_name + ".ucf", _build_ucf(named_sc, named_pc))
            if run:
                _run_ise(build_name, toolchain_path, source, isemode,
                         ngdbuild_opt, self.bitgen_opt, self.ise_commands,
                         self.map_opt, self.par_opt)
        finally:
            os.chdir(cwd)

        return vns
开发者ID:32bitmicro,项目名称:migen,代码行数:58,代码来源:ise.py


示例12: _build_batch

    def _build_batch(self, platform, sources, edifs, ips, build_name):
        tcl = []
        tcl.append("create_project -force -name {} -part {}".format(build_name, platform.device))
        tcl.append("set_property XPM_LIBRARIES {XPM_CDC XPM_MEMORY} [current_project]")
        for filename, language, library in sources:
            filename_tcl = "{" + filename + "}"
            tcl.append("add_files " + filename_tcl)
            tcl.append("set_property library {} [get_files {}]"
                       .format(library, filename_tcl))

        for filename in edifs:
            filename_tcl = "{" + filename + "}"
            tcl.append("read_edif " + filename_tcl)

        for filename in ips:
            filename_tcl = "{" + filename + "}"
            ip = os.path.splitext(os.path.basename(filename))[0]
            tcl.append("read_ip " + filename_tcl)
            tcl.append("upgrade_ip [get_ips {}]".format(ip))
            tcl.append("generate_target all [get_ips {}]".format(ip))
            tcl.append("synth_ip [get_ips {}] -force".format(ip))
            tcl.append("get_files -all -of_objects [get_files {}]".format(filename_tcl))

        tcl.append("read_xdc {}.xdc".format(build_name))
        tcl.extend(c.format(build_name=build_name) for c in self.pre_synthesis_commands)
        # "-include_dirs {}" crashes Vivado 2016.4
        if platform.verilog_include_paths:
            tcl.append("synth_design -top top -part {} -include_dirs {{{}}}".format(platform.device, " ".join(platform.verilog_include_paths)))
        else:
            tcl.append("synth_design -top top -part {}".format(platform.device))
        tcl.append("report_timing_summary -file {}_timing_synth.rpt".format(build_name))
        tcl.append("report_utilization -hierarchical -file {}_utilization_hierarchical_synth.rpt".format(build_name))
        tcl.append("report_utilization -file {}_utilization_synth.rpt".format(build_name))
        tcl.append("opt_design")
        tcl.append("place_design")
        if self.with_phys_opt:
            tcl.append("phys_opt_design -directive AddRetime")
        tcl.append("report_utilization -hierarchical -file {}_utilization_hierarchical_place.rpt".format(build_name))
        tcl.append("report_utilization -file {}_utilization_place.rpt".format(build_name))
        tcl.append("report_io -file {}_io.rpt".format(build_name))
        tcl.append("report_control_sets -verbose -file {}_control_sets.rpt".format(build_name))
        tcl.append("report_clock_utilization -file {}_clock_utilization.rpt".format(build_name))
        tcl.append("route_design")
        tcl.append("phys_opt_design")
        tcl.append("report_timing_summary -no_header -no_detailed_paths")
        tcl.append("write_checkpoint -force {}_route.dcp".format(build_name))
        tcl.append("report_route_status -file {}_route_status.rpt".format(build_name))
        tcl.append("report_drc -file {}_drc.rpt".format(build_name))
        tcl.append("report_timing_summary -datasheet -max_paths 10 -file {}_timing.rpt".format(build_name))
        tcl.append("report_power -file {}_power.rpt".format(build_name))
        for bitstream_command in self.bitstream_commands:
            tcl.append(bitstream_command.format(build_name=build_name))
        tcl.append("write_bitstream -force {}.bit ".format(build_name))
        for additional_command in self.additional_commands:
            tcl.append(additional_command.format(build_name=build_name))
        tcl.append("quit")
        tools.write_to_file(build_name + ".tcl", "\n".join(tcl))
开发者ID:peteut,项目名称:migen,代码行数:57,代码来源:vivado.py


示例13: _build_yosys

def _build_yosys(device, sources, vincpaths, build_name):
    ys_contents = ""
    incflags = ""
    for path in vincpaths:
        incflags += " -I" + path
    for filename, language, library in sources:
        ys_contents += "read_{}{} {}\n".format(language, incflags, filename)

    ys_contents += """synth_ice40 -top top -blif {build_name}.blif""".format(build_name=build_name)

    ys_name = build_name + ".ys"
    tools.write_to_file(ys_name, ys_contents)
开发者ID:wzab,项目名称:migen,代码行数:12,代码来源:icestorm.py


示例14: _run_ise

def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
             toolchain, platform, ver=None):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source_cmd = "call "
        script_ext = ".bat"
        shell = ["cmd", "/c"]
        build_script_contents = "@echo off\nrem Autogenerated by Migen\n"
        fail_stmt = " || exit /b"
    else:
        source_cmd = "source "
        script_ext = ".sh"
        shell = ["bash"]
        build_script_contents = "# Autogenerated by Migen\nset -e\n"
        fail_stmt = ""
    if source:
        settings = common.settings(ise_path, ver, "ISE_DS")
        build_script_contents += source_cmd + tools.cygpath(settings) + "\n"
    if mode == "edif":
        ext = "edif"
    else:
        ext = "ngc"
        build_script_contents += """
xst -ifn {build_name}.xst{fail_stmt}
"""

    build_script_contents += """
ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd{fail_stmt}
"""
    if mode == "cpld":
        build_script_contents += """
cpldfit -ofmt verilog {par_opt} -p {device} {build_name}.ngd{fail_stmt}
taengine -f {build_name}.vm6 -detail -iopath -l {build_name}.tim{fail_stmt}
hprep6 -s IEEE1532 -i {build_name}.vm6{fail_stmt}
"""
    else:
        build_script_contents += """
map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf{fail_stmt}
par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf{fail_stmt}
bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt}
"""
    build_script_contents = build_script_contents.format(
        build_name=build_name,
        ngdbuild_opt=ngdbuild_opt, bitgen_opt=toolchain.bitgen_opt, ext=ext,
        par_opt=toolchain.par_opt, map_opt=toolchain.map_opt,
        device=platform.device, fail_stmt=fail_stmt)
    build_script_contents += toolchain.ise_commands.format(build_name=build_name)
    build_script_file = "build_" + build_name + script_ext
    tools.write_to_file(build_script_file, build_script_contents, force_unix=False)
    command = shell + [build_script_file]
    r = tools.subprocess_call_filtered(command, common.colors)
    if r != 0:
        raise OSError("Subprocess failed")
开发者ID:peteut,项目名称:migen,代码行数:52,代码来源:ise.py


示例15: _run_diamond

def _run_diamond(build_name, source, ver=None):
    if sys.platform == "win32" or sys.platform == "cygwin":
        build_script_contents = "REM Autogenerated by Migen\n"
        build_script_contents = "pnmainc " + build_name + ".tcl\n"
        build_script_file = "build_" + build_name + ".bat"
        tools.write_to_file(build_script_file, build_script_contents)
        r = subprocess.call([build_script_file])
        shutil.copy(os.path.join("implementation", build_name + "_implementation.bit"), build_name + ".bit")
    else:
        raise NotImplementedError

    if r != 0:
        raise OSError("Subprocess failed")
开发者ID:32bitmicro,项目名称:migen,代码行数:13,代码来源:diamond.py


示例16: _build_files

def _build_files(device, sources, vincpaths, build_name):
    tcl = []
    tcl.append("prj_project new -name \"{}\" -impl \"implementation\" -dev {} -synthesis \"synplify\"".format(build_name, device))
    for path in vincpaths:
        tcl.append("prj_impl option {include path} {\"" + path + "\"}")
    for filename, language, library in sources:
        tcl.append("prj_src add \"" + filename + "\" -work " + library)
    tcl.append("prj_run Synthesis -impl implementation -forceOne")
    tcl.append("prj_run Translate -impl implementation")
    tcl.append("prj_run Map -impl implementation")
    tcl.append("prj_run PAR -impl implementation")
    tcl.append("prj_run Export -impl implementation -task Bitgen")
    tools.write_to_file(build_name + ".tcl", "\n".join(tcl))
开发者ID:32bitmicro,项目名称:migen,代码行数:13,代码来源:diamond.py


示例17: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
              toolchain_path=None, source=True, run=True, mode="xst", **kwargs):
        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        if toolchain_path is None:
            if sys.platform == "win32":
                toolchain_path = "C:\\Xilinx"
            elif sys.platform == "cygwin":
                toolchain_path = "/cygdrive/c/Xilinx"
            else:
                toolchain_path = "/opt/Xilinx"

        platform.finalize(fragment)
        ngdbuild_opt = self.ngdbuild_opt
        vns = None

        os.makedirs(build_dir, exist_ok=True)
        with ChdirContext(build_dir):
            if mode in ("xst", "yosys", "cpld"):
                v_output = platform.get_hdl(fragment, name=build_name, **kwargs)
                vns = v_output.ns
                named_sc, named_pc = platform.resolve_signals(vns)
                v_file = build_name + ".v"
                v_output.write(v_file)
                sources = platform.sources | {(v_file, "verilog", "work")}
                if mode in ("xst", "cpld"):
                    _build_xst_files(platform.device, sources, platform.verilog_include_paths, build_name, self.xst_opt)
                    isemode = mode
                else:
                    _run_yosys(platform.device, sources, platform.verilog_include_paths, build_name)
                    isemode = "edif"
                    ngdbuild_opt += "-p " + platform.device

            if mode == "mist":
                from mist import synthesize
                synthesize(fragment, platform.constraint_manager.get_io_signals())

            if mode == "edif" or mode == "mist":
                e_output = platform.get_edif(fragment)
                vns = e_output.ns
                named_sc, named_pc = platform.resolve_signals(vns)
                e_file = build_name + ".edif"
                e_output.write(e_file)
                isemode = "edif"

            tools.write_to_file(build_name + ".ucf", _build_ucf(named_sc, named_pc))
            if run:
                _run_ise(build_name, toolchain_path, source, isemode,
                         ngdbuild_opt, self, platform)

        return vns
开发者ID:peteut,项目名称:migen,代码行数:51,代码来源:ise.py


示例18: _build_script

def _build_script(build_name, device, toolchain_path, source, ver=None):
    if sys.platform in ("win32", "cygwin"):
        script_ext = ".bat"
        build_script_contents = "@echo off\nrem Autogenerated by Migen\n\n"
        copy_stmt = "copy"
        fail_stmt = " || exit /b"
    else:
        script_ext = ".sh"
        build_script_contents = "# Autogenerated by Migen\nset -e\n\n"
        copy_stmt = "cp"
        fail_stmt = ""

    if source:
        bindir = _get_bindir(toolchain_path, ver)
        if sys.platform in ("win32", "cygwin"):
            build_script_contents += "set PATH={};%PATH%\n".format(bindir)
        else:
            build_script_contents += "bindir={}\n".format(bindir)
            build_script_contents += ". ${{bindir}}/diamond_env{fail_stmt}\n".format(
                fail_stmt=fail_stmt)

    build_script_contents += "pnmainc {tcl_script}{fail_stmt}\n".format(
        tcl_script=build_name + ".tcl",
        fail_stmt=fail_stmt)
    for ext in (".bit", ".jed"):
        if ext == ".jed" and not _produces_jedec(device):
            continue

        diamond_product = os.path.join("impl", build_name + "_impl" + ext)
        if sys.platform in ("win32", "cygwin"):
            # While Windows itself has no problems with forward slashes
            # in paths, the COPY command on Windows uses forward slash for
            # arguments. MinGW Python 3 may (it is not consistent) create
            # paths with forward slashes on Windows, so remove them just in
            # case.
            diamond_product = diamond_product.replace("/", "\\")

        build_script_contents += "{copy_stmt} {diamond_product} {migen_product}" \
                                 "{fail_stmt}\n".format(
            copy_stmt=copy_stmt,
            fail_stmt=fail_stmt,
            diamond_product=diamond_product,
            migen_product=build_name + ext)

    build_script_file = "build_" + build_name + script_ext
    tools.write_to_file(build_script_file, build_script_contents,
                        force_unix=False)
    return build_script_file
开发者ID:m-labs,项目名称:migen,代码行数:48,代码来源:diamond.py


示例19: build

    def build(self, platform, fragment, build_dir="build", build_name="top",
              toolchain_path=None, run=True, **kwargs):
        if toolchain_path is None:
            toolchain_path = "/usr/share/trellis/"
        os.makedirs(build_dir, exist_ok=True)
        cwd = os.getcwd()
        os.chdir(build_dir)

        # generate verilog
        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        platform.finalize(fragment)

        top_output = platform.get_verilog(fragment, name=build_name, **kwargs)
        named_sc, named_pc = platform.resolve_signals(top_output.ns)
        top_file = build_name + ".v"
        top_output.write(top_file)
        platform.add_source(top_file)

        # generate constraints
        tools.write_to_file(build_name + ".lpf",
                            _build_lpf(named_sc, named_pc))

        # generate yosys script
        yosys_script_file = build_name + ".ys"
        yosys_script_contents = "\n".join(_.format(build_name=build_name,
                                                   read_files=yosys_import_sources(platform))
                                          for _ in self.yosys_template)
        tools.write_to_file(yosys_script_file, yosys_script_contents)

        # transform platform.device to nextpnr's architecture / basecfg
        (family, size, package) = platform.device.split("-")
        architecture = nextpnr_ecp5_architectures[(family + "-" + size).lower()]
        basecfg = "empty_" + (family + "-" + size).lower() + ".config"
        basecfg = os.path.join(toolchain_path, "misc", "basecfgs", basecfg)
        freq_constraint = str(max(self.freq_constraints.values(),
                                  default=0.0))

        script = _build_script(False, self.build_template, build_name,
                               architecture, basecfg, freq_constraint)

        # run scripts
        if run:
            _run_script(script)

        os.chdir(cwd)

        return top_output.ns
开发者ID:m-labs,项目名称:migen,代码行数:48,代码来源:trellis.py


示例20: _build_xst_files

def _build_xst_files(device, sources, vincpaths, build_name, xst_opt):
    prj_contents = ""
    for filename, language, library in sources:
        prj_contents += language + " " + library + " " + filename + "\n"
    tools.write_to_file(build_name + ".prj", prj_contents)

    xst_contents = """run
-ifn {build_name}.prj
-top top
{xst_opt}
-ofn {build_name}.ngc
-p {device}
""".format(build_name=build_name, xst_opt=xst_opt, device=device)
    for path in vincpaths:
        xst_contents += "-vlgincdir " + path + "\n"
    tools.write_to_file(build_name + ".xst", xst_contents)
开发者ID:AmesianX,项目名称:migen,代码行数:16,代码来源:ise.py



注:本文中的migen.build.tools.write_to_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xilinx.XilinxPlatform类代码示例发布时间:2022-05-27
下一篇:
Python utils.execute函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap