Example #1
0
def _build_files(device, sources, vincpaths, build_name, bitstream_compression):
	tcl = []
	for filename, language in sources:
		tcl.append("add_files " + filename.replace("\\", "/"))

	tcl.append("read_xdc %s.xdc" %build_name)
	tcl.append("synth_design -top top -part %s -include_dirs {%s}" %(device, " ".join(vincpaths)))
	tcl.append("report_utilization -hierarchical -file %s_utilization_hierarchical_synth.rpt" %(build_name))
	tcl.append("report_utilization -file %s_utilization_synth.rpt" %(build_name))
	tcl.append("place_design")
	tcl.append("report_utilization -hierarchical -file %s_utilization_hierarchical_place.rpt" %(build_name))
	tcl.append("report_utilization -file %s_utilization_place.rpt" %(build_name))
	tcl.append("report_io -file %s_io.rpt" %(build_name))
	tcl.append("report_control_sets -verbose -file %s_control_sets.rpt" %(build_name))
	tcl.append("report_clock_utilization -file %s_clock_utilization.rpt" %(build_name))
	tcl.append("route_design")
	tcl.append("report_route_status -file %s_route_status.rpt" %(build_name))
	tcl.append("report_drc -file %s_drc.rpt" %(build_name))
	tcl.append("report_timing_summary -max_paths 10 -file %s_timing.rpt" %(build_name))
	tcl.append("report_power -file %s_power.rpt" %(build_name))
	if bitstream_compression:
		tcl.append("set_property BITSTREAM.GENERAL.COMPRESS True [current_design]")
	tcl.append("write_bitstream -force %s.bit " %build_name)
	tcl.append("quit")
	tools.write_to_file(build_name + ".tcl", "\n".join(tcl))
