Fast Track 1: Digital Design

Lectures 1 to 9 in about 60 minutes, questions included. Each lecture is one card: the idea, why it works, the move for its main exam problem, the usual trap, and three questions that make you apply it to something new.

L1The digital abstraction

Every device accepts a sloppy input and must produce a cleaner output, so noise never builds up.

Why it works

LowForbidden zoneHigh
Output must be≤ VOLnever, once settled≥ VOH
Input is accepted if≤ VILno promise≥ VIH
Noise marginVIL − VOLVOH − VIH

The move: check a device or pick thresholds

  1. Check the order of the four thresholds. Wrong order means not a legal choice.
  2. For every valid input (≤ VIL or ≥ VIH), check the output is valid (≤ VOL or ≥ VOH). This is the static discipline.
  3. Compute both margins. Noise immunity is the smaller one.
TrapSubtracting the wrong pair. Margins pair an output threshold with the input threshold on the same side: OL with IL, OH with IH.

VOL = 0.4, VIL = 1.1, VIH = 2.6, VOH = 3.1. What is the noise immunity?

  1. 0.7 V
  2. 0.5 V
  3. 1.5 V
  4. 1.2 V

Low margin is 1.1 − 0.4 = 0.7. High margin is 3.1 − 2.6 = 0.5. Immunity is the smaller, 0.5. The 1.5 answer is the width of the forbidden zone.

Same thresholds. A buffer gets 1.0 V in and gives 0.6 V out. Does it obey the static discipline?

  1. Yes, 0.6 is below VIL
  2. Yes, the output is lower than the input
  3. No, a valid low input needs an output at or below 0.4

1.0 V is a valid low input, so the output must meet the output rule, VOL = 0.4. Meeting the input rule is not enough.

Someone proposes VOL = VIL and VOH = VIH to make devices easier to build. What is lost?

  1. All noise margin: any noise on a wire can make a valid output an invalid input
  2. Nothing, the forbidden zone is still there
  3. The ability to tell 0 from 1

Margins are the gaps between output and input thresholds. With equal thresholds both gaps are zero.

More depth: the digital abstraction

L2Combinational devices and Boolean algebra

A circuit with no memory is fully described by a truth table and two delays, and any truth table can be built from AND, OR and NOT.

Why it works

Circuit delayWhich pathWhat you add up
tPD (propagation)Longest input-to-output pathThe tPD of each gate on it
tCD (contamination)Shortest input-to-output pathThe tCD of each gate on it

The move: table to expression

  1. Mark the rows with output 1.
  2. Write one AND term per row: the variable if it is 1, its complement if it is 0.
  3. OR the terms. That is the normal form.
  4. Merge pairs that differ in one variable. A term may be reused in several merges.
TrapUsing the longest path for tCD. Contamination asks how soon the output could start changing, so it follows the fastest path.

F(A,B,C) is 1 only for ABC = 010, 110, 111. Which is a minimal expression?

  1. A̅BC̅ + ABC̅ + ABC
  2. B
  3. AB + C̅
  4. BC̅ + AB

010 and 110 merge to BC̅. 110 and 111 merge to AB. Option A is correct but not minimal. B alone would wrongly include 011.

Output gate Z (tPD 4, tCD 2) is fed by gate X (3, 1) and gate Y (2, 0.5). What are the circuit's tPD and tCD?

  1. 7 and 2.5
  2. 7 and 3
  3. 9 and 0.5
  4. 6 and 2.5

Longest path X then Z: 3 + 4 = 7. Shortest path Y then Z: 0.5 + 2 = 2.5. Each bound uses its own path.

The outputs of two inverters are wired to the same node. Is the result a valid combinational circuit?

  1. Yes, both are combinational devices
  2. No, a node may be driven by only one output
  3. Yes, as long as there is no loop

If the two outputs disagree, the node sits at an undefined voltage. The composition rules require exactly one driver per node.

More depth: Boolean algebra and gates

L3Combinational logic in Minispec

A Minispec function is a drawing of a circuit: every line is hardware that exists all the time, not a step that runs.

Why it works

