utils/vlog: Use same capitalisation scheme in xmlgen as everywhere else Lowercase for file names and uppercase for model names Signed-off-by: David Shah <davey1576@gmail.com> Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
diff --git a/vlog_to_model.py b/vlog_to_model.py index 2932e43..ef71a44 100755 --- a/vlog_to_model.py +++ b/vlog_to_model.py
@@ -34,8 +34,8 @@ parser.add_argument( '--top', help="""\ -Top level module, not needed if only one module exists across all input Verilog -files, in which case that module will be used as the top level. +Top level module, will usually be automatically determined from the file name +%.sim.v """) parser.add_argument( '-o', @@ -47,12 +47,18 @@ aig_json = yosys.run.vlog_to_json(args.infiles, True, True) -if "top" in args: +if args.top is not None: yj = YosysJson(aig_json, args.top) + top = yj.top else: - yj = YosysJson(aig_json) + wm = re.match(r"([A-Za-z0-9_]+)\.sim\.v", args.infiles[0]) + if wm: + top = wm.group(1).upper() + else: + print("ERROR file name not of format %.sim.v, cannot detect top level. Manually specify the top level module using --top") + sys.exit(1) + yj = YosysJson(aig_json, top) -top = yj.top if top is None: print("ERROR: more than one module in design, cannot detect top level. Manually specify the top level module using --top") sys.exit(1)
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 5af3601..66ecaaf 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -64,8 +64,8 @@ parser.add_argument( '--top', help="""\ -Top level module, not needed if only one module exists across all input Verilog -files, in which case that module will be used as the top level. +Top level module, will usually be automatically determined from the file name +%.sim.v """) parser.add_argument( '-o', @@ -89,11 +89,13 @@ if args.top is not None: top = args.top else: - top = yj.top + wm = re.match(r"([A-Za-z0-9_]+)\.sim\.v", args.infiles[0]) + if wm: + top = wm.group(1).upper() + else: + print("ERROR file name not of format %.sim.v, cannot detect top level. Manually specify the top level module using --top") + sys.exit(1) -if top is None: - print("ERROR: more than one module in design, cannot detect top level. Manually specify the top level module using --top") - sys.exit(1) tmod = yj.module(top) @@ -160,7 +162,7 @@ # Heuristic for autogenerated files from w.py wm = re.match(r"([A-Za-z0-9_]+)\.sim\.v", module_basename) if wm: - pb_type_path = "%s/%s.pb_type.xml" % (module_path, wm.group(1)) + pb_type_path = "%s/%s.pb_type.xml" % (module_path, wm.group(1).lower()) else: pb_type_path = "%s/pb_type.xml" % module_path include_xml(xml_parent, pb_type_path)