Digital Design Foundations

A rebuild of 6.191 Lectures 1 to 9, from voltages to pipelined circuits. It starts from zero, puts the ideas that generalize first, and then drills the problem types this material is usually tested with. The worked code is from your own lab1-yumelody, lab2-yumelody and lab3-yumelody.

combinationalstatetimingmeets the rulebreaks the rule
What this page is built fromThe lecture slides and the quizzes need an MIT login that I could not use, so I do not know what your quizzes asked. This page teaches the standard material for these nine lecture titles and uses your lab code as the examples. The practice problems are the usual problem types for this material, written by me, with full solutions.

0The big picture: five ideas

Every topic below is one of these five ideas with details attached. If you can explain each idea in a sentence and draw its picture, the details have somewhere to go.

Idea 1 · Digital means every stage cleans up the signal

A wire carries a voltage, and voltages pick up noise. Digital circuits survive because every gate accepts a sloppy input and produces a clean output, so errors do not accumulate.

gate outputs 4.8 V
clean 1
→ wire adds noise →
arrives as 3.9 V
still read as 1
→ gate →
outputs 4.8 V
clean again
→ noise →
4.1 V
→ gate →
4.8 V

The same idea recurs at every level of the course. A flip-flop cleans up timing the way a gate cleans up voltage. A valid bit cleans up the question of whether data is real. The pattern is: define what counts as acceptable, demand more of outputs than of inputs, and the gap between them is your safety margin.

Idea 2 · Any function is a truth table, and any truth table is gates

A combinational circuit has no memory, so it is completely described by a table of outputs for every input. Any such table can be built from AND, OR and NOT, or from NAND alone.

specification
in words
→
truth table
→
sum of products
→
simplify
→
gates
→
transistors

This chain always works, which is why combinational design is mechanical. The table doubles with every added input, so real designs do not flatten everything into one table. They build small blocks (a full adder, a mux) and compose them. The skill tested is moving between adjacent boxes in either direction.

Idea 3 · Time has two bounds: the slowest path and the fastest path

After an input changes, the output stays at its old value for at least the contamination delay and reaches its new value by the propagation delay. In between it is garbage.

The slow bound, tPD, sets how fast the clock can run. The fast bound, tCD, decides whether a value changes too early and corrupts the register that is still capturing the previous one. Every timing problem is one of these two inequalities.

Idea 4 · State plus a clock turns functions into machines

Put registers around a combinational function and feed the output back. The function computes the next state, the clock decides when it becomes the current state. That loop is every sequential circuit.

inputs
→
combinational logic
next state, outputs
→
registers
current state
→ back into the logic, and out

A counter, a finite state machine, your folded multiplier, your cache and your whole processor all have this shape. In Minispec the registers are Reg, the logic is a rule, and the outputs are methods. Once you see the shape, an unfamiliar module is read the same way every time: what is the state, what is the next-state function.

Idea 5 · Registers trade latency for throughput, and everything trades against area

Cutting a long computation with registers lets several inputs be in progress at once. Each result takes at least as long as before, but results come out more often.

Way to build the same functionClock periodLatencyThroughputArea
Combinational: all the logic in one cyclelongone long cycleone result per long cycleall the logic
Pipelined: same logic cut by registersshortseveral short cyclesone result per short cycleall the logic plus registers
Folded: one small piece reused over several cyclesshortseveral short cyclesone result per several cyclesone piece plus control

Lab 3 built all three for multiplication and sorting. Lab 6 is the pipelined row applied to a processor. There is no best row. The question is always which of time, throughput, area and power the design is short of.

1The digital abstraction (L1)

Four voltage thresholds define a logic family. Outputs must be more extreme than inputs are required to be. The difference is the noise margin.

ThresholdMeaning
VOLA gate driving 0 must output at or below this
VILA gate must treat any input at or below this as 0
VIHA gate must treat any input at or above this as 1
VOHA gate driving 1 must output at or above this

They must be ordered VOL < VIL < VIH < VOH. Inputs between VIL and VIH are in the forbidden zone, where the gate promises nothing.

Try it

Set the four thresholds and see the noise margins

What outputs may produce
What inputs must accept
Noise margins
low noise margin, VIL − VOL
high noise margin, VOH − VIH

