diff options
author | Brian Woods | 2023-03-23 22:30:40 -0400 |
---|---|---|
committer | Brian Woods | 2023-03-23 22:39:44 -0400 |
commit | 2e5b437fc94aa989ca81aa820739178281d218d8 (patch) | |
tree | e4810865577993efb28545d914ad7b01e8ba58f7 /counter_v/counter.v | |
parent | ac193d21bf29672513afbab5102708e0d4fee61e (diff) |
counter_v: add counter example in verilog
Uses icarus verilog and gtkwave to simulate a simple counter.
Diffstat (limited to 'counter_v/counter.v')
-rw-r--r-- | counter_v/counter.v | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/counter_v/counter.v b/counter_v/counter.v new file mode 100644 index 0000000..79e55df --- /dev/null +++ b/counter_v/counter.v @@ -0,0 +1,17 @@ +module counter(out, clk, reset); + + parameter WIDTH = 8; + + output [WIDTH-1: 0] out; + input clk, reset; + + reg [WIDTH-1: 0] out; + wire clk, reset; + + always @(posedge clk or posedge reset) + if (reset) + out <= 0; + else + out <= out + 1; + +endmodule // counter |