Add support for specifying `port_class` Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/tests/dff/pb_type.xml b/tests/dff/pb_type.xml index 83b56e9..7d63821 100644 --- a/tests/dff/pb_type.xml +++ b/tests/dff/pb_type.xml
@@ -1,9 +1,11 @@ <pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".latch" class="flipflop" name="dff" num_pb="1"> - <clock equivalent="false" name="clk" num_pins="1"/> + <clock equivalent="false" name="clk" num_pins="1" port_class="clock"/> <input equivalent="false" name="rst" num_pins="1"/> - <input equivalent="false" name="d" num_pins="1"/> - <output equivalent="false" name="q" num_pins="1"/> + <input equivalent="false" name="d" num_pins="1" port_class="D"/> + <output equivalent="false" name="q" num_pins="1" port_class="Q"/> <interconnect/> + <T_setup clock="clk" port="dff.rst" value="200e-12"/> + <T_hold clock="clk" port="dff.rst" value="50e-12"/> <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"/>
diff --git a/tests/dff/sim.v b/tests/dff/sim.v index 4e7731d..bb464c6 100644 --- a/tests/dff/sim.v +++ b/tests/dff/sim.v
@@ -1,13 +1,16 @@ (* TYPE="bel" *) (* CLASS="flipflop" *) module dff(clk, rst, d, q); +(* PORT_CLASS = "clock" *) input wire clk; -input wire rst; (* SETUP = "clk 200e-12" *) (* HOLD = "clk 50e-12" *) +input wire rst; + +(* PORT_CLASS = "D" *) (* SETUP = "clk 200e-12" *) (* HOLD = "clk 50e-12" *) input wire d; -(* CLK_TO_Q = "clk 400e-12" *) +(* PORT_CLASS = "Q" *) (* CLK_TO_Q = "clk 400e-12" *) output wire q; always @(posedge clk)
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 5f51a63..11ee815 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -32,6 +32,8 @@ - `(* CLOCK *)` : force a given port to be a clock - `(* ASSOC_CLOCK="RDCLK" *)` : force a port's associated clock to a given value + + - `(* PORT_CLASS="clock" *)` : specify the VPR "port_class" """ import yosys.run @@ -234,6 +236,9 @@ clocks = yosys.run.list_clocks(args.infiles, mod.name) for name, width, iodir in mod.ports: ioattrs = {"name": name, "num_pins": str(width), "equivalent": "false"} + pclass = mod.net_attr(name, "PORT_CLASS") + if pclass is not None: + ioattrs["port_class"] = pclass if name in clocks: ET.SubElement(pb_type_xml, "clock", ioattrs) elif iodir == "input":