Example #2
0
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
		bitgen_opt, ise_commands, map_opt, par_opt, ver=None):
	if sys.platform == "win32" or sys.platform == "cygwin":
		source = False
	build_script_contents = "# Autogenerated by mibuild\nset -e\n"
	if source:
		settings = xilinx_common.settings(ise_path, ver, "ISE_DS")
		build_script_contents += "source " + settings + "\n"
	if mode == "edif":
		ext = "edif"
	else:
		ext = "ngc"
		build_script_contents += """
xst -ifn {build_name}.xst
"""

	build_script_contents += """
ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd
map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf
par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf
bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit
"""
	build_script_contents = build_script_contents.format(build_name=build_name,
			ngdbuild_opt=ngdbuild_opt, bitgen_opt=bitgen_opt, ext=ext,
			par_opt=par_opt, map_opt=map_opt)
	build_script_contents += ise_commands.format(build_name=build_name)
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #3
0
def _run_ise(build_name, ise_path, source):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source = False
    build_script_contents = "# Autogenerated by mibuild\nset -e\n"
    if source:
        vers = [ver for ver in os.listdir(ise_path) if _is_valid_version(ise_path, ver)]
        tools_version = max(vers)
        bits = struct.calcsize("P") * 8
        xilinx_settings_file = "%s/%s/ISE_DS/settings%d.sh" % (ise_path, tools_version, bits)
        build_script_contents += "source " + xilinx_settings_file + "\n"

    build_script_contents += """
xst -ifn {build_name}.xst
ngdbuild -uc {build_name}.ucf {build_name}.ngc
map -ol high -w {build_name}.ngd
par -ol high -w {build_name}.ncd {build_name}-routed.ncd
bitgen -g LCK_cycle:6 -g Binary:Yes -w {build_name}-routed.ncd {build_name}.bit
""".format(
        build_name=build_name
    )
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file, build_script_contents)

    r = subprocess.call(["bash", build_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
Example #4
0
def _run_ise(build_name, ise_path, source):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source = False
    build_script_contents = "# Autogenerated by mibuild\nset -e\n"
    if source:
        vers = [
            ver for ver in os.listdir(ise_path)
            if _is_valid_version(ise_path, ver)
        ]
        tools_version = max(vers)
        bits = struct.calcsize("P") * 8
        xilinx_settings_file = '%s/%s/ISE_DS/settings%d.sh' % (
            ise_path, tools_version, bits)
        build_script_contents += "source " + xilinx_settings_file + "\n"

    build_script_contents += """
xst -ifn {build_name}.xst
ngdbuild -uc {build_name}.ucf {build_name}.ngc
map -ol high -w {build_name}.ngd
par -ol high -w {build_name}.ncd {build_name}-routed.ncd
bitgen -g LCK_cycle:6 -g Binary:Yes -w {build_name}-routed.ncd {build_name}.bit
""".format(build_name=build_name)
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file, build_script_contents)

    r = subprocess.call(["bash", build_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
Example #5
0
File: ise.py Project: fallen/migen
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
        bitgen_opt, ise_commands, map_opt, par_opt, ver=None):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source = False
    build_script_contents = "# Autogenerated by mibuild\nset -e\n"
    if source:
        settings = common.settings(ise_path, ver, "ISE_DS")
        build_script_contents += "source " + settings + "\n"
    if mode == "edif":
        ext = "edif"
    else:
        ext = "ngc"
        build_script_contents += """
xst -ifn {build_name}.xst
"""

    build_script_contents += """
ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd
map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf
par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf
bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit
"""
    build_script_contents = build_script_contents.format(build_name=build_name,
            ngdbuild_opt=ngdbuild_opt, bitgen_opt=bitgen_opt, ext=ext,
            par_opt=par_opt, map_opt=map_opt)
    build_script_contents += ise_commands.format(build_name=build_name)
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

    r = subprocess.call(["bash", build_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
Example #6
0
    def _build_batch(self, platform, sources, build_name):
        tcl = []
        for filename, language, library in sources:
            tcl.append("add_files " + filename)
            tcl.append("set_property library {} [get_files {}]".format(library, filename))

        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))
Example #7
0
def _run_yosys(device, sources, vincpaths, build_name):
    ys_contents = ""
    incflags = ""
    for path in vincpaths:
        incflags += " -I" + path
    for filename, language in sources:
        ys_contents += "read_{}{} {}\n".format(language, incflags, filename)

    if device[:2] == "xc":
        archcode = device[2:4]
    else:
        archcode = device[0:2]
    arch = {
        "6s": "spartan6",
        "7a": "artix7",
        "7k": "kintex7",
        "7v": "virtex7",
        "7z": "zynq7000"
    }[archcode]

    ys_contents += """hierarchy -check -top top
proc; memory; opt; fsm; opt
synth_xilinx -arch {arch} -top top -edif {build_name}.edif""".format(
        arch=arch, build_name=build_name)

    ys_name = build_name + ".ys"
    tools.write_to_file(ys_name, ys_contents)
    r = subprocess.call(["yosys", ys_name])
    if r != 0:
        raise OSError("Subprocess failed")
Example #8
0
    def build(self,
              fragment,
              build_dir="build",
              build_name="top",
              vivado_path="/opt/Xilinx/Vivado",
              source=True,
              run=True,
              bitstream_compression=False):
        tools.mkdir_noerror(build_dir)
        os.chdir(build_dir)

        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        self.finalize(fragment)
        v_src, named_sc, named_pc = self.get_verilog(fragment)
        v_file = build_name + ".v"
        tools.write_to_file(v_file, v_src)
        sources = self.sources + [(v_file, "verilog")]
        _build_files(self.device, sources, self.verilog_include_paths,
                     build_name, bitstream_compression)
        tools.write_to_file(build_name + ".xdc",
                            _build_xdc(named_sc, named_pc))
        if run:
            _run_vivado(build_name, vivado_path, source)

        os.chdir("..")
Example #9
0
def _run_yosys(device, sources, vincpaths, build_name):
	ys_contents = ""
	incflags = ""
	for path in vincpaths:
		incflags += " -I" + path
	for filename, language in sources:
		ys_contents += "read_{}{} {}\n".format(language, incflags, filename)
	
	if device[:2] == "xc":
		archcode = device[2:4]
	else:
		archcode = device[0:2]
	arch = {
		"6s": "spartan6",
		"7a": "artix7",
		"7k": "kintex7",
		"7v": "virtex7",
		"7z": "zynq7000"
	}[archcode]
	
	ys_contents += """hierarchy -check -top top
proc; memory; opt; fsm; opt
synth_xilinx -arch {arch} -top top -edif {build_name}.edif""".format(arch=arch, build_name=build_name)
	
	ys_name = build_name + ".ys"
	tools.write_to_file(ys_name, ys_contents)
	r = subprocess.call(["yosys", ys_name])
	if r != 0:
		raise OSError("Subprocess failed")
Example #10
0
def _build_files(device, sources, named_sc, named_pc, build_name):
	qsf_contents = ""
	for filename, language in sources:
		qsf_contents += "set_global_assignment -name "+language.upper()+"_FILE " + filename.replace("\\","/") + "\n"

	qsf_contents += _build_qsf(named_sc, named_pc)
	qsf_contents += "set_global_assignment -name DEVICE " + device
	tools.write_to_file(build_name + ".qsf", qsf_contents)
Example #11
0
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")
Example #12
0
def _build_files(device, sources, named_sc, named_pc, build_name):
    qsf_contents = ""
    for filename, language in sources:
        qsf_contents += "set_global_assignment -name " + language.upper(
        ) + "_FILE " + filename.replace("\\", "/") + "\n"

    qsf_contents += _build_qsf(named_sc, named_pc)
    qsf_contents += "set_global_assignment -name DEVICE " + device
    tools.write_to_file(build_name + ".qsf", qsf_contents)
def main():
	platform = m1.Platform()
	soc = top.SoC(platform)
	
	platform.add_platform_command("""
NET "{clk50}" TNM_NET = "GRPclk50";
TIMESPEC "TSclk50" = PERIOD "GRPclk50" 20 ns HIGH 50%;
""", clk50=platform.lookup_request("clk50"))

	platform.add_platform_command("""
INST "m1crg/wr_bufpll" LOC = "BUFPLL_X0Y2";
INST "m1crg/rd_bufpll" LOC = "BUFPLL_X0Y3";

PIN "m1crg/bufg_x1.O" CLOCK_DEDICATED_ROUTE = FALSE;
""")

	if hasattr(soc, "fb"):
		platform.add_platform_command("""
NET "vga_clk" TNM_NET = "GRPvga_clk";
NET "sys_clk" TNM_NET = "GRPsys_clk";
TIMESPEC "TSise_sucks1" = FROM "GRPvga_clk" TO "GRPsys_clk" TIG;
TIMESPEC "TSise_sucks2" = FROM "GRPsys_clk" TO "GRPvga_clk" TIG;
""")

	if hasattr(soc, "minimac"):
		platform.add_platform_command("""
NET "{phy_rx_clk}" TNM_NET = "GRPphy_rx_clk";
NET "{phy_tx_clk}" TNM_NET = "GRPphy_tx_clk";
TIMESPEC "TSphy_rx_clk" = PERIOD "GRPphy_rx_clk" 40 ns HIGH 50%;
TIMESPEC "TSphy_tx_clk" = PERIOD "GRPphy_tx_clk" 40 ns HIGH 50%;
TIMESPEC "TSphy_tx_clk_io" = FROM "GRPphy_tx_clk" TO "PADS" 10 ns;
TIMESPEC "TSphy_rx_clk_io" = FROM "PADS" TO "GRPphy_rx_clk" 10 ns;
""",
		phy_rx_clk=platform.lookup_request("eth_clocks").rx,
		phy_tx_clk=platform.lookup_request("eth_clocks").tx,)

	if hasattr(soc, "dvisampler0"):
		platform.add_platform_command("""
NET "{dviclk0}" TNM_NET = "GRPdviclk0";
NET "{dviclk0}" CLOCK_DEDICATED_ROUTE = FALSE;
TIMESPEC "TSdviclk0" = PERIOD "GRPdviclk0" 26.7 ns HIGH 50%;
""", dviclk0=platform.lookup_request("dvi_in", 0).clk)
	if hasattr(soc, "dvisampler1"):
		platform.add_platform_command("""
NET "{dviclk1}" TNM_NET = "GRPdviclk1";
NET "{dviclk1}" CLOCK_DEDICATED_ROUTE = FALSE;
TIMESPEC "TSdviclk1" = PERIOD "GRPdviclk1" 26.7 ns HIGH 50%;
""", dviclk1=platform.lookup_request("dvi_in", 1).clk)
	mor1kx_dir = os.path.join("mor1kx", "submodule", "rtl", "verilog")
	for d in ["m1crg", "s6ddrphy", "minimac3", mor1kx_dir]:
		platform.add_source_dir(os.path.join("verilog", d))

	platform.build_cmdline(soc)
	csr_header = cif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
	write_to_file("software/include/hw/csr.h", csr_header)
Example #14
0
File: la.py Project: olofk/misoc
 def export(self, vns, filename):
     def format_line(*args):
         return ",".join(args) + "\n"
     r = ""
     r += format_line("config", "dw", str(self.dw))
     r += format_line("config", "depth", str(self.depth))
     r += format_line("config", "with_rle", str(int(self.with_rle)))
     if not isinstance(self.layout, tuple):
         self.layout = [self.layout]
     for e in self.layout:
         r += format_line("layout", vns.get_name(e), str(flen(e)))
     write_to_file(filename, r)
Example #15
0
def _run_diamond(build_name, source, ver=None):
    if sys.platform == "win32" or sys.platform == "cygwin":
        build_script_contents = "REM Autogenerated by mibuild\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")
Example #16
0
    def export(self, vns, filename):
        def format_line(*args):
            return ",".join(args) + "\n"

        r = ""
        r += format_line("config", "dw", str(self.dw))
        r += format_line("config", "depth", str(self.depth))
        r += format_line("config", "with_rle", str(int(self.with_rle)))
        if not isinstance(self.layout, tuple):
            self.layout = [self.layout]
        for e in self.layout:
            r += format_line("layout", vns.get_name(e), str(flen(e)))
        write_to_file(filename, r)
Example #17
0
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))
Example #18
0
    def build(self, fragment, build_dir="build", build_name="top", ise_path="/opt/Xilinx", source=True, run=True):
        tools.mkdir_noerror(build_dir)
        os.chdir(build_dir)

        v_src, named_sc, named_pc = self.get_verilog(fragment)
        v_file = build_name + ".v"
        tools.write_to_file(v_file, v_src)
        sources = self.sources + [(v_file, "verilog")]
        _build_files(self.device, sources, named_sc, named_pc, build_name)
        if run:
            _run_ise(build_name, ise_path, source)

        os.chdir("..")
