How CPUs work — Part 2:

Chris Harwell
2 min readJan 20, 2022

--

In my previous post I discussed in depth how the Memory, and Buses in a computer work and briefly discussed how the ALU, CU, PC, and registers work. In this post I will discuss in detail how the ALU, and CU work.

ALU

As discussed in my last post the computer stores data in its registers and memory. This being said, the component in the CPU that is responsible for the bulk of operations is the ALU or Arithmetic Logic Unit. The ALU performs both Arithmetic and Logic operations. Typically the registers will send bits of data to the ALU and tell it to perform some operation on those two seperate pieces of data. The ALU will then perform this operation and send that data back to the registers. Based on the data from the control bits (the data sent to the ALU from the registers), the ALU knows which calculation that it needs to perform. If you change the control bits, you change which operation is performed by the ALU

CU

The main purpose of the control unit is to make sure the CPU is performing the correct operations, by sending and modifying the signals sent to the datapath where the registers the ALU and different select operands are executed. The way that the CU knows what needs to be executed is, it has a register known as a IR (instruction register) that holds instructions in binary, it then decodes the binary and deduces the steps needed to carry out the instruction. Of course the instruction comes fromm a program that is stored in RAM. The PC (Program Counter) exists inside the CU and it is in charge of making sure that it gets the correct address from RAM where the program instructions are stored. So it gets the data from the RAM, using the PC it to know which memory address to retrieve instructions from, it then stores it in the CU unit, decodes the data, it then sends signals to the CPU and syncs with the CPU clock and then reads the operands from the Register-Bank, selects the right operation in the ALU and stroes the result the result is then written in another register…it then increases/updates the PC. These steps can be different for different instructions, the example I gave is for doing an Addition operation.

--

--

No responses yet