verilog importer improvements for use with actual arch Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/vlog_to_model.py b/vlog_to_model.py index b3fcd5f..2932e43 100755 --- a/vlog_to_model.py +++ b/vlog_to_model.py
@@ -6,6 +6,12 @@ - `(* CLOCK *)` : force a given port to be a clock - `(* ASSOC_CLOCK="RDCLK" *)` : force a port's associated clock to a given value + +The following Verilog attributes are considered on modules: + - `(* MODEL_NAME="model" *)` : override the name used for <model> and for + ".subckt name" in the BLIF model. Mostly intended for use with w.py, when several + different pb_types implement the same model. + """ import argparse, re import os, tempfile, sys @@ -53,7 +59,10 @@ tmod = yj.top_module models_xml = ET.Element("models") -model_xml = ET.SubElement(models_xml, "model", {'name': top}) + +topname = tmod.attr("MODEL_NAME", top) + +model_xml = ET.SubElement(models_xml, "model", {'name': topname}) ports = tmod.ports inports_xml = ET.SubElement(model_xml, "input_ports")
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 0f2a126..c15bffc 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -17,6 +17,10 @@ modes of another module (i.e. a <mode> in the pb_type). Note that all modes must be visible at the time of pb_type generation. + - `(* MODEL_NAME="model" *)` : override the name used for <model> and for + ".subckt name" in the BLIF model. Mostly intended for use with w.py, when several + different pb_types implement the same model. + The following are allowed on nets within modules (TODO: use proper Verilog timing): - `(* SETUP="clk 10e-12" *)` : specify setup time for a given clock @@ -147,8 +151,15 @@ # Process cells. First build the list of cnames. for cname, i_of in mod.cells: pb_name = i_of - module_path = os.path.dirname(yj.get_module_file(i_of)) - pb_type_path = "%s/pb_type.xml" % module_path + module_file = yj.get_module_file(i_of) + module_path = os.path.dirname(module_file) + module_basename = os.path.basename(module_file) + # Heuristic for autogenerated files from w.py + wm = re.match(r"sim\.([A-Za-z0-9]+)\.v", module_basename) + if wm: + pb_type_path = "%s/pb_type.%s.xml" % (module_path, wm.group(1)) + else: + pb_type_path = "%s/pb_type.xml" % module_path include_xml(xml_parent, pb_type_path) # In order to avoid overspecifying interconnect, there are two directions we currently # consider. All interconnect going INTO a cell, and interconnect going out of a cell @@ -258,7 +269,7 @@ else: assert False elif is_blackbox and not has_modes: - pb_xml_attrs["blif_model"] = ".subckt " + mod.name + pb_xml_attrs["blif_model"] = ".subckt " + mod.attr("MODEL_NAME", mod.name) #TODO: might not always be the case? should be use Verilog `generate`s to detect this? pb_xml_attrs["num_pb"] = "1"