Source: http://onmyphd.com/?p=flip.flop

Flip-flops

What do you need to know to understand this topic?

Sections

What is a Flip-flop?

A Flip-flop (FF) is an electronic circuit that stores digital information, i.e., a single bit, when a specific type of edge (rising or falling) of a clock signal is detected. The pins of a FF are divided in 3 parts:

The following figure shows the signal relations of a general flip-flop that transfers the input bit to the output during a rising edge of the clock signal. Note that the output signal does not change when the input does, but only when the clock signal is asserted.

Together with latches, they are the basic data storage element of synchronous logic, i.e., logic that changes the signal at times synchronized by a clock signal.

What is the difference between Flip-flops and latches?

The main difference between flip-flops and latches is that latches are asynchronous while flip-flops are synchronous. A latch becomes "transparent" while the input clock is high. In this state, a change in its inputs takes immediate effect at its output. When the input clock is low, the output of the latch does not change. In latches, the clock is also known as Enable. The most simple latches are transparent all the time. On the other hand, a flip-flop takes a snapshot of its inputs only when a transition of the input clock occurs. Some examples of latches and their signals:

SR Latch (NOR type always transparent)

SR Latch with two NORs

Timing diagram of SR Latch

StateSRQ
hold 00$Q_{prev}$
reset 010
set 101
not allowed11???

Truth table of SR Latch

Gated SR Latch (transparent when E=1)

SR Latch with enable

Timing diagram of SR Latch with enable

StateSREQ
hold XX0$Q_{prev}$
hold 001$Q_{prev}$
reset 0110
set 1011
not allowed111???

Truth table of Gated SR Latch

Types of Flip-flops

There are 3 types of flip-flops: