mirror of https://github.com/YosysHQ/yosys.git
Support multiple pmg files (right now just concatenated together)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
408161ea3a
commit
32881a989c
|
@ -3,14 +3,34 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import pprint
|
import pprint
|
||||||
|
import getopt
|
||||||
|
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
|
||||||
pmgfile = sys.argv[1]
|
prefix = None
|
||||||
assert pmgfile.endswith(".pmg")
|
pmgfiles = list()
|
||||||
prefix = pmgfile[0:-4]
|
outfile = None
|
||||||
prefix = prefix.split('/')[-1]
|
|
||||||
outfile = sys.argv[2]
|
opts, args = getopt.getopt(sys.argv[1:], "p:o:")
|
||||||
|
|
||||||
|
for o, a in opts:
|
||||||
|
if o == "-p":
|
||||||
|
prefix = o
|
||||||
|
elif o == "-o":
|
||||||
|
outfile = a
|
||||||
|
|
||||||
|
if outfile is None:
|
||||||
|
outfile = args[-1]
|
||||||
|
args = args[0:-1]
|
||||||
|
|
||||||
|
for a in args:
|
||||||
|
assert a.endswith(".pmg")
|
||||||
|
if prefix is None and len(args) == 1:
|
||||||
|
prefix = a[0:-4]
|
||||||
|
prefix = prefix.split('/')[-1]
|
||||||
|
pmgfiles.append(a)
|
||||||
|
|
||||||
|
assert prefix is not None
|
||||||
|
|
||||||
state_types = dict()
|
state_types = dict()
|
||||||
udata_types = dict()
|
udata_types = dict()
|
||||||
|
@ -77,7 +97,7 @@ def rewrite_cpp(s):
|
||||||
|
|
||||||
return "".join(t)
|
return "".join(t)
|
||||||
|
|
||||||
with open(pmgfile, "r") as f:
|
def process_pmgfile(f):
|
||||||
while True:
|
while True:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
if line == "": break
|
if line == "": break
|
||||||
|
@ -180,6 +200,10 @@ with open(pmgfile, "r") as f:
|
||||||
|
|
||||||
blocks.append(block)
|
blocks.append(block)
|
||||||
|
|
||||||
|
for fn in pmgfiles:
|
||||||
|
with open(fn, "r") as f:
|
||||||
|
process_pmgfile(f)
|
||||||
|
|
||||||
with open(outfile, "w") as f:
|
with open(outfile, "w") as f:
|
||||||
print("// Generated by pmgen.py from {}.pgm".format(prefix), file=f)
|
print("// Generated by pmgen.py from {}.pgm".format(prefix), file=f)
|
||||||
print("", file=f)
|
print("", file=f)
|
||||||
|
|
Loading…
Reference in New Issue