r += "\n" + "\n\n".join(named_pc)
return r
-def _build_xst_files(device, sources, build_name):
+def _build_xst_files(device, sources, 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 %s.prj
+-ifn {build_name}.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)
+{xst_opt}
+-ofn {build_name}.ngc
+-p {device}""".format(build_name=build_name, xst_opt=xst_opt, device=device)
tools.write_to_file(build_name + ".xst", xst_contents)
def _run_yosys(device, sources, build_name):
except:
return False
-def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt):
+def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
+ bitgen_opt, ise_commands):
if sys.platform == "win32" or sys.platform == "cygwin":
source = False
build_script_contents = "# Autogenerated by mibuild\nset -e\n"
build_script_contents += """
map -ol high -w -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf
par -ol high -w {build_name}_map.ncd {build_name}.ncd {build_name}.pcf
-bitgen -g LCK_cycle:6 -g Binary:Yes -w {build_name}.ncd {build_name}.bit
+bitgen {bitgen_opt} -w {build_name}.ncd {build_name}.bit
"""
- build_script_contents = build_script_contents.format(build_name=build_name, ngdbuild_opt=ngdbuild_opt)
+ build_script_contents = build_script_contents.format(build_name=build_name,
+ ngdbuild_opt=ngdbuild_opt, bitgen_opt=bitgen_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)
return XilinxMultiRegImpl(dr.i, dr.o, dr.odomain, dr.n)
class XilinxISEPlatform(GenericPlatform):
+ xst_opt = """-ifmt MIXED
+-opt_mode SPEED
+-reduce_control_sets auto
+-register_balancing yes"""
+ ngdbuild_opt = ""
+ bitgen_opt = "-g LCK_cycle:6 -g Binary:Yes"
+ ise_commands = ""
def get_verilog(self, *args, special_overrides=dict(), **kwargs):
so = {
NoRetiming: XilinxNoRetiming,
fragment = fragment.get_fragment()
self.finalize(fragment)
- ngdbuild_opt = ""
+ ngdbuild_opt = self.ngdbuild_opt
if mode == "xst" or mode == "yosys":
v_src, named_sc, named_pc = self.get_verilog(fragment)
tools.write_to_file(v_file, v_src)
sources = self.sources + [(v_file, "verilog")]
if mode == "xst":
- _build_xst_files(self.device, sources, build_name)
+ _build_xst_files(self.device, sources, build_name, self.xst_opt)
isemode = "xst"
else:
_run_yosys(self.device, sources, build_name)
isemode = "edif"
- ngdbuild_opt = "-p " + self.device
+ ngdbuild_opt += "-p " + self.device
if mode == "mist":
from mist import synthesize
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)
+ _run_ise(build_name, ise_path, source, isemode,
+ ngdbuild_opt, self.bitgen_opt, self.ise_commands)
os.chdir("..")