2020年1月3日 星期五

JK flip flop behavioral verilog

JK flip flop behavioral verilog





//JK 正反器(Flip-Flop)
module JK_FF_behavioral(J,K,CLK,Q,Qn);
       output Q,Qn;
       input J,K,CLK;
  
       reg Q;
       assign Qn = ~ Q ;
  
       always @ (posedge CLK)
       case ({J,K})
              2'b00: Q = Q;
              2'b01: Q = 1'b0;
              2'b10: Q = 1'b1;
              2'b11: Q = ~ Q;
       endcase
endmodule


// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps     
module Test_bench;
   reg   CLK=1;
   reg   J;
   reg   K;   
   wire  Q;
   wire  Qn;   
   
   //module JK_FF_behavioral(J,K,CLK,Q,Qn);
   // Instantiate the Unit Under Test (UUT)
   initial begin
   // Initialize Inputs
       J = 0; K = 0;
       #15 J = 1;K = 1;
       #15 J = 0;K = 1;
       #15 J = 1;K = 0;
       #15 J = 1;K = 1;
       #15 J = 1;K = 0;
       #15 J = 0;K = 1;
       #15 J = 1;K = 1;
       #15 J = 0;K = 1;
    
    end

    JK_FF_behavioral  DUT(J,K,CLK,Q,Qn);
initial begin
#150  $stop;
end
    always #10 CLK=!CLK;

endmodule





沒有留言:

張貼留言

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

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