075582814553
How does the CPU recognize the Code?

FREE-SKY (HK) ELECTRONICS CO.,LIMITED / 02-25 11:11

Hello everyone, I am Rose. Welcome to the new post today. Today I will explain how the CPU recognizes the code to you.

Let's start with discussing semiconductors to introduce this subject. A semiconductor is what?

A diode is an example of a semiconductor, which is something that is in between a conductor and an insulator.

Figure. 1

Figure. 1

However, current cannot flow in the opposite direction from terminal A to terminal C. It serves as a barrier that keeps the current from flowing in the opposite direction.

The diode can be thought of as disconnected when the C terminal is 10V and the A terminal is 0V.

The diode can be thought of as a wire when the C terminal is at 0 volts and the A terminal is at 10 volts. As a result, the current from the A terminal flows continuously to the C terminal, and as a result, the A terminal equals the C terminal=10V.

What, the C terminal is supposed to be 0V and the A terminal is supposed to be 10V? The outcome is that A terminal = C terminal = 10V, as it turns out.

This is the starting state, and as it stabilizes, it will become A terminal = C terminal = 10V.

We can create some intriguing circuits with semiconductors, like [AND gates].

Figure. 2

Figure. 2

At this point, the Y terminal will be directly connected to the 0V spot, causing the Y terminal to become 0V, as long as one of the A terminals and the B terminals is 0V. Only when AB has two 10V ends, no current flows between Y and AB, and the Y end has a 10V voltage.

We refer to this component as a "AND gate" and count the presence of voltage as 1 and the absence of voltage as 0. It doesn't matter what voltage the V is at.

In other words, AB must input 1 simultaneously, and output terminal Y is set to 1; AB has a 0, and output terminal Y is set to 0.

Other similar gates are [OR gate], [NOT gate], and [XOR gate]. The OR gate has an input of 00 and an input of 0 and one input of 1 and one output of 1.

Being that input 0 outputs 1, and input 1 outputs 0, the NOT gate is likewise simple to comprehend.

The XOR gate is a little trickier to comprehend, but that's just how it is. Outputs are produced from inputs 01 or 10, input 00, or 11, respectively. (that is, if two input values are the same, 0 is output; if two input values are different, 1 is output.)

We won't show you how to make any of these gates because diodes can be used to create them all. Friends who are curious can give it a go. Additionally, drawing diodes repeatedly is a bother, so we condense the gate circuit into the following symbols.

Figure. 3

Figure. 3


The CPU can then be created using the gate circuit. Of fact, creating a CPU is still a challenging task. The adder is a good place to start.

The adder is a circuit that performs addition, as its name suggests. The following one is the simplest.

Figure. 4

Figure. 4

The adder can only calculate 0+0, 1+0, or 1+1 because AB can only input 0 or 1.

Binary 1+1=10, the output S denotes the outcome, and C indicates if a carry has happened. Currently, C=1 and S=0.

Is there any satisfaction in adding 1+1 after spending the most of the day doing it?

Calculating 1+2 (binary 01+10) further revealed a new issue: the second bit must address any potential issues that the first bit may carry, necessitating the creation of a full adder.

Figure. 5

Figure. 5

It would be difficult to draw this way each time, so let's make it easier.

Figure. 6

Figure. 6

In other words, there are three inputs and two outputs: the two numbers to be added and whether to carry the preceding digit are inputted first, followed by the result and the decision to carry.

Then we tie this whole adder to a string.

Figure. 7

Figure. 7

We have a four-digit adder that can compute the sum of four digits, or 15 + 15. It is now at the intermediate class level for kindergarten. Is it especially potent?

Let's create a multiplier after the adder is finished. Multiplying any decimal number is, of course, a little challenging. Let's start by multiplying by two.

By two, you can multiply extremely easily. A binary number is multiplied by two by the addition of a 0 after it.

for instance:

5=101 (2) 10=1010 (2)

Thus, we just need to multiply the input by two and advance the input ahead by one before adding a zero to the lowest bit. You only need to be aware of what is happening; I won't draw the precise logic circuit schematic.

How about a 3x multiplier? It's easy; just shift once (multiply by 2), then twice. How about a 5x multiplier? Initially, (by 4) twice, and then once.

As a result, software implements multiplication using a combination of displacement and addition; multiplication is not possible with ordinary basic CPUs. This is a little too far; let's keep using the CPU.

Now imagine you have a module that shifts by one bit and an 8-bit adder. You're done after you string it up!

(A+B)X2\sAX2+B

It's easy; all you have to do is adjust the wiring between the displacement and adder modules and change input A so that it enters the adder after passing the displacement module.

What? ? ? ? What are your thoughts? Do you imply that if I alter the program, I have to rewire?

What do you think, then? All programming requires is back-and-forth plugging of the wire.

Figure. 8

Figure. 8

Unexpected or not? Unintentional or not?

Early computers took only a few minutes to program but required days of plug-in time. Additionally, plugging in is a laborious task that requires patience and precision. In order for the CPU to add or multiply by two in accordance with the instruction, it must be improved.

Here, we introduce two additional modules. The first is called flip-flop and is denoted by the initials FF; flip-flop appears to be the name in Chinese.