The static discipline

If every input to a device is a valid input (below VIL or above VIH), then after tPD every output is a valid output (below VOL or above VOH). Valid in gives valid out. This is the contract that lets you stack gates without thinking about voltages again.

The voltage transfer characteristic plots a device's output voltage against its input voltage. For the discipline to hold with positive noise margins, the curve must stay out of two forbidden boxes, which forces it to be steeper than slope 1 somewhere in the middle. A device with gain below 1 everywhere, such as a wire or a resistor divider, cannot restore signals.

Chart

Voltage transfer characteristic of an inverter

With VIL = 1.5 V the output must be at least VOH = 4.5 V for every input at or left of 1.5. With VIH = 3.5 V it must be at most VOL = 0.5 V for every input at or right of 3.5. The curve may do anything in between, and it has to fall 4 V while the input moves 2 V, so the gain there exceeds 1.

How to attack a VTC or noise-margin problem
  1. Write the order VOL < VIL < VIH < VOH. Any choice that breaks it is wrong immediately.
  2. For an inverting device, read the curve at VIL: the output there, and everywhere to the left, must be ≥ VOH. Read it at VIH: the output there, and everywhere to the right, must be ≤ VOL.
  3. For a non-inverting device swap the pairing: inputs ≤ VIL must give outputs ≤ VOL, inputs ≥ VIH must give outputs ≥ VOH.
  4. Noise margins are the two differences. The smaller one is the margin of the family.

Recall

Worked: VOL = 0.3, VIL = 1.2, VIH = 3.0, VOH = 4.4. What are the noise margins, and how much noise can a wire add safely?

Low margin = VIL − VOL = 1.2 − 0.3 = 0.9 V. High margin = VOH − VIH = 4.4 − 3.0 = 1.4 V. The guarantee must hold for both values, so the tolerable noise is the smaller one, 0.9 V.

Why must outputs be held to a stricter standard than inputs?

The wire between an output and the next input adds noise. If the output only just met the input requirement, any noise would push it into the forbidden zone. The stricter output rule leaves room for that noise.

Worked: an inverter's curve passes through (1.0 V in, 4.6 V out), (2.0, 4.0), (3.0, 0.8), (4.0, 0.2). Is VIL = 2.0, VOH = 4.5 a legal choice?

No. At an input of exactly VIL = 2.0 V, which is a valid 0, the output is 4.0 V, below VOH = 4.5 V. Valid in gave invalid out. Either lower VIL to about 1.0 V or lower VOH to 4.0 V, and then recheck the ordering and the margins.

Can a device whose curve has slope magnitude below 1 everywhere obey a static discipline with positive noise margins?

No. The output range [VOL, VOH] is wider than the input range [VIL, VIH] it must be crossed within. Covering a larger output swing over a smaller input swing needs gain above 1 somewhere.

2Boolean algebra and gates (L2)

A truth table with n inputs has 2n rows. Write one AND term for each row where the output is 1, OR them together, and you have a correct circuit. Simplifying only makes it smaller.

ABANDORXORNANDNOR
0000011
0101110
1001110
1111000
Try it

Click the F column to define a function of three inputs

Truth table
Karnaugh map (columns in Gray order)
Sum of products, one term per 1

Minimal sum of products

A′ means NOT A. Adjacent 1s in the map differ in one variable, and that variable drops out of the term. Bigger rectangles of 1s give smaller terms.

The identities worth memorising

NameAND formOR formUse
Identity, nulla·1 = a, a·0 = 0a+0 = a, a+1 = 1Remove constants
Complementa·a′ = 0a+a′ = 1The step that removes a variable
Distributivea·(b+c) = a·b + a·ca+(b·c) = (a+b)·(a+c)Factor out a common term
Combininga·b + a·b′ = a(a+b)·(a+b′) = aWhat a Karnaugh rectangle does
Absorptiona·(a+b) = aa + a·b = aA bigger term swallows a smaller one
De Morgan(a·b)′ = a′ + b′(a+b)′ = a′·b′Push a NOT through, flipping the operator

