C7 · Lesson 40 · Register-transfer design
A datapath that computes and a controller that steers it
A multiplier, a GCD engine or a checksum unit isn't one big formula; it's a sequence of small steps, each moving values between registers through an adder or a comparator. Digital designers describe such machines at the register-transfer level: what each register receives on each clock. The design splits into a datapath (the registers and the arithmetic) and a controller (a state machine that decides which transfer happens next). Every processor is built this way.
Play
- The curves compare a combinational array multiplier, which finishes an n-bit product in one long clock, with a sequential shift-and-add multiplier, which reuses one adder for n short clocks, in units of a full adder's delay.
- At small n the sequential design is slower; it always uses far less hardware.
- Watch the area readouts: n full adders against n², the price of doing it all at once.
Predict
A sequential multiplier adds one shifted copy of the multiplicand per clock. How many clocks does it take to multiply two 8-bit numbers?
Eight: on each clock the controller looks at one multiplier bit and, if it's 1, adds the multiplicand shifted into place. One adder does the work of eight, at the price of eight clocks. An array multiplier spends 64 full adders to finish in one (longer) clock.
Name it
Register transfers
RTL notation writes what happens on a clock edge: means register A loads the difference. Several transfers in the same state happen together, on the same edge.
Datapath and controller
- The datapath holds the registers, the arithmetic units and the multiplexers that route values between them. It reports status signals, such as or a counter reaching zero.
- The controller is a state machine. In each state it asserts control signals: which registers load, what the ALU does, which multiplexer inputs pass. Its transitions depend on the status signals.
An ASM chart (algorithmic state machine) draws the controller: a box per state listing its transfers, diamonds for decisions on status signals.
Trading time for hardware
- Single-cycle: all the work of one operation in one long clock.
- Multi-cycle: one shared unit used over several short clocks: less hardware, the same or more time per result.
- Pipelined: separate hardware for each step, with registers between, so a new operation starts every short clock: the most hardware and the most throughput.
Worked example
A GCD machine repeats "if A > B, then A ← A − B, else B ← B − A" until A = B. Trace it from A = 48, B = 18.
Show the solution
- Trace it. (48, 18) → (30, 18) → (12, 18) → (12, 6) → (6, 6): four subtractions, and the controller's equality test then stops it with A = B = 6.
- The datapath. It needs two registers, a subtractor (shared through multiplexers), and comparators for A > B and A = B.
- The controller. It has an idle state, a run state and a done state.
- Its weakness. Subtraction is slow for very different inputs: GCD(100, 1) takes 99 steps.
Answer four subtractions, stopping at A = B = 6.
Worked example
Multiply 13 by 11 with a 4-bit shift-and-add multiplier.
Show the solution
- Write the multiplier in binary. 11 = 1011.
- Bit 0 is 1. The accumulator gets 13.
- Bit 1 is 1. Add 13 shifted once, 26:
- Bit 2 is 0. Add nothing.
- Bit 3 is 1. Add 13 shifted three times, 104:
- Count the cost. Four clocks, one adder, and the product 143 = 13 × 11; the controller is little more than a counter that stops after four bits.
Answer 143, in four clocks.
Worked example
An operation has three steps of 4 ns each, plus 0.5 ns of register overhead per clock. Compare single-cycle, multi-cycle (one shared unit) and pipelined designs.
Show the solution
- Single-cycle. One 12.5 ns clock per result.
- Multi-cycle. Three 4.5 ns clocks per result: with a third of the arithmetic hardware.
- Pipelined. A 4.5 ns clock and a new result every clock: times the throughput of single-cycle, though each result takes 13.5 ns to emerge.
- Choosing. The choice depends on whether hardware, latency or throughput matters most.
Answer single-cycle gives a result every 12.5 ns, multi-cycle every 13.5 ns with a third of the hardware, and pipelined every 4.5 ns, 2.8 times the throughput, with 13.5 ns of latency.
Check
An n-bit shift-and-add multiplier with n = 16 adds in 1 ns, plus 1 ns of register overhead per clock.
(a)
How many clocks per product?
(b)
How long does a product take?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
An operation has 3 steps of 2 ns each, with 0.5 ns of register overhead per clock.
(a)
What's the time per result in a single-cycle design?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
(b)
And in a pipelined one, once it's full?
Check
The GCD machine starts with A = 50 and B = 12. How many times does it subtract B from A before A first drops below B?
Check
The GCD controller has states IDLE = 00, RUN = 01, DONE = 10. It loads A (with A − B) only in RUN when G = (A > B) is 1. Write load_A.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
An operation of k steps, each taking t, runs N times; every clock costs r of register overhead.
Step 1
How long does a single-cycle design take?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
A multi-cycle design?
Step 3
A k-stage pipeline?
Check
Write gcd_rtl(a, b) returning (g, steps): the GCD found by the subtraction machine, and the number of subtractions it performed.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why do designers split a digital system into a datapath and a controller?
The datapath and the controller change for different reasons and are designed in different ways. The datapath is about moving and transforming values: how wide the registers are, which arithmetic units exist, how values are routed. The controller is about sequence: which transfer happens in which state, and how decisions depend on what the datapath reports. Separating them lets each be designed with its own tools: the datapath from standard blocks like adders and multiplexers, and the controller as a state machine. It also lets the same datapath run different algorithms by changing only the controller, which is exactly what a programmable processor does.
Practice
Keep practicing
4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.