Sequential Logic Design

Vivid Light Show Controller

Two state machines turn button presses into a four-colour sequence and a timed musical cue.

My contribution
State-machine design, Boolean minimisation, D/T/JK implementations and simulation
Context
Interactive light-controller concept · UNSW
Focus
Embedded & hardware
Colour state machine: Magenta → Cyan → Yellow → White, with forward, skip and hold transitions.
State MachinesColour state machine: Magenta → Cyan → Yellow → White, with forward, skip and hold transitions.
Music state machine: count accepted Forward actions, reset on Skip and signal the third Forward action.
State MachinesMusic state machine: count accepted Forward actions, reset on Skip and signal the third Forward action.
Colour-state implication table: all four output colours remain distinguishable.
State MachinesColour-state implication table: all four output colours remain distinguishable.
Music-state implication table: zero, one and two Forward actions require distinct states.
State MachinesMusic-state implication table: zero, one and two Forward actions require distinct states.
Complete controller using D flip-flops for the colour and music state registers.
D Flip-FlopsComplete controller using D flip-flops for the colour and music state registers.
D flip-flop implementation of the two-bit colour state.
D Flip-FlopsD flip-flop implementation of the two-bit colour state.
D flip-flop implementation of the musical-cue state machine.
D Flip-FlopsD flip-flop implementation of the musical-cue state machine.
Original Karnaugh-map groupings for the D flip-flop colour implementation.
D Flip-FlopsOriginal Karnaugh-map groupings for the D flip-flop colour implementation.
Original Karnaugh-map groupings for the D flip-flop music implementation.
D Flip-FlopsOriginal Karnaugh-map groupings for the D flip-flop music implementation.
Complete controller using T flip-flops and toggle excitation logic.
T Flip-FlopsComplete controller using T flip-flops and toggle excitation logic.
T flip-flop implementation of the colour state machine.
T Flip-FlopsT flip-flop implementation of the colour state machine.
T flip-flop implementation of the musical-cue state machine.
T Flip-FlopsT flip-flop implementation of the musical-cue state machine.
Original Karnaugh-map groupings for the T flip-flop colour implementation.
T Flip-FlopsOriginal Karnaugh-map groupings for the T flip-flop colour implementation.
Original Karnaugh-map groupings for the T flip-flop music implementation.
T Flip-FlopsOriginal Karnaugh-map groupings for the T flip-flop music implementation.
Complete controller using JK flip-flops and derived excitation logic.
JK Flip-FlopsComplete controller using JK flip-flops and derived excitation logic.
JK flip-flop implementation of the colour state machine.
JK Flip-FlopsJK flip-flop implementation of the colour state machine.
JK flip-flop implementation of the musical-cue state machine.
JK Flip-FlopsJK flip-flop implementation of the musical-cue state machine.
Original Karnaugh-map groupings for the JK flip-flop colour implementation.
JK Flip-FlopsOriginal Karnaugh-map groupings for the JK flip-flop colour implementation.
Original Karnaugh-map groupings for the JK flip-flop music implementation.
JK Flip-FlopsOriginal Karnaugh-map groupings for the JK flip-flop music implementation.
Verilog testbench declarations, signal connections and initialisation for controller simulation.
SimulationVerilog testbench declarations, signal connections and initialisation for controller simulation.
Verilog stimulus loop: advance the Forward/Skip input pair and pulse the clock.
SimulationVerilog stimulus loop: advance the Forward/Skip input pair and pulse the clock.
ISim controller waveform sample 1: button inputs, state bits and music output.
SimulationISim controller waveform sample 1: button inputs, state bits and music output.
ISim controller waveform sample 2: button inputs, state bits and music output.
SimulationISim controller waveform sample 2: button inputs, state bits and music output.
ISim controller waveform sample 3: button inputs, state bits and music output.
SimulationISim controller waveform sample 3: button inputs, state bits and music output.
ISim controller waveform sample 4: button inputs, state bits and music output.
SimulationISim controller waveform sample 4: button inputs, state bits and music output.
ISim controller waveform sample 5: button inputs, state bits and music output.
SimulationISim controller waveform sample 5: button inputs, state bits and music output.
ISim controller waveform sample 6: button inputs, state bits and music output.
SimulationISim controller waveform sample 6: button inputs, state bits and music output.

Experience In Practice

Skills Applied

View All Skills

Define What Each Button Should Do

The concept is an interactive light display with four colours: Magenta, Cyan, Yellow and White. Forward advances one colour, while Skip advances two. After three Forward actions without a Skip, the controller requests a musical beep for one clock cycle.

The outputs are a two-bit colour code and a one-bit music signal. Reset returns the colour to Magenta and clears the musical-cue progress. With neither button pressed, the state holds; the design also treats both buttons pressed together as a hold.

The challenge is remembering two different things: the current colour and progress towards the musical cue. A colour alone cannot identify whether the preceding actions were Forward or Skip.

Control Rules
InputColour ActionMusic Progress
ResetReturn to MagentaClear to zero
F=0, S=0HoldHold; no cue
F=0, S=1Advance two coloursClear to zero; no cue
F=1, S=0Advance one colourAdvance count; cue on the third Forward
F=1, S=1HoldHold; no cue

F = Forward and S = Skip. Button actions are evaluated by the clocked logic.

Separate Colour State From Sequence Memory

I split the design into a colour state machine and a music state machine. The colour machine needs four states, encoded as Magenta=00, Cyan=01, Yellow=10 and White=11. Its state directly identifies the displayed colour.

The music machine needs three states: zero, one or two accepted Forward actions since the last Skip or musical cue. A Forward from the two-action state requests the cue and returns the counter to zero.

