diff options
| author | uvok | 2026-01-18 10:58:56 +0100 |
|---|---|---|
| committer | uvok | 2026-01-18 10:58:56 +0100 |
| commit | 1cfdda0d9f76d36df95677e631b8b15dd19b4dcb (patch) | |
| tree | 414b86b7cb21c042bef0df13a39359ff93d713da /nandgame/counter_tb.sv | |
| parent | 16dc52fc55961e029efe2588cae7c4375132efe9 (diff) | |
counter: Add "count_enable" pin
Diffstat (limited to 'nandgame/counter_tb.sv')
| -rw-r--r-- | nandgame/counter_tb.sv | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/nandgame/counter_tb.sv b/nandgame/counter_tb.sv index 1603a31..b725475 100644 --- a/nandgame/counter_tb.sv +++ b/nandgame/counter_tb.sv @@ -2,14 +2,15 @@ module counter_tb; -logic tst_clk, tst_store_X; +logic tst_clk, tst_store_X, tst_count; logic [15:0] tst_in_X, tst_result; counter uut ( .clk_in(tst_clk), .X_in(tst_in_X), .counter_out(tst_result), - .st_store_X_in(tst_store_X) + .st_store_X_in(tst_store_X), + .count_enable_in(tst_count) ); string filename; @@ -23,12 +24,23 @@ initial begin tst_clk = 0; tst_store_X = 0; tst_in_X = 0; + tst_count = 0; end always #10 tst_clk = ~tst_clk; initial begin - #200 + // start of with count disabled + repeat(5) @(posedge tst_clk); + assert (tst_result == 0) + else $error("Expected 0, got %d", tst_result); + tst_count = 1; + + // now that counting is enabled + repeat(5) @(posedge tst_clk); + assert (tst_result == 5) + else $error("Expected 5, got %d", tst_result); + @(posedge tst_clk); tst_store_X = 1; tst_in_X = 16'd834; @@ -36,8 +48,12 @@ initial begin @(posedge tst_clk); assert (tst_result == 834) else $error("Expected 834, got %d", tst_result); + // this shouldn't matter + tst_count = !tst_count; end tst_store_X = 0; + tst_count = 1; + @(posedge tst_clk); assert (tst_result == 835) else $error("Expected 835, got %d", tst_result); |
