`timescale 1ps / 1ps
module top_module ( );
reg clk;
dut u_dut( .clk(clk) ) ;
initial begin
clk = 1'b0;
forever begin
#(5) clk = ~clk;
end
end
endmodule
tb1
`timescale 1ps / 1ps
module top_module ( output reg A, output reg B );//
// generate input patterns here
initial begin
A = 1'b0;
B = 1'b0;
#10;
A = 1'b1;
#5;
B = 1'b1;
#5;
A = 1'b0;
#20;
B = 1'b0;
end
endmodule
`timescale 1ps/1ps
module top_module();
reg [2:0] s;
reg clk,in;
wire out;
q7 u_q7(
.clk(clk),
.in(in),
.s(s),
.out(out)
);
initial begin
clk = 1'b0;
forever begin
#5;
clk = ~clk;
end
end
initial begin
in = 1'b0;
s = 3'd2;
#10;
s = 3'd6;
#10;
s = 3'd2;
in = 1'b1;
#10;
s = 3'd7;
in = 1'b0;
#10;
s = 3'd0;
in = 1'b1;
#30;
in = 1'b0;
end
endmodule
tff
`timescale 1ps/1ps
module top_module ();
reg clk,reset,t;
wire q;
tff u_tff(
.clk(clk),
.reset(reset),
.t(t),
.q(q)
);
initial begin
clk = 1'b0;
forever begin
#5;
clk = ~clk;
end
end
initial begin
reset = 1'b0;
t = 1'b0;
#10;
reset = 1'b1;
#10;
reset = 1'b0;
t = 1'b1;
end
endmodule
//reset the T flip-flop then toggle it to the "1" state.意思是把t置1