Universal gates. NAND alone can build everything: NOT a = NAND(a, a). a AND b = NOT(NAND(a, b)). a OR b = NAND(NOT a, NOT b), by De Morgan. NOR is universal the same way. AND and OR without NOT are not universal, because they can never make an output fall when an input rises.

Lab 1 made you write functions gate by gate. This one is not the flat sum of products (which would be four 4-input ANDs). It uses structure: a 4-bit value is a power of two when exactly one pair has exactly one bit and the other pair has none. Finding structure like this is what beats the mechanical method.

How to attack a simplification problem
  1. Get a truth table, even if the question starts from an expression or from words.
  2. Three or four inputs: draw the Karnaugh map with Gray-ordered columns (00, 01, 11, 10). Circle the largest rectangles of 1s whose sides are powers of two. Rectangles may wrap around the edges.
  3. Each rectangle is one product term containing only the variables that stay constant inside it.
  4. Cover every 1 with as few and as large rectangles as possible. Overlap is allowed.
  5. If asked to prove an identity algebraically, the usual moves are: distribute, find x + x′ = 1, or duplicate a term (a = a + a) so it can combine twice.

Recall

Worked: write the sum of products for the 3-input majority function and simplify it.

Output is 1 for ABC = 011, 101, 110, 111. Full form: A′BC + AB′C + ABC′ + ABC.

Duplicate ABC twice (x = x + x): (A′BC + ABC) + (AB′C + ABC) + (ABC′ + ABC) = BC + AC + AB. Select majority in the tool above to check.

Worked: simplify F = A·B + A·B′·C.

Factor A: A·(B + B′·C). By the second distributive law B + B′C = (B + B′)(B + C) = B + C. So F = A·(B + C) = AB + AC.

Worked: build a 2-input OR from NAND gates only. How many gates?

a + b = (a′·b′)′ by De Morgan = NAND(a′, b′). Each inversion is a NAND with its inputs tied together. Total 3 NAND gates.

How many different Boolean functions of 3 inputs exist?

The table has 23 = 8 rows and each row's output is a free choice of 0 or 1, so 28 = 256 functions. In general 2(2n).

Worked: apply De Morgan to (A·B + C′)′.

Outer NOT over an OR: (A·B)′ · (C′)′ = (A′ + B′)·C = A′C + B′C.

Why is {AND, OR} not a universal set?

Both are monotonic: raising an input can never lower the output. Any circuit built only from them is also monotonic, so it can never implement NOT.

3Combinational design and Minispec (L3–L4)

Big circuits are small circuits copied and wired together. A Minispec function is a description of that wiring. Loops and parameters run at compile time and leave only gates behind.

Numbers first: two's complement

An n-bit pattern read as unsigned is the sum of its bits times powers of two. Two's complement gives the top bit the weight −2n−1 instead of +2n−1. The range is −2n−1 to 2n−1 − 1. To negate, invert every bit and add 1. The payoff is that one adder handles signed and unsigned numbers, and subtraction is addition of the negation.

Reading Minispec as hardware

You writeYou get
Bit#(1) x = a & b;A wire named x driven by an AND gate. Reassigning x later makes a new wire with the same name.
if (s == 1) r = a; else r = b;A multiplexer. Both a and b are computed. s only selects.
for (Integer i = 0; i < n; …)n copies of the loop body. Nothing loops at run time.
rca#(32)The parameter is fixed at compile time. rca#(4) and rca#(32) are different circuits from one description.
case (x) …A wide multiplexer, or a lookup table as in your seven_segment_decoder.

Delay of a combinational circuit

tPD of a circuit is the largest sum of gate tPDs along any input-to-output path. tCD is the smallest sum of gate tCDs along any path. The critical path of a ripple-carry adder is the carry chain, so its delay grows linearly with width. Faster adders spend area to shorten that chain.

Chart

Adder delay against width, in gate delays (a simple model)

Ripple-carry delay grows as n. A carry-lookahead adder computes carries with a tree, so its delay grows as log n, at the cost of more gates. A carry-select adder sits between: it computes the upper half for both possible carries and picks one with a mux.

Three reusable tricks from Lab 2