Example #19
0
def _run_vivado(build_name, vivado_path, source, ver=None):
	if sys.platform == "win32" or sys.platform == "cygwin":
		source = False
	build_script_contents = "# Autogenerated by mibuild\nset -e\n"
	if source:
		settings = xilinx_common.settings(vivado_path, ver)
		build_script_contents += "source " + settings + "\n"
	build_script_contents += "vivado -mode tcl -source " + build_name + ".tcl\n"
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #20
0
def _build_files(device, sources, vincpaths, build_name):
	tcl_contents = ""
	for filename, language in sources:
		tcl_contents += "add_files " + filename.replace("\\", "/") + "\n"

	tcl_contents += "read_xdc %s.xdc\n" %build_name
	tcl_contents += "synth_design -top top -part %s -include_dirs {%s}\n" %(device, " ".join(vincpaths))
	tcl_contents += "place_design\n"
	tcl_contents += "route_design\n"
	tcl_contents += "report_timing_summary -file %s_timing.rpt\n" %(build_name)
	tcl_contents += "report_utilization -file %s_utilization.rpt\n" %(build_name)
	tcl_contents += "write_bitstream -force %s.bit \n" %build_name
	tcl_contents += "quit\n"	
	tools.write_to_file(build_name + ".tcl", tcl_contents)
