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 !!!
We learned about XORER in a previous post. This is a device that has eight XOR gates, receives two bytes as inputs and derives one byte as output. You can see the structure of this device again in diagram below:
Our comparator will be built based on this XORER. You knew the function of this device in a previous post. Now, we will build the comparator in this post. Before constructing a comparator, let’s mention its special features. Look at the diagram and read the explanation below to understand:
Comparator will have eight components that each of them connect to the below component through two wires labeled “equal” and “‘a’ larger” (‘a’ is the bit in “a” byte), you can see that thing easily in the diagram. The “1” bit and “0” bit will connect in order to the “equal” and “‘a’ larger” part of the first component. And the last component will not connect to any other components, it will output two bits for this comparator.
How do each component of the comparator work? OK. As you can see in the diagram, each component will receive two corresponding bit inputs (the first bit of the first byte and the first bit of the second byte; the second bit of the first byte and the second bit of the second byte;...) from two bytes that we are comparing. And let’s look at the structure of one component in the comparator as below:
You can see two bit inputs will go into a XOR gate and also have a “c” output of XOR gate. It looks similar to XORER. But, this structure has more gates than XORER. Assuming we are examining the first component of the comparator, the “equal” signal coming to “3” gate will be “1” and the “‘a’ larger” signal coming to “5” gate will be “0”.
If two bit inputs of the first component are equal, the “equal” wire will still be “1” (“on”) and the “‘a’ larger” wire will still be “0” (“off”). The “equal” and “‘a’ larger” wires will connect to the second component. As you can see in the diagram above, these wires will be used as inputs for “3” AND gate and “5” OR gate of the second component.
OK. It’s easy to understand. Now, coming to the second component that has a similar structure and lies immediately below to the first one. The “equal” wire of the first component (bit “1”) will be the input of “3” AND gate and the “‘a’ larger” wire of the first component (bit “0”) will be the input of the “5” OR gate.
If two bits input of the second component are equal, you will see that the "equal" and "'a' larger" wires from this component will also be "1" and "0" in order. And they will be the inputs for the "3" AND gate and the "5" OR gate of the third component.
And from here, you can see that if all pairs of bit inputs are equal, the “equal” and “‘a’ larger” wires that output from all components in the comparator will always be in order “1” and “0”. And the last component will output bits: “1” for “equal” and “0” for “‘a’ larger”. That’s true because if all pairs of bit inputs are equal, two input bytes will be equal and “a” byte is not larger than “b” byte.
We checked the case that two bit inputs are equal. Now, we will check the case that two inputs are not equal for the second component. If two bit inputs are not equal, the “not same” wire will be “1”, the “same” wire will be “0”. So, the “equal” wire that comes from the second component will be “0” and you can see that from now on, the “equal” wire of all below components will always be “0” because it serves as an input of AND gate for the next below “equal” wire. And the last component will output “0” for this case.
It’s easy to explain. Once bit inputs are not equal, “a” byte and “b” byte will not be equal surely. And the output “0” for the “equal” bit is suitable. What about “‘a’ larger” wire? Haha, it’s also easy. We have two situations: ‘a’ bit is “1” and ‘a’ bit is “0”.
Firstly, if ‘a’ bit is “1” and ‘b’ bit is “0”, the output of “4” AND gate will be “1” clearly (the “not same” is “1” and the “equal” from the first component is “1”). And the output of “4” OR gate (the “‘a’ larger”) will be “1”. Because this “‘a’ larger” wire will be as an input of below “4” OR gate of the next below component, so the “‘a’ larger” will always be “1” from now on for all components. So, the last component will output “1” for “‘a’ larger” bit of this comparator.
This thing is also easy to understand. For example, with two bytes of “1000000” (128) and “0111111” (127), you can see that the byte of “10000000” is larger because the first bit of the first byte is “1” while the one of second byte is “0” and we do not need to compare two bytes anymore. The “a” byte is always the larger byte!!!
Secondly, if ‘a’ bit is “0” and ‘b’ bit is “1”, the “‘a’ larger” wire will be “0”. Oh my god! Clearly the “b” byte will be larger than the “a” byte now but if “a” byte has one ‘a’ bit that is larger than ‘b’ bit of “b” byte later, “‘a’ larger” wire will be “1” and “a” byte will be larger than “b” byte? No, that thing will not occur because once two bit inputs are different, the “equal” wire will be “0” forever and thus the output of “4” AND gate will be “0” forever. There is no chance for later bits comparison!!!
So, this situation will output “0” for “‘a’ larger” wire. We also have “0” for “equal” wire. From those things, we have the “b” byte will be the larger byte.
Now, we will abstract this comparator to use for constructing larger devices in computers. Let’s look at the diagram below for this abstraction:
We also mention another structure that determines whether the byte in the bus is zero. This structure will comprise one OR gate that receives eight inputs and one NOT gate that connects to the output of the OR gate. Look at the diagram below to understand about this structure:
On the right of the picture is the full diagram of this structure. You can see that the zero output will be “1” when and only when all eight inputs are “0”. So this structure is called simply “zero”.
On the right of the picture is the abstraction of this structure and you can use it to build larger structures in the next post. I hope you like my post. Thanks for reading and see you later !!!
0 Nhận xét