You writeThe circuit contains
a + b, a & b, a == bOne adder, AND array, or comparator
if (s) y = e1; else y = e2;The logic for e1, the logic for e2, and a mux selected by s
case (s) …Every arm's logic, and a wider mux
for (Integer i = 0; i < 4; …)Four copies of the body, chained
x[5:2], {a, b}Just wires. No gates, no delay

The move: read code as a circuit

  1. Draw one block per operator, in the order values flow.
  2. Turn each if or case into a mux with all branches present.
  3. Unroll loops into repeated blocks.
  4. For delay, follow the longest chain. For area, count every block.
TrapThinking the branch not taken costs nothing. In hardware it costs its full area, and its delay can still be on the critical path.

if (s) y = a + b; else y = a - b; What is built?

  1. One adder that is switched to subtract
  2. An adder or a subtractor, whichever s chooses
  3. An adder, a subtractor and a mux

As written, both expressions become hardware and s selects between the results. Sharing one adder is a design choice you would have to write yourself.

Bit#(4) x = 4'b1010; What is x[2:1]?

  1. 2'b01
  2. 2'b10
  3. 2'b11
  4. 2'b00

Bit 0 is the rightmost. x[3..0] = 1, 0, 1, 0, so x[2] = 0 and x[1] = 1, giving 01.

A loop runs sum = sum + v[i] for i from 0 to 5. How does the delay compare with a single addition?

  1. The same, the adder is reused
  2. About six adders in series
  3. Six adders in parallel, so one adder delay

Each copy needs the previous copy's sum, so the six adders form a chain. Reuse over time would need a register and a clock.

More depth: combinational Minispec

L4Parametric circuits and adders

An Integer is a number the compiler uses while building the circuit, a Bit#(n) is a bundle of wires in the circuit, and faster adders buy speed with extra hardware.

Why it works

AdderDelayAreaHow
Ripple-carryGrows with nSmallestCarry passes through every bit
Carry-selectAbout half, plus a muxAbout 1.5×Upper half precomputed for both carries
Carry-lookaheadGrows with log nLargestCarries computed by a tree

The move: estimate adder delay

  1. Find the carry chain. It is the critical path.
  2. Ripple: bits × carry delay per bit.
  3. Carry-select: delay of the lower block, plus one mux. Both halves run at the same time.
  4. State the price: count the duplicated hardware.
TrapUsing a wire value where a compile-time number is needed. A loop bound or a bit width cannot depend on a Bit#(n) input.

A 32-bit ripple-carry adder has 2 ns carry delay per bit. Rebuilt as carry-select with two 16-bit halves and a 1 ns mux, the delay is about:

  1. 33 ns
  2. 64 ns
  3. 65 ns
  4. 17 ns

Lower half: 16 × 2 = 32 ns. The upper halves finish in the same 32 ns. Add the mux: 33 ns. The ripple version was 64 ns.

Which inputs make an 8-bit ripple-carry adder take its worst-case time?

  1. 00000000 + 00000000
  2. 10000000 + 10000000
  3. 11111111 + 00000001

The carry created at bit 0 must travel through all eight bits. In option B the only carry is created at the top bit and goes nowhere.

for (Integer i = 0; i < n; i = i + 1) with n = 8. What hardware does the loop counter become?

  1. A 3-bit counter register
  2. None. The compiler unrolls the loop into 8 copies of the body
  3. An 8-way mux

Integer values exist only while the circuit is being generated. Nothing of i remains in the circuit.

More depth: parametric circuits and adders

L5CMOS

A CMOS gate is two opposite switch networks: nFETs pull the output down to 0, pFETs pull it up to 1, and exactly one network conducts for every input.

Why it works

NAND: A BPull-down (nFETs in series)Pull-up (pFETs in parallel)Output
0 0offon1
0 1offon1
1 0offon1
1 1onoff0

The move: build a gate for F

  1. Write F as NOT(G). If you cannot, F needs more than one gate.
  2. Build G with nFETs between output and ground: AND in series, OR in parallel.
  3. Build the pull-up with pFETs between VDD and output using the dual shape.
  4. Sanity check: all inputs 1 must give 0, all inputs 0 must give 1.
