36f83e4a637e91df8b92b040067aac4f07af1ac5
[minecraft-eda] / example / counter.sv
1 module counter #(parameter WIDTH=3, parameter MAX=(1<<WIDTH)-1) (
2 input clock,
3 input reset,
4 output logic [WIDTH-1:0] count,
5 output logic max
6 );
7
8 assign max = count == MAX;
9
10 always_ff @(posedge clock) begin
11 if (reset) count <= 0;
12 else if (!max) count <= count + 1;
13 end
14
15 endmodule