litex/build.py

44 lines
1.2 KiB
Python
Raw Normal View History

2011-12-13 11:33:12 -05:00
import os
import top
# list Verilog sources before changing directory
verilog_sources = []
def add_core_dir(d):
root = os.path.join("verilog", d)
files = os.listdir(root)
for f in files:
if f[-2:] == ".v":
2011-12-13 11:33:12 -05:00
verilog_sources.append(os.path.join(root, f))
def add_core_files(d, files):
for f in files:
verilog_sources.append(os.path.join("verilog", d, f))
2012-05-19 18:30:03 -04:00
add_core_dir("generic")
2012-02-16 12:02:37 -05:00
add_core_dir("m1crg")
add_core_dir("s6ddrphy")
2011-12-13 11:33:12 -05:00
add_core_files("lm32", ["lm32_cpu.v", "lm32_instruction_unit.v", "lm32_decoder.v",
"lm32_load_store_unit.v", "lm32_adder.v", "lm32_addsub.v", "lm32_logic_op.v",
"lm32_shifter.v", "lm32_multiplier_spartan6.v", "lm32_mc_arithmetic.v",
"lm32_interrupt.v", "lm32_ram.v", "lm32_dp_ram.v", "lm32_icache.v",
"lm32_dcache.v", "lm32_top.v", "lm32_debug.v", "lm32_jtag.v", "jtag_cores.v",
"jtag_tap_spartan6.v"])
2012-05-19 18:30:03 -04:00
add_core_dir("minimac3")
2011-12-13 11:33:12 -05:00
os.chdir("build")
def str2file(filename, contents):
2012-02-14 07:15:00 -05:00
f = open(filename, "w")
2011-12-13 11:33:12 -05:00
f.write(contents)
f.close()
# generate source
2011-12-16 10:02:49 -05:00
(src_verilog, src_ucf) = top.get()
2011-12-13 11:33:12 -05:00
str2file("soc.v", src_verilog)
str2file("soc.ucf", src_ucf)
verilog_sources.append("build/soc.v")
# generate XST project file
2011-12-13 11:33:12 -05:00
xst_prj = ""
for s in verilog_sources:
xst_prj += "verilog work ../" + s + "\n"
str2file("soc.prj", xst_prj)