Skip to content

Commit dbd1e7f

Browse files
authored
Make the counter synthesizable, update comment
- Use nonblocking assignment for counter. Sequential design use nonblockgin assignments. - Add reset and remove initial block as initial block is not synthesizable - Add counter output port
1 parent 195103b commit dbd1e7f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
// count down from 10 to 0
1+
// count up from 0 to 10
22

3-
module main(input clk);
3+
module main(
4+
input logic clk,
5+
input logic reset
6+
output logic [3:0] counter,
7+
);
48

5-
reg [3:0] counter;
6-
7-
initial counter = 0;
8-
9-
always @(posedge clk)
10-
if(counter != 10)
11-
counter = counter + 1;
9+
always_ff @(posedge clk or posedge reset)
10+
if (reset)
11+
counter <= 'b0;
12+
else if (counter != 10)
13+
counter <= counter + 1;
1214

1315
// expected to pass
14-
p0: assert property (s_eventually counter == 10);
16+
ASSERT_COUNTER_EVENTUALLY_10: assert property (@(posedge clk) disable iff (reset) s_eventually (counter == 10));
1517

1618
endmodule

0 commit comments

Comments
 (0)