Challenge Problems: System Integration
These challenge problems test deeper understanding. Only final answers are provided — work through each problem on your own.
Challenge 1: GCD Calculator — Datapath-Controller Design
Design a datapath and controller for a circuit that computes the Greatest Common Divisor (GCD) of two 8-bit unsigned numbers \(A\) and \(B\) using the subtraction-based Euclidean algorithm:
while A != B:
if A > B: A = A - B
else: B = B - A
GCD = A
Provide the complete datapath (registers, comparator, subtractor, MUX), controller FSM states, and control signal table. How many clock cycles does it take to compute GCD(12, 8)?
Show Answer
A_IN[7:0]──→[MUX_A]──→[Reg_A]──┬──→[Comparator]──→ A_EQ_B, A_GT_B
↑ │ │ ↑
SEL_A │ │ [Reg_B]←──[MUX_B]←── B_IN[7:0]
│ │ │ ↑
↓ └───────┤ SEL_B
[Subtractor] │
A - B B - A ←─────┘
│ │
↓ ↓
(to MUX_A) (to MUX_B)
Challenge 2: Multi-Stage Pipeline Timing with Clock Skew
A 5-stage pipeline has the following stage delays (combinational logic only):
| Stage | Delay |
|---|---|
| 1 | 3.2 ns |
| 2 | 4.8 ns |
| 3 | 5.1 ns |
| 4 | 3.9 ns |
| 5 | 2.5 ns |
Flip-flop parameters: \(T_{cq}\) = 0.4 ns, \(T_{setup}\) = 0.3 ns, \(T_{hold}\) = 0.15 ns.
Clock distribution introduces the following skews at each pipeline register (positive means clock arrives late relative to the source register):
| Register boundary | Skew \(\delta\) |
|---|---|
| Reg 1→2 | +0.2 ns |
| Reg 2→3 | -0.3 ns |
| Reg 3→4 | +0.4 ns |
| Reg 4→5 | -0.1 ns |
(a) Find the true \(f_{max}\) considering clock skew. (b) Identify any hold time violations. (c) What is the pipeline throughput and latency?
Show Answer
Challenge 3: UART Receiver FSM with Error Detection
Design a UART receiver FSM that receives 8-bit data at 9600 baud from a 50 MHz system clock. The receiver must:
- Detect the start bit (falling edge on RX line)
- Sample data bits at the center of each bit period
- Detect framing errors (invalid stop bit)
- Detect a break condition (RX held low for entire frame)
Provide the FSM states, transitions, and outputs. Include the baud-rate counter values for center-of-bit sampling.
Show Answer
RX: ‾‾‾\_____/‾‾‾‾‾\____/‾‾‾‾‾\____/‾‾‾‾‾\____/‾‾‾‾‾\_____/‾‾‾
idle |start| D0=1| D1=0| D2=1| D3=0| D4=1| D5=0| D6=1| D7=0|stop|
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
detect sample points at center of each bit
Challenge 4: FPGA LUT Cascade for Functions Exceeding Single LUT Capacity
An FPGA has 4-input LUTs (LUT-4). A design requires implementing the following 7-input function:
Decompose this function using Shannon expansion to map it onto LUT-4 resources. Determine:
(a) The minimum number of LUT-4s required. (b) The number of logic levels (LUT depth). (c) The LUT contents for each LUT in the decomposition.
Show Answer
A ──┬──→ [LUT 1: ABCD] ──→ P ──→ ┐
B ──┼──→ │ │
C ──┼──→ │ │
D ──┘ │
├──→ [LUT 5: P+Q+RS] ──→ H
A ──┬──→ [LUT 2: AEFG] ──→ Q ──→ ┤
E ──┼──→ │ │
F ──┼──→ │ │
G ──┘ │
│
A ──┬──→ [LUT 3: A̅B̅C̅D̅] ──→ R ──→ ┤
B ──┼──→ │ │
C ──┼──→ │ │
D ──┘ │
│
E ──┬──→ [LUT 4: E̅F̅G̅] ──→ S ──→ ┘
F ──┼──→ │
G ──┘ │
Challenge 5: Complete System Integration — Vending Machine with Display and Coin Handling
Design a complete vending machine system with:
- Coin acceptor: nickels (5c), dimes (10c), quarters (25c)
- 4 product selections (A, B, C, D) costing 50c, 75c, 100c, 125c
- Coin return button
- 2-digit 7-segment display showing amount deposited
- Change return mechanism (returns smallest number of coins)
Provide: (1) the complete system block diagram with all modules and interconnections, (2) the controller FSM states and transitions, (3) the datapath for coin accumulation and change calculation, and (4) the display subsystem design.
Show Answer
┌──────────────────────────────────────────────────────────────┐
│ VENDING MACHINE SYSTEM │
│ │
│ [Coin Sensor]──→ COIN[1:0] ──→ ┐ │
│ (N=01,D=10,Q=11) │ │
│ ┌─────┴──────┐ │
│ [Button Inputs] │ MAIN │ │
│ SEL[1:0] ──────────────→ │ CONTROLLER │ │
│ COIN_RETURN ───────────→ │ (FSM) │ │
│ └──┬──┬──┬───┘ │
│ ┌─────────────┘ │ └────────────┐ │
│ ↓ ↓ ↓ │
│ ┌──────────────────┐ ┌──────────────┐ ┌────────────┐ │
│ │ COIN DATAPATH │ │ PRODUCT │ │ CHANGE │ │
│ │ │ │ PRICE │ │ CALCULATOR│ │
│ │ [Accumulator Reg]│ │ ROM │ │ │ │
│ │ [8-bit Adder] │ │ A=50,B=75 │ │ [Subtractor]│ │
│ │ [Comparator] │ │ C=100,D=125 │ │ [Dividers] │ │
│ └────────┬─────────┘ └──────┬───────┘ └──────┬─────┘ │
│ │ │ │ │
│ ↓ ↓ ↓ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ DISPLAY │ │ DISPENSER │ │ COIN RETURN │ │
│ │ SUBSYSTEM │ │ CONTROL │ │ MECHANISM │ │
│ │ [Bin→BCD] │ │ │ │ │ │
│ │ [7-Seg Dec] │ │ DISP_A..D │ │ RET_Q,D,N │ │
│ │ [Digit MUX] │ └──────────────┘ └──────────────┘ │
│ └──────────────┘ │
└──────────────────────────────────────────────────────────────┘
COIN[1:0] ──→ [Coin Value LUT] ──→ COIN_VAL[4:0]
│
↓
TOTAL[7:0] ←── [Adder] ←── TOTAL (feedback)
↑
ADD_EN (from controller)
CHANGE = TOTAL - PRICE
NUM_QUARTERS = CHANGE / 25 (integer division)
REMAINDER1 = CHANGE mod 25
NUM_DIMES = REMAINDER1 / 10
REMAINDER2 = REMAINDER1 mod 10
NUM_NICKELS = REMAINDER2 / 5
TOTAL[7:0] ──→ [Binary-to-BCD] ──→ TENS[3:0], ONES[3:0]
│ │
[7-Seg Dec] [7-Seg Dec]
│ │
SEG_T[6:0] SEG_O[6:0]
│ │
┌────┴────┐ ┌───┴────┐
MUX_CLK ──→ [MUX] │ Digit 1 │ │ Digit 0│
↓ └─────────┘ └────────┘
DIGIT_SEL ──→ (anode drivers)