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 !!!
The adder is a component in the CPU of computers that helps add binary numbers. The summation of binary numbers can be performed easily, it is similar to decimal numbers. So, let’s review the summation of decimal numbers to understand the summation of binary numbers.
Firstly, let’s conduct adding two decimal numbers as below:
Now, we will analyze this summation. As you know, we will add “3” and “9” first. Because “9” is the largest digit in decimal system and digits in decimal system must work in a “close cycle” (from 0 to 9 and from 9 to 0), so when add “3” and “9”, we will have “2” and remember “1” to the next column on the left of this “2” digit. The remembered “1” digit is the number of cycles (from 0 to 9 and return 0) that digit on the right conduct and “2” is the digit that represents the value in the present cycle (second cycle but not complete second cycle).
Then, we will add “2” and “1” is “3”. The remembered “1” will be added to “3” and the result that we have is “4”. So, in the same way, you can conduct simple arithmetic calculations in binary system like this:
The first three calculations are easy to understand. We will come to the fourth one. Because we are using a binary system, digits in the numbers will work in a close cycle “from 0 to 1 and from 1 to 0”. We have “1” + “1” in the binary system, so the rightmost digit will be “0” and remember “1” to the column on the left of this rightmost digit (because we have finished one cycle in the rightmost digit). So, we have the result “10”.
OK. That is about theory. What about practicing? How can we build a system that can conduct arithmetic calculations in computers? Let’s review all four calculations above, you can see that when two binary numbers are the same, the rightmost digit will be “0”, except when the binary digit is “1”, we will have a more remembered digit. And when two binary numbers are different, the result that we have is “1”.
From the theory above, we can associate it with a XOR gate and AND gate (for carry (remembered digits)) for these simple calculations. So, people have gate combinations as:
Now, let’s check again. If we have different inputs (0 and 1), we will have the sum is 1 and carry is 0, it is true for calculations: 1 + 0 and 0 + 1. If we have the same inputs of 0’s, we will have sum is 0 and carry is 0, it is true for 0 + 0. If we have the same inputs of 1’s, we will have sum is 0 and carry is 1, it is true for 1 + 1.
That is about one-digit numbers in a binary system. How about summations of multi-digits numbers in a binary system. How can we establish gate combinations for them? Let’s look at the example below:
From left to right we have: 1 + 1 = 10, write 0 and remember 1; 1 + 1 = 10, 10 + 1 (remembered digit) = 11, write 1 and remember 1;...Finally, we have “1110” as the result. So, we must have "carry in" for all calculations in the binary system. The gate combination that I introduced does not have a “carry in” part, so it is not a full edition for adder. The diagram below will be a full edition for adder:
Let’s check again for this gate combination. Start with different inputs (0 and 1) with carry is 1, the sum will be 0 and the carry will be 1, it is true. If we have different inputs (0 and 1) with carry is 0, we will have 1 for the sum and 0 for the carry, it is also true. You can try for the remaining situations, it is true completely.
Now, we continue a familiar work that is abstract this adder to use for building larger structures. Let’s look at the symbol for adder below:
But wait!!! We want to build an adder for two one-byte numbers but this adder is only for one bit. What should we do now? We only need to stack them eight times (eight bits = one byte). That is easy to build. Let’s look at the diagram below:
Now, one more time, we abstract it for building more complicated structures in the computers. Look at the simple diagram below:
We have 8-bit numbers for inputs and output. So, we will have a max value of 255 for them. If we have a value of 1 in the carry out, you will have a result that is greater than a byte. This bit will be used in another part of computers.
So, we have discussed adder in the CPU of computers. This is a basic structure that is responsible for adding binary numbers in computers. Thanks for reading and see you later!!!
0 Nhận xét