How to attack a delay problem
  1. Draw the circuit as boxes and label each with its tPD and tCD.
  2. tPD: find the path with the largest sum. Look for chains (carries) and for the deepest mux tree.
  3. tCD: find the path with the smallest sum. It is often an input that goes through a single gate to an output.
  4. For a repeated structure, write the delay as a formula in n before plugging in numbers.

Recall

Worked: what is −6 as a 4-bit two's complement number? What does 1011 mean?

6 = 0110. Invert: 1001. Add 1: 1010. Check: −8 + 2 = −6.

1011 = −8 + 2 + 1 = −5.

Worked: a full adder has tPD = 2 ns from carry-in to carry-out and 3 ns from any input to sum. What is tPD of a 32-bit ripple-carry adder?

The worst path enters at bit 0, ripples through the carry of adders 0 to 30, then goes carry-in to sum in adder 31. For this estimate take carry-out from any input as 2 ns: 31 × 2 + 3 = 65 ns. As a formula, (n − 1)·tcarry + tsum.

How does addSub subtract with an adder?

a − b = a + (−b) = a + ~b + 1. It inverts b and feeds 1 into the carry-in of bit 0, so the +1 is free.

Worked: how many 2-way 1-bit muxes does a 32-bit barrel shifter use? What would a design with one 32-way mux per output bit use?

Barrel: 5 layers × 32 bits = 160 muxes, with 5 muxes on the longest path. A 32-way mux is 31 two-way muxes, and 32 of them is 992 muxes, also 5 deep. Same delay, about six times the area.

In rca#(4), how many times does the for loop execute when the circuit runs?

Zero. The loop runs in the compiler and produces four chained full adders. At run time there is only combinational logic settling.

Worked: adding 0111 + 0001 in 4 bits gives 1000. Is that correct?

As unsigned, yes: 7 + 1 = 8. As two's complement, no: 7 + 1 produced −8. Signed overflow happens when two operands with the same sign give a result with the other sign.

4CMOS (L5)

A CMOS gate is two switch networks. The pull-up connects the output to power, the pull-down connects it to ground. They are built as duals so exactly one conducts for every input.

TransistorConducts when gate input isPasses wellLives in
nFET10 (ground)Pull-down network
pFET01 (power)Pull-up network

Why a single CMOS gate always inverts

Raising an input turns nFETs on and pFETs off. That can only strengthen the path to ground and weaken the path to power, so the output can fall or stay but never rise. A single gate therefore implements only functions where raising an input never raises the output: NOT, NAND, NOR, and compound forms such as (A·B + C)′. AND is a NAND followed by an inverter.

How to build the CMOS gate for F = (expression)′
  1. Make sure F is written as the NOT of an expression using only AND and OR of un-inverted inputs. If it is not, the function needs more than one gate.
  2. Pull-down network, nFETs: AND becomes series, OR becomes parallel. It conducts exactly when the expression is 1, pulling F to 0.
  3. Pull-up network, pFETs: the dual. Series becomes parallel and parallel becomes series.
  4. Count: one nFET and one pFET per input appearance.
GatePull-down (nFETs)Pull-up (pFETs)Transistors
NOT AAA2
NAND(A, B)A in series with BA in parallel with B4
NOR(A, B)A in parallel with BA in series with B4
(A·B + C)′(A series B) parallel C(A parallel B) series C6

Recall

Worked: draw the networks for F = ((A + B)·C)′.

Pull-down: (A parallel B) in series with C. Pull-up is the dual: (A series B) in parallel with C. Six transistors. Check one row: A = 1, B = 0, C = 1 makes the pull-down conduct, so F = 0, and (1 + 0)·1 = 1 inverted is 0.

Can F = A·B + C be built as one CMOS gate?

No. With A = B = 0, raising C from 0 to 1 raises F from 0 to 1. A single gate cannot make its output rise when an input rises. Build (A·B + C)′ and follow it with an inverter: 8 transistors.

What goes wrong if the pull-up and pull-down are not complementary?

If both conduct for some input, power is shorted to ground and the output is an invalid middle voltage. If neither conducts, the output floats and keeps whatever charge it had. Both break the static discipline.

Why are nFETs used to pull down and pFETs to pull up, and not the reverse?

An nFET passes a strong 0 but a weak 1, and a pFET passes a strong 1 but a weak 0. Using each for the value it passes well gives outputs that reach all the way to the rails, which is what restores the signal.

