Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 56 of 9361. Foundations of Digital Logic and Computer ArchitectureFree lesson

Designing Single-Cycle Control Unit Logic

You will create combinational logic that generates control signals based on the opcode to configure data path components for specific instructions.

In this lesson, you will learn how the control unit acts as the "brain" of your CPU by turning simple machine code opcodes into the physical signals that steer data through your hardware.

The Brain of the Data Path

In a single-cycle processor, every instruction flows through the same hardware components (like the ALU and Register File). However, not every instruction needs every component to perform the same task. For instance, an ADD instruction needs the ALU to perform addition, while a LOAD instruction needs the ALU to calculate a memory address.

The Control Unit is a block of combinational logic that sits between the instruction memory and your data path components. It reads the opcode (the instruction type) and outputs specific signals to tell the hardware how to behave for that one cycle.

Translating Opcode to Signals

Think of the opcode as an input to a truth table. Based on the bits of the opcode, the logic gates inside the control unit pull specific wires HIGH (1) or LOW (0). These wires act as switches for your multiplexers and enable pins for registers or memory.

For example, consider a simplified RegWrite signal, which determines if the result of an operation should be saved into the register file:

// Simplified logic for RegWrite
// RegWrite is 1 if the instruction is an R-type (ADD) or a Load
assign RegWrite = (opcode == ADD_OPCODE) | (opcode == LOAD_OPCODE);

// ALUSrc determines if the ALU takes a register input or an immediate value
assign ALUSrc = (opcode == LOAD_OPCODE) | (opcode == STORE_OPCODE);

When the processor fetches an ADD instruction, the control unit sees that ADD_OPCODE and instantly sets RegWrite to 1 and ALUSrc to 0. This happens entirely through combinational logic—no clock cycles are wasted; the signals simply ripple through the gates until they reach the data path components. By the time the next clock edge arrives, the hardware is already configured correctly to process the instruction.

Key Takeaway: The control unit uses combinational logic to translate the instruction opcode into specific control signals, configuring the data path hardware for each unique instruction in a single clock cycle.