The central processing unit (CPU) executes instructions and processes dataโmaking it the brain of a computer system.
The CPUโs job can be summarized as:
- Fetch: gets an instruction and translates opcode to control.
- Datapath: performs the computation based on control.
- Control: decides which computation to perform, routes data through datapath.
This fetch-decode-execute cycle consists of two component types, combinational and sequential. The former performs stateless computation (ALUs, muxes, logic), and the latter stores state (PC, memories, register file).
We can split the CPUโs work into two main parts:
- The ๐ Datapath is responsible for executing the instructions by manipulating registers, ALUs, muxes, and memories.
- The control unit is responsible for coordinating the datapathโs execution by fetching and decoding the instructions, then setting the mux selectors and write-enables within the datapath to their correct values.
Control Unit
We can think of control as a giant table that sets the correct values for mux selectors and write-enables for each instruction in the ๐ ISA. Implementing this is impractical, and real machines use logic gates.