3 import argparse
, importlib
, subprocess
5 from mibuild
.tools
import write_to_file
7 from misoclib
.gensoc
import cpuif
8 from misoclib
.s6ddrphy
import initsequence
12 parser
= argparse
.ArgumentParser(description
="MiSoC - a high performance SoC based on Migen.")
14 parser
.add_argument("-p", "--platform", default
="mixxeo", help="platform to build for")
15 parser
.add_argument("-t", "--target", default
="mlabs_video", help="SoC type to build")
16 parser
.add_argument("-s", "--sub-target", default
="", help="variant of the SoC type to build")
18 parser
.add_argument("-B", "--no-bitstream", default
=False, action
="store_true", help="do not build bitstream file")
19 parser
.add_argument("-H", "--no-header", default
=False, action
="store_true", help="do not build C header files with CSR/IRQ/SDRAM_PHY definitions")
20 parser
.add_argument("-c", "--csr-csv", default
="", help="save CSR map into CSV file")
22 parser
.add_argument("-l", "--load", default
=False, action
="store_true", help="load bitstream to FPGA volatile memory")
23 parser
.add_argument("-f", "--flash", default
=False, action
="store_true", help="load bitstream to flash")
25 return parser
.parse_args()
30 platform_module
= importlib
.import_module("mibuild.platforms." + args
.platform
)
31 target_module
= importlib
.import_module("targets." + args
.target
)
32 platform
= platform_module
.Platform()
34 top_class
= getattr(target_module
, args
.sub_target
)
36 top_class
= target_module
.get_default_subtarget(platform
)
37 build_name
= top_class
.__name
__.lower() + "-" + args
.platform
38 soc
= top_class(platform
)
40 if not args
.no_bitstream
:
41 platform
.build(soc
, build_name
=build_name
)
42 subprocess
.call(["tools/byteswap",
43 "build/" + build_name
+ ".bin",
44 "build/" + build_name
+ ".fpg"])
47 if not args
.no_header
:
54 """.format(args
.platform
, args
.target
, top_class
.__name
__)
55 csr_header
= cpuif
.get_csr_header(soc
.csr_base
, soc
.csrbankarray
, soc
.interrupt_map
)
56 write_to_file("software/include/hw/csr.h", boilerplate
+ csr_header
)
57 sdram_phy_header
= initsequence
.get_sdram_phy_header(soc
.ddrphy
)
58 write_to_file("software/include/hw/sdram_phy.h", boilerplate
+ sdram_phy_header
)
60 csr_csv
= cpuif
.get_csr_csv(soc
.csr_base
, soc
.csrbankarray
)
61 write_to_file(args
.csr_csv
, csr_csv
)
64 jtag
.load("build/" + build_name
+ ".bit")
66 jtag
.flash("build/" + build_name
+ ".fpg")
68 if __name__
== "__main__":