Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Illustration | you call this stupid thing a computer?

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > IT Information >

Share

Shulou(Shulou.com)11/24 Report--

This article comes from the official account of Wechat: low concurrency programming (ID:dibingfa). Author: flash.

Xiao Yu and I are in puppy love. We live next door.

First, code and circuit-signal conversion parents will confiscate the phone at night, but we still want to continue to chat, but do not dare to make a sound, so we came up with this way.

We express all the Chinese with the combination of the light bulb, and agree to read and record the status of the light bulb every other second. This is our code.

Me: bright off and off

Joy: extinguish the bright and bright.

Huan: turn on and off

You: the light goes out

In this way, although we do not have a mobile phone, we can still chat day and day, although the efficiency is very low, but still very happy.

Xiao Yu and I inadvertently converted the language into a combination of light bulbs, a process called coding.

Second, the connection of the door circuit-the connection of the signal Xiao Yu and I kept talking in secret until we went to college, and our parents could no longer control our use of mobile phones.

But after so many years of small light bulb calls, we always felt that things were not so simple, so we started some new exploration.

We added a switch. At this point, the light bulb will only light up when the two switches are closed at the same time.

In this way, the relationship between the two switches and the light bulb is no longer the simple corresponding relationship before, but there is logic.

The opening and closing of the switch correspond to the disconnection and connection of the circuit respectively. The lack of light and light of the small light bulb also corresponds to the disconnection and connection of the circuit respectively. Then the two can be unified and no longer rely on specific physical performance.

In addition, the connection and disconnection of the switch is active. The connection and disconnection of the small light bulb is passive and the result.

We call the connection and disconnection of the switch as the input, the connection and disconnection of the light bulb as the output, and encapsulate the whole circuit in a graph, which can be abstracted as follows:

We decided to call this circuit a gate circuit, and the one above is called a gate.

For a more abstract exploration in the future, we represent the circuit connectivity as the number 1 and the circuit disconnection as the number 0.

We call this representation binary.

Enter A

Enter B

Output

0

0

0

0

one

0

one

0

0

one

one

one

Slowly, we found more and more ways to play.

The above circuit, I abstracted it into the following gate circuit shape, called OR gate.

After that, it got out of hand. Xiao Yu and I designed more and more gate circuits, and we found that as long as it was a logical relationship that we could think of, we could design corresponding gate circuits.

3. Adder-the decimal number of the signal can be converted into a binary number, and the binary number can correspond to the input and output of the gate circuit.

So Xiao Yu and I had a bold idea. Can we design a circuit for calculating addition?

Let's start with the simplest addition of one-digit binary numbers:

0: 00: 1: 1: 1: 1: 1: 1: 1: 1: 1: 1: 1: 10

Into a table as follows

Add A

Add B

Add and output

Carry output

0

0

0

0

0

one

one

0

one

0

one

0

one

one

0

one

That is, we need to design a circuit that can achieve the input and output effects in the table.

After unremitting efforts, it is finally found that this circuit can be composed of XOR gates and and gates.

This device implements a binary one-bit addition, but it is not perfect, because only the carry output of these two numbers is considered, but the carry of the previous bit is not taken into account, so it can only be called a semi-adder.

If the previous carry is taken into account, it is only necessary to add one and a half adder and splice one or door.

At this point we have built a perfect one-bit adder and proudly call it a full adder.

After the full adder is made, no matter how many bits the adder can be made, you just need to put the full adder together one by one. We try to make an eight-bit adder.

OK, it is done, with the adder, you can theoretically achieve any mathematical operation.

Because we know that multiplication can be converted into addition, division into subtraction, and subtraction into complement addition. Now we can proudly call this part the arithmetic logic unit ALU.

Fourth, clock-signal concussion Xiao Yu and I are very happy, and finally use the circuit to achieve the calculation function.

But slowly felt that it was no longer interesting, so we had a whim and designed the following weird circuit.

When closing switch A, the whole circuit is connected, switch B will be sucked off, the whole circuit will be disconnected, the electromagnet will lose magnetism, switch B will pop up again, and the circuit will be connected again, and switch B will be sucked off again.

In this way, switch B continues to cycle quickly between opening and closing, and we never interfere with the circuit, so the circuit has the characteristic of self-feedback.

Because the switch B oscillates back and forth, we call this circuit an oscillator. Because it can produce constantly changing electrical signals, running as constantly and regularly as a clock, we also call this device a clock. The alternating electrical signal it produces is called a clock signal.

Fifth, RAM-- save signal although there is an adder, but where does the input number come from? Can you keep it somewhere first?

After many experiments, Xiao Yu and I invented a very complex circuit:

If the input is 1 and the "control side" signal is changed (the signal changes from 0 to 1), the output becomes 1, and then the output still maintains (stores) the original 1.

If the input is 0 and the "some control side" signal is changed, the output becomes 0, and then the output still maintains (stores) the original 0.

It doesn't matter if you don't understand, as long as you remember the design of this circuit and realize the one-bit storage function! We call it a 1-bit latch.

