A flip-flop or latch is a circuit that has two stable states and can be used to store state information. The circuit can be made to change state by signals applied to one or more control inputs and will have one or two outputs. It is the basic storage element in sequential logic. Flip-flops and latches are a fundamental building block of digital electronics systems used in computers, communications, and many other types of systems.
If the T input is high, the T flip-flop changes state (“toggles”) whenever the clock input is strobed. If the T input is low, the flip-flop holds the previous value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
module t(q,q1,t,c); output q,q1; input t,c; reg q,q1; initial begin q=1'b1; q1=1'b0; end always @ (c) begin if(c) begin if (t==1'b0) begin q=q; q1=q1; end else begin q=~q; q1=~q1; end end end endmodule
Leave a Reply