Verilog Counter & testbench with synchronous enable control.
// Just the code snippet below.
always @(posedge clock or negedge reset)
if (~reset) cnt_C <= 0;
else cnt_C <= cnt_C + 1;
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-