Then we combine multiple latches and add some circuits such as 3-8 decoders and 8-1 selectors to achieve a memory that can hold 8-bit binary and can read and write it randomly. We call it RAM, or memory for short.

By reassembling this component, an N × M RAM array can be formed. For example, we can represent a 1024 * 8 RAM array.

This represents a storage capacity of 1024 units, each with 8 bits.

To make it easier to express, we specify 1024 = 1K byte 8 bits = 1 byte (8 bit = 1 byte), so we can say that the storage capacity of this RAM is 1K units, each unit is 1B. In other words, the address space is 1K and the storage capacity is 1KB.

At this point, the RAM module is almost perfect, and we can even use it alone to store the data in an address and read out the data in a certain address.

How is it convenient for people to operate? You only need to connect the address input, data input and write operation to a control panel, and the switch can control whether the input of these signals is 1 or 0, and then connect the data output to some light bulbs for easy observation. such a separate storage device that can be operated manually is done. (there are colored eggs in the picture below)

With read-write memory, we can store several numbers in memory beforehand. Next, can we let the arithmetic logic unit ALU automatically read this number and add it?

Sixth, program-Automation We first introduce a new component, 10-bit counter, where the Clk is connected to the clock signal we talked about in the fourth part, Clr is the zero-clearing end, the specific effect is clear at a glance.

The output of the counter is 0pl _ 2pm _ 3pm _ 4pr _ 5, which can be used as an address in memory.

We connect this counter, as well as the ALU and RAM mentioned above, and try to implement a device that can accumulate and sum.

What we want to calculate is 1 "2" 3 "4" 5 "6" 7, which is how this automated calculator works.

1. Using the control panel to store the numbers 1: 7 at the address 0x6 of RAM has been realized in the previous section.

2. When the value of the counter is 0, data 1 is output to the adder for calculation. At this time, the adder 1 is calculated, and the calculation result is 1, but remember that the latch stores the output 0 of the last adder. This calculation will wait until the next time the latch encounters the rising edge signal.

3. When the value of the counter is 1, data 2 is input to the adder, and the latch stores the last calculation result 1, and outputs this 1 to the small light bulb, and sends it back to the B of the adder at the same time, so at this time, the adder Apati2 is the last one, and the calculation result is 3.

4. When the value of the counter is 3, and so on, see the following figure

We automate the process of cumulative summation! After that, if you want to calculate the sum, you just need to use the control panel to store the data in memory in advance. Isn't it convenient?

Program instructions We also want more automation!

Now this device can only add up the data in RAM from beginning to end, and can't choose which one to add or when to stop.

For example, the data in our RAM is like this.

Address (hexadecimal)

Data (decimal)

0x00

...

0x01

ten

0x02

...

0x03

twenty

0x04

thirty

0x05

...

...

...

We just want the data at the blue address of the RAM to accumulate, the data from other places to be ignored, and stop at the RAM 0x05. What should we do?

We can add another RAM, the data stored in this RAM, to express the meaning of "instruction"!

Let's invent three instructions first.

Add: accumulate the values at the position of RAM

Nop: ignore the value here (that is, do nothing)

Halt: stop (disable adding one to the value of the counter)

So in order to achieve the above functions, the data in the corresponding instruction RAM should be like this.

Note: there is an one-to-one correspondence between the address of the following instruction RAM and the address of the data RAM above!

Address

(hexadecimal)

The value of the instruction RAM

Instruction meaning

0x00

Nop

Do nothing

0x01

Add

Accumulate

0x02

Nop

Do nothing

0x03

Add

Accumulate

0x04

Add

Accumulate

0x05

Halt

Stop it

...

...

...

We need to introduce a control unit and put it in the following location.

If you encounter the nop instruction (0x00), the output disables the W bit of the latch and does not allow the latch write operation, so that the cumulative result will not be entered.

For example, if the input is halt instruction (0x05), the EN bit of the counter is prohibited, and the counter + 1 is not allowed, so the effect of stopping is achieved.

At this point, if the clock signal is oscillated again, the selective summation process can be achieved and hover at the specified position. Now let's vibrate the clock signal and take a look at the process. (only key components are left here)

How to implement this control unit? We know that any component can be built as long as the input and output are given. This article will no longer be carried out.

With three instructions, we know that through instructions, together with a variety of complex controllers, we can automate all operations.

The next thing we need to do is to design the controller and agree on a lot of instructions so that any automatic computing operation can be realized through the arrangement and combination of these instructions.

We're going to design a lot of instructions.

It's called instruction set.

The functions that can be achieved by arranging and combining instructions

Called a program.

The process of arranging and combining instructions

Called programming.

We will arrange and combine the people who combine these instructions.

Called a programmer.

And what is the name of the device that we will carry all this?

Yeah, this damn thing, it is.

Meter

Calculate

Machine

This article comes from the official account of Wechat: low concurrency programming (ID:dibingfa). Author: flash.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

IT Information

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report