Computer Organization and Architecture Friday #2

Okay! So, from the last Friday, you now know that a computer is based on the binary number system or computer understands the language of 0s and 1s. You also know that the computer is a dumb device and it mainly consists of four modules - Central Processing Unit, Input Unit, Output Unit, and Memory Unit.

In this post, we are going to understand how a simple computer internally works. Remember, understanding how a modern computer works internally is a daunting task and it requires a huge amount of knowledge in circuits, hardware, and engineering. But, let's initiate the learning journey with a simple computer that does only basic operations!

For example, let's assume that our small computer only does arithmetic and logical operations using ALU. The supported arithmetic operations by our simple computer are addition, subtraction, multiplication, and division. The supported logical operations by our simple computer are and, or, and not.

ALU will do these operations. But, someone needs to tell him what operation he needs to perform! Now, CU comes in the scene. We know that the CU or Control Unit controls the operation of execution and also instructs ALU on what to perform.

CU sends a signal to ALU in the language which both understands - the language of 0s and 1s. Let's say 0 means arithmetic operation and 1 means logic operation. So, if CU sends a signal to ALU with the value of 0 means ALU needs to perform an arithmetic operation and if CU sends a signal to ALU with the value of 1 means ALU needs to perform a logical operation. Now, CU will not come near to ALU and tell in his ear that what he needs to perform. Instead, there will be a dedicated line between ALU and CU. Let's call it a bus from where CU can send 0 or 1 as a signal to ALU and based on this signal ALU can perform the type of operation.

But, hey! CU needs to be more specific about the particular operation that CU wants ALU to perform. For example, CU wants to perform the addition of the arithmetic operation. In this case, CU again needs to send a signal to ALU on what specific operation to perform. There are four arithmetic operations. So, we need two digits number in the following way -

00   -   addition
01   -   subtraction
10   -   multiplication
11   -   division

Good! Similarly, again two digits number for logical operations also.

00   -   and
01   -   or
10   -   not
11   -   NOP (No Operation)

Again good! In summary, CU needs three connection lines between ALU and itself. So, that it can send a proper signal on what to perform. The first line will send the category e.g. arithmetic or logic and the remaining two lines will send specific operations to need to perform. Also, as of now, we are assuming that somehow CU sends these signals to ALU and ALU decode these signals in such a way that it knows what to perform.

Our computer is ready to do the arithmetic and logical operations! Let's say I want to perform addition operation on 23 and 64, and I write a hypothetical program in the following way -

ADD 23 64

What our simple computer will do? Nothing! Because it needs some memory. Normally, you save all the information in Hard Disk or secondary memory. But, CPU can't work with it! Why? Because it is far from the CPU and it is too slow. CPU can easily work with the main memory or RAM. Because it is near to the CPU and it is fast. CPU can easily grab the data from RAM and can write data back to RAM at full speed.

I can save the above program on my hard disk but to execute this program it needs to go on RAM. So, that CPU can grab the data and instructions. Let's assume that our computer somehow managed to get this program from Hard Disk to RAM or main memory. But, how the CPU can take this data from the main memory? Because we need to perform addition operation and it can be done via ALU.

Now, this reading and writing data from and to RAM can be done via signals 0 and 1. CU can send 0 or 1 to RAM to perform READ or WRITE operation. Let's say -

0   -   READ data from RAM
1   -   WRITE data to RAM

Let's say CU sends a 0 signal via a signal line to RAM to tell that CU wants to read the program. CU read ADD, understands it and instantly sends 000 to ALU e.g. ALU needs to perform addition operation. Next CU read 23. Now? What it will do with 23? CU also needs to read another number 64. So, that it can perform 000 operation. To do that CU needs to save 23 number somewhere within CPU until second number 64 comes. To store this small number CPU needs some memory inside of it apart from Hard Disk and RAM. This memory inside of the CPU is known as register. They are small in size and can only store a single number or instruction.

Our simple computer has four registers - one for the operation (remember CU read first the operation and to read it needs to be saved) and two others for operands e.g. numbers on which operation needs to perform. Finally, the fourth register will save the result of the operation from ALU and then send it back to RAM. To do that CU will send signal WRITE to RAM so that RAM can be prepared to get the data from CPU and save it. Now, RAM can send this saved result to Hard Disk or output device e.g. Monitor and you see 87!

That's it for this Friday. There are many loose connections in our simple computer that I haven't mentioned such as how CPU can read data from RAM because CPU doesn't know where the data is or what is the location of the numbers within memory. Also, this explanation is too lame and don't consider this as the exact working computer model. Next Friday, we will re-visit this modal again with more technical details.

Rhett Trickett picture

Interesting post, thanks Kiran. Things get a bit complicated in the third last paragraph. Perhaps some diagrams, maybe with, could help to clarify this. Enjoyed reading it though!

Minenash picture

Great post, though I think the way you described the communication lines could be confusing to people learning this.

Instead, there will be a dedicated line between ALU and CU. Let's call it a bus

(Correct me if I'm wrong, but this is what I understand:) Buses are typically lines that multiple devices use to communicate with each other, therfore not dedicated. You also talked about sending to and from the RAM, yet have no mention on how it communicates with the it. (Same bus or different bus? If the same, how do we know which one should be talking).

Also, I have a feeling you're going to talk about this on another post, but I think should have been mentioned (if only to say it would be in a different post): What's the difference between 000 and not sending anything?

KC picture

There are many buses - some are dedicated and some are not. The reason why I was too abstract about details is, I haven't cover anything than just two concepts in last Friday. Also, I'm learning and what I written here is based on my initial understanding. Please correct me at places where I'm wrong.