Verilog code not vhdl for 2 bit counter with active high re
Verilog code ( not vhdl) for 2 bit counter with active high reset signal using two jk flip flops.
Verilog code ( not vhdl) for 2 bit counter with active high reset signal using two jk flip flops.
Solution
module twobitJKcounter( q_O, qbar_O, j,k, clk, reset); input [1:0] j; input [1:0] k; input clk; input reset; output [1:0] q_O; output [1:0] qbar_O; wire [1:0] q_O; wire [1:0] qbar_O; assign j[0] = 1; assign k[0] = 1; assign j[1] = 1; assign k[1] = 1; jkff M1(q_O[0], qbar_O[0], j[0], k[0], clk, reset); jkff M2(q_O[1], qbar_O[1], j[1], k[1], qbar_O[0]); endmodule module jk(q,q1,j,k,c); output q,q1; input j,k,c; reg q,q1; initial begin q=1\'b0; q1=1\'b1; end always @(posedge clk or posedge reset) begin if (reset == 1\'b1) begin q=1\'b0; q1=1\'b1; end else begin case({j,k}) {1\'b0, 1\'b0}: begin q=q; q1=q1; end {1\'b0, 1\'b1}: begin q=1\'b0; q1=1\'b1; end {1\'b1, 1\'b0}: begin q=1\'b1; q1=1\'b0; end {1\'b1, 1\'b1}: begin q=~q; q1=~q1; end endcase end end