summaryrefslogtreecommitdiff
path: root/nandgame/counter.sv
diff options
context:
space:
mode:
Diffstat (limited to 'nandgame/counter.sv')
-rw-r--r--nandgame/counter.sv8
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