5Sequential circuits, timing and FSMs (L6)

A D flip-flop copies its input to its output at the rising clock edge and ignores it the rest of the time. For that to be reliable, the input must be steady in a small window around the edge.

Setup time is how long before the edge D must be stable. Hold time is how long after. If D changes inside the window the flip-flop can go metastable: its output hovers at an invalid voltage for an unbounded time.

The two constraints

Take any path from one register, through combinational logic, to another register on the same clock.

Setup (slow path)

tCLK ≥ tPD,reg + tPD,logic + tSETUP

The new value must arrive before the next edge. Fix by slowing the clock or shortening the logic.
Hold (fast path)

tCD,reg + tCD,logic ≥ tHOLD

The old value must not disappear too soon after the same edge. The clock period does not appear, so slowing the clock cannot fix it. Add delay to the path.
Try it

Check both constraints for one register-to-register path (ns)

SLOW PATH AGAINST THE CLOCK PERIOD
FAST PATH AGAINST THE HOLD TIME
minimum clock period
maximum clock frequency

Finite state machines

An FSM is a set of states, a start state, a rule for the next state given the current state and input, and a rule for the output. In a Moore machine the output depends on the state only. In a Mealy machine it depends on the state and the current input, so it can react a cycle earlier and often needs fewer states. N states need at least ⌈log2 N⌉ state bits. One-hot encoding uses N bits and simpler logic.

flowchart LR
  S0((S0
out 0)) -->|1| S1((S1 saw 1
out 0)) S0 -->|0| S0 S1 -->|1| S1 S1 -->|0| S2((S2 saw 10
out 0)) S2 -->|0| S0 S2 -->|1| S3((S3 saw 101
out 1)) S3 -->|0| S2 S3 -->|1| S1
A Moore machine that outputs 1 whenever the last three inputs were 1, 0, 1. Overlaps count, so S3 goes to S2 on a 0.
How to attack an FSM design problem
  1. Name each state by what the machine needs to remember, such as "saw 10". If two states remember the same thing, merge them.
  2. For every state, write a transition for every input value. A missing arrow is the most common error.
  3. Ask on a mismatch: how much of what I just saw is still a useful prefix? That decides where the arrow goes, and it is usually not back to the start.
  4. Choose Moore or Mealy from where the question puts the output: in the state bubble or on the arrow.
  5. Encode the states, then write the next-state table as a truth table and simplify as in section 2.

Recall

Worked: register tPD = 0.5, tCD = 0.1, tSETUP = 0.4, tHOLD = 0.2. Logic tPD = 4, tCD = 0.3 (ns). Minimum clock period? Is hold met?

Setup: tCLK ≥ 0.5 + 4 + 0.4 = 4.9 ns, about 204 MHz. Hold: 0.1 + 0.3 = 0.4 ≥ 0.2, met with 0.2 ns to spare. These are the default slider values above.

Worked: same registers, but one path is a direct wire from one register's output to the next register's input. Hold time is now 0.3 ns. Does it work?

Logic tCD = 0. Fast path = 0.1 + 0 = 0.1 ns, less than 0.3. Hold is violated. No clock period fixes this. Add a buffer with at least 0.2 ns of contamination delay on that wire.

Why does the hold constraint not contain tCLK?

It is a race within a single clock edge. The same edge that launches the new value from the first register is the edge at which the second register is capturing the old one. How long until the next edge is irrelevant.

Worked: a circuit has three register-to-register paths with logic tPD of 3, 7 and 5 ns. Register tPD = 1, tSETUP = 1. What is the minimum clock period?

One clock serves every path, so the slowest path decides: 1 + 7 + 1 = 9 ns. Speeding up the 3 ns or 5 ns path changes nothing until the 7 ns path is shortened.

Worked: an FSM has 6 states. How many flip-flops with binary encoding? With one-hot?

Binary: ⌈log2 6⌉ = 3 flip-flops, with two of the eight codes unused. One-hot: 6 flip-flops, one per state.

For the 101 detector, why does S3 go to S2 on input 0, and not to S0?

