Test Fixture Program :-
module tf_TFF_vlog;
// Inputs
reg t;
reg clr;
reg pr;
reg clk;
// Outputs
wire q;
wire nq;
// Instantiate the Unit Under Test (UUT)
TFF_vlog uut (
.t(t),
.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
t = 0; clr = 0; pr = 0; #100;
clr = 0; pr = 1; #100;
clr = 1; pr = 0; #100;
clr = 1; pr = 1; #100;
#100;
t = 1; #100;
#100;
end
endmodule
--------------------------------------------------------------------------------------------------------------------------
Program for TFF ( VERILOG ) :-
module TFF_vlog (input t ,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 if (t==0) begin
nq = nq;
q = q;
end else begin
q = !q;
nq = q;
end
end
endmodule
No comments:
Post a Comment