Skip to main content

Command Palette

Search for a command to run...

The Chef Inside your CPU - Understanding the ALU

Published
2 min read
The Chef Inside your CPU -  Understanding the ALU
V

I turn computer science into stories, and narration, my goal and intention isn't to teach the how. It is to help people see why the Algorithms, Data Structures, and Flows exist through visualisation by connecting the systems.

In last blog, I said we’d discuss about Control Unit’s Character, How it decodes and Commands signal. Well, to understand that, we first have to know how the Arithmetic Logic Unit(ALU) and Memory Unit(MU) work. The combination of how these two operates will tell us how the CU actually decodes and commands signals.


I think everyone knows how people around the world cooks something.
Be it pizza, pasta, ramen, chicken, panner etc..
but there’s one common thing in every dish which makes it better and edible.
Those are spices - turmeric, coriander, cumin, chili flakes, ginger and garlic etc. which decide the entire taste of a dish.

The same way, Arithmetic Logic Unit has its own set of spices which are called Logic Gates - AND, OR, NOT, XOR, NAND, NOR.
Your data(the operands) are like the food ingredients.
Depending on what you’re going to modify and execute, the Arithmetic Logic Unit mixes these logic gates in different permutations and combinations to produce a new result

How the ALU Executes - step by step:

  • When the Control Unit gives a command signal, the ALU uses multiplexers and demultiplexers to select and enable appropriate logic gates, forming logical equations ( it’s like having its own recipe or process for solving the task).

  • Then the logical equation gets simplified by K-maps(Karnaugh maps) (its like, rather than using every spice, we use seasonings which makes our task easy to cook).

  • Finally, the simplified logical equation gets executed by adders, half adders, and multipliers ( It’s like oven baking, pressure cooking, air frying, pan frying).

So in the end, no matter how many times you use the same data, you can get completely different results just by changing the combination of logic gates and simplifying it.

All these - the logic gates, k-maps, adders and multipliers come together inside what we call as Combinational Circuits. These circuits don’t store anything, whatever the CU commands and whatever data the MU loads, the Combinational Circuits instantly produces the output.


So, Arithmetic logic unit doesn’t just run the numbers, it cooks results, but like how every chef needs ingredients, ALU needs it too( those are data(operands)), In our next blog we will learn where do those operands come from?

Note: There are tons of videos on Internet, which tells how each of logic gates, k-maps, adders and multiplier works, my intention here is to show you how everything connects together so you can see the bigger picture.