Module 3 · 14 min read · Free chapter
ALU, data-path and control unit
A CPU has an ALU, registers and a control unit. A single-bus data-path needs registers Y and Z around the ALU, so ADD R1, R2 takes six steps. Hardwired control is fast and rigid, while microprogrammed control stores control words in a control memory and is easier to change.
Start from zero: the reservation counter
Picture a railway reservation counter. A passenger slides a form through the window, and the clerk reads it to see what is wanted. The clerk uses a calculator for the fare, keeps notes in small trays on the desk, and passes papers in and out through one shared window.
A CPU works the same way. The clerk who reads the request and decides each next step is the control unit, and the calculator is the arithmetic logic unit (ALU). The trays are registers, small and very fast storage inside the CPU, and the window through which everything passes is a bus.
The path that data takes between registers, the ALU and the buses is called the data-path. The control unit opens and closes gates on this path, one clock step at a time, so that each instruction gets done. This chapter opens up both halves: the data-path that moves and computes, and the control unit that directs it.
Why it matters. The speed of a processor depends on how many clock steps each instruction needs and how short each step can be. Both are decided by the data-path and the control unit, which is why GATE asks you to count control steps and size control memories.
Registers, flags and buses
Some registers are visible to the programmer and some work behind the scenes. The program counter (PC) holds the address of the next instruction, and the instruction register (IR) holds the instruction being executed. The memory address register (MAR) holds the address sent to memory, and the memory data register (MDR) holds the word just read or about to be written.
General-purpose registers such as R0 to R31 hold operands and results. The status register keeps flags set by the ALU: zero (Z) when the result is 0, sign (N) when it is negative, carry (C) for an unsigned carry out, and overflow (V) for signed overflow. Branch instructions such as "branch if zero" simply test these flags.
The CPU talks to memory and devices over the system bus, which has three parts. The address bus runs one way, from the CPU, and with lines it can name locations. The data bus runs both ways and its width is the number of bits moved per transfer, while the control bus carries read, write, clock and interrupt signals.
Worked example. A processor has a 32-bit address bus, a 16-bit data bus and byte-addressable memory. It can address bytes, which is 4 GB. Reading one 32-bit word needs two bus transfers, because each transfer carries only 16 bits.
Why it matters. Bus widths set the largest memory a machine can use and how fast data can move. Exams ask for the memory size from the address width, or for the number of transfers needed for a word, and both follow from these definitions.
The instruction cycle and micro-operations
Every instruction goes through the same loop, called the instruction cycle. The CPU fetches the instruction, decodes it, fetches any operands, executes it and writes back the result. Before starting the next fetch it checks whether an interrupt is waiting.
The fetch phase is the same for all instructions and can be written in register transfer notation, where the arrow means "is loaded with".
The step adds one instruction length, which is 4 on a machine with 4-byte instructions and byte addresses. Increasing the PC early means it already points to the next instruction while the current one executes.
Each such step is a micro-operation, the smallest action the hardware performs in one clock step. There are four kinds: register transfer such as , arithmetic such as , logic such as AND, OR and XOR, and shifts such as a logical or arithmetic shift. A machine instruction is simply a short sequence of micro-operations.
Why it matters. Once you can write an instruction as micro-operations, you can count its clock steps, spot which registers it uses and design its control signals. Every data-path question in GATE starts from this habit.
The single-bus data-path and its control steps
The cheapest data-path joins every register and the ALU to one internal bus. Each register has an "in" gate, which loads it from the bus, and an "out" gate, which places its value on the bus. Only one register may drive the bus in a clock step, so the ALU needs a helper register Y to hold one operand while the other comes over the bus, and a register Z to catch the result.
Take ADD R1, R2, which means , on a machine with 4-byte instructions. The control unit raises these signals, one row per clock step.
Step Control signals
T1 PCout, MARin, Read, Select4, Add, Zin
T2 Zout, PCin, Yin, WMFC
T3 MDRout, IRin
T4 R1out, Yin
T5 R2out, SelectY, Add, Zin
T6 Zout, R1in, End
In T1 the PC goes to MAR, a memory read starts, and the ALU adds the constant 4 to the PC value into Z. In T2 the new value returns to the PC while the unit waits for memory (WMFC means "wait for memory function complete"), and in T3 the instruction moves from MDR to IR. Steps T4 to T6 copy R1 into Y, add R2 to it, and write Z back to R1, so the instruction needs six steps in all.
Worked example. With a 2 ns clock and memory that answers within T2, ADD R1, R2 takes ns. An instruction ADD R1, [R2] that reads its second operand from memory needs extra steps to send R2 to MAR and wait for the word, so it might take 8 steps, or 16 ns.
Why it matters. The single bus keeps hardware small, which suits simple controllers, but it forces almost every transfer into its own step. GATE gives such sequences and asks how many steps an instruction takes or which signal is missing.
Two-bus and three-bus data-paths
The single bus is a narrow road, so the natural fix is to build more lanes. In a two-bus data-path one bus carries values out of registers and the other carries results back, so a value can leave one register and a result can enter another in the same step. A three-bus data-path goes further, with buses A and B feeding the two ALU inputs and bus C carrying the result back.
With three buses, needs just one execute step: R2 goes out on bus A, R3 on bus B, the ALU adds, and R1 loads from bus C. The temporary registers Y and Z are no longer needed, and the fetch phase also shortens because the PC can be incremented by its own adder.
| Data-path | Execute steps for ADD R1, R2, R3 | Hardware cost |
|---|---|---|
| Single bus | 3, with Y and Z | Lowest: one bus, one port per register |
| Two buses | 2, with one temporary register | Medium |
| Three buses | 1 | Highest: two read ports and one write port |
Worked example. A program runs 10⁶ register-to-register add instructions. With 3 fetch steps plus the execute steps above, a single-bus machine needs 6 steps each and a three-bus machine needs about 4, if its fetch still takes 3 steps. At a 1 ns clock the totals are 6 ms and 4 ms, a saving of one third.
Why it matters. Every modern processor uses a multi-port register file and several buses, because cutting steps per instruction is the cheapest speed-up. The trade-off between steps and wiring is a favourite comparison question in written papers.
Hardwired and microprogrammed control
The control unit must raise the right signals at the right step for every instruction. There are two ways to build it, and the difference is like a clerk who has memorised every procedure versus one who looks each step up in a rule book.
A hardwired control unit is a logic circuit. A step counter counts T1, T2, T3 and so on, a decoder turns the opcode in IR into one active line, and gates combine these with the flags to produce each control signal. For example, the signal Zin might be the logic expression .
A microprogrammed control unit stores the signal pattern of each step as a word, called a microinstruction, in a small fast control memory. A control address register, also called the micro-program counter, points to the current word, and the sequence of words for one instruction is its microprogram. Changing an instruction then means changing words in the control memory, not rewiring gates.
| Feature | Hardwired | Microprogrammed |
|---|---|---|
| Speed | Faster, signals come straight from gates | Slower, each step reads control memory |
| Changing or adding instructions | Hard, needs redesign | Easy, rewrite the microprogram |
| Suits | RISC, few simple instructions | CISC, many complex instructions |
| Design effort for a large set | High and error-prone | Systematic |
Why it matters. This choice follows the RISC and CISC divide, so exams often pair the two comparisons. It also explains why instruction bugs in some processors could be fixed by an update to their microcode.
Horizontal and vertical microcode: control-memory numericals
How wide should a microinstruction be? In horizontal microcode every control signal gets its own bit, so a machine with 40 signals has 40 signal bits. Any combination of signals can be active in one step and nothing needs decoding, but the words are wide.
In vertical microcode, signals that can never be active together are packed into a field and encoded. A field for a group of such signals needs bits, where the extra code means "none of them". The words become narrow, but each field needs a decoder, which adds delay, and fewer signals can be active at once.
Each word also needs sequencing fields. A next-address field for a control memory of words needs bits, and a condition-select field that chooses among conditions needs bits.
Worked example. A CPU has 40 control signals that fall into four mutually exclusive groups of 7, 15, 10 and 8 signals, and its control memory holds 512 microinstructions. The next-address field needs bits in both formats.
The vertical field widths come from , , and . So vertical coding saves more than half the control memory, at the cost of four decoders.
If the same machine must branch on any of 4 flags or branch always, the condition field must choose among 5 cases. That needs more bits in each word.
Why it matters. Control-memory sizing is a regular GATE numerical, and the only traps are the ceiling and the "none" code. Real designs mix the two styles, encoding some groups and leaving urgent signals as single bits.
Descriptive lens: how written papers ask this
Written papers for engineering services, IT officer posts and state Assistant Programmer exams ask about this topic in four ways:
- Draw and explain a single-bus data-path and write the control sequence for a given instruction.
- Compare single-bus and multi-bus organisations by steps per instruction and hardware cost.
- Compare hardwired and microprogrammed control units, with a block diagram of each.
- Calculate microinstruction width and control-memory size for horizontal and vertical formats.
Practice questions (our own, not previous-year questions).
- Draw a single-bus data-path and write the control steps for SUB R3, R4, explaining the role of registers Y and Z. (10 marks)
- Compare hardwired and microprogrammed control under five heads, and state which suits a RISC processor and why. (10 marks)
- A processor has 64 control signals in mutually exclusive groups of 15, 31, 10 and 8, and 1,024 microinstructions. Find the word width and control-memory size in horizontal and vertical formats. (15 marks)
Answer plan for question 3.
- State that horizontal coding gives one bit per signal, so the signal part is 64 bits wide.
- Find the next-address field as bits, which both formats need.
- Give the horizontal word as bits and the memory as bits.
- Find the vertical fields as , , and , which add to 17 bits including a "none" code in each group.
- Give the vertical word as bits and the memory as bits.
- Conclude that vertical coding saves about 63 percent of control memory but needs four decoders and allows less parallelism.
Quick revision
- A CPU has an ALU, registers and a control unit, and the flags Z, N, C and V record ALU results.
- The address bus is one-way and names locations with lines, while the data bus is two-way.
- Fetch is , then a memory read with the PC increment, then .
- Micro-operations are register transfers, arithmetic, logic and shifts, each done in one clock step.
- A single-bus data-path needs Y and Z around the ALU, and ADD R1, R2 takes six steps.
- A three-bus data-path performs in one execute step.
- Hardwired control is fast and rigid, while microprogrammed control is slower and flexible.
- Horizontal microcode uses one bit per signal, and vertical microcode uses bits per group of signals.
- Control memory size equals the number of words times the word width, including next-address and condition fields.