Small fixes, add example output Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/.gitignore b/.gitignore index db17b36..fb96a08 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,6 +1,4 @@ -model.xml __pycache__ *.pyc dump.json -pb_type.xml merged.xml
diff --git a/tests/adder/model.xml b/tests/adder/model.xml new file mode 100644 index 0000000..987196e --- /dev/null +++ b/tests/adder/model.xml
@@ -0,0 +1,13 @@ +<models> + <model name="adder"> + <input_ports> + <port combinational_sink_ports="co y" name="a"/> + <port combinational_sink_ports="co y" name="b"/> + <port combinational_sink_ports="co y" name="ci"/> + </input_ports> + <output_ports> + <port name="y"/> + <port name="co"/> + </output_ports> + </model> +</models>
diff --git a/tests/adder/pb_type.xml b/tests/adder/pb_type.xml new file mode 100644 index 0000000..509ce66 --- /dev/null +++ b/tests/adder/pb_type.xml
@@ -0,0 +1,8 @@ +<pb_type blif_model=".subckt adder" name="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"/> + <interconnect/> +</pb_type>
diff --git a/tests/dff/model.xml b/tests/dff/model.xml new file mode 100644 index 0000000..f8b4458 --- /dev/null +++ b/tests/dff/model.xml
@@ -0,0 +1,12 @@ +<models> + <model name="dff"> + <input_ports> + <port is_clock="1" name="clk"/> + <port clock="clk" name="rst"/> + <port clock="clk" name="d"/> + </input_ports> + <output_ports> + <port clock="clk" name="q"/> + </output_ports> + </model> +</models>
diff --git a/tests/dff/pb_type.xml b/tests/dff/pb_type.xml new file mode 100644 index 0000000..4bf0c6e --- /dev/null +++ b/tests/dff/pb_type.xml
@@ -0,0 +1,7 @@ +<pb_type blif_model=".latch" class="flipflop" name="dff" num_pb="1"> + <clock equivalent="false" name="clk" num_pins="1"/> + <input equivalent="false" name="rst" num_pins="1"/> + <input equivalent="false" name="d" num_pins="1"/> + <output equivalent="false" name="q" num_pins="1"/> + <interconnect/> +</pb_type>
diff --git a/tests/model.xml b/tests/model.xml new file mode 100644 index 0000000..b12691a --- /dev/null +++ b/tests/model.xml
@@ -0,0 +1,15 @@ +<models> + <model name="test_pb"> + <input_ports> + <port is_clock="1" name="clk"/> + <port clock="clk" name="rst"/> + <port clock="clk" combinational_sink_ports="co" name="a"/> + <port clock="clk" combinational_sink_ports="co" name="b"/> + <port clock="clk" combinational_sink_ports="co" name="ci"/> + </input_ports> + <output_ports> + <port clock="clk" name="q"/> + <port clock="clk" name="co"/> + </output_ports> + </model> +</models>
diff --git a/tests/pb_type.xml b/tests/pb_type.xml new file mode 100644 index 0000000..b190a13 --- /dev/null +++ b/tests/pb_type.xml
@@ -0,0 +1,21 @@ +<pb_type blif_model=".subckt test_pb" name="test_pb" num_pb="1"> + <clock equivalent="false" name="clk" num_pins="1"/> + <input equivalent="false" name="rst" num_pins="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="q" num_pins="1"/> + <output equivalent="false" name="co" num_pins="1"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="./adder/pb_type.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="./dff/pb_type.xml"/> + <interconnect> + <direct input="test_pb.a" name="test_pb_a_to_adder_a" output="adder.a"/> + <direct input="test_pb.b" name="test_pb_b_to_adder_b" output="adder.b"/> + <direct input="test_pb.ci" name="test_pb_ci_to_adder_ci" output="adder.ci"/> + <direct input="adder.co" name="adder_co_to_test_pb_co" output="test_pb.co"/> + <direct input="test_pb.clk" name="test_pb_clk_to_dff_clk" output="dff.clk"/> + <direct input="adder.y" name="adder_y_to_dff_d" output="dff.d"/> + <direct input="test_pb.rst" name="test_pb_rst_to_dff_rst" output="dff.rst"/> + <direct input="dff.q" name="dff_q_to_test_pb_q" output="test_pb.q"/> + </interconnect> +</pb_type>
diff --git a/vlog_to_model.py b/vlog_to_model.py index 65d90b2..6b2f72f 100755 --- a/vlog_to_model.py +++ b/vlog_to_model.py
@@ -56,7 +56,7 @@ for name, width, iodir in ports: attrs = dict(name=name) sinks = yosys.run.get_combinational_sinks(args.infiles, top, name) - if len(sinks) > 0: + if len(sinks) > 0 and iodir == "input": attrs["combinational_sink_ports"] = " ".join(sinks) if name in clocks: attrs["is_clock"] = "1"
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 1af272d..ae9264d 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -120,7 +120,7 @@ # Process IOs clocks = yosys.run.list_clocks(args.infiles, mod.get_name()) for name, width, iodir in mod.get_ports(): - ioattrs = {"name": name, "num_pins": str(width)} + ioattrs = {"name": name, "num_pins": str(width), "equivalent": "false"} if name in clocks: ET.SubElement(pb_type_xml, "clock", ioattrs) elif iodir == "input":