A CPU has 8 registers of 16 bits each that must share one common bus. (a) Using multiplexers, how many are needed, of what size, and with how many select lines? (b) Using three-state buffers instead, how many buffers and what decoder are needed?
Every instruction is carried out as a sequence of register-level micro-operations — transfers, arithmetic, logic and shifts — written in register transfer language (RTL). The control unit, hardwired or microprogrammed, issues the timed control signals that make them happen.
A register is a group of flip-flops that stores one binary word: an n-bit register has n flip-flops sharing a clock, plus a load control that decides whether new data enters at the next clock edge. Registers are the fastest storage in a computer, and every instruction is executed by moving and transforming data between them.
Special-purpose registers have fixed jobs that the control unit depends on. General-purpose registers (R0, R1, … or AX, BX, …) hold whatever operands and results the program chooses. A machine with one main working register is an accumulator machine; one with many is a general-register machine.
| Register | Role |
|---|---|
| PC — program counter | Address of the next instruction; incremented during fetch, reloaded by jumps |
| IR — instruction register | The current instruction; its opcode field feeds the decoder |
| MAR / AR — address register | The address sent to memory |
| MDR / MBR / DR — data register | The word read from, or written to, memory |
| AC — accumulator | Default ALU operand and destination |
| TR — temporary register | Intermediate values during multi-step instructions |
| SP — stack pointer | Address of the top of the stack |
| PSW / flags — status register | Condition bits set by the ALU (carry C, zero Z, sign S, overflow V) plus control bits such as interrupt enable |
| XR — index register, base register | Help form effective addresses for arrays and relocation |
Mano's basic computer — the model used in most B.Tech courses — has a 4096 × 16 memory, so every register that holds an address needs log₂4096 = 12 bits, while registers that hold data words need 16.
| Register | Bits | Name |
|---|---|---|
| DR | 16 | Data register (holds the memory operand) |
| AR | 12 | Address register (holds the memory address) |
| AC | 16 | Accumulator |
| IR | 16 | Instruction register |
| PC | 12 | Program counter |
| TR | 16 | Temporary register |
| INPR | 8 | Input register (character from the keyboard) |
| OUTR | 8 | Output register (character to the printer) |
Alongside these sit single flip-flops — E (carry out of the AC adder), I (indirect bit), S (start/stop), R (interrupt cycle), IEN (interrupt enable), FGI and FGO (input and output flags) — and a 4-bit sequence counter SC that produces the timing signals.
RTL is a compact notation for the elementary operations performed on register contents, called micro-operations; each one completes in a single clock pulse. Designers use RTL to state exactly what the hardware must do before drawing a single gate.
| Notation | Meaning | Example |
|---|---|---|
| Capital letters | A register (or its contents) | AR, PC, R2 |
| Parentheses | Part of a register | R2(0–7), PC(L), IR(12–14) |
| Arrow ← | Transfer (copy) into the register on the left | R2 ← R1 |
| Colon : | Control condition — act only while it is 1 | P: R2 ← R1 |
| Comma , | Micro-operations done in the same clock pulse | T1: IR ← M[AR], PC ← PC + 1 |
| M[ ] | Memory word at the given address | DR ← M[AR] (read); M[AR] ← R1 (write) |
P: R2 ← R1 has a precise hardware meaning. R1's outputs are wired to R2's inputs, and the control signal P drives R2's load input, so the copy happens at the next clock edge while P = 1. The source register R1 keeps its value.
R2 ← R1 unconditional transfer
T1: R2 ← R1 transfer when timing signal T1 = 1
T2: R1 ← R2, R2 ← R1 swap in ONE clock pulse (edge-triggered flip-flops)
P + Q: R3 ← R1 act if P = 1 OR Q = 1 (+ means OR in a control function)
DR ← M[AR] memory read
M[AR] ← R1 memory writeAC ← AC + DR, AC ← 0) or the same bus. Designers check every control function for such conflicts.Wiring every register to every other register would need a huge number of wires. Instead, registers share a common bus: n lines, one per bit, onto which exactly one source register is placed at a time while the destination register's load input is enabled.
Mano builds the bus from multiplexers. Bit i of every register goes into multiplexer i, and the same select lines drive all the multiplexers, so they all pick the same register at once.
The alternative uses three-state buffers. A three-state gate outputs 0, 1 or a high-impedance (Z) state that behaves like an open circuit, so many outputs can share one line as long as only one is enabled. For k registers of n bits you need n × k buffers and one log₂k-to-k decoder that enables exactly one register's buffers.
Mano's basic computer has a 16-bit bus whose select inputs S2 S1 S0 choose a source: 1 = AR, 2 = PC, 3 = DR, 4 = AC, 5 = IR, 6 = TR, 7 = memory (0 selects nothing). For DR ← M[AR] the control unit sets S2S1S0 = 111 so the memory word drives the bus, and enables DR's load input; for AR ← PC it sets S2S1S0 = 010 and enables AR's load.
| RTL | Description |
|---|---|
| R3 ← R1 + R2 | Add |
| R3 ← R1 − R2 | Subtract |
| R2 ← R2' | 1's complement (invert every bit) |
| R2 ← R2' + 1 | 2's complement (negate) |
| R3 ← R1 + R2' + 1 | Subtract by adding the 2's complement — how the hardware really subtracts |
| R1 ← R1 + 1 | Increment |
| R1 ← R1 − 1 | Decrement |
A 4-bit binary adder is four full adders in a chain, each carry-out feeding the next carry-in. Turning it into an adder–subtractor takes only four XOR gates and a mode line M: each B bit passes through an XOR with M, and M also drives the first carry-in.
Example: 0110 − 0011 becomes 0110 + 1100 + 1 = 1 0011. The end carry is discarded, leaving 0011 = 3, which is 6 − 3. An incrementer is simpler still: a chain of half adders whose first carry-in is fixed at 1.
Mano's general arithmetic circuit feeds each B input of the adder through a 4 × 1 multiplexer. The select lines S1 S0 choose B, B', all 0s or all 1s as the second input Y, and the carry-in C_in adds 1, so one adder gives eight operations: D = A + Y + C_in.
| S1 S0 | Y input | C_in = 0 | C_in = 1 |
|---|---|---|---|
| 0 0 | B | A + B (add) | A + B + 1 (add with carry) |
| 0 1 | B' | A + B' (subtract with borrow) | A + B' + 1 = A − B (subtract) |
| 1 0 | all 0s | A (transfer) | A + 1 (increment) |
| 1 1 | all 1s | A − 1 (decrement) | A (transfer) |
Logic micro-operations work bit by bit, with no carries between positions. Two inputs allow 2^(2²) = 16 possible bitwise functions, but AND, OR, XOR and complement cover practical needs. Mano writes OR as ∨ and AND as ∧ in micro-operations so that + keeps its arithmetic meaning.
Their real power is bit manipulation: register B acts as a pattern that chooses which bits of A to change. With A = 1001 0110 and B = 1111 0000 (the high nibble selected):
| Application | Micro-operation | Result |
|---|---|---|
| Selective set — force chosen bits to 1 | A ← A ∨ B | 1111 0110 |
| Selective complement — flip chosen bits | A ← A ⊕ B | 0110 0110 |
| Selective clear — force chosen bits to 0 | A ← A ∧ B' | 0000 0110 |
| Mask — keep only chosen bits | A ← A ∧ B | 1001 0000 |
| Insert 0101 into the high nibble | A ← A ∧ 0000 1111, then A ← A ∨ 0101 0000 | 0101 0110 |
| Clear the whole register | A ← A ⊕ A | 0000 0000 |
Shift micro-operations move bits sideways. The variants differ only in what enters the vacated end and what happens to the bit pushed out. Take R = 1001 0111, which is −105 as a signed 8-bit number:
| Symbol | Operation | R = 1001 0111 becomes |
|---|---|---|
| shl R | Logical shift left; 0 enters the LSB | 0010 1110 |
| shr R | Logical shift right; 0 enters the MSB | 0100 1011 |
| cil R | Circular shift left; the MSB wraps to the LSB | 0010 1111 |
| cir R | Circular shift right; the LSB wraps to the MSB | 1100 1011 |
| ashl R | Arithmetic shift left (× 2); same bits as shl, but overflow is checked | 0010 1110 — overflow |
| ashr R | Arithmetic shift right (÷ 2); the sign bit is copied | 1100 1011 |
Here cir and ashr happen to agree because the LSB and the sign bit are both 1; with other data they differ. An arithmetic logic shift unit (ALSU) combines the arithmetic, logic and shift circuits for each bit and picks one result with a final multiplexer: in Mano's design S3 S2 choose the class (00 arithmetic, 01 logic, 10 shift right, 11 shift left), while S1 S0 and C_in choose the exact operation.
The control unit turns each instruction into the right sequence of micro-operations by activating control signals — register loads, bus selects, ALU function, memory read/write — at the right clock pulses. In Mano's basic computer a 4-bit sequence counter (SC) drives a 4 × 16 decoder that produces timing signals T0, T1, …, T15. SC counts up every clock and is cleared (SC ← 0) when an instruction finishes.
A basic-computer instruction is 16 bits: I (bit 15, the indirect bit), a 3-bit opcode (bits 12–14) and a 12-bit address (bits 0–11). Opcodes 000–110 are memory-reference instructions, decoded into D0–D6. Opcode 111 with I = 0 is a register-reference instruction; with I = 1 it is an input–output instruction.
R'T0: AR ← PC
R'T1: IR ← M[AR], PC ← PC + 1
R'T2: D0 … D7 ← Decode IR(12–14), AR ← IR(0–11), I ← IR(15)
D7'IT3: AR ← M[AR] indirect: read the effective address
D7'I'T3: nothing direct: AR already holds the address| Instruction | Decoder | Micro-operations |
|---|---|---|
| AND (AC ∧ M[EA]) | D0 | D0T4: DR ← M[AR]; D0T5: AC ← AC ∧ DR, SC ← 0 |
| ADD (AC + M[EA]) | D1 | D1T4: DR ← M[AR]; D1T5: AC ← AC + DR, E ← Cout, SC ← 0 |
| LDA (load AC) | D2 | D2T4: DR ← M[AR]; D2T5: AC ← DR, SC ← 0 |
| STA (store AC) | D3 | D3T4: M[AR] ← AC, SC ← 0 |
| BUN (branch unconditionally) | D4 | D4T4: PC ← AR, SC ← 0 |
| BSA (branch and save return address) | D5 | D5T4: M[AR] ← PC, AR ← AR + 1; D5T5: PC ← AR, SC ← 0 |
| ISZ (increment and skip if zero) | D6 | D6T4: DR ← M[AR]; D6T5: DR ← DR + 1; D6T6: M[AR] ← DR, if (DR = 0) then (PC ← PC + 1), SC ← 0 |
Why does LDA take two steps? In this design memory data can reach AC only through DR and the adder–logic circuit, so the word is first read into DR at T4 and moved into AC at T5. STA needs one step because AC can drive the bus straight into memory. BSA stores the return address at the subroutine's first word and starts execution at the next one.
A hardwired control unit produces its control signals with fixed logic — decoders, gates, flip-flops and the sequence counter — exactly as the RTL above implies. It is fast, but any change to the instruction set means redesigning the circuit, so it suits small, regular instruction sets such as RISC.
Microprogrammed control, proposed by Maurice Wilkes in 1951, stores the control signals as words in a control memory. Each word is a microinstruction, and the set of routines — one per machine instruction — is the microprogram. Because control memory is normally a ROM, the microcode is firmware: fixed software built into the hardware.
A microinstruction must say two things: which control signals to activate in this step, and where the next microinstruction is. Its width is therefore the control field plus the sequencing fields. Mano's example machine uses a 20-bit word with three encoded micro-operation fields and an explicit branch address:
| Field | Bits | Purpose (Mano's 20-bit microinstruction) |
|---|---|---|
| F1, F2, F3 | 3 + 3 + 3 | Three encoded micro-operation fields; each picks one of 7 operations (000 = none) |
| CD | 2 | Condition to test: always 1, indirect bit I, sign of AC, or AC = 0 |
| BR | 2 | Branch type: JMP, CALL, RET or MAP |
| AD | 7 | Branch address into a 128-word control memory |
| Total | 20 | Control memory = 128 × 20 bits |
Microinstruction formats sit on a spectrum. Horizontal microcode gives one bit to every control signal: words are wide, but any combination of signals can fire in parallel with no decoding delay. Vertical microcode packs mutually exclusive signals into short encoded fields that must be decoded: words are narrow, parallelism is limited and decoding adds delay. A field that picks one of m signals (or none) needs ⌈log₂(m + 1)⌉ bits.
| Feature | Horizontal | Vertical |
|---|---|---|
| Encoding | None — one bit per control signal | Highly encoded fields |
| Word width | Wide | Narrow |
| Micro-operations per microinstruction | Many, in parallel | Few |
| Decoders needed | No | Yes |
| Speed | Faster | Slower |
| Microprogram length | Fewer, wider words | More, narrower words |
Try the problem first, then reveal the working one step at a time.
A CPU has 8 registers of 16 bits each that must share one common bus. (a) Using multiplexers, how many are needed, of what size, and with how many select lines? (b) Using three-state buffers instead, how many buffers and what decoder are needed?
A microprogrammed control unit uses 24-bit microinstructions with three fields: a horizontal control field of 12 bits, a condition-select field that picks one of 16 status inputs through a multiplexer, and a next-address field. Find the width of each remaining field and the size of the control memory.
In Mano's basic computer, PC = 021, AC = 0007, E = 0, and memory holds M[021] = 9083, M[083] = 0123, M[123] = 0005 (all hex). Trace the micro-operations of the instruction at 021 and give the final register values.
Register A = 1100 1010. Using a suitable B and logic micro-operation, (a) set bits 0–3, (b) complement bits 4–7, (c) clear bits 0 and 7. Give B, the operation and the result each time (start from the original A each time).
R = 0110 1101 (+109). Find the result of shl, shr, cil, cir, ashl and ashr, and state whether ashl overflows.
A control unit needs 40 control signals. They fall into 5 groups of mutually exclusive signals containing 3, 7, 12, 8 and 10 signals. How wide is the control field in (a) horizontal format and (b) vertical format with one encoded field per group?
Write the fetch and execute micro-operations, one clock period per line, for SUB X (AC ← AC − M[X]) on a CPU with PC, MAR, MBR, IR, AC and an ALU that can complement its second input and add a carry-in.
Mano's microinstruction has fields F1, F2, F3 (3 bits each), CD (2), BR (2) and AD (7). (a) How many micro-operations can each F field specify? (b) Why is AD 7 bits? (c) If control memory grew to 512 words and the number of testable conditions to 8, what would the microinstruction width become?
T1: IR ← M[AR], PC ← PC + 1 is one step; writing two loads of the same register in one statement is a design error.10 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.