Fixed more issues with GreenPAK counter sim models
authorAndrew Zonenberg <azonenberg@drawersteak.com>
Tue, 15 Aug 2017 07:50:31 +0000 (00:50 -0700)
committerAndrew Zonenberg <azonenberg@drawersteak.com>
Tue, 15 Aug 2017 16:18:36 +0000 (09:18 -0700)
techlibs/greenpak4/cells_sim_digital.v

index 6fba941a013a19b761252db15ae45608eefaef90..043cd18d4e3dcbbd29b76cebd528c65afff8f30c 100644 (file)
@@ -58,23 +58,25 @@ module GP_COUNT14(input CLK, input wire RST, output reg OUT);
 
                        "RISING": begin
                                always @(posedge CLK, posedge RST) begin
-                                       count           <= count - 1'd1;
-                                       if(count == 0)
-                                               count   <= COUNT_TO;
-
                                        if(RST)
-                                               count   <= 0;
+                                               count           <= 0;
+                                       else begin
+                                               count           <= count - 1'd1;
+                                               if(count == 0)
+                                                       count   <= COUNT_TO;
+                                       end
                                end
                        end
 
                        "FALLING": begin
                                always @(posedge CLK, negedge RST) begin
-                                       count           <= count - 1'd1;
-                                       if(count == 0)
-                                               count   <= COUNT_TO;
-
                                        if(!RST)
-                                               count   <= 0;
+                                               count           <= 0;
+                                       else begin
+                                               count           <= count - 1'd1;
+                                               if(count == 0)
+                                                       count   <= COUNT_TO;
+                                       end
                                end
                        end
 
@@ -88,7 +90,7 @@ module GP_COUNT14(input CLK, input wire RST, output reg OUT);
                        "LEVEL": begin
                                always @(posedge CLK, posedge RST) begin
                                        if(RST)
-                                               count   <= 0;
+                                               count           <= 0;
 
                                        else begin
                                                count           <= count - 1'd1;
@@ -422,23 +424,25 @@ module GP_COUNT8(
 
                        "RISING": begin
                                always @(posedge CLK, posedge RST) begin
-                                       count           <= count - 1'd1;
-                                       if(count == 0)
-                                               count   <= COUNT_TO;
-
                                        if(RST)
                                                count   <= 0;
+                                       else begin
+                                               count           <= count - 1'd1;
+                                               if(count == 0)
+                                                       count   <= COUNT_TO;
+                                       end
                                end
                        end
 
                        "FALLING": begin
                                always @(posedge CLK, negedge RST) begin
-                                       count           <= count - 1'd1;
-                                       if(count == 0)
-                                               count   <= COUNT_TO;
-
                                        if(!RST)
                                                count   <= 0;
+                                       else begin
+                                               count           <= count - 1'd1;
+                                               if(count == 0)
+                                                       count   <= COUNT_TO;
+                                       end
                                end
                        end