fix awful c-flag bug in Memory.ship
authoradam <adam@megacz.com>
Sun, 16 Nov 2008 14:22:51 +0000 (15:22 +0100)
committeradam <adam@megacz.com>
Sun, 16 Nov 2008 14:22:51 +0000 (15:22 +0100)
ships/Alu.ship
ships/Counter.ship
ships/Memory.ship

index 50fcfee..3b2117f 100644 (file)
@@ -130,7 +130,10 @@ public void service() {
   wire                    eq;
   wire                    cout;
 
-  assign isplus        = inOp_d[2:0]==2;
+  wire [3:0]              inOp_d_trunc;
+  assign                  inOp_d_trunc = inOp_d[3:0];
+
+  assign isplus        = inOp_d_trunc[2:0]==2;
   assign cin           = isplus ? 0 : 1;
   assign in2_inverted  = isplus ? in2_d : ~in2_d;
   assign sum           = {in1_d,cin} + {in2_inverted,cin};
@@ -141,25 +144,25 @@ public void service() {
   assign cout          = sum[`WORDWIDTH];
 
   assign out_d_[`WORDWIDTH] =
-          (inOp_d==0) ? 1'b0 :
-          (inOp_d==1) ? 1'b0 :
-          (inOp_d==2) ? cout :
-          (inOp_d==3) ? cout :
-          (inOp_d==4) ? ~greater :
-          (inOp_d==5) ?  greater :
-          (inOp_d==6) ?  eq :
-          (inOp_d==9) ? ~greater :
+          (inOp_d_trunc==0) ? 1'b0 :
+          (inOp_d_trunc==1) ? 1'b0 :
+          (inOp_d_trunc==2) ? cout :
+          (inOp_d_trunc==3) ? cout :
+          (inOp_d_trunc==4) ? ~greater :
+          (inOp_d_trunc==5) ?  greater :
+          (inOp_d_trunc==6) ?  eq :
+          (inOp_d_trunc==9) ? ~greater :
           0;
 
   assign out_d_[(`WORDWIDTH-1):0] =
-          (inOp_d==0) ? (in1_d)  :
-          (inOp_d==1) ? (in2_d)  :
-          (inOp_d==2) ? (res)  :
-          (inOp_d==3) ? (res)  :
-          (inOp_d==4) ? (greater ? in1_d : in2_d)  :
-          (inOp_d==5) ? (greater ? in2_d : in1_d)  :
-          (inOp_d==6) ? {{ (`WORDWIDTH-1) {1'b0 }}, eq  } :
-          (inOp_d==9) ? (both_negative ? in1_d : (greater ? in1_d : in2_d)) :
+          (inOp_d_trunc==0) ? (in1_d)  :
+          (inOp_d_trunc==1) ? (in2_d)  :
+          (inOp_d_trunc==2) ? (res)  :
+          (inOp_d_trunc==3) ? (res)  :
+          (inOp_d_trunc==4) ? (greater ? in1_d : in2_d)  :
+          (inOp_d_trunc==5) ? (greater ? in2_d : in1_d)  :
+          (inOp_d_trunc==6) ? {{ (`WORDWIDTH-1) {1'b0 }}, eq  } :
+          (inOp_d_trunc==9) ? (both_negative ? in1_d : (greater ? in1_d : in2_d)) :
           0;
 
   always @(posedge clk) begin
@@ -170,15 +173,15 @@ public void service() {
       `cleanup
       if (`out_draining) begin
         `drain_inOp
-        if      (inOp_d==0) `drain_in1
-        else if (inOp_d==1) `drain_in2
-        else if (inOp_d==9 &&  both_negative) begin `drain_in1 `drain_in2 end
-        else if (inOp_d==4 &&  greater) `drain_in1
-        else if (inOp_d==5 &&  greater) `drain_in2
-        else if (inOp_d==9 &&  greater) `drain_in1
-        else if (inOp_d==4 && !greater) `drain_in2
-        else if (inOp_d==5 && !greater) `drain_in1
-        else if (inOp_d==9 && !greater) `drain_in2
+        if      (inOp_d_trunc==0) `drain_in1
+        else if (inOp_d_trunc==1) `drain_in2
+        else if (inOp_d_trunc==9 &&  both_negative) begin `drain_in1 `drain_in2 end
+        else if (inOp_d_trunc==4 &&  greater) `drain_in1
+        else if (inOp_d_trunc==5 &&  greater) `drain_in2
+        else if (inOp_d_trunc==9 &&  greater) `drain_in1
+        else if (inOp_d_trunc==4 && !greater) `drain_in2
+        else if (inOp_d_trunc==5 && !greater) `drain_in1
+        else if (inOp_d_trunc==9 && !greater) `drain_in2
         else begin
           `drain_in1
           `drain_in2
index fa2ac8d..2e71152 100644 (file)
@@ -26,11 +26,14 @@ public void service() { }
 
 == FPGA ==============================================================
 
+  wire [3:0]              inOp_d_trunc;
+  assign                  inOp_d_trunc = inOp_d[3:0];
+
   reg [`WORDWIDTH-1:0] temp;
   initial temp   = {`WORDWIDTH{1'b1}};
   reg     full;
   initial full = 0;
-  wire    op_count;  assign op_count  = inOp_d==12;
+  wire    op_count;  assign op_count  = inOp_d_trunc==12;
   wire    op_repeat; assign op_repeat = inOp_d[3:2]==0;
   wire    op_pass;   assign op_pass   = inOp_d[3:2]==1;
   wire    op_drop;   assign op_drop   = inOp_d[3:2]==2;
index 7245737..6291093 100644 (file)
@@ -205,6 +205,7 @@ sequence guarantee problem mentioned in the previous paragraph.
         end
         `fill_out
         out_w <= 0;
+
       end else if (`inCBD_full && `out_draining) begin
         if (counter != inCBD_d[(`CODEBAG_SIZE_BITS-1):0]) begin
           cursor  <= cursor + 1;
@@ -214,9 +215,11 @@ sequence guarantee problem mentioned in the previous paragraph.
           counter <= 0;
           dispatching_cbd <= 0;
         end
+
       end else if (!dispatching_cbd && `out_empty && `inAddrRead_full) begin
         `drain_inAddrRead
         `fill_out
+        out_w <= 0;
 
       end else if (!dispatching_cbd && `out_empty && `inAddrWrite_full && `inDataWrite_full) begin
         // timing note: it's okay to drain here because *_d will still