跳到主要内容

How Simple On/Off Switches Store the Digital World | Working of Computer Memory(原声文稿)

· 阅读需 13 分钟
Science Simplified 4 All

Have you ever wondered how computer memory actually works?

Today, all the books you could read in your lifetime can fit into a single tiny memory chip.

And it is not just books, your photos, music, movies, bank details, even your passport or medical records, almost everything about you, now lives in digital form.

But how does this digital memory really work?

We have all heard that computers use a binary language.

But how can just two numbers, zero and one, represent such a wide variety of data?

Back in the early days, when we tried to know more about these machines, the only answers we got were confusing diagrams and technical terms like CPU, memory unit and so on.

Today, everyone carries a computer in their pocket in the form of a smartphone, yet hardly anyone knows the simple secret behind it all.

In this video, I will break down how computer memory really works in the simplest way possible.

And by the end, you will see how the simple idea of on and off builds our entire digital world.

Hi friends, welcome to a new video on science simplified for all.

We often hear the computers work using the binary system.

That means a computer has only two numbers to deal with, zero and one.

Every book, every picture, every song, every movie stored inside a computer is represented only by these two numbers, 0 and 1.

But how does that really happen? Let us understand this with a simple example.

Imagine you are standing on a quiet road where not many vehicles pass.

Someone asks you to count how many cars go by in one hour. You cannot just count.

You must also record the number somehow, but you are not given a notebook or pen. Instead, you are given four light bulbs, each with its own switch. You can turn each bulb on or off whenever you like.

At the end of one hour, you must use these bulbs to show exactly how many cars passed.

You can do this in two ways.

First method, switch on one bulb for the first car, the second bulb for the second car and so on.

This works fine, but only up to four cars.

Once all four bulbs are on, you cannot record any more.

If a fifth car passes, you have no way to show it. So there is a second method.

When the first car goes by, you switch on the first bulb.

When the second car comes, you switch off the first bulb and turn on the second.

For the third car, you keep the second bulb on and also turn on the first again.

For the fourth car, you turn off both the first and second bulbs and turn on the third bulb.

For the fifth car, you keep the third bulb on and switch on the first again.

If you continue like this, only when the 15th car passes will all four bulbs be on.

That means with four bulbs, you can represent numbers from 0 to 15.

In other words, four bulbs with on and off states can create 16 different combinations. These combinations are shown in this table.

When all bulbs are off, that represents zero. When all are on, that represents 15.

Any other combination in between represents a number between zero and 15.

So with just four bulbs, you can not only record the number, but anyone else looking at the bulbs later can also read the same number from it.

This is very similar to how a computer's memory works.

We often say that computers use binary and that memory is stored in zeros and ones.

But in reality, there are no actual zeros and ones inside the computer. What exists are only two states, on and off.

We call off zero and on one.

In our bulb example earlier, a glowing bulb can be called one and an unlit bulb can be called zero.

In that case, this table can also be written in the form of zeros and ones as shown here. That is why we call it the binary system.

But remember, at its core, there are no actual ones and zeros. It is simply on and off states.

In the bulb example, to read the result, we had to look with our eyes and see which bulbs were glowing.

But now imagine that instead of bulbs, we are using devices called capacitors.

Some of you may already know what a capacitor is.

For those who do not, you just need to remember this.

A capacitor is a tiny device that can temporarily store a small amount of electric charge. You can think of it like a miniature battery.

The difference is that, unlike a battery, a capacitor can charge and discharge very quickly, though it cannot hold that charge for long.

Now, let us replace the four bulbs with four capacitors. Instead of switching on a bulb, we charge a capacitor.

Instead of switching off a bulb, we discharge it.

If all four capacitors are discharged, that represents zero.

If all four are charged, that represents 15.

The intermediate states work exactly like they did in the bulb example.

The advantage now is that we no longer need to count glowing bulbs with our eyes.

We can simply connect an electrical circuit and it can detect which capacitors are charged and which are not.

That means the number stored in these capacitors can be read directly by a circuit.

In short, these capacitors can be used to store any number between 0 and 15 and we can read that number whenever needed.

This is in principle how computer memory stores data.

Instead of bulbs, computers use capacitors and to control the flow of charge into and out of a capacitor, capacitor.

They use electronic switches called transistors.

Instead of the mechanical switches, we used in our example.

So the smallest unit of memory is made up of a single capacitor and a single transistor.

Millions and millions of such units are combined to make up computer memory.

In this system, a charged capacitor is called a 1 and a discharged capacitor is called a 0.

This is what we mean when we say, computers use the binary system.

The smallest unit made of one capacitor and one transistor is called a bit, and each bit can only exist in one of two states, 0 or 1.

If this much is clear, we can now move to the next stage. Now the next thing we need to understand is this.

How do different types of data like text, images and more get stored in this simple on and off format, or in other words in the binary format of 0 and 1?

From here on in the video, we will mostly use the terms zero and one.

Remember, one means either a glowing bulb or a charged capacitor.

Zero means either an unlit bulb or a discharged capacitor. Keep this picture in mind.

Earlier, we saw that with four bulbs, we could form 16 different combinations.

That meant we could represent numbers from zero to 15.

By the same logic, if we had eight bulbs, then 256 different combinations would be possible. Here is why.

A single bulb has two possible states, on or off.

With two bulbs, the total combinations are 2 times 2 equals 4.

With three bulbs, 2 times 2 times 2 equals 8 combinations.

With four bulbs, 2 to the power of 4 which equals 16 combinations. That is what we saw earlier.

So continuing this pattern with 8 bulbs, we get 2 to the power of 8 equals 256 possible combinations.

