ChipFACTORYFoundations
Apply now
Foundations/STAGE 05
Foundations Track/STAGE 05
35 min discovery journey
SECTION 5

Can a circuit change its behavior over time?

The Big Question

“How can a physical circuit of gates and registers follow an orderly sequence of events?”

In Section 4, we learned how flip-flops hold onto bits. But holding static data is only half the story. Real digital systems—from traffic lights to CPU instruction pipelines—must step through complex sequences, react to changing inputs, and evolve their behavior over time. In this section, we will combine combinational logic with memory registers to build the ultimate digital controller: The Finite State Machine (FSM).

5.1Establishing State Sequences

What should happen first?

Consider an intersection traffic light. It cannot behave randomly or turn green and red at the same instant. It must follow a strict, predetermined sequence of events.

How does a traffic light follow a sequence?

When the system powers on, it starts in a safe default state: RED (Stop).
After the red phase finishes, what should happen next? The light turns GREEN (Go).
After green? It turns YELLOW (Prepare to stop).
And after yellow? It cycles back to RED.

Why is establishing this strict sequence the first step in circuit design?

Before we write boolean equations or place transistors, we must clearly define the order of operations. This operational order defines the State Transition Sequence of our digital machine.

Pedagogy: Slides 2, 3 & 4Interactive Discovery

5.1 What Should Happen First? Establishing State Sequences

A traffic light controller is the canonical real-world example of sequential logic. It cannot behave randomly: it must progress through a strictly defined sequence of events where each step leads inevitably to the next.

Sequence Step: #0
Current State: RED
Intersection Traffic Light Controller
STOP
STOP
Vehicles must halt. Cross-traffic or pedestrians have right-of-way.
State Transition Sequence FlowStrict Operational Order
01.
STATE RED
Standard Duration: 30 seconds
CURRENT
02.
STATE GREEN
Standard Duration: 40 seconds
NEXT UP →
03.
STATE YELLOW
Standard Duration: 5 seconds
The Fundamental Question: Notice that when the light is GREEN, the next state is YELLOW. But when the light is YELLOW, the next state is RED. The circuit can only make this choice if it has internal memory of its current state!
First Principles: Sequential logic does not merely calculate—it remembers where it is in a sequence to determine what happens next.
5.2Defining & Encoding States

What does the circuit need to remember?

To make the sequence work, the circuit must retain information about where it currently is in the cycle.

What is a “State”?

A State is a distinct, uniquely identifiable condition that the circuit holds in its physical memory. For our traffic light, the system has three primary states: RED, GREEN, and YELLOW, plus an optional EMERGENCY state.

How do we accurately represent each state in hardware?

Semiconductor flip-flops only store 0s and 1s. We assign each human-readable state a distinct binary pattern:
• Binary Encoding: 4 states require 2 D Flip-Flops (00₂ = RED, 01₂ = GREEN, 10₂ = YELLOW, 11₂ = EMERGENCY).
• One-Hot Encoding: 4 states use 4 flip-flops where exactly one bit is 1 at any time (0001₂, 0010₂, 0100₂, 1000₂).

Pedagogy: Slide 5Interactive Discovery

5.2 What Does the Circuit Remember? Defining & Encoding States

Silicon transistors do not know what 'RED' or 'GREEN' means. Hardware memory maps distinct operational situations to unique binary patterns stored inside D Flip-Flop registers.

Select State:
Physical State Register (2 × D Flip-Flops)Hardware Memory
DFF_1 (Bit Q1)
0
LOW (0V)
DFF_0 (Bit Q0)
0
LOW (0V)
Stored Register State:
Q₁Q₀ = 00₂
Mapped to: S0: RED (Stop)
State Encoding MapLookup Table
StateBinary CodeOne-Hot Code
RED00₂1000₂
GREEN01₂0100₂
YELLOW10₂0010₂
EMERGENCY11₂0001₂
Tradeoff: Binary encoding minimizes the number of flip-flops ($\lceil\log_2 4\rceil = 2$), while One-Hot encoding uses 1 flip-flop per state ($4$) to completely eliminate complex next-state decoding logic!
Encoding Rule: N states require ⌈log₂ N⌉ flip-flops for Binary Encoding, or N flip-flops for One-Hot Encoding.
5.3Clocks, Timers & External Triggers

What causes a state change?

Once states are defined, we must determine what forces the circuit to transition from its current state to the next state.

The Four Primary Transition Triggers

In real digital designs, state changes are driven by four distinct factors:
1. System Clock: The global periodic heartbeat that synchronizes state sampling.
2. Internal Timers: Countdown counters that hold a state for a fixed duration (e.g. 30s Red, 40s Green).
3. External Inputs: Asynchronous events from the real world (e.g. a pedestrian pressing a crossing button).
4. Emergency Overrides: High-priority sensor lines (e.g. emergency vehicle siren detection).

How do asynchronous inputs integrate cleanly?

When a pedestrian presses a push-button at an arbitrary instant, the signal is captured into a synchronizing flip-flop on the next clock rising edge (↑), preventing glitches from propagating into the state register.

Pedagogy: Slide 6Interactive Discovery

5.3 What Causes a State Change? Clocks, Timers & External Inputs

State transitions do not happen spontaneously. They are triggered by a combination of internal system clock ticks, duration timers, and external asynchronous sensor events (pedestrian buttons or emergency sirens).

Trigger Inputs & Event Stimuli:
TRIGGER 01: CLOCK
CLK Line: LOW (0)
Global synchronization heartbeat.
TRIGGER 02: TIMER
Countdown: 5s
Controls duration per state.
Current Active Machine StateState Register: Q₁Q₀ = 00₂
Active FSM Node:
RED (Stop)
Synchronous Integration: External asynchronous events (like a button press) are captured on the next clock rising edge (↑) to guarantee glitch-free transitions.
5.4State Diagrams, Tables & Output Models

