In this tutorial, we'll describe a T flip flip without reset, with synchronous reset and asynchronous reset.
Clock Edge |
T |
Q |
Description |
$$\downarrow$$ |
X |
Q |
No Change (Store previous input) |
$$\uparrow$$ |
0 |
Q |
Previous State |
$$\uparrow$$ |
1 |
$$\overline Q$$ |
Toogle |
module tff(clk,t,q);
input clk,t;
output reg q;
always @ (posedge clk)begin
if(t == 0)
q <= q;
else
q = ~q;
end
endmodule
module tff(clk,reset,d,q);
input clk,reset,t;
output reg q;
always @ (posedge clk)begin
if(reset)
q <= 0;
else begin
if(t == 0)
q <= q;
else
q = ~q;
end
end
endmodule
module tff(clk,reset,d,q);
input clk,reset,d;
output reg q;
always @ (posedge clk or negedge reset)begin
if(~reset)
q <= 0;
else begin
if(t == 0)
q <= q;
else
q = ~q;
end
end
endmodule
Click like if you found this useful