TrapTrying to build AND or OR as one gate. They are not inverting, so each needs a NAND or NOR followed by an inverter.

A pull-down has nFET A in series with (nFETs B and C in parallel). What does the gate compute?

  1. A·(B + C)
  2. NOT(A·(B + C))
  3. NOT(A + B·C)

The pull-down conducts when A and (B or C) are 1, and conducting means output 0. So the output is the complement.

For that same gate, what is the pull-up network?

  1. pFET A in series with (B parallel C)
  2. pFETs A, B and C all in parallel
  3. pFET A in parallel with (B in series with C)

Take the dual: the outer series becomes parallel and the inner parallel becomes series.

F(A,B) is 1 when A = 1 and B = 0, else 0. Can one CMOS gate with inputs A and B compute it?

  1. No. Raising A from 0 to 1 raises the output, which one gate cannot do
  2. Yes, with two nFETs in series
  3. Yes, any two-input function fits in one gate

With B = 0, the output goes 0 to 1 as A rises. A single gate's output can only fall when an input rises.

More depth: CMOS

L6Sequential circuits and timing

Registers sample only at the rising clock edge, and two inequalities guarantee that what they sample is stable: one for the slowest path and one for the fastest.

Why it works

ConstraintInequalityUsesFix if violated
SetuptCLK ≥ tPD,FF1 + tPD,CL + tSETUP,FF2Slowest pathSlow the clock or shorten the logic
HoldtCD,FF1 + tCD,CL ≥ tHOLD,FF2Fastest pathAdd delay to the short path. The clock cannot help

The move: timing problem

  1. List every register-to-register path, including a register back to itself.
  2. Hold first: for each path check tCD,FF1 + tCD,CL ≥ tHOLD,FF2. One failure means the circuit is broken at any clock speed.
  3. Setup: compute tPD,FF1 + tPD,CL + tSETUP,FF2 per path. The largest is the minimum tCLK.
TrapTrying to fix a hold violation by slowing the clock. tCLK does not appear in the hold inequality.

tPD,FF = 2, tPD,CL = 6, tSETUP = 1, tCD,FF = 0.5, tCD,CL = 1 (ns). What is the minimum clock period?

  1. 9 ns
  2. 8 ns
  3. 10.5 ns
  4. 2.5 ns

2 + 6 + 1 = 9. Contamination delays belong to the hold check only.

tCD,FF = 0.3, tCD,CL = 0.2, tHOLD = 0.8 ns. What is true?

  1. Fine, if the clock is slow enough
  2. Fine, 0.3 + 0.2 is under 0.8
  3. Hold is violated. Add at least 0.3 ns of delay on the path

The sum 0.5 must be at least 0.8. It is 0.3 short. Only extra contamination delay fixes it.

A controller needs 5 distinct states. What is the fewest flip-flops that can hold its state?

  1. 2
  2. 3
  3. 5

2 flip-flops give 4 states, which is too few. 3 give 8. Five would be needed only for a one-per-state encoding.

More depth: sequential circuits and timing

L7Sequential circuits in Minispec

Inside a rule every register read sees the value from the start of the cycle, and every <= lands together at the clock edge.

Why it works

Rule: x <= x + 1; y <= x;xy
Start50
After edge 165 (old x, not 6)
After edge 276

The move: trace a module

  1. Write the current value of every register in a row.
  2. Evaluate the rule using only that row. Follow wire variables in order.
  3. Write all new register values in the next row at once.
  4. Repeat. Conditions such as if (x == 3) also test the old value.
TrapReading <= as ordinary assignment and using the new value on the next line.

A rule contains a <= b; b <= a; with a = 3 and b = 7. After one clock edge:

  1. a = 7, b = 7
  2. a = 7, b = 3
  3. a = 3, b = 7

Both right-hand sides read old values, so the registers swap. Getting 7, 7 means you treated the first line as already done.

Rule: x <= x + 1; if (x == 3) done <= True; with x = 0 at the start. After which clock edge is done first True?

  1. The 3rd
  2. The 5th
  3. The 4th

