Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Industrial programming >> Verilog

JK Flip‑Flop: Design, Implementation, and Testbench

Design

  
  
module jk_ff ( input j,
               input k,
               input clk,
               output q);

   reg q;

   always @ (posedge clk)
      case ({j,k})
         2'b00 :  q <= q;
         2'b01 :  q <= 0;
         2'b10 :  q <= 1;
         2'b11 :  q <= ~q;
      endcase
endmodule

  

Hardware Schematic

Testbench

  
  
module tb_jk;
   reg j;
   reg k;
   reg clk;
   
   always #5 clk = ~clk;
   
   jk_ff    jk0 ( .j(j),
                  .k(k),
                  .clk(clk),
                  .q(q));

   initial begin
      j <= 0;
      k <= 0;
      
      #5 j <= 0;
         k <= 1;
      #20 j <= 1;
          k <= 0;
      #20 j <= 1;
          k <= 1;
      #20 $finish;
   end

   initial
      $monitor ("j=%0d k=%0d q=%0d", j, k, q);
endmodule	

  

Verilog

  1. Implementing Sequential Logic Using Verilog 'always' Blocks
  2. Designing a D Flip-Flop with Asynchronous Active-Low Reset
  3. Designing a Verilog T Flip-Flop: RTL Implementation & Testbench
  4. Verilog Asynchronous Ripple Counter Design & Implementation
  5. Verilog Ring Counter Module: Design & Testbench Example
  6. 4‑Bit Johnson Counter in Verilog – Design, Testbench & Simulation
  7. Verilog Mod-N Counter Design: Parameterized Module & Testbench
  8. Verilog Gray Counter Module – 4‑bit Gray Code Generator
  9. Arduino Flip Clock with 8×8 LED Matrix – DIY Real‑Time Clock Project
  10. Transistor Flip‑Flop: The Fundamental Sequential Logic Circuit for Reliable Binary Data Storage