Example #21
0
def _build_files(device, sources, vincpaths, named_sc, named_pc, build_name):
	qsf_contents = ""
	for filename, language in sources:
		# Enforce use of SystemVerilog (Quartus does not support global parameters in Verilog)
		if language == "verilog":
			language = "systemverilog"
		qsf_contents += "set_global_assignment -name "+language.upper()+"_FILE " + filename.replace("\\","/") + "\n"

	for path in vincpaths:
		qsf_contents += "set_global_assignment -name SEARCH_PATH " + path.replace("\\","/") + "\n"

	qsf_contents += _build_qsf(named_sc, named_pc)
	qsf_contents += "set_global_assignment -name DEVICE " + device
	tools.write_to_file(build_name + ".qsf", qsf_contents)
Example #22
0
def _build_files(device, sources, vincpaths, named_sc, named_pc, build_name):
	qsf_contents = ""
	for filename, language in sources:
		# Enforce use of SystemVerilog (Quartus does not support global parameters in Verilog)
		if language == "verilog":
			language = "systemverilog"
		qsf_contents += "set_global_assignment -name "+language.upper()+"_FILE " + filename.replace("\\","/") + "\n"

	for path in vincpaths:
		qsf_contents += "set_global_assignment -name SEARCH_PATH " + path.replace("\\","/") + "\n"

	qsf_contents += _build_qsf(named_sc, named_pc)
	qsf_contents += "set_global_assignment -name DEVICE " + device
	tools.write_to_file(build_name + ".qsf", qsf_contents)
Example #23
0
File: ise.py Project: rohit91/migen
    def build(self, platform, fragment, build_dir="build", build_name="top",
            ise_path=_default_ise_path(), source=_default_source(), run=True, mode="xst"):
        if not isinstance(fragment, _Fragment):
            fragment = fragment.get_fragment()
        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, ise_path, source, isemode,
                         ngdbuild_opt, self.bitgen_opt, self.ise_commands,
                         self.map_opt, self.par_opt)
        finally:
            os.chdir(cwd)

        return vns
Example #24
0
File: make.py Project: shuckc/misoc
def main():
	args = _get_args()

	platform_module = _misoc_import("mibuild.platforms", args.external_platform, args.platform)
	target_module = _misoc_import("targets", args.external_target, args.target)
	platform = platform_module.Platform()
	if args.sub_target:
		top_class = getattr(target_module, args.sub_target)
	else:
		top_class = target_module.get_default_subtarget(platform)
	build_name = top_class.__name__.lower() + "-" + args.platform
	top_kwargs = dict((k, autotype(v)) for k, v in args.target_option)
	soc = top_class(platform, **top_kwargs)

	soc.finalize()

	if not args.no_header:
		boilerplate = """/*
 * Platform: {}
 * Target: {}
 * Subtarget: {}
 */

""".format(args.platform, args.target, top_class.__name__)
		linker_header = cpuif.get_linker_regions(soc.cpu_memory_regions)
		write_to_file("software/include/generated/regions.ld", boilerplate + linker_header)
		csr_header = cpuif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
		write_to_file("software/include/generated/csr.h", boilerplate + csr_header)
		if hasattr(soc, "ddrphy"):
			sdram_phy_header = initsequence.get_sdram_phy_header(soc.ddrphy)
			write_to_file("software/include/generated/sdram_phy.h", boilerplate + sdram_phy_header)
	if args.csr_csv:
		csr_csv = cpuif.get_csr_csv(soc.csr_base, soc.csrbankarray)
		write_to_file(args.csr_csv, csr_csv)

	if hasattr(soc, "init_bios_memory"):
		ret = subprocess.call(["make", "-C", "software/bios"])
		if ret:
			raise OSError("BIOS build failed")
		bios_file = open("software/bios/bios.bin", "rb")
		bios_data = []
		while True:
			w = bios_file.read(4)
			if not w:
				break
			bios_data.append(struct.unpack(">I", w)[0])
		bios_file.close()
		soc.init_bios_memory(bios_data)

	if not args.no_bitstream:
		build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
		platform.build(soc, build_name=build_name, **build_kwargs)
		subprocess.call(["tools/byteswap",
			"build/" + build_name + ".bin",
			"build/" + build_name + ".fpg"])

	if args.load:
		jtag.load(platform.name, "build/" + build_name + ".bit")
	if args.flash:
		jtag.flash("build/" + build_name + ".fpg")