I checked whether any states could be merged. Different colour states already have different outputs. The music states also remain distinct because the same future Forward sequence reaches the cue at different times. Two state bits per machine are sufficient.

Colour state machine: Magenta → Cyan → Yellow → White, with forward, skip and hold transitions.
Colour state machine: Magenta → Cyan → Yellow → White, with forward, skip and hold transitions.
Music state machine: count accepted Forward actions, reset on Skip and signal the third Forward action.
Music state machine: count accepted Forward actions, reset on Skip and signal the third Forward action.

Make Every State Transition Explicit

The colour table below contains all 16 combinations of current colour and button inputs. Reading across a row shows hold, skip, forward and hold again. In binary, Forward adds one modulo four and Skip adds two modulo four.

The music table contains all 12 valid state/input combinations. Pauses preserve progress; Skip clears it. The unused music encoding 11 is excluded from the three-state design and was available as a don’t-care when minimising the logic.

Colour Next-State Table
Present Colour · ABFS=00 · HoldFS=01 · SkipFS=10 · ForwardFS=11 · Hold
Magenta · 00Magenta · 00Yellow · 10Cyan · 01Magenta · 00
Cyan · 01Cyan · 01White · 11Yellow · 10Cyan · 01
Yellow · 10Yellow · 10Magenta · 00White · 11Yellow · 10
White · 11White · 11Cyan · 01Magenta · 00White · 11

Each cell gives the next colour and its two-bit output. Reset selects Magenta · 00.

Music Next-State / Cue Table
Present Count · CDFS=00FS=01FS=10FS=11
0 · 000 / 00 / 01 / 00 / 0
1 · 011 / 00 / 02 / 01 / 0
2 · 102 / 00 / 00 / 12 / 0

Each cell is “next count / music output”. Reset selects count 0 · 00; the cue occurs on the third Forward action.

Reduce The Table To A Small Set Of Rules

I used state assignments and Karnaugh maps to derive the flip-flop excitation inputs. A useful way to understand the colour logic is to look at which state bits toggle.

The least significant colour bit B toggles only on Forward. The most significant bit A toggles on Skip, or on Forward when B is already 1 and the increment carries into A. Neither bit toggles for input 00 or 11.

The equations below restate those transitions directly from the state tables. For the music machine, count 2 is encoded CD=10, so the cue requires that state together with Forward alone.

TB = F·¬S

TA = ¬F·S + B·F·¬S

Bnext = B XOR TB

Anext = A XOR TA

MUSIC = C·¬D·F·¬S

A and C are the most significant state bits. · means AND, + means OR, ¬ means NOT; TA and TB are colour toggle requests.

Original Karnaugh-map groupings for the T flip-flop colour implementation.
Original Karnaugh-map groupings for the T flip-flop colour implementation.

Implement The Same Behaviour With D, T And JK Flip-Flops

I developed three gate-level versions around the same state-transition requirements. D flip-flops take the required next-state bit directly. T flip-flops need a toggle request when the bit must change. JK flip-flops use excitation conditions that set, clear or retain each state bit.

For each version, I derived the excitation table, grouped the corresponding Karnaugh maps and drew the colour and music circuits. The slideshow includes the complete D, T and JK schematics as well as the separate logic blocks.

The excitation table explains why the Boolean networks differ even though the intended controller behaviour is the same. X is a don’t-care: either value produces the required transition when the other input is fixed.

Single-Bit Flip-Flop Excitation Table
Q → QnextDTJK
0 → 0000X
0 → 1111X
1 → 001X1
1 → 110X0
Complete controller using JK flip-flops and derived excitation logic.
Complete controller using JK flip-flops and derived excitation logic.

Follow The Sequence In Simulation

I connected the controller designs to Verilog test inputs and used ISim to inspect button signals, colour bits, music-state bits and the cue output. The retained stimulus code cycles the Forward/Skip input pair and pulses the clock; six waveform captures are included in the slideshow.

A simple trace makes the intended behaviour easy to follow: reset to Magenta, then three Forward actions reach Cyan, Yellow and White, with the cue on the third action. A Skip anywhere in the sequence clears progress towards the next cue.

This trace is derived from the design’s state tables; the original simulation captures are shown separately so the intended transitions and the recorded circuit behaviour can both be inspected.

Worked Trace From Reset
ActionColour After ActionForward CountMusic Cue
ResetMagenta · 0000
ForwardCyan · 0110
ForwardYellow · 1020
ForwardWhite · 1101
ForwardMagenta · 0010
SkipYellow · 1000
ForwardWhite · 1110
ISim controller waveform sample 1: button inputs, state bits and music output.
ISim controller waveform sample 1: button inputs, state bits and music output.

The Engineering Journey

Model

Separate visible colour from the memory needed to recognise three Forward actions.

Minimise

Assign states and use truth tables and Karnaugh maps to derive excitation logic.

Implement

Build D, T and JK versions and inspect their signals in ISim.

What This Experience Achieved

The result

A complete sequential-logic design record: two state machines, explicit transition tables, Karnaugh-map derivations, three flip-flop circuit implementations and simulation captures.

Technical decisions & tools

The colour machine has four states and the music machine three. Their separate two-bit registers make the two responsibilities explicit.

Music is a Mealy-style output: the current music state and Forward/Skip inputs determine the cue. The state-table explanation assumes a button action is sampled for one clock interval.

The unused music state 11 is a minimisation don’t-care, not a fourth progress state. Reset establishes the intended starting state.

The readable equations on this page are derived from the transition tables; the image gallery retains the original design diagrams and Karnaugh-map working.

Finite-state machinesSequential logicKarnaugh mapsD / T / JK flip-flopsSchematic captureVerilog testbenchesISim