How Things Work in The Central Processing Unit

 All things in all posts will help you visualize about the way that computers work generally. Note that it is not the real structure of modern computers, but the way that modern computers work is nearly the same as in my posts. I am sure that if you understand about the way that computers work in my posts, you will easy to learn about all fields of computer afterward. Thank you !!!

In the previous post, we have known the way that one thing is conducted in one cycle of clock or one step (in stepper) in another word. Now, we will learn to conduct the really useful things in the CPU (central processing unit) such as adding two binary numbers and saving it to any register,...

Firstly, let’s look at the diagram of the control unit for adding binary number in R1 register to binary number in R0 register and save the result in R0 again:

In the diagram, you can see that I use step 4 to step 6 in stepper for adding two binary numbers and step 7 for resetting the stepper to step 1. The bit of the step 4 will connect to the “enable” of the R1 register and to the “set” of the TMP register. The bit of the step 5 will connect to the “enable” of the R0 register and to the “set” of the ACC register. The bit of the step 6 will connect to the “enable” of the ACC register and to the “set” of the R0 register. The bit of the step 7 will connect to the reset bit. Now, we will find out the way that this device works.

In the  step 4 (or fourth cycle of the clock), the R1 register will be enabled and the TMP register will be set, so the binary number in the R1 register will be saved in the TMP register.

In the step 5 (or fifth cycle of the clock), the R0 register will be enabled for the binary number on the bus, the ACC register will be set and the ‘op’ code will be chosen in this situation for ADD. The ALU operation of ADD for two binary numbers (in TMP register and on the bus) will be conducted in ALU part of the CPU. Then, the result will be saved in the ACC register.

In the step 6 (or sixth cycle of the clock), the ACC register will be enabled and the R0 register will be set, so the result in the ACC register will be saved in the R0 register again. That is all about adding R1 to R0 and saving the result to the R0 again.

For more, in the step 7 (or the seventh cycle of the clock), the wire of this step bit will connect to the reset bit and the stepper will be reset to the first cycle of the clock.

Below is the graph that represent the three cycles of clock: step 4, step 5 and step 6 for adding two binary numbers:

It is easy to understand if you have read my post about the clock. 

That is only one useful thing that we mention. There are more useful things that are needed for computer work. If this addition is conduction repeatedly by the stepper, the result in R0 will be up to 255 quickly. 

You may think that is a long process but it is not. Imagining that the clock that is used in computers works about billions of cycles per second. And useful things that use several cycles to perform like addition are conducted by this clock. You can calculate the number of useful things that computers can have in one second. Yes, it’s about hundreds of millions or more. It's an enormous useful thing!!!

Now, we also want to save the result to the RAM that has the address in R2 register. How can we conduct this useful thing? Ok, let’s look at the diagram that conduct this useful thing below in the:

In the diagram, we will connect the bit of the step 4 (fourth cycle of the clock) to the “enable” of R2 register and “set” of MAR register. We also connect the bit of the step 5 (fifth cycle of the clock) to the “enable” of R0 register and to the “set” of RAM register.

In step 4, the R2 register will be enabled for its binary code on the bus and the MAR (for address) of RAM will be set. The binary code on the bus will go through MAR and choose the address in RAM for saving the later byte of data.

In step 5, the R0 register will be enabled for its byte of data on the bus and the RAM will be set. Now, the byte of data on the bus will be saved in the address of RAM that we chose before. The result of the process above is the byte of data in the R0 register will be saved in the RAM register that has the address of the binary code in R2.

From here, you can realize how the control unit works in a computer's CPU. It will tell the CPU things that must do to conduct whatever useful things such as addition or save bytes of data in RAM. You can have many interesting combinations of steps for any useful thing yourself. You can manipulate registers, ALU operations, RAM freely.

You can see that having so many steps for only one useful thing such as adding two binary numbers,...So, we will want one way that conducts useful things by only one something. This thing can conduct every step in useful things only by one byte of binary code. The thing that we are mentioning is “instruction”. We will discover instructions in next posts. Thanks for reading and see you later!!!

Đăng nhận xét

0 Nhận xét