Figure. 9

Figure. 9

This module's purpose is to store 1-bit data. For instance, input 1 will clear the RS-type FF from above where R stands for Reset. Enter 1 to save 1 once S is set. The material you just saved will always be output when all of the RS inputs are 0.

One bit is clearly insufficient, but we can use 4 or 8 in parallel to save 4 or 8 bits of data. We use FF to record the intermediate data of the calculation (it can also be the intermediate state or something else). We refer to this as the register (Register).

The other is referred to as MUX, or selector in Chinese.

Figure. 10

Figure. 10

Simple: input 0 to produce the data of i0, output whatever i0 is, and i0 might be 01 at this point. The data from i1 will be output if sel is input 1, too. The selector can, of course, be very long, like this four-in-one-out

Figure. 11

Figure. 11

I won't delve into the specifics of the principles here. In reality, by thinking about the logic diagram, you can comprehend it. Knowing that there is such a thing is sufficient.

With this, we can create a multiply-by-2 module and adder activation pin (displacement).

This activation pin's input 1 turns the module on, while input 0 turns it off. By doing this, we may decide whether data enters the adder or the displacement module.

Therefore, we started by creating 8 CPU input pins, 4 bits of instructions, and 4 bits of data.

We create 3 additional instructions:

Data is read into the register at 1:00.

0001, the register is updated with the data, and the outcome is recorded.

0010 shifts the register data one bit to the left (by 2)

Why was this design chosen?

We can create an activation pin for each module, as I mentioned earlier. The activation pins for the register, adder, and shifter can then be connected to pins 2, 3, and 4 of the instruction input, accordingly.

In this method, the register input is active when the 0100 instruction is entered, while other modules are deactivated 0 and the data is stored in the register. Similar to this, the adder begins to operate when we enter the instruction 0001, allowing us to complete the addition operation.

The short answer to the question's first sub-question is as follows:

How are these secondary numbers made understandable to the CPU?

Because of the way the CPU's internal lines are connected, the CPU can comprehend it. You enter a binary number, turn on a number of predetermined CPU modules like switches, switch between these modules, and then you obtain the outcome.

Several queries that might be posed

The CPU may contain thousands of tiny modules. That many can a 32-bit/64-bit instruction control?

A: Since the CPU in our sample only has 3 modules, we linked them directly. The actual CPU will include a decoder that converts the instructions into the necessary format.

What happens if I enter the command 0011 into the straightforward CPU you used as an example?

A: It goes without saying that when the adder and the shifter are turned on simultaneously, unforeseen results will occur. Simply said, the repercussions are at your own responsibility if you follow an order that was poorly written. (There is a good chance that this may crash if done on a real CPU. There must, of course, be numerous defensive designs. Careful friends may discover a problem: the instructions you designed will fail if you pass away.

[0001, adding the data to the register and saving the outcome to the register]

Can't complete this step? There is a write-back procedure after all, which is true. A single instruction is carried out by the straightforward CPU we created in almost three steps: reading the command, carrying it out, and writing the register.

Read instruction (IF), decode instruction (ID), execute instruction (EX), memory operation (MEM), and write register are the five steps of the traditional RISC design (WB). The x86 CPU we typically use has instructions that can be broken down into as many as 20 stages.

You can see why there would be such a switch. The CPU will move when we click it. The CPU will operate at a faster rate the faster you press it. Modern CPUs operate at speeds of above 2GHz, or over 2 billion clicks per second.

Even if you can press it that quickly, the stability of the heat rise will decrease and the power consumption will significantly increase.

How does the CPU determine its location? I thought I had introduced FF before. This can be used to store intermediate states, or where to go, in addition to intermediate data.

The specific design uses FF to construct FSM (finite-state machine), which is the theory of finite state machines. This is also a crucial component. Although the exam is required, it has little bearing on the subject, therefore I won't discuss it here.

Adding to what we just discussed, there are now three instructions. Let's attempt to compute (1+4)X2+3.

0100 0001 ; register is stored in 1

0001 0100 ; the number of the register plus 4

0010 0000 ; multiply by 2

0001 0011 ; plus three

In truth, controlling the CPU with a software is a highly sophisticated idea. The computer's (device's) CPU had previously been developed independently.

When the American business in charge of creating the CPU decided that it would be stupid to reinvent the CPU every time a Japanese company, BUSICOM, wished to create a program-controlled calculator, the two parties collaborated and launched an epoch-making device in 1970. The 4004 was the first microprocessor.

The world was altered by this architecture, and the American company that created the CPU gradually grew to be an industry juggernaut. Oh, it's Intel, that one with the beep, isn't it?

Let's organize the program right now.

01000001000101000010000000010011

You bring it to the CPU, input it, and I'll be ready to go play in the gym with the kindergarten class. What? Can the kids break their fingers and figure it out if we lose?

Machine language cannot possibly be so anti-human. Machine language (also known as machine code) is the only language that the CPU can comprehend and is made up entirely of the digit 1. However, if you translate machine language into a language that people can understand, it will instantly become a classic. Nobody can handle it.



Processed in 0.657625 Second , 23 querys.