Example #25
0
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt, bitgen_opt,
             ise_commands, map_opt, par_opt):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source = False
    build_script_contents = "# Autogenerated by mibuild\nset -e\n"
    if source:
        vers = [
            ver for ver in os.listdir(ise_path)
            if _is_valid_version(ise_path, ver)
        ]
        tools_version = max(vers)
        bits = struct.calcsize("P") * 8

        xilinx_settings_file = os.path.join(ise_path, tools_version, "ISE_DS",
                                            "settings{0}.sh".format(bits))
        if not os.path.exists(xilinx_settings_file) and bits == 64:
            # if we are on 64-bit system but the toolchain isn't, try the 32-bit env.
            xilinx_settings_file = os.path.join(ise_path, tools_version,
                                                "ISE_DS", "settings32.sh")
        build_script_contents += "source " + xilinx_settings_file + "\n"
    if mode == "edif":
        ext = "edif"
    else:
        ext = "ngc"
        build_script_contents += """
xst -ifn {build_name}.xst"""

    build_script_contents += """
ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd
map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf
par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf
bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit
"""
    build_script_contents = build_script_contents.format(
        build_name=build_name,
        ngdbuild_opt=ngdbuild_opt,
        bitgen_opt=bitgen_opt,
        ext=ext,
        par_opt=par_opt,
        map_opt=map_opt)
    build_script_contents += ise_commands.format(build_name=build_name)
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file,
                        build_script_contents,
                        force_unix=True)

    r = subprocess.call(["bash", build_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
Example #26
0
def _run_quartus(build_name, quartus_path):
    build_script_contents = """# Autogenerated by mibuild

quartus_map {build_name}.qpf
quartus_fit {build_name}.qpf
quartus_asm {build_name}.qpf
quartus_sta {build_name}.qpf

""".format(build_name=build_name)
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file, build_script_contents)

    r = subprocess.call(["bash", build_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
Example #27
0
def _run_quartus(build_name, quartus_path):
	build_script_contents = """# Autogenerated by mibuild

quartus_map --read_settings_files=on --write_settings_files=off {build_name} -c {build_name}
quartus_fit --read_settings_files=off --write_settings_files=off {build_name} -c {build_name}
quartus_asm --read_settings_files=off --write_settings_files=off {build_name} -c {build_name}
quartus_sta {build_name} -c {build_name}

""".format(build_name=build_name)
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #28
0
def _run_quartus(build_name, quartus_path):
	build_script_contents = """# Autogenerated by mibuild

quartus_map --read_settings_files=on --write_settings_files=off {build_name} -c {build_name}
quartus_fit --read_settings_files=off --write_settings_files=off {build_name} -c {build_name}
quartus_asm --read_settings_files=off --write_settings_files=off {build_name} -c {build_name}
quartus_sta {build_name} -c {build_name}

""".format(build_name=build_name)
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #29
0
def _run_vivado(build_name, vivado_path, source):
	if sys.platform == "win32" or sys.platform == "cygwin":
		source = False
	build_script_contents = "# Autogenerated by mibuild\nset -e\n"
	if source:
		raise NotImplementedError
	build_script_contents += """
vivado -mode tcl -source {build_name}.tcl
""".format(build_name=build_name)
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #30
0
def _run_quartus(build_name, quartus_path):
	build_script_contents = """# Autogenerated by mibuild

quartus_map {build_name}.qpf
quartus_fit {build_name}.qpf
quartus_asm {build_name}.qpf
quartus_sta {build_name}.qpf

""".format(build_name=build_name)
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #31
0
def _build_xst_files(device, sources, vincpaths, build_name, xst_opt):
    prj_contents = ""
    for filename, language in sources:
        prj_contents += language + " work " + 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)
Example #32
0
def _build_xst_files(device, sources, vincpaths, build_name, xst_opt):
	prj_contents = ""
	for filename, language in sources:
		prj_contents += language + " work " + 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)
Example #33
0
def _run_vivado(build_name, vivado_path, source, ver=None):
    if sys.platform == "win32" or sys.platform == "cygwin":
        source = False
    build_script_contents = "# Autogenerated by mibuild\nset -e\n"
    if source:
        settings = xilinx_common.settings(vivado_path, ver)
        build_script_contents += "source " + settings + "\n"
    build_script_contents += "vivado -mode tcl -source " + build_name + ".tcl\n"
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file,
                        build_script_contents,
                        force_unix=True)

    r = subprocess.call(["bash", build_script_file])
    if r != 0:
        raise OSError("Subprocess failed")
Example #34
0
def _build_files(device, sources, vincpaths, build_name):
    tcl_contents = ""
    for filename, language in sources:
        tcl_contents += "add_files " + filename.replace("\\", "/") + "\n"

    tcl_contents += "read_xdc %s.xdc\n" % build_name
    tcl_contents += "synth_design -top top -part %s -include_dirs {%s}\n" % (
        device, " ".join(vincpaths))
    tcl_contents += "place_design\n"
    tcl_contents += "route_design\n"
    tcl_contents += "report_timing_summary -file %s_timing.rpt\n" % (
        build_name)
    tcl_contents += "report_utilization -file %s_utilization.rpt\n" % (
        build_name)
    tcl_contents += "write_bitstream -force %s.bit \n" % build_name
    tcl_contents += "quit\n"
    tools.write_to_file(build_name + ".tcl", tcl_contents)
Example #35
0
File: ise.py Project: rohit91/migen
def _run_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 += """hierarchy -check -top top
proc; memory; opt; fsm; opt
synth_xilinx -top top -edif {build_name}.edif""".format(build_name=build_name)

    ys_name = build_name + ".ys"
    tools.write_to_file(ys_name, ys_contents)
    r = subprocess.call(["yosys", ys_name])
    if r != 0:
        raise OSError("Subprocess failed")
Example #36
0
    def build(self,
              fragment,
              build_dir="build",
              build_name="top",
              quartus_path="/opt/Altera",
              run=True):
        tools.mkdir_noerror(build_dir)
        os.chdir(build_dir)

        v_src, named_sc, named_pc = self.get_verilog(fragment)
        v_file = build_name + ".v"
        tools.write_to_file(v_file, v_src)
        sources = self.sources + [(v_file, "verilog")]
        _build_files(self.device, sources, named_sc, named_pc, build_name)
        if run:
            _run_quartus(build_name, quartus_path)

        os.chdir("..")
Example #37
0
	def build(self, fragment, build_dir="build", build_name="top",
			vivado_path="/opt/Xilinx/Vivado", source=True, run=True):
		tools.mkdir_noerror(build_dir)
		os.chdir(build_dir)

		if not isinstance(fragment, _Fragment):
			fragment = fragment.get_fragment()
		self.finalize(fragment)
		v_src, named_sc, named_pc = self.get_verilog(fragment)
		v_file = build_name + ".v"
		tools.write_to_file(v_file, v_src)
		sources = self.sources + [(v_file, "verilog")]
		_build_files(self.device, sources, self.verilog_include_paths, build_name)
		tools.write_to_file(build_name + ".xdc", _build_xdc(named_sc, named_pc))
		if run:
			_run_vivado(build_name, vivado_path, source)
		
		os.chdir("..")
	def build(self):
		# FIXME: Workaround for Xst bug with byte-wide WEs connected to FSMs
		self.mibuild_platform.build(FullMemoryWE(self))
		symtab = self.get_formatted_symtab()
		os.chdir("build")
		build_name = "top"
		write_to_file(build_name + ".symtab", symtab)
		bof_name = build_name + ".bof"
		r = subprocess.call(["mkbof",
			"-t", str(self.mkbof_hwrtyp),
			"-s", build_name + ".symtab",
			"-o", bof_name,
			build_name + ".bin"])
		if r != 0:
			raise OSError("mkbof failed")
		st = os.stat(bof_name)
		os.chmod(bof_name, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
		os.chdir("..")
Example #39
0
def _run_vivado(build_name, vivado_path, source, ver=None):
    if sys.platform == "win32" or sys.platform == "cygwin":
        build_script_contents = "REM Autogenerated by mibuild\n"
        build_script_contents += "vivado -mode batch -source " + 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])
    else:
        build_script_contents = "# Autogenerated by mibuild\nset -e\n"
        settings = common.settings(vivado_path, ver)
        build_script_contents += "source " + settings + "\n"
        build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
        build_script_file = "build_" + build_name + ".sh"
        tools.write_to_file(build_script_file, build_script_contents)
        r = subprocess.call(["bash", build_script_file])

    if r != 0:
        raise OSError("Subprocess failed")
Example #40
0
	def build(self, fragment, build_dir="build", build_name="top",
			quartus_path="/opt/Altera", run=True):
		tools.mkdir_noerror(build_dir)
		os.chdir(build_dir)

		if not isinstance(fragment, _Fragment):
			fragment = fragment.get_fragment()
		self.finalize(fragment)
		
		v_src, named_sc, named_pc = self.get_verilog(fragment)
		v_file = build_name + ".v"
		tools.write_to_file(v_file, v_src)
		sources = self.sources + [(v_file, "verilog")]
		_build_files(self.device, sources, self.verilog_include_paths, named_sc, named_pc, build_name)
		if run:
			_run_quartus(build_name, quartus_path)
		
		os.chdir("..")
Example #41
0
def _build_files(device, sources, vincpaths, named_sc, named_pc, build_name):
    lines = []
    for filename, language, library in sources:
        # Enforce use of SystemVerilog
        # (Quartus does not support global parameters in Verilog)
        if language == "verilog":
            language = "systemverilog"
        lines.append(
            "set_global_assignment -name {lang}_FILE {path} "
            "-library {lib}".format(
                lang=language.upper(),
                path=filename.replace("\\", "/"),
                lib=library))

    for path in vincpaths:
        lines.append("set_global_assignment -name SEARCH_PATH {}".format(
            path.replace("\\", "/")))

    lines.append(_build_qsf(named_sc, named_pc))
    lines.append("set_global_assignment -name DEVICE {}".format(device))
    tools.write_to_file("{}.qsf".format(build_name), "\n".join(lines))