In S3 the last inputs were 1, 0, 1. After another 0 the most recent inputs end in 1, 0, which is the prefix S2 remembers. Going to S0 would miss the overlapping match in 10101.

6Sequential circuits in Minispec (L7)

A module is registers plus rules. Each cycle every rule reads the current register values, computes, and schedules writes. All writes land together at the clock edge.

ConstructHardwareRule to remember
Reg#(T) x(init)Flip-flops with a reset valueReading x gives the value from the start of the cycle
x <= v;Wire into the flip-flop inputTakes effect at the next edge. At most one write per register per cycle
ruleThe next-state logicRuns every cycle. Local variables are wires
inputWire from the parentHas a default when not driven
methodCombinational outputComputed from registers, visible this cycle

Because writes are simultaneous, a <= b; b <= a; swaps the two registers. Both right-hand sides are read before either write happens.

Read it with Idea 4. The state is a, b, prod and the counter i. The next-state function has two cases: start, or do one more step. The output is valid only when the counter says all n bits are done. The counter is an FSM whose states are idle, 1, 2, … n.

How to trace a Minispec module by hand
  1. Make a table with one column per register and one row per clock cycle.
  2. For each cycle, evaluate the rule using only the values in the current row.
  3. Write the scheduled values into the next row. Registers not written keep their value.
  4. Evaluate methods from the current row, since they are combinational.

Recall

Worked: registers x = 3 and y = 5. The rule is x <= y; y <= x + y;. What are x and y after one cycle? After two?

Cycle 1 reads x = 3, y = 5 and writes x = 5, y = 8. Cycle 2 reads x = 5, y = 8 and writes x = 8, y = 13. The write to x does not affect the y computed in the same cycle.

Worked: FoldedMultiplier#(4) gets a valid input in cycle 0. In which cycle is getResult first valid?

Cycle 0 writes i = 1. Cycles 1, 2 and 3 process bits 1, 2 and 3 and write i = 2, 3, 4. In cycle 4 the register i reads 4 = n, so the result is valid in cycle 4. In general, n cycles after the input.

What is the difference between Bit#(8) t = x + 1; and x <= x + 1; inside a rule?

The first names a wire that carries x + 1 right now, in this cycle. The second schedules the register x to hold x + 1 from the next cycle on.

Why does getResult return a Maybe?

The module takes several cycles, and the consumer needs to know whether prod is a finished product or a partial sum. The valid bit carries that information next to the data.

7Pipelining (L8)

Throughput is set by the clock period, and the clock period is set by the slowest stage. Cut the circuit so the stages are balanced, and cut every path the same number of times.

QuantityDefinitionFor a K-stage pipeline
Clock periodTime between rising edgesmax stage delay + register overhead
LatencyTime from an input entering to its result leavingK × clock period
ThroughputResults per unit time1 / clock period
Try it

Choose where to cut a chain of six blocks

stages
clock period
latency
throughput

Click between blocks to place or remove a pipeline register. There is always one register at the output. Try to reach an 8 ns period with the fewest cuts, then cut everywhere and see what the unbalanced blocks cost.

Well-formed pipelines

A K-stage pipeline is well formed when every path from any input to any output passes through exactly K registers. If one path crosses two registers and another crosses one, values from different inputs meet in the same gate and the result is wrong. The drawing method: draw a line across the circuit that every signal crosses in the same direction, and place a register wherever the line crosses a wire.

Each register reads the one before it, and all three are written in the same rule. Because reads see old values, the three assignments describe three stages working on three different inputs in the same cycle. The Invalid case passes bubbles along, so a cycle with no input produces a cycle with no output three cycles later.

How to attack a pipelining problem
  1. Find the combinational tPD: the longest path. That is the unpipelined clock period.
  2. For K stages, the best possible period is about total / K. The real one is the largest stage, so look for the single biggest block: no cut can make the period smaller than that block.
  3. Place cuts so every input-to-output path crosses the same number. Check each path separately when the circuit branches and rejoins.
  4. Period = slowest stage (+ register overhead if given). Latency = K × period. Throughput = 1 / period.
  5. Remember the output register counts as a stage boundary.

Recall

Worked: blocks in a chain have delays 3, 5, 2, 6, 4, 4 ns. Ideal registers. Give period, latency and throughput unpipelined, and for the best 2-stage and 3-stage pipelines.

