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.sv | |
| parent | 16dc52fc55961e029efe2588cae7c4375132efe9 (diff) | |
counter: Add "count_enable" pin
Diffstat (limited to 'nandgame/counter.sv')
| -rw-r--r-- | nandgame/counter.sv | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nandgame/counter.sv b/nandgame/counter.sv index 2089194..87ecdd7 100644 --- a/nandgame/counter.sv +++ b/nandgame/counter.sv @@ -1,11 +1,12 @@ // nandgame counter +// counts on *falling* edge `timescale 1us/1us `ifndef NANDGAME_COUNTER `define NANDGAME_COUNTER -module counter #( +module counter #( parameter DATA_WIDTH = 16 ) ( // input / value to store in counter @@ -14,6 +15,9 @@ module counter #( input wire st_store_X_in, // clock input wire clk_in, + // active high, whether to count + // st_store_X_in overrides this in any case. + input wire count_enable_in, // counter value output wire [(DATA_WIDTH-1):0] counter_out @@ -45,7 +49,7 @@ end always @(negedge clk_in) begin if (st_store_X_in) counter_int <= X_in; - else + else if (count_enable_in) counter_int <= counter_int + 1; end |
