Verilog Counter & testbench with synchronous enable control.
Counter implementation and use of synchronous signal ‘count_en’ to disable the counter. Lets start with simple counter code in rtl.
// Just the code snippet below.
always @(posedge clock or negedge reset)
begin
if (~reset) cnt_C <= 0;
else cnt_C <= cnt_C + 1;
end
Next lets review code to allow the counter to get enable/disable through additional signals. We will use asynchronous reset here in the example. Also test-