Fixed $lut simlib model for a wider range of tools
authorClifford Wolf <clifford@clifford.at>
Sat, 18 Jan 2014 18:27:16 +0000 (19:27 +0100)
committerClifford Wolf <clifford@clifford.at>
Sat, 18 Jan 2014 18:31:40 +0000 (19:31 +0100)
techlibs/common/simlib.v

index e522e37c6ea1938ef342cd2164b5192e88f3a454..0e041e12eeab5802b1cbf136d47eb5ae843088ce 100644 (file)
@@ -715,17 +715,19 @@ generate
                \$lut #( .WIDTH(WIDTH-1), .LUT(LUT                  ) ) lut0 ( .I(I[WIDTH-2:0]), .O(lut0_out) );
                \$lut #( .WIDTH(WIDTH-1), .LUT(LUT >> (2**(WIDTH-1))) ) lut1 ( .I(I[WIDTH-2:0]), .O(lut1_out) );
        end
-endgenerate
 
-always @* begin
-       casez ({I[WIDTH-1], lut0_out, lut1_out})
-               3'b?11: O = 1'b1;
-               3'b?00: O = 1'b0;
-               3'b0??: O = lut0_out;
-               3'b1??: O = lut1_out;
-               default: O = 1'bx;
-       endcase
-end
+       if (WIDTH > 0) begin:lutlogic
+               always @* begin
+                       casez ({I[WIDTH-1], lut0_out, lut1_out})
+                               3'b?11: O = 1'b1;
+                               3'b?00: O = 1'b0;
+                               3'b0??: O = lut0_out;
+                               3'b1??: O = lut1_out;
+                               default: O = 1'bx;
+                       endcase
+               end
+       end
+endgenerate
 
 endmodule