Test Fixture Program :-
module tf_DFF_vlog;
// Inputs
reg d;
reg clr;
reg pr;
reg clk;
// Outputs
wire q;
wire nq;
// Instantiate the Unit Under Test (UUT)
DFF_vlog uut (
.d(d),
.clr(clr),
.pr(pr),
.clk(clk),
.q(q),
.nq(nq)
);
initial begin
forever begin
clk=0;
#50
clk=1;
#50
clk=0;
end
end
initial begin
d = 0; clr = 0; pr = 0; #100;
clr = 0; pr = 1; #100;
clr = 1; pr = 0; #100;
clr = 1; pr = 1; #100;
#100;
d = 1; #100;
#100;
end
endmodule
--------------------------------------------------------------------------------------------------------------------------
Program for DFF ( VERILOG ) :-
module DFF_vlog (input d ,input clr ,
input pr ,input clk , output q , output nq );
reg q;reg nq;
always @ (posedge clk) begin
if (pr==0) begin
q = 1;
nq = 0;
end else if (clr==0) begin
nq = 1;
q = 0;
end else begin
q = d;
nq = !d;
end
end
endmodule
No comments:
Post a Comment