module D_Latch(
input D,
input En,
output reg Q=1'b0,
output wire Qbar=1'b1
);
always@(D or En)
if (En)
Q <= D ;
assign Qbar = ~Q ;
endmodule
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
reg D,En;
wire Q,Qbar;
//module D_Latch(input D,input En,output reg Q=1'b0,output Qbar=1'b1);
D_Latch DUT(
.D(D),
.En(En),
.Q(Q),
.Qbar(Qbar) );
initial begin
$monitor(D,En,Q,Qbar);
// Initialize Inputs
D = 0;
En = 1;
// Add stimulus here
#100 D = 0;
#100 D = 1;
#100 D = 1;
#100 D = 1;
#100 D = 0;
#100 D = 1;
#100 D = 0;
En = 0;
#100 D = 0;
#100 D = 1;
#100 D = 1;
#100 D = 1;
#100 D = 0;
#100 D = 1;
#100 D = 0;
#100 ; $stop;
end
endmodule
沒有留言:
張貼留言