Can now pass `--seed` to `nextpnr-ecp5` via `TrellisToolchain` `kwargs`
authorIlya Epifanov <elijah.epifanov@gmail.com>
Tue, 28 Apr 2020 20:10:20 +0000 (22:10 +0200)
committerIlya Epifanov <elijah.epifanov@gmail.com>
Tue, 28 Apr 2020 20:25:57 +0000 (22:25 +0200)
litex/build/lattice/trellis.py

index fa19b91929e7700559e3a92ef8d9b9a67b8a3389..3aba0a849f6d997758ae33f03cb88c15243e0576 100644 (file)
@@ -117,11 +117,11 @@ nextpnr_ecp5_architectures = {
 _build_template = [
     "yosys -l {build_name}.rpt {build_name}.ys",
     "nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config  \
-    --{architecture} --package {package} --speed {speed_grade} {timefailarg} {ignoreloops}",
+    --{architecture} --package {package} --speed {speed_grade} {timefailarg} {ignoreloops} {seed}",
     "ecppack {build_name}.config --svf {build_name}.svf --bit {build_name}.bit"
 ]
 
-def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict, ignoreloops):
+def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict, ignoreloops, seed):
     if sys.platform in ("win32", "cygwin"):
         script_ext = ".bat"
         script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
@@ -140,7 +140,8 @@ def _build_script(source, build_template, build_name, architecture, package, spe
             speed_grade     = speed_grade,
             timefailarg     = "--timing-allow-fail" if not timingstrict else "",
             ignoreloops     = "--ignore-loops" if ignoreloops else "",
-            fail_stmt       = fail_stmt)
+            fail_stmt       = fail_stmt,
+            seed            = f"--seed {seed}" if seed is not None else "")
 
     script_file = "build_" + build_name + script_ext
     tools.write_to_file(script_file, script_contents, force_unix=False)
@@ -186,6 +187,7 @@ class LatticeTrellisToolchain:
         nowidelut      = False,
         timingstrict   = False,
         ignoreloops    = False,
+        seed           = None,
         **kwargs):
 
         # Create build directory
@@ -217,7 +219,7 @@ class LatticeTrellisToolchain:
 
         # Generate build script
         script = _build_script(False, self.build_template, build_name, architecture, package,
-            speed_grade, timingstrict, ignoreloops)
+            speed_grade, timingstrict, ignoreloops, seed)
 
         # Run
         if run: