Try again for passes/pmgen/ice40_dsp_pm.h rule
authorLarry Doolittle <ldoolitt@recycle.lbl.gov>
Sat, 2 Mar 2019 04:15:20 +0000 (20:15 -0800)
committerClifford Wolf <clifford@clifford.at>
Sat, 2 Mar 2019 04:20:53 +0000 (20:20 -0800)
Tested on both in-tree and out-of-tree builds

passes/pmgen/Makefile.inc
passes/pmgen/pmgen.py

index e0dd0fc0690bf0b77992ea722f911d94c4c63017..e0609d9ba368e1f76e0092bbb0cd60ff63ff4927 100644 (file)
@@ -5,4 +5,4 @@ EXTRA_OBJS += passes/pmgen/ice40_dsp_pm.h
 .SECONDARY: passes/pmgen/ice40_dsp_pm.h
 
 passes/pmgen/ice40_dsp_pm.h: passes/pmgen/pmgen.py passes/pmgen/ice40_dsp.pmg
-       $(P) mkdir -p passes/pmgen && python3 $^
+       $(P) mkdir -p passes/pmgen && python3 $^ $@
index 762d8621fd59de79d37ee3176168cc8e30d28bc6..d9747b065bed36dd1b527a8fd8637de9deecda7f 100644 (file)
@@ -9,7 +9,8 @@ pp = pprint.PrettyPrinter(indent=4)
 pmgfile = sys.argv[1]
 assert pmgfile.endswith(".pmg")
 prefix = pmgfile[0:-4]
-pmname = prefix.split('/')[-1]
+prefix = prefix.split('/')[-1]
+outfile = sys.argv[2]
 
 state_types = dict()
 udata_types = dict()
@@ -179,7 +180,7 @@ with open(pmgfile, "r") as f:
 
             blocks.append(block)
 
-with open("%s_pm.h" % prefix, "w") as f:
+with open(outfile, "w") as f:
     print("// Generated by pmgen.py from {}.pgm".format(prefix), file=f)
     print("", file=f)
 
@@ -190,10 +191,10 @@ with open("%s_pm.h" % prefix, "w") as f:
     print("YOSYS_NAMESPACE_BEGIN", file=f)
     print("", file=f)
 
-    print("struct {}_pm {{".format(pmname), file=f)
+    print("struct {}_pm {{".format(prefix), file=f)
     print("  Module *module;", file=f)
     print("  SigMap sigmap;", file=f)
-    print("  std::function<void()> on_accept;".format(pmname), file=f)
+    print("  std::function<void()> on_accept;".format(prefix), file=f)
     print("", file=f)
 
     for index in range(len(blocks)):
@@ -291,7 +292,7 @@ with open("%s_pm.h" % prefix, "w") as f:
     print("  }", file=f)
     print("", file=f)
 
-    print("  {}_pm(Module *module, const vector<Cell*> &cells) :".format(pmname), file=f)
+    print("  {}_pm(Module *module, const vector<Cell*> &cells) :".format(prefix), file=f)
     print("      module(module), sigmap(module) {", file=f)
     for s, t in sorted(udata_types.items()):
         if t.endswith("*"):
@@ -321,7 +322,7 @@ with open("%s_pm.h" % prefix, "w") as f:
     print("  }", file=f)
     print("", file=f)
 
-    print("  ~{}_pm() {{".format(pmname), file=f)
+    print("  ~{}_pm() {{".format(prefix), file=f)
     print("    for (auto cell : autoremove_cells)", file=f)
     print("      module->remove(cell);", file=f)
     print("  }", file=f)
@@ -340,7 +341,7 @@ with open("%s_pm.h" % prefix, "w") as f:
     print("  }", file=f)
     print("", file=f)
 
-    print("  void run(std::function<void({}_pm&)> on_accept_f) {{".format(pmname), file=f)
+    print("  void run(std::function<void({}_pm&)> on_accept_f) {{".format(prefix), file=f)
     print("    run([&](){on_accept_f(*this);});", file=f)
     print("  }", file=f)
     print("", file=f)