Chapter 35 Half and Full Additives

35.

After Cheng Li finished speaking, everyone's eyes became hot.

"This ...... I can understand the logical operation, but how can I make four operations with this logical operation?"

With this puzzlement and curiosity, everyone watched Cheng Li's demonstration intently.

As a result, more and more people gathered in this room, and finally even the room could not be stuffed, and even the outside passage was crowded with many admiring people.

In the face of so many people, Cheng Li still did not panic, but began to form an adding machine at his own pace.

Then Cheng Li also explained to the old man while forming it.

"For the sake of explanation, here I use the symbol '0' instead of yin, and the symbol '1' instead of yang. Cheng Li said first.

Because there are no Arabic numerals in this world, and Cheng Li is used to using Arabic numerals, he still noted them first.

"In order to achieve addition through logical operations, you first need to decompose binary addition operations. ”

So, let's take a look at the binary addition of 1 digit numbers first. ”

0+0=0

0+1=1

1+0=1

1+1=10。

That's the binary addition of 1 digit, a list of all cases.

Compared to the decimal system, it is undoubtedly much simpler.

We can make a small improvement to the binary addition table above, that is, the results are uniformly expressed in two digits.

It becomes:

0+0=00

0+1=01

1+0=01

1+1=10

In this way, the addition of binary digits results in two digits, which become "and" and "carry", respectively. ”

Cheng Li wrote this binary addition table on a blackboard handed over by the old man.

"In this way, we can split the binary addition table into two tables. ”

The first one is the 'and' table:

0+0=0

0+1=1

1+0=1

1+1=0

"It can be seen that this 'sum' table is the result of taking out the last digit of the result in the binary addition table. ”

The second is the 'in' table:

0+0=0

0+1=0

1+0=0

1+1=1

"It can be seen that this 'incoming' table is the result of removing the first step of the result in the binary addition table. ”

At this time, the old man was very keenly aware that the split 'in' table was very similar to the logic of 'and door'!

So the old man said a little excitedly.

"This entry table is very similar to the output of 'and door'. ”

The logic of 'AND gate' is.

Two yin is yin.

Two yangs are yangs.

One yin and one yang is yin.

Yin is 0 and Yang is 1.

So in fact, if the 'AND gate' logic is represented by 0 and 1, it is:

0+0=0

0+1=0

1+0=0

1+1=1

And this is exactly the manifestation of the 'incoming' table!

"In other words, we can use the 'and door' spiritual path to calculate the carry in binary addition calculations!" said the old man excitedly.

Cheng Li said in his heart, he deserved to be the person with the deepest attainment in yin and yang arithmetic on Qingling Island, and he reacted so quickly.

So Cheng Li exclaimed: "That's right, that's right." ”

At this time, the old man set his sights on the "and" table.

Then he looked at it for a long time, but he didn't find a door spirit road that could match the "and" table.

"The binary 'and' table is more complicated to implement with the door spirit road, and it takes several steps. ”

Cheng Li began a series of dazzling operations, and one spirit path after another was continuously constructed in Cheng Li's hands.

"First of all, it is necessary to connect a 'and door' spiritual path and a 'non-door' spiritual path to form a 'and non-door' spiritual path. ”

The spiritual path of "and non" is a derivative of the spiritual path of the door, which is formed by the series of "and door" and "non door", and this concatenation form is to carry out the "and" logical operation first, and then carry out the "non" logical operation, that is, the first and then the non.

Because, the "and" logic is:

0+0=0

0+1=0

1+0=0

1+1=1

Take the result of this logical operation and then use all the "non" logic operations once, and you will get it.

0+0=0→1

0+1=0→1

1+0=0→1

1+1=1→0

And this is the output result of the NAND gate.

"The output of this 'AND gate' still doesn't match the 'AND' table, so we need to pile it up further. ”

"So, next, we're going to do parallel to the 'non-gate' spiritual path and the 'or gate' spiritual path......"

"Then, the spiritual path that has been connected in parallel is connected to a 'and door'. ”

Cheng Li further spliced the spiritual path.

When the NAND gate and the OR gate are connected in parallel, you get two outputs.

If the parallel spiritual path is connected in series with an "AND door", then the output result equivalent to "AND AND Gate" and "OR Gate" becomes the input data of the "AND Gate" spiritual path.

We already know:

The output of NAND Gate is: 1, 1, 1, 0.

The output of OR Gate is: 0, 1, 1, 1.

If these two outputs are used as input data, they will become if they are calculated by the AND gate logic in one pass.

1+0=0

1+1=1

1+1=1

0+1=0

"And, 0, 1, 1, 0, that's what we want the 'and' table result!"

"So, just connect an NAND gate and an OR gate in parallel, and then concatenate it with an AND gate, and you can get the result of a 'and' table required for binary addition!"

"And this special spiritual path that can get the results of binary addition' and 'table' also has a special name, called 'XOR' spiritual path!"

After Cheng Li's resounding words ended, everyone at the scene was silent, there was silence on the field, and everyone was deeply shocked.

The charm of logic shines in this world for the first time.

The people on the scene are all people who have a certain degree of yin-yang arithmetic attainments, so they can feel the incomparably profound inner truth from the complicated operation demonstrated by Cheng Ligang!

So, for a while, everyone fell into deep thought and couldn't extricate themselves.

Cheng Li didn't care so much, but continued to make his own adding machine.

At this point, our next step is to connect 'AND door' and 'XOR gate' in parallel. ”

"'AND Gate' outputs carry results, and 'XOR Gate' outputs and results. ”

"In this way, we get a half-adder. ”

"A half-adder, which can only do binary addition calculations of 1 digit, and there is no way to scale. Obviously, the usefulness is low, and we need to improve it further. ”

Cheng Li said as he carried out a more complex spiritual path construction operation.

Gradually, the spiritual path on the ground became more and more complex and huge, and unconsciously, there were dozens of basic logic gates spiritual paths, which were connected in series and parallel by Cheng Li in various ways, making the people around them already a little dazzled.

"Uh-huh, so connect the two half-adders, plus a carry input, and we get a full adder. ”

"A full adder can do 1-bit binary addition, but compared to a half adder, a full adder has room for expansion.

"As long as you connect 2 full adders together like this, you can calculate the 2-bit binary computation......"

"So, the next thing is the stacking of quantities, and if you want to achieve 8-digit binary calculations, you need to build a total of 8 full adders and 144 spirit relay devices.

"It's going to take a while, you guys wait a little longer......"

Cheng Li began to keep busy, and a world's most primitive spiritual power computer was gradually forming in Cheng Li's hands!

======

(These chapters are too difficult to write, I basically spent the entire National Day holiday looking for information, didn't go out to play, but held a few programming books to gnaw, rabbits have always been more rigorous in writing books.)

For the sake of the rabbit being so serious, let's vote for the rabbit more!)