More refactoring and general fixes, including of module types

Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/adder/pb_type.xml b/adder/pb_type.xml
index e675790..f14d676 100644
--- a/adder/pb_type.xml
+++ b/adder/pb_type.xml
@@ -1,10 +1,9 @@
-<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="adder" num_pb="1">
+<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" 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/>
   <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"/>
diff --git a/adder/sim.v b/adder/sim.v
index 2d9be56..3411e3e 100644
--- a/adder/sim.v
+++ b/adder/sim.v
@@ -1,3 +1,4 @@
+(* blackbox *)
 module adder(
 	input a,
 	input b,
diff --git a/dff/model.xml b/dff/model.xml
index f8b4458..07cce64 100644
--- a/dff/model.xml
+++ b/dff/model.xml
@@ -2,7 +2,6 @@
   <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>
diff --git a/dff/pb_type.xml b/dff/pb_type.xml
index 7d63821..5d80b66 100644
--- a/dff/pb_type.xml
+++ b/dff/pb_type.xml
@@ -1,11 +1,7 @@
 <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" port_class="clock"/>
-  <input equivalent="false" name="rst" 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/dff/sim.v b/dff/sim.v
index bb464c6..e2ae093 100644
--- a/dff/sim.v
+++ b/dff/sim.v
@@ -1,12 +1,9 @@
-(* TYPE="bel" *) (* CLASS="flipflop" *)
-module dff(clk, rst, d, q);
+(* blackbox *) (* CLASS="flipflop" *)
+module dff(clk, d, q);
 
 (* PORT_CLASS = "clock" *)
 input wire clk;
 
-(* 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;
 
@@ -14,9 +11,6 @@
 output wire q;
 
 always @(posedge clk)
-	if (rst == 1'b1)
-		q <= 1'b0;
-	else
 		q <= d;
 
 endmodule
diff --git a/lut2/model.xml b/lut2/model.xml
index f062f9f..6c721c2 100644
--- a/lut2/model.xml
+++ b/lut2/model.xml
@@ -5,7 +5,6 @@
     </input_ports>
     <output_ports>
       <port name="y"/>
-      <port name="co"/>
     </output_ports>
   </model>
 </models>
diff --git a/lut2/pb_type.xml b/lut2/pb_type.xml
index 953d8f3..8c11624 100644
--- a/lut2/pb_type.xml
+++ b/lut2/pb_type.xml
@@ -1,8 +1,6 @@
-<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="lut2" num_pb="1">
+<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" blif_model=".subckt lut2" name="lut2" num_pb="1">
   <input equivalent="false" name="in" num_pins="2"/>
   <output equivalent="false" name="y" num_pins="1"/>
-  <output equivalent="false" name="co" num_pins="1"/>
-  <interconnect/>
   <delay_matrix in_port="lut2.in" out_port="lut2.y" type="max">
 10e-12
  10e-12
diff --git a/lut2/sim.v b/lut2/sim.v
index 34c235d..e7f9760 100644
--- a/lut2/sim.v
+++ b/lut2/sim.v
@@ -1,9 +1,9 @@
+(* blackbox *)
 module lut2 (
 		input [1:0] in,
+
 		(* DELAY_MATRIX_in = "10e-12; 10e-12" *)
-		output y,
-		output co);
+		output y);
 parameter [3:0] content = 4'b1000;
 assign y = content[in];
-assign co = 1'b0;
 endmodule
diff --git a/model.xml b/model.xml
index a1985e3..5bbe083 100644
--- a/model.xml
+++ b/model.xml
@@ -2,7 +2,6 @@
   <model name="test_pb">
     <input_ports>
       <port name="clk"/>
-      <port name="rst"/>
       <port name="a"/>
       <port name="b"/>
       <port name="ci"/>
diff --git a/pb_type.xml b/pb_type.xml
index 83bcaf3..b733dce 100644
--- a/pb_type.xml
+++ b/pb_type.xml
@@ -1,6 +1,5 @@
 <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"/>
@@ -16,7 +15,6 @@
       <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>
@@ -26,11 +24,9 @@
     <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_in[2]" output="lut2.in[2]"/>
-      <direct input="test_lut.b" name="lut2_in[2]" output="lut2.in[2]"/>
-      <direct input="lut2.co" name="test_lut_co" output="test_lut.co"/>
+      <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]"/>
     </interconnect>
   </mode>
 </pb_type>
diff --git a/sim.v b/sim.v
index ed6ceff..1151952 100644
--- a/sim.v
+++ b/sim.v
@@ -4,23 +4,23 @@
 
 
 (* blackbox *)
-module test_pb(input clk, rst, a, b, ci, output q, co);
+module test_pb(input clk, a, b, ci, output q, co);
 endmodule
 
 (* ALTERNATIVE_TO="test_pb" *)
-module test_add(input clk, rst, a, b, ci, output q, co);
+module test_add(input clk, 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));
+dff dff_i(.clk(clk), .d(d), .q(q));
 
 endmodule
 
 (* ALTERNATIVE_TO="test_pb" *)
-module test_lut(input clk, rst, a, b, ci, output q, co);
+module test_lut(input clk, a, b, ci, output q, co);
 
 wire d;
-lut2 lut2_i(.in({b, a}), .y(d), .co(co));
-dff dff_i(.clk(clk), .rst(rst), .d(d), .q(q));
+lut2 lut2_i(.in({b, a}), .y(d));
+dff dff_i(.clk(clk), .d(d), .q(q));
 
 endmodule