Unpipelined: 24 ns period, 24 ns latency, 1 result per 24 ns.

Two stages: the options split the total as 3|21, 8|16, 10|14, 16|8, 20|4. Best is 10|14: period 14 ns, latency 28 ns, 1 per 14 ns.

Three stages: 3+5 | 2+6 | 4+4 gives 8|8|8. Period 8 ns, latency 24 ns, 1 per 8 ns. Use the tool above to check.

Worked: same chain, cut after every block (6 stages). What is the period and latency? Why is it worse than you might hope?

Period = the largest block = 6 ns. Latency = 6 × 6 = 36 ns. Throughput 1 per 6 ns. Six stages gave only a 4× speed-up in throughput over 24 ns because the stages are unbalanced: the 2 ns stage wastes 4 ns every cycle.

Worked: the 3-stage design above, but each register adds 1 ns (tPD,reg + tSETUP). New period, latency and throughput?

Period = 8 + 1 = 9 ns. Latency = 27 ns, now worse than the 24 ns combinational circuit. Throughput 1 per 9 ns. Pipelining never improves latency and real registers make it worse.

Two paths from input to output: one through blocks A and B, the other directly to B's second input. You put one register between A and B. Is the pipeline well formed?

No. The A path crosses the register and the direct path does not, so B combines the previous cycle's A result with the current cycle's direct input. Add a register on the direct path as well.

In PipelineMath, an input arrives in cycle 0. In which cycle does out show its result?

The edge ending cycle 0 writes stage1. The edge ending cycle 1 writes stage2. The edge ending cycle 2 writes result. out reads the register, so it is valid during cycle 3.

8Design tradeoffs (L9)

The same function can be built many ways. Each way is a point with coordinates (area, delay, power). Design is choosing the point that fits the constraint you actually have.

Lab 3 multiplierHowAreaClock periodCycles per resultResults in flight
multiply_by_addingn adders chained combinationallyn addersn adder delays11
FoldedMultiplier1 adder, used n times1 wide adder + registersabout 1 adder delayn1
FastFoldedMultiplierShift the product right so the adder is only n+1 bits1 narrow adder + registersshorter stilln1
Pipelined (not in the lab)n adders with registers betweenn adders + n registersabout 1 adder delay1 (after filling)n

The folded module is this loop with the loop variable turned into a register. That conversion is general: any loop that unrolls into a chain can instead be folded into one copy plus a counter, trading time for area.

Power

Dynamic power is roughly α·C·V2·f: how often nodes switch, how much capacitance they drive, the supply voltage squared, and the clock frequency. Lowering voltage helps the most but slows the gates. Running slower, or switching fewer nodes, saves power directly. A folded design has less capacitance but runs for more cycles, so energy per result may not improve.

How to compare two designs
  1. State the metric the question cares about: time per result, results per second, area, or energy.
  2. Compute clock period for each from its critical path.
  3. Time per result = cycles per result × period. Throughput = results in flight ÷ latency for a pipeline, or 1 ÷ (cycles × period) for a folded design.
  4. If area matters, compare throughput ÷ area.

Recall

Worked: a 16-bit combinational multiplier has tPD = 48 ns. A folded version has a 4 ns clock and needs 16 cycles. Which finishes one multiplication sooner? Which gives more results per second?

Combinational: 48 ns per result. Folded: 16 × 4 = 64 ns per result. The combinational design wins on both latency and throughput here. The folded design wins on area, and on clock period if the multiplier shares a clock with other logic that could run at 4 ns.

Worked: pipeline that 48 ns multiplier into 4 balanced stages with 1 ns register overhead. Period, latency, throughput?

Period = 48/4 + 1 = 13 ns. Latency = 4 × 13 = 52 ns. Throughput = 1 per 13 ns, about 3.7 times the combinational design, for the cost of three extra rows of registers.

Worked: supply voltage drops from 1.0 V to 0.8 V at the same frequency. By what factor does dynamic power change?

Power scales with V2: 0.82 = 0.64, so 36% less. In practice the gates also get slower at lower voltage, so the frequency may have to drop too.

Know this cold