ice40 cells_sim.v: SB_IO: update clock enable behaviour based on hardware experiments
authorLuke Wren <wren6991@gmail.com>
Wed, 17 Apr 2019 21:56:41 +0000 (22:56 +0100)
committerLuke Wren <wren6991@gmail.com>
Sun, 21 Apr 2019 20:40:11 +0000 (21:40 +0100)
techlibs/ice40/cells_sim.v

index 62a28364ba0bc33943260c44adabeb4e5d13fe70..00843b97cb5cb6b2cae5eb901e5a4c49ca32eaf3 100644 (file)
@@ -27,18 +27,27 @@ module SB_IO (
        reg dout_q_0, dout_q_1;
        reg outena_q;
 
+       // IO tile generates a constant 1'b1 internally if global_cen is not connected
+       wire clken_pulled = CLOCK_ENABLE || CLOCK_ENABLE === 1'bz;
+       reg  clken_pulled_ri;
+       reg  clken_pulled_ro;
+
        generate if (!NEG_TRIGGER) begin
-               always @(posedge INPUT_CLK)  if (CLOCK_ENABLE) din_q_0  <= PACKAGE_PIN;
-               always @(negedge INPUT_CLK)  if (CLOCK_ENABLE) din_q_1  <= PACKAGE_PIN;
-               always @(posedge OUTPUT_CLK) if (CLOCK_ENABLE) dout_q_0 <= D_OUT_0;
-               always @(negedge OUTPUT_CLK) if (CLOCK_ENABLE) dout_q_1 <= D_OUT_1;
-               always @(posedge OUTPUT_CLK) if (CLOCK_ENABLE) outena_q <= OUTPUT_ENABLE;
+               always @(posedge INPUT_CLK)                       clken_pulled_ri <= clken_pulled;
+               always @(posedge INPUT_CLK)  if (clken_pulled)    din_q_0         <= PACKAGE_PIN;
+               always @(negedge INPUT_CLK)  if (clken_pulled_ri) din_q_1         <= PACKAGE_PIN;
+               always @(posedge OUTPUT_CLK)                      clken_pulled_ro <= clken_pulled;
+               always @(posedge OUTPUT_CLK) if (clken_pulled)    dout_q_0        <= D_OUT_0;
+               always @(negedge OUTPUT_CLK) if (clken_pulled_ro) dout_q_1        <= D_OUT_1;
+               always @(posedge OUTPUT_CLK) if (clken_pulled)    outena_q        <= OUTPUT_ENABLE;
        end else begin
-               always @(negedge INPUT_CLK)  if (CLOCK_ENABLE) din_q_0  <= PACKAGE_PIN;
-               always @(posedge INPUT_CLK)  if (CLOCK_ENABLE) din_q_1  <= PACKAGE_PIN;
-               always @(negedge OUTPUT_CLK) if (CLOCK_ENABLE) dout_q_0 <= D_OUT_0;
-               always @(posedge OUTPUT_CLK) if (CLOCK_ENABLE) dout_q_1 <= D_OUT_1;
-               always @(negedge OUTPUT_CLK) if (CLOCK_ENABLE) outena_q <= OUTPUT_ENABLE;
+               always @(negedge INPUT_CLK)                       clken_pulled_ri <= clken_pulled;
+               always @(negedge INPUT_CLK)  if (clken_pulled)    din_q_0         <= PACKAGE_PIN;
+               always @(posedge INPUT_CLK)  if (clken_pulled_ri) din_q_1         <= PACKAGE_PIN;
+               always @(negedge OUTPUT_CLK)                      clken_pulled_ro <= clken_pulled;
+               always @(negedge OUTPUT_CLK) if (clken_pulled)    dout_q_0        <= D_OUT_0;
+               always @(posedge OUTPUT_CLK) if (clken_pulled_ro) dout_q_1        <= D_OUT_1;
+               always @(negedge OUTPUT_CLK) if (clken_pulled)    outena_q        <= OUTPUT_ENABLE;
        end endgenerate
 
        always @* begin