Skip navigation.
Home

Counter with clear and enable

This is a simple Verilog counter with clear and enable signals. The width of the counter is configurable with the parameter.

module counter_clear #(parameter WIDTH=8) 
(
 input                  clk,
 input                  clear,
 input                  enable,
 output reg [WIDTH-1:0] count
);
 
always @(posedge clk)
  if      (clear)  count <= 0;
  else if (enable) count <= count + 1;
 
endmodule

AttachmentSize
counter_clear.v276 bytes