Sequential Circuits, Timing, Data Converters, Memories and Computer Organisation
Propagation Delay, Setup and Hold, and the Critical Path
Four delays describe a clocked stage, and mixing them up is the single most expensive habit in this section. Propagation delay t_pcq is the longest time from the clock edge until the flip-flop's output has settled. Contamination delay t_ccq is the shortest time from that edge until the output begins to change. Setup time t_su is how long the data must already be stable before the edge, and hold time t_h is how long it must remain stable after it. The combinational logic between two flip-flops has its own longest and shortest paths, t_pd and t_cd. The critical path is the longest register-to-register route through the whole design, and the clock period must exceed it; the shortest such route matters too, but for a completely different reason.
Work one stage all the way through. Take t_pcq = 0.9 ns, t_ccq = 0.5 ns, t_su = 0.4 ns, t_h = 0.25 ns, a combinational block whose longest path is t_pd = 3.2 ns and whose shortest is t_cd = 0.15 ns, and clock skew of 0.2 ns between the two flip-flops. The setup constraint says data launched at one edge must arrive and settle before the next: T_c ≥ t_pcq + t_pd + t_su + t_skew = 0.9 + 3.2 + 0.4 + 0.2 = 4.7 ns, so f_max = 1/4.7 ns ≈ 212.8 MHz. The hold constraint is a different inequality with no T_c in it at all: t_ccq + t_cd ≥ t_h + t_skew, that is 0.5 + 0.15 = 0.65 ns against 0.25 + 0.2 = 0.45 ns, satisfied with 0.2 ns of margin. Now push the skew to 0.45 ns and the hold requirement becomes 0.70 ns, which 0.65 ns fails — and no clock frequency fixes it, because the clock period does not appear in the inequality.
| Constraint | Inequality | Value in the worked stage | Cure when it fails |
|---|---|---|---|
| Setup, the long path | T_c ≥ t_pcq + t_pd + t_su + t_skew | 4.7 ns, so 212.8 MHz | Slow the clock, or pipeline the logic |
| Hold, the short path | t_ccq + t_cd ≥ t_h + t_skew | 0.65 ns against 0.45 ns, so 0.2 ns of margin | Add delay buffers, or reduce skew — never the clock |
Counters and Shift Registers, Counted in Nanoseconds
A mod-N counter needs ⌈log₂ N⌉ flip-flops, so a mod-12 counter takes four and a mod-100 counter takes seven, with the unused states either unreachable by design or steered back by decoding logic. The examinable divide is not the count but the clocking. In a ripple (asynchronous) counter each flip-flop's output clocks the next, so the delays add: four flip-flops of 7 ns propagation delay leave the outputs unsettled for up to 4 × 7 = 28 ns after an edge, which caps the usable clock at about 1/28 ns ≈ 35.7 MHz and, worse, means the output bus passes through counts the sequence never really visits. Decode those transient patterns and you get glitches — the reason a ripple counter's outputs should never drive a decoder directly.
A synchronous counter clocks every flip-flop from the same edge, so the outputs change together and the delays do not accumulate. What limits it instead is one stage of the loop: T_c = t_pcq + t_comb + t_su. With the same 7 ns flip-flops, 4 ns of enable-chain logic between stages and a 2 ns setup requirement, T_c = 13 ns and f_max ≈ 76.9 MHz — more than twice the ripple counter's ceiling. Look at what has vanished from that expression: the number of bits. Adding a fifth stage to a synchronous counter does not slow it down unless it lengthens the enable chain, whereas adding one to a ripple counter always does. That asymmetry, and not gate count, is why synchronous counters dominate despite costing more logic.
A shift register is n flip-flops in a chain, each feeding the next, so a serial bit stream is delayed by exactly n clocks — the standard serial-to-parallel and parallel-to-serial converter, and the delay line inside every digital filter. Feed the output back and the sequence closes: a ring counter of n stages has n states with one hot bit circulating, while a Johnson or twisted-ring counter feeds back the complement and gets 2n states from the same n flip-flops. Feed back an XOR of two tapped stages and you have a linear feedback shift register, which is what generates pseudo-random bit sequences in communication test equipment. A 4-bit LFSR with taps on the third and fourth stages cycles through 15 states — every pattern except all zeros, which is a fixed point the register can never leave. In general an n-bit maximal LFSR has 2^n − 1 states, and the missing one is always the all-zero word.
| Structure | Feedback | States in the cycle |
|---|---|---|
| Binary counter | Toggle logic on the enable chain | 16, the full count |
| Ring counter | Last output to first input | 4, one hot bit circulating |
| Johnson counter | Complement of the last output | 8, twice the flip-flop count |
| Maximal LFSR | XOR of the third and fourth stages | 15, all but the all-zero word |
Finite State Machines: Mealy, Moore and One Clock of Difference
A synchronous FSM is a state register plus two blocks of combinational logic: next-state logic reading the present state and the inputs, and output logic. In a Moore machine the output is a function of the state alone; in a Mealy machine it is a function of the state and the current input. That single difference has three consequences worth carrying into the exam. A Mealy machine usually needs fewer states, because the input can do some of the discriminating. Its output appears one clock earlier, because it does not wait for the transition to be registered. And its output can glitch, since it follows an input directly through combinational logic, whereas a Moore output changes only just after a clock edge and is therefore clean enough to drive other logic without qualification.
Design the standard detector both ways to see it. The task is to raise an output whenever the serial input has just completed the pattern 101, with overlaps allowed. As a Moore machine four states are needed: S0 has no useful prefix, S1 has seen a 1, S2 has seen 10, and S3 has seen 101 and is the only state whose output is 1. The transitions worth checking are the ones out of S3: on a 0 it goes to S2, because the sequence now ends in 10, and on a 1 it goes to S1, because the sequence now ends in a single useful 1. Get those two wrong and the machine stops detecting overlaps. As a Mealy machine three states suffice — A, B after a 1, C after 10 — and the output is asserted on the transition from C on input 1, which returns to B rather than to A for exactly the same overlap reason.
| Present state | Meaning | Next state on input 0 | Next state on input 1 | Output |
|---|---|---|---|---|
S0 | No useful prefix yet | S0 | S1 | 0 |
S1 | Seen 1 | S2 | S1 | 0 |
S2 | Seen 10 | S0 | S3 | 0 |
S3 | Seen 101, pattern complete | S2, since the tail is now 10 | S1, since the tail is now 1 | 1 |
Trace the input 1101011 through the Moore table, starting in S0, and the states visited are S1, S1, S2, S3, S2, S3, S1. The output is high in the two visits to S3, so the machine reports two detections — which is right, because 1101011 contains 101 starting at its second bit and again starting at its fourth, the two occurrences sharing a 1. A machine that reported one detection was built without the overlap transitions; a machine that reported three has invented one. Notice that both designs need ⌈log₂ 4⌉ = 2 flip-flops for Moore and ⌈log₂ 3⌉ = 2 for Mealy, so on this example the Mealy saving in states buys no hardware at all — a useful corrective to the idea that fewer states always means a smaller circuit.
S3 (101) on a 0 the input ends in 1010, whose longest useful suffix is 10, so the next state is S2, and the overlap handling comes out automatically instead of being remembered. The same recipe scales to any pattern and to any alphabet, and it is much faster under exam pressure than drawing arrows and hoping. It also tells you the state count before you start: a pattern of length k needs k + 1 Moore states when no prefix repeats.Sample and Hold, ADCs and DACs
An ADC needs its input to stand still while it decides, so almost every converter is preceded by a sample and hold: a switch that connects the input to a hold capacitor C_H through a buffer, and a high-impedance amplifier that reads the capacitor once the switch opens. Four numbers characterise it. Acquisition time is how long the switch must stay closed for the capacitor to settle to within the required error — set by the source resistance and C_H. Aperture time and its jitter are the uncertainty in when the switch actually opened, which converts input slew into amplitude error. Droop is the slow decay of the held voltage caused by leakage into the switch and the amplifier's input. And pedestal error is the step injected by charge from the switch as it opens.
Droop is where a clean numerical question lives, because it ties the analog part to the resolution. Take a 12-bit converter with a 5 V reference. One least significant bit is 5/4096 = 1.2207 mV, and a sensible error budget for the hold stage is half of that, 0.6104 mV. Now let the hold capacitor be C_H = 100 pF with a total leakage of 10 nA. The droop rate is dV/dt = I/C = 10 × 10^(−9) / 100 × 10^(−12) = 100 V/s, which is 0.1 mV/µs. Divide the budget by the rate: the voltage may be held for 0.6104 / 0.1 = 6.1 µs before the droop alone costs half a bit. That single division decides whether a given converter can be driven by a given sample-and-hold, and it explains the design pull in both directions — a larger C_H droops more slowly but takes longer to acquire, and the two requirements meet somewhere in the middle.
The same 12-bit, 5 V converter fixes the other standard figures. Quantisation error is bounded by ± half an LSB = ±0.61 mV, and the signal-to-quantisation-noise ratio of an ideal converter on a full-scale sine is 6.02n + 1.76 = 6.02 × 12 + 1.76 = 74.0 dB — the reason resolution is quoted in bits and dynamic range in decibels, one bit being worth about 6 dB. On the ADC side the architectures trade speed against hardware in a way worth knowing as a table rather than as prose. On the DAC side, a weighted-resistor DAC needs resistances spanning R to 2^(n−1)R, which is unbuildable at 12 bits, while an R-2R ladder needs only two resistor values and is therefore what real parts use. For an 8-bit R-2R DAC with V_ref = 8 V, the output is V_ref × D/256; the code 10100000 is D = 160, so the output is 8 × 160/256 = 5.000 V, and one LSB is 8/256 = 31.25 mV.
| Architecture | How it decides | Conversion time | Hardware at 12 bits |
|---|---|---|---|
| Flash | All thresholds compared at once | One clock — the fastest there is | 2^12 − 1 = 4095 comparators, which is why flash stops at 6 to 8 bits |
| Successive approximation | Binary search, one bit per clock | n clocks, so 12 µs at a 1 MHz clock | One comparator and one DAC |
| Dual slope, integrating | Charges then discharges an integrator | Up to 2 × 2^n counts — slow by design | An integrator and a counter; rejects mains hum |
| Sigma-delta | Oversamples one bit, then filters digitally | Many oversampled clocks per output sample | A one-bit loop plus a decimation filter; best resolution |
ROM, SRAM and DRAM: What a Bit Costs
All three memories are the same architecture — an address decoder driving one row of an array, and a column circuit reading or writing the selected cells — and they differ almost entirely in the cell. A ROM cell is the presence or absence of a transistor at a crossing, so a ROM is literally a printed truth table: address lines are the inputs, the addressed word is the outputs. That makes a ROM a general combinational logic block, and the sizing question follows directly: to implement three arbitrary functions of four variables you need 2^4 words of 3 bits, which is 16 × 3 = 48 bits, and no minimisation is required or possible. An SRAM cell is two cross-coupled inverters plus two access transistors, six transistors, which holds its value as long as power is present and can be read without disturbing it. A DRAM cell is one transistor and one capacitor, which is why DRAM is several times denser and cheaper per bit than SRAM, and it pays for that density twice over.
The first payment is that a DRAM read is destructive. Sharing the tiny cell capacitor's charge onto the much larger bit-line capacitance leaves only a few tens of millivolts of signal, which a sense amplifier must resolve and then write back — so every read is a read-modify-write, and the row must be precharged before the next access. The second payment is refresh. Leakage discharges the cell, so every row must be rewritten within a retention time, typically 64 ms. A part with 4096 rows must therefore refresh one row every 64 ms / 4096 = 15.625 µs, and if a refresh cycle occupies 100 ns the overhead is 100 ns / 15.625 µs = 0.64 % of the available bandwidth — small, but never zero, and it is why DRAM has a controller and SRAM does not.
| Memory | Cell | Read behaviour | Where it is used |
|---|---|---|---|
| Mask ROM and its programmable cousins | A transistor present or absent at a crossing | Non-destructive, non-volatile | Boot code, lookup tables, hard-wired logic |
| SRAM | Six transistors, two cross-coupled inverters | Non-destructive, no refresh, fastest | Registers, caches, on-chip buffers |
| DRAM | One transistor, one capacitor | Destructive, needs sense amplifier and refresh | Main memory, wherever density decides |
The other examinable habit is address arithmetic, which is pure counting. A 1K × 8 chip has 2^10 words, so it needs 10 address lines and 8 data lines. Build a 4K × 8 memory from four of them and the address bus is 12 bits wide: A9 down to A0 go to every chip in parallel, and A11 and A10 drive a 2-to-4 decoder whose four outputs are the chip selects, so exactly one device answers any address. The general rule is worth stating once: the low-order address bits select within a chip and the high-order bits select between chips, and a question that asks which lines go where is answered by counting log₂ of the chip depth. Word-width expansion is the other direction — two 1K × 4 chips side by side make 1K × 8, with the same address on both and the data buses concatenated rather than decoded.
Computer Organisation, in the Four Items EC Asks For
Machine instructions and addressing modes come first, and the fastest way in is field arithmetic. A 32-bit instruction with a 6-bit opcode and three 5-bit register fields has 32 − 6 − 15 = 11 bits left for an immediate, which as a two's complement value spans −1024 to +1023; change the opcode to 7 bits and the immediate range halves. An addressing mode is just a rule for turning instruction fields into an effective address. With R1 = 0x2000 as a base, R2 = 0x40 as an index and a displacement of 0x8, base-plus-index-plus-displacement gives EA = 0x2000 + 0x40 + 0x8 = 0x2048. Counting memory accesses is the other standard question, and the ordering is what matters: immediate and register modes touch memory not at all beyond the fetch, direct and register-indirect take one access, and memory-indirect takes two because the address itself must be fetched first.
| Mode | Effective address or operand | What it is for |
|---|---|---|
| Immediate | The operand is in the instruction itself | Constants, with no memory access at all |
| Register | The operand is the content of R1 | The fastest form, used by every ALU operation |
| Register indirect | EA = 0x2000, the content of R1 | Pointer walking through a structure |
| Base with displacement | EA = 0x2000 + 0x8 = 0x2008 | A field at a fixed offset inside a record |
| Base plus index plus displacement | EA = 0x2000 + 0x40 + 0x8 = 0x2048 | Array element inside a based structure |
| Memory indirect | Fetch the word at 0x2008, then use it as the address | Jump tables — and two memory accesses, not one |
| PC relative | EA = PC + displacement | Branches, and position-independent code |
The ALU is the arithmetic core of the last chapter wrapped in a function select: one adder-subtractor built as described earlier, a logic unit, a shifter, and a multiplexer choosing which result reaches the output, with the status flags — zero, carry, sign and overflow — generated as a side effect. The data path is the registers, the ALU, the buses and the memory interface; the control unit is what asserts the enable, select and write lines in the right sequence. Control comes in two flavours, and the trade is the same one that runs through this whole section. Hardwired control is a finite state machine of exactly the kind designed earlier in this chapter: fast, and fixed at fabrication. Microprogrammed control keeps a small memory whose words are the control signals themselves, so the instruction set can be changed by rewriting a table: flexible, and slower by the access time of that memory.
Instruction pipelining is the last item, and it is arithmetic on the same critical-path idea that governed the flip-flop stage. Split execution into stages with latches between them; the clock period is then the slowest stage plus the latch overhead, never the average. Take a four-stage pipeline whose stages need 1.8, 2.4, 2.0 and 1.6 ns with 0.2 ns of latch delay. The unpipelined machine takes 1.8 + 2.4 + 2.0 + 1.6 = 7.8 ns per instruction; the pipelined one clocks at 2.4 + 0.2 = 2.6 ns, so the ideal speedup is 7.8/2.6 = 3.0 — against four stages, because the imbalance wastes the difference. For a finite run of 100 instructions the pipeline needs (k + n − 1) cycles, that is (4 + 99) × 2.6 = 267.8 ns against 100 × 7.8 = 780 ns, a speedup of 2.91. Both numbers are below k, for two separate reasons, and a question usually applies exactly one of them.
2.4 ns stage into two of 1.2 ns would drop the clock period to 1.6 + 0.2 = 1.8 ns and raise the speedup, while adding a fifth stage somewhere else would change nothing at all, because the slowest stage still sets the period. That is the practical reading of pipelining and it is worth stating as a rule: depth helps only after balance. The same arithmetic sets the limit on how deep it is worth going, since the latch overhead is paid once per cycle and becomes a larger fraction of a shorter cycle — at 0.2 ns of overhead, a design clocked at 1.0 ns is spending a fifth of every cycle on the latches alone. And this is the point at which an EC candidate should stop: hazards, forwarding and branch prediction are the Computer Science paper's material, not the four items named here.Key takeaways
- A latch is level sensitive and a flip-flop edge triggered; know the characteristic equations
Q+ = D,Q+ = T ⊕ QandQ+ = JQ′ + K′Qrather than the tables. - Setup fixes the clock:
T_c ≥ t_pcq + t_pd + t_su + t_skewgave 4.7 ns and 212.8 MHz. Hold has noT_cin it, so a hold violation survives any frequency. - Ripple-counter delay accumulates as
n × t_pd— 28 ns for four 7 ns stages — while a synchronous counter's period is one stage,t_pcq + t_comb + t_su, with no bit count in it. - Name FSM states by the longest pattern prefix that is still a suffix of the input, and overlap detection falls out — the 101 detector needs four Moore states or three Mealy ones.
- For a 12-bit, 5 V converter one LSB is 1.2207 mV and the ideal SQNR is 74.0 dB; a 100 pF hold capacitor leaking 10 nA droops 0.1 mV/µs and may hold for only 6.1 µs.
- SRAM costs six transistors a bit and reads non-destructively; DRAM costs one transistor and a capacitor, reads destructively, and must refresh 4096 rows every 64 ms, one row per 15.625 µs.
- A pipeline's clock is the slowest stage plus latch overhead: stages of 1.8, 2.4, 2.0 and 1.6 ns clock at 2.6 ns, giving an ideal speedup of 3.0 and 2.91 over 100 instructions.
Practice questions (8)
Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.
A shift register built from six flip-flops is wired as a twisted-ring (Johnson) counter, the complement of the last stage output being returned to the first stage input. How many distinct states does its repeating cycle contain?
Show answer
Answer: A — 12
A Johnson counter returns the complement of the last stage to the first, so the register fills with ones and then empties again, visiting 2n distinct patterns for n stages: 2 x 6 = 12. The tempting 6 is the count for a plain ring counter, which feeds back the true output and therefore just circulates one hot bit through n positions. The value 64 is the full binary count 2^6 that a synchronous binary counter of six flip-flops would reach, and 63 is the cycle length of a six-bit maximal linear feedback shift register, which omits only the all-zero word.Five identical flip-flops, each with a propagation delay of 6 ns, are connected first as an asynchronous ripple counter and then re-connected as a synchronous counter in which 3 ns of enable-chain logic sits between stages and every flip-flop requires 2 ns of setup time. By what factor does the highest usable clock frequency improve on re-connection?
Show answer
Answer: C — 2.73
In a ripple counter each flip-flop clocks the next, so the delays accumulate and the outputs are unsettled for 5 x 6 = 30 ns, capping the clock at 1/30 ns. A synchronous counter clocks every stage together, so its period is one stage of the loop, t_pcq + t_comb + t_su = 6 + 3 + 2 = 11 ns. The frequency ratio is therefore 30/11 = 2.73, and note that the bit count has vanished from the synchronous expression. The value 3.33 comes from writing the synchronous period as 6 + 3 = 9 ns and dropping the setup time, which is the commonest slip here; 5.00 comes from comparing 30 ns against a single flip-flop delay and ignoring the enable logic and setup time entirely.A flash analogue-to-digital converter resolves 7 bits by comparing its input against every threshold at once. How many comparators does its resistor-ladder network require?
Show answer
Answer: B — 127
A flash converter of n bits divides the reference into 2^n equal steps, and the boundaries between those steps are the thresholds it must test, so it needs 2^n - 1 comparators: 2^7 - 1 = 127. The tempting 128 is 2^n itself, obtained by counting the output codes rather than the boundaries between them; there is no comparator needed above the top code or below the bottom one. The value 7 counts the bits, which is what a successive-approximation converter needs in clock cycles rather than in comparators, and 126 arises from subtracting two.Five arbitrary Boolean functions of the same six variables are to be implemented by a single ROM used as a lookup table, the six variables driving the address lines directly. What is the smallest ROM capacity, in bits, that will do it?
Show answer
Answer: D — 320
Six address variables select one of 2^6 = 64 words, and each word must hold one output bit for each of the five functions, so the ROM is 64 words by 5 bits, that is 320 bits. No minimisation is possible or needed, because a ROM stores the truth table itself. The tempting 192 is 2^5 x 6, produced by swapping the roles of the two numbers and letting the function count set the address width; 64 counts the words but forgets that each word is five bits wide, and 30 is simply the product of the six variables and the five functions, which confuses a count of symbols with a count of stored bits.A processor has already fetched an instruction that reads two operands from memory, the first by register-indirect addressing and the second by memory-indirect addressing. Counting only the accesses made after the instruction word itself has been fetched, how many memory accesses are needed to bring both operands into the processor?
Show answer
Answer: A — 3
Register-indirect addressing already holds the effective address in a register, so exactly one access fetches the operand. Memory-indirect addressing holds only a pointer to the address, so the address itself must be read first and the operand read second, which is two accesses. The total is 1 + 2 = 3. The tempting 2 treats memory-indirect as if it were register-indirect and charges one access for each operand, which is precisely the distinction the two modes exist to mark; 4 charges two accesses for both operands, and 1 counts only the final operand read.A machine's execution is split into four pipeline stages whose combinational delays are 3.0, 5.0, 4.0 and 2.0 ns, and every inter-stage latch adds 0.25 ns. The 5.0 ns stage is then divided into two stages of 2.5 ns each, with a further latch of the same 0.25 ns between them. What is the ideal speedup of the rebalanced pipeline over an unpipelined machine that performs the same work in one long stage?
Show answer
Answer: B — 3.29
The unpipelined machine takes 3.0 + 5.0 + 4.0 + 2.0 = 14.0 ns for one instruction. After the split the stage delays are 3.0, 2.5, 2.5, 4.0 and 2.0 ns, so the slowest is now 4.0 ns and the clock period is the slowest stage plus one latch, 4.0 + 0.25 = 4.25 ns. The ideal speedup is 14.0/4.25 = 3.29. The tempting 2.67 is 14.0/5.25, the speedup of the original pipeline before the split, and it is wrong because the limiting stage has changed from the 5.0 ns stage to the 4.0 ns one. The value 3.50 is 14.0/4.0, obtained by forgetting that the latch is paid once every cycle, and 5.00 is just the new stage count, which the imbalance prevents the design from reaching.An asynchronous input arriving from an unrelated clock domain is captured by passing it through two flip-flops in series, both clocked by the destination clock. What does this arrangement actually achieve?
Show answer
Answer: C — It gives any metastable level a further full clock period in which to resolve, cutting the failure rate without ever driving it to zero.
A flip-flop's two stable states are separated by an unstable balance point, and a data edge arriving inside the sampling window can leave the internal node near it. Resolution from there is exponential, so the probability of still being undecided after a time t falls as exp(-t/tau) but never reaches zero. The second flip-flop samples the first a whole clock period later, by which time that residual probability is negligible, so the synchroniser reduces a failure rate and is quoted as a mean time between failures. The tempting claim that no metastable level can ever reach the downstream logic is exactly the statement the exponential forbids: a synchroniser makes failure improbable, never impossible, and no circuit can be metastability-free.A synchronous design contains register-to-register paths with combinational logic between the flip-flops, and its control is written as a finite state machine. Which of the following statements about such a design are correct?
Show answer
Answer: A — A hold-time violation on one of those paths cannot be cured by lowering the clock frequency, because the clock period does not appear in the hold inequality.; B — If the control is written as a Mealy machine its output can change part-way through a clock period, whereas a Moore output changes only just after a clock edge.
The setup constraint reads T_c >= t_pcq + t_pd + t_su + t_skew and the hold constraint reads t_ccq + t_cd >= t_h + t_skew. The clock period appears only in the first, so a hold failure is a race against the same edge and survives any frequency, including zero; the cures are structural, such as added delay on the short path or a rebalanced clock tree. A Mealy output is a function of the state and the current input, so it follows an input change through combinational logic and can glitch within a period, while a Moore output depends on the registered state alone. Skew is not a trade between the two constraints: it appears with a plus sign on the right of the hold inequality and on the right of the setup inequality as well, so it eats into both budgets at once. And a Mealy machine usually needs fewer states than a Moore machine, not more, because the input itself does some of the discriminating.