Theory:
Counter design, in a general sense, refers to the process of creating a circuit that counts events or pulses. This involves understanding different types of counters (asynchronous, synchronous),
Block diagram:
Truth table:
Verilog code:
module JK_flipflops
input clk,
input reset,
input J,
input K,
output reg Q;
always @(posedge clk or posedge reset)
if (reset)
Q <= 0; // Reset Q to 0 on reset signal
else if (J == 1 && K == 1)
Q <= ~Q; // Toggle Q when J=K=1
end
endmodule
Testbench:
module counter_design_tb;
reg clk_rent;
wire [3:0] count;
bit, fun unit (clk(clk), reset(reset), count (count));
initial begin
clk = 0, reset = 1; #100;
reset = 0; #100;
end
initial begin
& clk <= ~clk;
end
end module
Output:
RTL schematic view:
Device utilization:
Time analysis: