//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
沒有留言:
張貼留言