digiwleeaLearn
Open the lab →

Decode

Splitting the instruction and choosing what to do

3 min read

Decode is the phase that splits the fetched instruction into its opcode (which operation) and operand (its data), then uses the opcode to select which control lines the execute phase must raise.

Fetch delivered an instruction byte into the instruction register. Decode is where the machine works out what that byte *means*. It has two jobs: carve the byte into its fields, and translate the operation field into the specific set of control lines the execute phase will need.

Splitting the byte into fields

In our machine code an instruction byte is two nibbles: the high 4 bits are the opcode (the operation) and the low 4 bits are the operand (here a memory address). Splitting them needs no logic at all, it is just wiring: the top four bits go to the decode logic, the bottom four go to the address bus. The instruction register already exposes them separately.
0x25 = opcode 0x2 (ADD) , operand 0x5 (address 5)

Opcode to control lines

The second job is the real decoding. The opcode is a small number (0x1, 0x2, 0x3, 0xF in our set), and the control unit must turn it into a plan: which register drives the bus, which register loads, what the ALU computes. This is combinational: a decoder turns the opcode into one-hot "this is a LOAD" / "this is an ADD" lines, and those select the right control pattern. Decode does not *do* anything to the data yet; it just decides what execute will do.
Decode splitting an instruction (IR8): load a byte on I0-I7, pulse LD, and read the opcode on OP0-OP3 (high nibble) and operand on AR0-AR3 (low nibble). Open it in the lab, load 0010 0101 (0x25, "ADD 5"), and read opcode 0010 and operand 0101.
Common mistakes. Decode is combinational: it computes a selection, it does not store or move data, and it takes no clock edge of its own in a simple machine (the split and the control-line logic just settle). Do not confuse the opcode (top nibble, the operation) with the operand (bottom nibble, the address). And decode only *chooses* the control lines; raising them and moving data is the execute phase.
Try it
Split the byte 0x25 into opcode and 4-bit operand, and name the operation (opcode 0x2 is ADD).

Frequently asked

What happens during the decode phase?

Decode splits the fetched instruction into its opcode (the operation) and operand (its data), then uses the opcode to select which control lines the execute phase must raise. It decides what to do without yet doing it.

How does a CPU decode an opcode?

The opcode is a small number, and a decoder turns it into one-hot signals (one line per instruction). Those lines, combined with the step counter, select the control pattern for that instruction. The whole thing is combinational logic, essentially a lookup from opcode to control lines.

What is the difference between decode and execute?

Decode *chooses* what to do: it splits the instruction and selects the control lines. Execute *does* it: it raises those control lines so the datapath actually moves data and runs the ALU. Decode is a decision; execute is the action.
With the opcode decoded into a control plan, the execute phase raises those lines and the datapath finally moves data and computes.

Every lesson here builds toward one thing: a working CPU, from the transistor up.

Open the free lab →
Builds towardExecute
Found this useful? Share itShare on X