Naming fixes Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/tests/adder/pb_type.xml b/tests/adder/pb_type.xml index f14d676..e48eb59 100644 --- a/tests/adder/pb_type.xml +++ b/tests/adder/pb_type.xml
@@ -1,13 +1,13 @@ -<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".subckt adder" name="adder" num_pb="1"> +<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".subckt adder" name="BLK_BB-adder" num_pb="1"> <input equivalent="false" name="a" num_pins="1"/> <input equivalent="false" name="b" num_pins="1"/> <input equivalent="false" name="ci" num_pins="1"/> <output equivalent="false" name="y" num_pins="1"/> <output equivalent="false" name="co" num_pins="1"/> - <delay_constant in_port="adder.a" max="20e-12" out_port="adder.y"/> - <delay_constant in_port="adder.b" max="20e-12" out_port="adder.y"/> - <delay_constant in_port="adder.ci" max="10e-12" out_port="adder.y"/> - <delay_constant in_port="adder.a" max="10e-12" out_port="adder.co"/> - <delay_constant in_port="adder.b" max="10e-12" out_port="adder.co"/> - <delay_constant in_port="adder.ci" max="7e-12" out_port="adder.co"/> + <delay_constant in_port="BLK_BB-adder.a" max="20e-12" out_port="BLK_BB-adder.y"/> + <delay_constant in_port="BLK_BB-adder.b" max="20e-12" out_port="BLK_BB-adder.y"/> + <delay_constant in_port="BLK_BB-adder.ci" max="10e-12" out_port="BLK_BB-adder.y"/> + <delay_constant in_port="BLK_BB-adder.a" max="10e-12" out_port="BLK_BB-adder.co"/> + <delay_constant in_port="BLK_BB-adder.b" max="10e-12" out_port="BLK_BB-adder.co"/> + <delay_constant in_port="BLK_BB-adder.ci" max="7e-12" out_port="BLK_BB-adder.co"/> </pb_type>
diff --git a/tests/dff/pb_type.xml b/tests/dff/pb_type.xml index 5d80b66..60e40f9 100644 --- a/tests/dff/pb_type.xml +++ b/tests/dff/pb_type.xml
@@ -1,8 +1,8 @@ -<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".latch" class="flipflop" name="dff" num_pb="1"> +<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".latch" class="flipflop" name="BLK_FF-dff" num_pb="1"> <clock equivalent="false" name="clk" num_pins="1" port_class="clock"/> <input equivalent="false" name="d" num_pins="1" port_class="D"/> <output equivalent="false" name="q" num_pins="1" port_class="Q"/> - <T_setup clock="clk" port="dff.d" value="200e-12"/> - <T_hold clock="clk" port="dff.d" value="50e-12"/> - <T_clock_to_Q clock="clk" max="400e-12" port="dff.q"/> + <T_setup clock="clk" port="BLK_FF-dff.d" value="200e-12"/> + <T_hold clock="clk" port="BLK_FF-dff.d" value="50e-12"/> + <T_clock_to_Q clock="clk" max="400e-12" port="BLK_FF-dff.q"/> </pb_type>
diff --git a/tests/lut2/pb_type.xml b/tests/lut2/pb_type.xml index 8c11624..1c6d780 100644 --- a/tests/lut2/pb_type.xml +++ b/tests/lut2/pb_type.xml
@@ -1,7 +1,7 @@ -<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".subckt lut2" name="lut2" num_pb="1"> +<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".subckt lut2" name="BLK_BB-lut2" num_pb="1"> <input equivalent="false" name="in" num_pins="2"/> <output equivalent="false" name="y" num_pins="1"/> - <delay_matrix in_port="lut2.in" out_port="lut2.y" type="max"> + <delay_matrix in_port="BLK_BB-lut2.in" out_port="BLK_BB-lut2.y" type="max"> 10e-12 10e-12 </delay_matrix>
diff --git a/tests/pb_type.xml b/tests/pb_type.xml index b733dce..a4b7408 100644 --- a/tests/pb_type.xml +++ b/tests/pb_type.xml
@@ -1,4 +1,4 @@ -<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="test_pb" num_pb="1"> +<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="BLK_IG-test_pb" num_pb="1"> <input equivalent="false" name="clk" num_pins="1"/> <input equivalent="false" name="a" num_pins="1"/> <input equivalent="false" name="b" num_pins="1"/> @@ -9,24 +9,24 @@ <xi:include href="adder/pb_type.xml"/> <xi:include href="dff/pb_type.xml"/> <interconnect> - <direct input="test_add.a" name="adder_a" output="adder.a"/> - <direct input="test_add.b" name="adder_b" output="adder.b"/> - <direct input="test_add.ci" name="adder_ci" output="adder.ci"/> - <direct input="adder.co" name="test_add_co" output="test_add.co"/> - <direct input="test_add.clk" name="dff_clk" output="dff.clk"/> - <direct input="adder.y" name="dff_d" output="dff.d"/> - <direct input="dff.q" name="test_add_q" output="test_add.q"/> + <direct input="test_pb.a" name="BLK_BB-adder_a" output="BLK_BB-adder.a"/> + <direct input="test_pb.b" name="BLK_BB-adder_b" output="BLK_BB-adder.b"/> + <direct input="test_pb.ci" name="BLK_BB-adder_ci" output="BLK_BB-adder.ci"/> + <direct input="BLK_BB-adder.co" name="test_pb_co" output="test_pb.co"/> + <direct input="test_pb.clk" name="BLK_FF-dff_clk" output="BLK_FF-dff.clk"/> + <direct input="BLK_BB-adder.y" name="BLK_FF-dff_d" output="BLK_FF-dff.d"/> + <direct input="BLK_FF-dff.q" name="test_pb_q" output="test_pb.q"/> </interconnect> </mode> <mode name="test_lut"> <xi:include href="dff/pb_type.xml"/> <xi:include href="lut2/pb_type.xml"/> <interconnect> - <direct input="test_lut.clk" name="dff_clk" output="dff.clk"/> - <direct input="lut2.y" name="dff_d" output="dff.d"/> - <direct input="dff.q" name="test_lut_q" output="test_lut.q"/> - <direct input="test_lut.a" name="lut2_in_0" output="lut2.in[0]"/> - <direct input="test_lut.b" name="lut2_in_1" output="lut2.in[1]"/> + <direct input="test_pb.clk" name="BLK_FF-dff_clk" output="BLK_FF-dff.clk"/> + <direct input="BLK_BB-lut2.y" name="BLK_FF-dff_d" output="BLK_FF-dff.d"/> + <direct input="BLK_FF-dff.q" name="test_pb_q" output="test_pb.q"/> + <direct input="test_pb.a" name="BLK_BB-lut2_in_0" output="BLK_BB-lut2.in[0]"/> + <direct input="test_pb.b" name="BLK_BB-lut2_in_1" output="BLK_BB-lut2.in[1]"/> </interconnect> </mode> </pb_type>
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 8dd5fee..0f2a126 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -90,13 +90,39 @@ tmod = yj.module(top) -def make_pb_content(mod, xml_parent): +def mod_pb_name(mod): + """Convert a Verilog module to a pb_type name in the format documented here: + https://github.com/SymbiFlow/symbiflow-arch-defs/#names""" + is_blackbox = (mod.attr("blackbox", 0) == 1) + modes = yj.modules_with_attr("ALTERNATIVE_TO", mod.name) + has_modes = len(modes) > 0 + # Process type and class of module + mod_cls = mod.CLASS + if mod_cls == "routing": + return "BLK_RX-" + mod.name + elif mod_cls == "mux": + return "BLK_MX-" + mod.name + elif mod_cls == "flipflop": + return "BLK_FF-" + mod.name + elif mod_cls == "lut": + return "BLK_LT-" + mod.name + elif is_blackbox and not has_modes: + return "BLK_BB-" + mod.name + else: + #TODO: other types + return "BLK_IG-" + mod.name + +def make_pb_content(mod, xml_parent, mod_pname): """Build the pb_type content - child pb_types, timing and direct interconnect, but not IO. This may be put directly inside <pb_type>, or inside <mode>.""" + def get_full_pin_name(pin): cname, cellpin = pin if cname != mod.name: cname = mod.cell_type(cname) + cname = mod_pb_name(yj.module(cname)) + else: + cname = mod_pname return ("%s.%s" % (cname, cellpin)) def make_direct_conn(ic_xml, source, dest): @@ -108,6 +134,8 @@ 'input': source_pin, 'output': dest_pin }) + + # Find out whether or not the module we are generating content for is a blackbox is_blackbox = (mod.attr("blackbox", 0) == 1) @@ -165,7 +193,7 @@ # Process timing for name, width, iodir in mod.ports: - port = "%s.%s" % (mod.name, name) + port = "%s.%s" % (mod_pname, name) # Clocked timing Tsetup = mod.net_attr(name, "SETUP") Thold = mod.net_attr(name, "HOLD") @@ -181,7 +209,7 @@ if attr.startswith(dly_prefix): # Single, constant delays inp = attr[len(dly_prefix):] - inport = "%s.%s" % (mod.name, inp) + inport = "%s.%s" % (mod_pname, inp) ET.SubElement(xml_parent, "delay_constant", { "in_port": inport, "out_port": port, @@ -190,7 +218,7 @@ elif attr.startswith(dly_mat_prefix): # Constant delay matrices inp = attr[len(dly_mat_prefix):] - inport = "%s.%s" % (mod.name, inp) + inport = "%s.%s" % (mod_pname, inp) mat = "\n" + atvalue.replace(";", "\n") + "\n" xml_mat = ET.SubElement(xml_parent, "delay_matrix", { "in_port": inport, @@ -205,9 +233,10 @@ attrs = mod.module_attrs modes = yj.modules_with_attr("ALTERNATIVE_TO", mod.name) + mod_pname = mod_pb_name(mod) pb_xml_attrs = dict() - pb_xml_attrs["name"] = mod.name + pb_xml_attrs["name"] = mod_pname # If we are a blackbox with no modes, then generate a blif_model is_blackbox = (mod.attr("blackbox", 0) == 1) has_modes = len(modes) > 0 @@ -220,6 +249,9 @@ elif mod_cls == "routing": # TODO: pb_xml_attrs["class"] = "routing" pass + elif mod_cls == "mux": + # TODO: ? + pass elif mod_cls == "flipflop": pb_xml_attrs["blif_model"] = ".latch" pb_xml_attrs["class"] = "flipflop" @@ -251,9 +283,9 @@ if len(modes) > 0: for mode_mod in modes: mode_xml = ET.SubElement(pb_type_xml, "mode", {"name" : mode_mod.name}) - make_pb_content(mode_mod, mode_xml) + make_pb_content(mode_mod, mode_xml, mod.name) else: - make_pb_content(mod, pb_type_xml) + make_pb_content(mod, pb_type_xml, mod_pname) return pb_type_xml