Sequential logic: flip flops

Comprehensive study notes, diagrams, and exam preparation for Sequential logic: flip flops.

Sequential Logic: Flip Flops

Definition

A flip-flop is a bistable sequential circuit that has two stable states and can store one bit of data. Its output changes state only when triggered by a control signal such as a clock, set, reset, or enable input.

In simple terms, a flip-flop is a memory element that holds either 0 or 1 until it is instructed to change. Because it responds to control timing, it is also called an edge-triggered or level-sensitive storage device depending on its design.


Main Content

1. Basics of Sequential Logic and Memory

Memory in digital circuits

Sequential logic differs from combinational logic because it contains memory. The present output of a sequential circuit depends on both current inputs and previously stored information. This storage is achieved using feedback paths, which allow the circuit to retain state.

For example, in a simple lamp control circuit, the light may remain ON even after the button is released if a memory element is used. This “remembering” behavior is a key property of sequential systems.

State and state changes

A state is the stored condition of the circuit at a given time. In flip-flops, the state is represented by outputs such as Q and Q̅. When a triggering event occurs, the state may change according to input values. In digital design, state transitions are carefully controlled to avoid unpredictable behavior.

Example:

  • If Q = 1, the flip-flop is storing a logic high.
  • If Q = 0, the flip-flop is storing a logic low.
  • A clock event can cause the output to switch from one state to another.

2. Types of Flip-Flops

SR Flip-Flop

The Set-Reset flip-flop is one of the simplest flip-flops. It has two inputs, S and R. When S is activated, the output is set to 1. When R is activated, the output is reset to 0. However, one input combination is usually invalid because it may cause undefined output.

Truth behavior:

  • S = 1, R = 0 → Set Q = 1
  • S = 0, R = 1 → Reset Q = 0
  • S = 0, R = 0 → Hold previous state
  • S = 1, R = 1 → Invalid/forbidden in basic SR design

JK Flip-Flop

The JK flip-flop improves on the SR design by removing the invalid condition. It has inputs J and K and can operate in four modes: hold, set, reset, and toggle. It is widely used in counters and control circuits.

Behavior:

  • J = 0, K = 0 → No change
  • J = 0, K = 1 → Reset
  • J = 1, K = 0 → Set
  • J = 1, K = 1 → Toggle output

D Flip-Flop and T Flip-Flop

The D flip-flop stores the value present at input D on the triggering clock edge. It is the most commonly used flip-flop in registers and memory systems because it is simple and reliable.

The T flip-flop toggles its output when T = 1 and holds its state when T = 0. It is useful in frequency division and counters.

Example:

  • D = 1 at clock edge → Q becomes 1
  • D = 0 at clock edge → Q becomes 0
  • T = 1 → output changes state every clock pulse

3. Clocking, Triggering, and Practical Behavior

Clocked operation

Most modern flip-flops are clocked devices. They respond to input only at a defined clock transition, either rising edge or falling edge. This makes digital systems synchronized and easier to design.

A rising-edge-triggered flip-flop changes state only when the clock goes from 0 to 1. A falling-edge-triggered flip-flop changes state when the clock goes from 1 to 0.

Setup and hold time

Flip-flops require input signals to be stable around the clock edge for reliable operation. Setup time is the minimum time the input must be stable before the clock edge. Hold time is the minimum time the input must remain stable after the clock edge. If these timing requirements are violated, the flip-flop may enter metastability or store the wrong value.

Metastability and real-world limitations

In practice, a flip-flop may momentarily enter an unstable intermediate state if inputs change too close to the clock edge. This is called metastability. Although the circuit usually settles to a valid state eventually, it can cause errors in high-speed systems if not properly managed.

Engineers reduce such problems by:

  • synchronizing asynchronous inputs,
  • using proper timing constraints,
  • designing with adequate clock margins.

Working / Process

1. Initial state is stored

The flip-flop begins in one of its two stable states, typically represented by Q = 0 or Q = 1. This stored state acts as the memory of the circuit. The output remains unchanged until a valid triggering event occurs.

2. Inputs are applied and sampled by the clock

The relevant input values are placed on the flip-flop inputs. The clock signal controls when these values are captured. In edge-triggered flip-flops, the input is sampled only at the active clock edge, not continuously.

3. Output updates and is retained

After the triggering edge, the flip-flop updates its output according to its input rules. The new state is then held until the next clock event. This allows the circuit to preserve data and coordinate operations across time.

For a better visual understanding of a basic D flip-flop behavior:

      D ──────────────┐
                      │
                  ┌───▼───┐
Clock ────────────►│  D    │─── Q
                  │Flip-Flop│
                  └───▲───┘
                      │
                     Q̅

Example working of a D flip-flop:

  • If D = 1 just before the rising clock edge, Q becomes 1.
  • If D = 0 just before the rising clock edge, Q becomes 0.
  • Between clock edges, Q stays unchanged.

A useful timing view:

Clock:  __|‾‾|__|‾‾|__|‾‾|__
D:      ___‾‾‾_____‾‾‾______
Q:      ___‾‾‾_____‾‾‾______

This shows that Q changes only at clock edges, not continuously with D.


Advantages / Applications

Data storage in digital systems

Flip-flops store individual bits and form the basis of registers, counters, shift registers, and memory cells. Without flip-flops, digital systems would not be able to remember information between operations.

Synchronization and timing control

Since flip-flops respond to clock signals, they help synchronize different parts of a digital system. This is essential in CPUs, communication circuits, and pipeline stages where operations must occur in a controlled sequence.

Use in counters, finite state machines, and digital control

Flip-flops are heavily used in binary counters, frequency dividers, and state machines. For example, a counter uses flip-flops to advance through binary states on each clock pulse, while a finite state machine uses them to store the current state of a controller.

Examples:

  • In a 4-bit register, four flip-flops store 4 bits of data.
  • In a binary counter, each flip-flop may represent one bit of the count.
  • In a traffic light controller, flip-flops help store the current operating state.

Summary

  • Flip-flops are bistable memory elements used in sequential logic.
  • They store one bit and change state only under control signals, usually a clock edge.
  • Common types include SR, JK, D, and T flip-flops.

Important terms to remember

Flip-flop, sequential logic, state, clock, set, reset, toggle, hold, setup time, hold time, metastability.