Example #42
0
    def build(self, platform, fragment, build_dir="build", build_name="top",
            vivado_path="/opt/Xilinx/Vivado", source=True, run=True):
        tools.mkdir_noerror(build_dir)
        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")}
        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, vivado_path, source)

        os.chdir("..")

        return v_output.ns
Example #43
0
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
		bitgen_opt, ise_commands, map_opt, par_opt):
	if sys.platform == "win32" or sys.platform == "cygwin":
		source = False
	build_script_contents = "# Autogenerated by mibuild\nset -e\n"
	if source:
		vers = [ver for ver in os.listdir(ise_path) if _is_valid_version(ise_path, ver)]
		tools_version = max(vers)
		bits = struct.calcsize("P")*8
		
		xilinx_settings_file = os.path.join(ise_path, tools_version, "ISE_DS", "settings{0}.sh".format(bits))
		if not os.path.exists(xilinx_settings_file) and bits == 64:
			# if we are on 64-bit system but the toolchain isn't, try the 32-bit env.
			xilinx_settings_file = os.path.join(ise_path, tools_version, "ISE_DS", "settings32.sh")
		build_script_contents += "source " + xilinx_settings_file + "\n"
	if mode == "edif":
		ext = "edif"
	else:
		ext = "ngc"
		build_script_contents += """
xst -ifn {build_name}.xst"""

	build_script_contents += """
ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd
map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf
par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf
bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit
"""
	build_script_contents = build_script_contents.format(build_name=build_name,
			ngdbuild_opt=ngdbuild_opt, bitgen_opt=bitgen_opt, ext=ext,
			par_opt=par_opt, map_opt=map_opt)
	build_script_contents += ise_commands.format(build_name=build_name)
	build_script_file = "build_" + build_name + ".sh"
	tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

	r = subprocess.call(["bash", build_script_file])
	if r != 0:
		raise OSError("Subprocess failed")
Example #44
0
def _build_sim(platform, vns, build_name, include_paths, sim_path, serial, verbose):
    include = ""
    for path in include_paths:
        include += "-I"+path+" "

    build_script_contents = """# Autogenerated by mibuild
    rm -rf obj_dir/
verilator {disable_warnings} -O3 --cc dut.v --exe dut_tb.cpp -LDFLAGS "-lpthread" -trace {include}
make -j -C obj_dir/ -f Vdut.mk Vdut

""".format(
    disable_warnings="-Wno-fatal",
    include=include)
    build_script_file = "build_" + build_name + ".sh"
    tools.write_to_file(build_script_file, build_script_contents, force_unix=True)

    _build_tb(platform, vns, serial, os.path.join("..", sim_path, "dut_tb.cpp"))
    if verbose:
        r = subprocess.call(["bash", build_script_file])
    else:
        r = subprocess.call(["bash", build_script_file], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
    if r != 0:
        raise OSError("Subprocess failed")
Example #45
0
def _build_files(device, sources, vincpaths, build_name,
                 bitstream_compression):
    tcl = []
    for filename, language in sources:
        tcl.append("add_files " + filename.replace("\\", "/"))

    tcl.append("read_xdc %s.xdc" % build_name)
    tcl.append("synth_design -top top -part %s -include_dirs {%s}" %
               (device, " ".join(vincpaths)))
    tcl.append(
        "report_utilization -hierarchical -file %s_utilization_hierarchical_synth.rpt"
        % (build_name))
    tcl.append("report_utilization -file %s_utilization_synth.rpt" %
               (build_name))
    tcl.append("place_design")
    tcl.append(
        "report_utilization -hierarchical -file %s_utilization_hierarchical_place.rpt"
        % (build_name))
    tcl.append("report_utilization -file %s_utilization_place.rpt" %
               (build_name))
    tcl.append("report_io -file %s_io.rpt" % (build_name))
    tcl.append("report_control_sets -verbose -file %s_control_sets.rpt" %
               (build_name))
    tcl.append("report_clock_utilization -file %s_clock_utilization.rpt" %
               (build_name))
    tcl.append("route_design")
    tcl.append("report_route_status -file %s_route_status.rpt" % (build_name))
    tcl.append("report_drc -file %s_drc.rpt" % (build_name))
    tcl.append("report_timing_summary -max_paths 10 -file %s_timing.rpt" %
               (build_name))
    tcl.append("report_power -file %s_power.rpt" % (build_name))
    if bitstream_compression:
        tcl.append(
            "set_property BITSTREAM.GENERAL.COMPRESS True [current_design]")
    tcl.append("write_bitstream -force %s.bit " % build_name)
    tcl.append("quit")
    tools.write_to_file(build_name + ".tcl", "\n".join(tcl))
Example #46
0
    def build(self,
              fragment,
              build_dir="build",
              build_name="top",
              ise_path="/opt/Xilinx",
              source=True,
              run=True,
              mode="xst"):
        tools.mkdir_noerror(build_dir)
        os.chdir(build_dir)

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

        ngdbuild_opt = self.ngdbuild_opt

        if mode == "xst" or mode == "yosys":
            v_src, named_sc, named_pc = self.get_verilog(fragment)
            v_file = build_name + ".v"
            tools.write_to_file(v_file, v_src)
            sources = self.sources + [(v_file, "verilog")]
            if mode == "xst":
                _build_xst_files(self.device, sources,
                                 self.verilog_include_paths, build_name,
                                 self.xst_opt)
                isemode = "xst"
            else:
                _run_yosys(self.device, sources, self.verilog_include_paths,
                           build_name)
                isemode = "edif"
                ngdbuild_opt += "-p " + self.device

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

        if mode == "edif" or mode == "mist":
            e_src, named_sc, named_pc = self.get_edif(fragment)
            e_file = build_name + ".edif"
            tools.write_to_file(e_file, e_src)
            isemode = "edif"

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

        os.chdir("..")
Example #47
0
def _build_files(device, sources, named_sc, named_pc, build_name):
    tools.write_to_file(build_name + ".ucf", _build_ucf(named_sc, named_pc))

    prj_contents = ""
    for filename, language in sources:
        prj_contents += language + " work " + filename + "\n"
    tools.write_to_file(build_name + ".prj", prj_contents)

    xst_contents = """run
-ifn %s.prj
-top top
-ifmt MIXED
-opt_mode SPEED
-reduce_control_sets auto
-register_balancing yes
-ofn %s.ngc
-p %s""" % (build_name, build_name, device)
    tools.write_to_file(build_name + ".xst", xst_contents)
Example #48
0
        actions["build-csr-header"] = True
        actions["build-bitstream"] = True
        actions["load-bitstream"] = True

    if actions["build-bitstream"]:
        actions["build-csr-csv"] = True
        actions["build-csr-header"] = True
        actions["build-bitstream"] = True
        actions["load-bitstream"] = True

    if actions["clean"]:
        subprocess.call(["rm", "-rf", "build/*"])

    if actions["build-csr-csv"]:
        csr_csv = cpuif.get_csr_csv(csr_regions)
        write_to_file(args.csr_csv, csr_csv)

    if actions["build-csr-header"]:
        csr_header = cpuif.get_csr_header(csr_regions,
                                          soc.get_constants(),
                                          with_access_functions=False)
        write_to_file(args.csr_header, csr_header)

    if actions["build-bitstream"]:
        vns = platform.build(soc, build_name=build_name)
        if hasattr(soc, "do_exit") and vns is not None:
            if hasattr(soc.do_exit, '__call__'):
                soc.do_exit(vns)

    if actions["load-bitstream"]:
        prog = platform.create_programmer()
Example #49
0
System Clk: {} MHz
===============================""".format(soc.clk_freq / 1000000))

    # dependencies
    if actions["all"]:
        actions["build-csr-csv"] = True
        actions["build-bitstream"] = True
        actions["load-bitstream"] = True

    if actions["build-bitstream"]:
        actions["build-csr-csv"] = True
        actions["build-bitstream"] = True
        actions["load-bitstream"] = True

    if actions["clean"]:
        subprocess.call(["rm", "-rf", "build/*"])

    if actions["build-csr-csv"]:
        csr_csv = cpuif.get_csr_csv(csr_regions)
        write_to_file(args.csr_csv, csr_csv)

    if actions["build-bitstream"]:
        vns = platform.build(soc, build_name=build_name, run=True)
        if hasattr(soc, "do_exit") and vns is not None:
            if hasattr(soc.do_exit, '__call__'):
                soc.do_exit(vns)

    if actions["load-bitstream"]:
        prog = platform.create_programmer()
        prog.load_bitstream("build/" + build_name + platform.bitstream_ext)
Example #50
0
File: make.py Project: gbraad/misoc
            ["make", "-C",
             os.path.join("software", "bios"), "clean"])

    if actions["build-headers"]:
        boilerplate = """/*
 * Platform:  {}
 * Target:    {}
 * Subtarget: {}
 * CPU type:  {}
 */

""".format(platform_name, args.target, top_class.__name__, soc.cpu_type)
        genhdir = os.path.join("software", "include", "generated")
        if soc.cpu_type != "none":
            cpu_mak = cpuif.get_cpu_mak(soc.cpu_type)
            write_to_file(os.path.join(genhdir, "cpu.mak"), cpu_mak)
            linker_output_format = cpuif.get_linker_output_format(soc.cpu_type)
            write_to_file(os.path.join(genhdir, "output_format.ld"),
                          linker_output_format)

            linker_regions = cpuif.get_linker_regions(memory_regions)
            write_to_file(os.path.join(genhdir, "regions.ld"),
                          boilerplate + linker_regions)

            for sdram_phy in ["sdrphy", "ddrphy"]:
                if hasattr(soc, sdram_phy):
                    sdram_phy_header = initsequence.get_sdram_phy_header(
                        getattr(soc, sdram_phy).settings)
                    write_to_file(os.path.join(genhdir, "sdram_phy.h"),
                                  boilerplate + sdram_phy_header)
        mem_header = cpuif.get_mem_header(