How do we describe all possible behavior?

To build complex controllers without bugs or missing edge cases, engineers use two formal representations: the State Diagram and the State Transition Table.

The Three Core FSM Mapping Questions

For every possible scenario, the state machine answers:
• Current State (Q): Where are we right now?
• Next State (Q'): Based on inputs (X), where should we go on the next clock tick?
• Active Outputs (Y): What control signals should be produced?

Moore vs Mealy Output Architecture

• Moore Machine (Output = f(State)): Outputs depend exclusively on the current state register bits. Outputs are perfectly synchronized to the clock and immune to input glitches.
• Mealy Machine (Output = f(State, Input)): Outputs depend on both the current state and raw input lines. Mealy outputs react immediately within the current clock cycle, but can glitch if inputs fluctuate.

Pedagogy: Slides 7, 8 & 10Interactive Discovery

5.4 Describing Behavior: State Diagrams, Tables & Moore vs Mealy

A state machine can be completely described by a visual State Diagram and a State Transition Table. The way outputs are generated separates FSMs into Moore machines (State only) and Mealy machines (State + Input).

Interactive State Transition DiagramDirected Graph
Timer Done → Next: S1Next: S2Next: S0S0STOP (RED)S1GO (GREEN)S2WAIT (YELLOW)
Moore Output (f(State)):
RED = 1, YEL = 0, GRN = 0
MOORE MODEL
State Transition TableFSM Specification
State (Q)Input (X)Next State (Q')Output (Y)
S0 (RED)0S1 (GREEN)RED=1
S0 (RED)1S1 (GREEN)RED=1
S1 (GREEN)0S2 (YELLOW)GRN=1
S1 (GREEN)1S2 (YELLOW)GRN=1, PB=1
S2 (YELLOW)0S0 (RED)YEL=1
S2 (YELLOW)1S0 (RED)YEL=1
Moore vs Mealy Key Insight: A Moore machine associates outputs strictly with states (state bubbles), whereas a Mealy machine associates outputs with transitions (arcs).
Architecture Rule: In a Moore machine, Output = f(State). In a Mealy machine, Output = f(State, Input).
5.5Silicon Hardware Implementation

How do we build it in hardware?

Translating our abstract state bubbles and transition tables into silicon requires three hardware components working together in a closed loop.

The Three Hardware Pillars of an FSM

1. State Register (Memory): A bank of D Flip-Flops that holds the present state bits (Q).
2. Next-State Logic (Combinational): A network of AND, OR, and Inverter gates that calculates the next state bits (D_next) from the current state (Q) and external inputs (X).
3. Output Logic (Combinational): Decoders that convert the present state bits into physical drive signals (e.g. lighting the red, yellow, or green LEDs).
4. Feedback Loop: Wires physically routing the register outputs (Q) back into the input terminals of the next-state logic.

Connecting Sections 2, 3, 4, and 5

Notice what has just happened: An FSM is not mysterious new hardware. It is simply Combinational Logic (Section 3) + Flip-Flop Memory (Section 4) wired into a feedback loop to create Behavior Over Time!

Pedagogy: Slides 9 & 11Interactive Discovery

5.5 Building the FSM in Hardware: Registers & Next-State Logic

A Finite State Machine in silicon is constructed from three fundamental blocks: 1) A State Register (D Flip-Flops), 2) Next-State Combinational Logic (deciding next bits), and 3) Output Logic (driving output lines).

Complete 3-Block Sequential Hardware DiagramNext-State Logic + State Register + Output Logic
1. NEXT-STATE LOGICCombinational Gates

Decodes current state bits (Q₁, Q₀) to calculate next inputs (D₁, D₀).

D₁_next = Q̄₁ · Q₀:0
D₀_next = Q̄₁ · Q̄₀:1
Outputs feed State Register inputs (D₁, D₀)
2. STATE REGISTER2 × D Flip-Flops

Samples D on clock rising edge (↑), holding current state Q.

DFF 1 (MSB)
Q₁ = 0
DFF 0 (LSB)
Q₀ = 0
State Q₁Q₀ = 00₂ (S0: RED)
3. OUTPUT LOGICLamps Decoder

Converts current state bits (Q₁, Q₀) into physical control signals.

RED LAMP:1
YELLOW LAMP:0
GREEN LAMP:0
Feedback loop routes Q back to Next-State Logic
Hardware Blueprint: Next-State Logic D = f(Q, Input) + State Register Q(t+1) = D + Output Logic Y = f(Q).
Section 5 Architectural Synthesis

The Journey: From Real-World Sequences to Silicon State Machines

1. SEQUENCE
Operational Order

Defining the strict real-world sequence of events (RED → GREEN → YELLOW).

2. STATE ENCODING
Memory Bits (Q)

Mapping situations to binary bit patterns stored in D Flip-Flop registers.

3. SPECIFICATION
Diagrams & Tables

Capturing all transitions and distinguishing Moore vs Mealy output models.

4. HARDWARE
Logic + Registers

Next-state combinational gates feeding clock-driven state registers in a feedback loop.

The Master System Transition

If we can build a state machine...
how do we design a complete digital computer?

Understanding a single Finite State Machine is just the beginning.

What happens when we take a master Control Unit FSM, and connect it to a Register File, an ALU Datapath, and a Memory Interface?

All of these building blocks come together to form the ultimate computational architecture: A Complete Digital Machine (Microprocessor).

Next Section: Stage 06 — How Do We Design a Complete Digital Machine?
Proceed to Stage 06