During cycles 1 to 4 the rule sees x = 0, 1, 2, 3. The test passes in cycle 4, and the write lands at the 4th edge.

Rule: Bit#(4) t = x + 1; x <= t; y <= t; with x = 4. After one edge:

  1. x = 5 and y = 5
  2. x = 5 and y = 4
  3. x = 5 and y = 6

t is a wire carrying old x plus 1. Both registers load that same wire.

More depth: modules, rules and methods

L8Pipelining

Registers between blocks let each block start on the next input while later blocks finish the current one: throughput rises, latency does not improve.

Why it works

Blocks 4, 6, 2, 5 ns in a chaintCLKLatencyThroughput
No registers inside17171/17
2 stages: 4 6 | 2 510201/10
4 stages: 4 | 6 | 2 | 56241/6

The move: place pipeline registers

  1. Draw a contour across the circuit so that every wire crosses it in the same direction. Put a register on every wire it crosses.
  2. Repeat for each stage. Always put a contour at the output.
  3. tCLK = slowest stage. Latency = K × tCLK. Throughput = 1 / tCLK.
  4. For best throughput, isolate the slowest block. No cut can beat its delay.
TrapSaying pipelining reduces latency. Stages are padded to the slowest one, so latency stays the same or grows.

Chain of 3, 7, 4, 4 ns blocks. With the best 2-stage pipeline, what are tCLK and latency?

  1. 9 and 18
  2. 10 and 20
  3. 7 and 14
  4. 11 and 22

Cuts give 3 | 15, 10 | 8 or 14 | 4. The best is 10 | 8, so tCLK = 10 and latency = 2 × 10 = 20.

Same chain. What is the fewest stages that reaches the best possible throughput?

  1. 2
  2. 4
  3. 3

The limit is the 7 ns block, so no stage may exceed 7. 3 + 7 is too long and so is 4 + 4 = 8, which forces 3 | 7 | 4 | 4. Three stages would leave a stage of 8 or more.

A two-input block receives input A through one register and input B through two registers. What is wrong?

  1. It combines A from one input with B from an earlier input
  2. Nothing, if the clock is slow enough
  3. The block needs a third register

Paths with different register counts are not a well-formed pipeline. The two values belong to different cycles' inputs.

More depth: pipelining

L9Design tradeoffs

The same function can be built combinational, pipelined or folded, and each wins on a different measure, so always ask which measure the question cares about.

Why it works

DesignLatencyThroughputArea
CombinationalBestMiddleMiddle
PipelinedSlightly worseBestLargest
FoldedUsually worstWorstSmallest

The move: compare designs

  1. For each design write tCLK and the number of cycles per result.
  2. Latency = cycles × tCLK.
  3. Throughput = 1 / tCLK if a new input enters every cycle, otherwise 1 / latency.
  4. Answer for the stated goal only.
TrapPicking the design with the shortest clock period. A 3 ns clock that needs 16 cycles is slower than a 40 ns single cycle.

A multiplier is built three ways: combinational, 40 ns. Folded, 16 cycles at 3 ns. Pipelined, 4 stages at 11 ns. Which has the lowest latency?

  1. Combinational, 40 ns
  2. Folded, 3 ns
  3. Pipelined, 11 ns

Folded takes 16 × 3 = 48 ns and pipelined 4 × 11 = 44 ns. The clock period alone is not latency.

Same three designs. Which has the highest throughput?

  1. Combinational, 1 per 40 ns
  2. Folded, 1 per 3 ns
  3. Pipelined, 1 per 11 ns

The pipeline accepts a new input every cycle. The folded design is busy for all 16 cycles, so it gives 1 per 48 ns.

A folded divider takes between 4 and 32 cycles depending on its inputs. How should the module that uses it know when to read the result?

  1. Always wait 32 cycles
  2. The divider marks its output valid only when done
  3. Read every cycle and keep the last value

A valid bit, a Maybe in Minispec, travels with the data. Waiting the worst case works but wastes time, and reading early gives garbage.

More depth: design tradeoffs

Have these memorised