2020年1月2日 星期四

Verilog JK Flip-Flop

Verilog JK Flip-Flop



// JK 型正反器

module JK_FF(input clk, J, K, output Q, Q_not);
    wire    wl0, wl1;

    nand    g0 (wl0, clk, J, Q_not),
            g1 (wl1, clk, K, Q),
            g2 (Q, wl0, Q_not),
            g3 (Q_not, wl1, Q);
endmodule


// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps     
module Test_bench;
   reg   clk;
   reg   J;
   reg   K; 
   wire  Q;
   wire  Q_not; 
   // Instantiate the Unit Under Test (UUT)
   initial begin
   // Initialize Inputs
       J = 0;
       K = 0;
       fork
       #5  J = 0;K = 1;
       #15 J = 1;K = 1;
       #15 J = 1;K = 0;
       #25 J = 1;K = 0;
       #25 J = 1;K = 1;
       #50 J = 0;K = 1;
       #50 J = 0;K = 0;
       #60 J = 0;K = 1;
       clk = 0;
       join
      // Wait 100 ns for global reset to finish
       #70;
     
    end

    JK_FF DUT(clk, J, K, Q, Q_not);
initial begin
#80  $stop;
end
    always #5 clk=!clk;

endmodule



沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...