module SR_Latch(
input S, R, En,
output Q, Qbar);
wire S2 = ~(En & S);
wire R2 = ~(En & R);
assign Q = ~(S2 & Qbar);
assign Qbar = ~(R2 & Q);
endmodule
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
reg S,R,En;
wire Q,Qbar;
//SR_Latch( input wire S, R, En, output wire Q, Qbar);
SR_Latch DUT(
.S(S),
.R(R),
.En(En),
.Q(Q),
.Qbar(Qbar) );
initial begin
$monitor(S,R,En,Q,Qbar);
// Initialize Inputs
S = 0;
R = 1;
En = 1;
// Add stimulus here
#100 S = 0; R = 1;
#100 S = 1; R = 0;
#100 S = 1; R = 1;
#100 R = 1; R = 0;
#100 S = 0; R = 0;
#100 S = 1; R = 1;
#100 S = 0; R = 0;
En = 0;
#100 S = 0; R = 1;
#100 S = 1; R = 0;
#100 S = 1; R = 1;
#100 R = 1; R = 0;
#100 S = 0; R = 0;
#100 S = 1; R = 1;
#100 S = 0; R = 0;
#100 ; $stop;
end
endmodule
沒有留言:
張貼留言