使用Quartus-II 9.1SP2 + ModelSim 6.5b-Aletra + Altera DE2-115 FPGA開發平台,設計SR Latch (ungated)為例(Test Bench開發平台)
//SR Latch (ungated)
module sr_latch_ungated(Q, Qn, S, R);
output Q;
output Qn;
input S;
input R;
nor(Qn, S, Q);
nor(Q, R, Qn);
endmodule
`timescale 1us/10ps
module tb_sr_latch_ungated;
reg tS;
reg tR;
wire tQ, tQn;
//module sr_latch_ungated(Q, Qn, S, R);
sr_latch_ungated DUT(tQ, tQn, tS, tR);
//instantiate counter to be tested.
initial
begin
#10 tS=1'b1;tR=1'b0;
#20 tS=1'b0;tR=1'b1;
#30 tS=1'b1;tR=1'b0;
#40 tS=1'b0;tR=1'b0;
#50 tS=1'b1;tR=1'b0;
#60 tS=1'b0;tR=1'b1;
#70 tS=1'b1;tR=1'b1;
#80 tS=1'b0;tR=1'b1;
#100 $stop;
end
endmodule
output Q;
output Qn;
input S;
input R;
nor(Qn, S, Q);
nor(Q, R, Qn);
endmodule
`timescale 1us/10ps
module tb_sr_latch_ungated;
reg tS;
reg tR;
wire tQ, tQn;
//module sr_latch_ungated(Q, Qn, S, R);
sr_latch_ungated DUT(tQ, tQn, tS, tR);
//instantiate counter to be tested.
initial
begin
#10 tS=1'b1;tR=1'b0;
#20 tS=1'b0;tR=1'b1;
#30 tS=1'b1;tR=1'b0;
#40 tS=1'b0;tR=1'b0;
#50 tS=1'b1;tR=1'b0;
#60 tS=1'b0;tR=1'b1;
#70 tS=1'b1;tR=1'b1;
#80 tS=1'b0;tR=1'b1;
#100 $stop;
end
endmodule
沒有留言:
張貼留言