Refactoring, rework how <mode> is specified in the Verilog

Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/adder/pb_type.xml b/adder/pb_type.xml
index 509ce66..05124b1 100644
--- a/adder/pb_type.xml
+++ b/adder/pb_type.xml
@@ -1,4 +1,4 @@
-<pb_type blif_model=".subckt adder" name="adder" num_pb="1">
+<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" 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"/>
diff --git a/dff/pb_type.xml b/dff/pb_type.xml
index 4bf0c6e..4b92f05 100644
--- a/dff/pb_type.xml
+++ b/dff/pb_type.xml
@@ -1,4 +1,4 @@
-<pb_type 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="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"/>
diff --git a/lut2/pb_type.xml b/lut2/pb_type.xml
index af537d1..96896f1 100644
--- a/lut2/pb_type.xml
+++ b/lut2/pb_type.xml
@@ -1,4 +1,4 @@
-<pb_type blif_model=".subckt lut2" name="lut2" num_pb="1">
+<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="lut2" num_pb="1">
   <input equivalent="false" name="a" num_pins="1"/>
   <input equivalent="false" name="b" num_pins="1"/>
   <output equivalent="false" name="y" num_pins="1"/>
diff --git a/model.xml b/model.xml
index 97d527b..a1985e3 100644
--- a/model.xml
+++ b/model.xml
@@ -1,14 +1,14 @@
 <models>
   <model name="test_pb">
     <input_ports>
-      <port is_clock="1" name="clk"/>
-      <port clock="clk" name="rst"/>
-      <port clock="clk" name="a"/>
-      <port clock="clk" name="b"/>
-      <port clock="clk" name="ci"/>
+      <port name="clk"/>
+      <port name="rst"/>
+      <port name="a"/>
+      <port name="b"/>
+      <port name="ci"/>
     </input_ports>
     <output_ports>
-      <port clock="clk" name="q"/>
+      <port name="q"/>
       <port name="co"/>
     </output_ports>
   </model>
diff --git a/pb_type.xml b/pb_type.xml
index cafd613..095c270 100644
--- a/pb_type.xml
+++ b/pb_type.xml
@@ -1,34 +1,36 @@
-<pb_type blif_model=".subckt test_pb" name="test_pb" num_pb="1">
-  <clock equivalent="false" name="clk" num_pins="1"/>
+<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="test_pb" num_pb="1">
+  <input 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"/>
-  <mode name="ADD">
-    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adder/pb_type.xml"/>
-    <interconn>
-      <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="adder.y" name="adder_y_to_dff_d" output="dff.d"/>
-    </interconn>
+  <mode name="test_add">
+    <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="test_add.rst" name="dff_rst" output="dff.rst"/>
+      <direct input="dff.q" name="test_add_q" output="test_add.q"/>
+    </interconnect>
   </mode>
-  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dff/pb_type.xml"/>
-  <mode name="LUT">
-    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="lut2/pb_type.xml"/>
-    <interconn>
-      <direct input="test_pb.a" name="test_pb_a_to_lut2_a" output="lut2.a"/>
-      <direct input="test_pb.b" name="test_pb_b_to_lut2_b" output="lut2.b"/>
-      <direct input="lut2.co" name="lut2_co_to_test_pb_co" output="test_pb.co"/>
-      <direct input="lut2.y" name="lut2_y_to_dff_d" output="dff.d"/>
-    </interconn>
+  <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="test_lut.rst" name="dff_rst" output="dff.rst"/>
+      <direct input="dff.q" name="test_lut_q" output="test_lut.q"/>
+      <direct input="test_lut.a" name="lut2_a" output="lut2.a"/>
+      <direct input="test_lut.b" name="lut2_b" output="lut2.b"/>
+      <direct input="lut2.co" name="test_lut_co" output="test_lut.co"/>
+    </interconnect>
   </mode>
-  <interconnect>
-    <direct input="test_pb.clk" name="test_pb_clk_to_dff_clk" output="dff.clk"/>
-    <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/sim.v b/sim.v
index ffee6e2..0500920 100644
--- a/sim.v
+++ b/sim.v
@@ -2,13 +2,25 @@
 `include "dff/sim.v"
 `include "lut2/sim.v"
 
+
+(* blackbox *)
 module test_pb(input clk, rst, a, b, ci, output q, co);
+endmodule
+
+(* ALTERNATIVE_TO="test_pb" *)
+module test_add(input clk, rst, a, b, ci, output q, co);
 
 wire d;
+adder adder_i(.a(a), .b(b), .ci(ci), .y(d), .co(co));
+dff dff_i(.clk(clk), .rst(rst), .d(d), .q(q));
 
-(* MODE="ADD" *) adder adder_i(.a(a), .b(b), .ci(ci), .y(d), .co(co));
-(* MODE="LUT" *) lut2 lut2_i(.a(a), .b(b), .y(d), .co(co));
+endmodule
 
+(* ALTERNATIVE_TO="test_pb" *)
+module test_lut(input clk, rst, a, b, ci, output q, co);
+
+wire d;
+lut2 lut2_i(.a(a), .b(b), .y(d), .co(co));
 dff dff_i(.clk(clk), .rst(rst), .d(d), .q(q));
 
 endmodule