That means with 8 bulbs, we can represent every number from 0 to 255.

This combination shown here represents 0 and this one represents 255.

All the other states in between represent the numbers from 1 to 254.

With these 256 combinations, we can represent everything that qualifies as text.

Capital and small English alphabets, numbers from 0 to 9, punctuation marks like full stop, comma, apostrophe, and even special characters such as number sign or asterisk.

There are standard systems for this. And one of the most widely used is called ASCII code.

According to ASCII, every text character and symbol is assigned a unique code between 0 and 255.

The table that lists all these codes is called the ASCII table.

For example, the capital letter A has an ASCII code of 65.

If you open a word file, hold the ALT key and type 65. The letter A will appear on the screen.

In this way, every character in the table can be typed using its ASCII code.

Each ASCII code also has a corresponding binary code.

For the letter A, the ASCII code is 65 and this is its binary form.

When you type A on the keyboard, what actually happens inside the computer's memory is that 8 capacitors switch to a particular on -off pattern that represents this binary number.

That on and off state of the capacitors is what becomes the computer's version of the letter A.

So to represent a single character, 8 bits are required, that is, 8 capacitors. This set of 8 bits is what we call a byte. One character equals 1 byte of memory.

If you create a new text file and type only the letter A, the size of that file will be 1 byte.

If you type, hello, 5 letters, the file size will be 5 bytes.

This calculation works exactly if you do it in command prompt or in older DOS systems.

In Windows however, the file size will appear larger because Windows automatically adds extra formatting information.

The important point is this, whenever we type any text, every character has a corresponding ASCII code. That code has a corresponding binary code.

And in memory, the on -off states of capacitors represent that binary code.

This is how all text content is stored inside a computer.

Now let us see how an image or a picture is stored in computer memory.

Things change a little here because images need to represent different colors.

Inside a computer, an image is created by putting together tiny dots called pixels.

If you zoom into an image closely, you can see the individual pixels that make it up.

Suppose we have an image that is 100 pixels wide and 100 pixels tall.

That means the image has a total of 10 ,000 pixels. Each of those pixels can have its own color.

So when storing an image, it is not enough to save only how many pixels there are. The computer must also save the color of each pixel.

For now, let us assume we are using a computer with an 8 -bit color system. That means each pixel will be defined by 8 bits.

Earlier, we saw that 8 bits can create 256 different combinations.

With these combinations, we can represent 256 different colors. These are the colors shown here.

The very first color corresponding to this binary code is black.

The last one, the 256th color is white.

All the other colors fall in between, each mapped to its own binary code.

So in the 8 -bit color system, each pixel is represented by 8 bits.

For example, if the first pixel of our image is white, its binary code will look like this.

In this way, every pixel in the image has its own 8 -bit binary code.

Since 8 bits make 1 byte, each pixel requires 1 byte of memory.

That means for our example image with 10 ,000 pixels, the file size will be 10 ,000 bytes, so the image you see on your screen with all its colors is ultimately stored in a computer as nothing more than zeros and ones.

In other words, it is stored as a set of capacitors, each in one of two states, on or off.

We have now seen how text is stored and how images are stored and the difference between them.

In the same way, there are specific methods for storing music and for storing video.

But in the end, no matter what type of data it is, everything in a computer is stored in the same simple way, as on and off states.

What we have explained so far is the most basic and simple way to understand how computer memory works.

In reality, modern computers function in ways that are a little more complicated. Let me quickly mention some of those differences.

Earlier, when we spoke about storing image colors, we considered an 8 -bit color system. That system can only produce 256 colors.

But this gives only one or two shades for each main color.

For example, the ASCII table of 8 -bit colors might show only three or four shades of yellow and red.

But if we want to display a picture of a sunset, we need a smooth transition from yellow to red with many shades in between.

That is not possible with only 8 bits.

That is why today's computers use a 24 -bit system, often called the true color system.

Here, 8 bits are used for red, 8 bits for green and 8 bits for blue, together making 24 bits.

With this system, 256 times 256 times 256 equals 16 .7 million colors are possible.

Of course, as the number of colors increases, the file size of the image also increases.

Similarly, earlier we said that an image of size 100 by 100 pixels or 10 ,000 pixels in total would need 10 ,000 bytes to store in memory. Memory.

Saving an image like this is called the raw format. But saving images in raw format takes up a lot of space.

That is why we often use compressed formats to reduce file size. One common format is JPEG.

Using such compression, we can make image files much smaller. Now let us return to memory itself.

We said earlier that computers use capacitors and transistors to store data. capacitor. This type of memory is called dynamic RAM.

The smallest unit here is one capacitor and one transistor, which together can store one bit.

So, when we say a computer has four gigabytes of RAM, it means there are about 35 billion of these tiny memory units inside it.

That sounds unbelievable, but remember, these capacitors and transistors are not the large components we see in electronics shops.

They are manufactured at the scale of nanometers.

That is how billions of them can fit into a single 4 gigabyte memory chip.

Modern computers use many other ways to store memory besides capacitors and transistors.

For example, hard disks use magnetic disks and memory sticks use specially arranged transistors.

There are many such technologies and I am not listing all of them here, but wherever it is stored, the principle remains the same.

Data is ultimately stored as two states.

On and off, we represent these states as zero and one, the binary form.

Computers are a rapidly developing field and by the time you watch this video, there may already be more advanced methods than the ones I have described.

But I hope this video has given you a clear and simple understanding of how computer memory works.

If you enjoyed this video, do not forget to like and share it.

For more such videos, subscribe to this channel and enable the bell icon.

And if you ever feel like asking yourself, why should I know all this?

Remember, the reward of knowing is knowledge itself. Thank you.