A T flip-flop (Toggle flip-flop) is a type of sequential logic circuit that toggles its output on each clock pulse when its input is high.
Definition: A T flip-flop is a bistable multivibrator that changes (toggles) its output state on every clock pulse if the T (Toggle) input is high
module tff(q,qb,t,clk);
input t,clk;
output q,qb;
reg q=0;
reg qb=1;
always @(posedge clk)
begin
if (t==0)
q=q;
else
q=~q;
qb<=~q;
end
endmodule
module tb_tff();
wire q,qb;
reg t,clk;
tff dux(q,qb,t,clk);
initial
begin
clk = 0;
repeat(10)
begin
#5 clk =~clk;
end
end
initial
begin
t = 0;
#10 t = 1;
#10 t = 0;
#10 t = 1;
#20 $finish;
end
endmodule