diff options
| author | Christian Cunningham <cc@local.lan> | 2026-03-28 16:35:19 -0700 |
|---|---|---|
| committer | Christian Cunningham <cc@local.lan> | 2026-03-28 16:35:19 -0700 |
| commit | 07cc3c5c788eff68b8d68713204613b07824fae2 (patch) | |
| tree | 8de16b7b00ceeeeb62103964ed4ea1be1487b6fd /natural_counter.v | |
Diffstat (limited to 'natural_counter.v')
| -rw-r--r-- | natural_counter.v | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/natural_counter.v b/natural_counter.v new file mode 100644 index 0000000..4e63ffd --- /dev/null +++ b/natural_counter.v @@ -0,0 +1,23 @@ +// This module is used to count things such as the number of rounds +// that have been won or the current position in the sequence +// If reset is high the counter will reset to 0 +// If increment is high the counter will be incremented by 1 +// NOTE: this module updates on the positive edge of the clock +module natural_counter ( + input clk, + input increment, + input reset, + output reg [4:0] count +); + + initial begin + count = 5'b00001; + end + + always @(negedge clk) begin + if (reset) + count <= 5'b00001; + else if (increment) + count <= count + 5'b00001; + end +endmodule |
