All data in the computer are zeros and ones. The text you are reading has been transferred from our server directly to your computer and recorded in memory – it is a sequence of zeros and ones. At the moment you are looking at your monitor, which consists of pixels and displays our website. A picture also consists of zeros and ones. Videos are zeros and ones. Music is zeros and ones. All content available on your computer can be represented as zeros and ones. But how?
It is worth starting with the fact that the computer only understands the binary number system. In life we use the decimal place because we have 10 fingers and it is simply more convenient for us, but the computer does not have 10 fingers – it can only work with logical devices that only work in two states – on or off, there is power supply or no electricity supply. If the logic device is active, there is a power supply and the bit is equal to one. If there is no power supply, the bit is zero. Bit is the smallest unit of measure. 1 bit can only have two states 1 and 0. 1 byte is 8 bits. So if we sort all possible combinations of zeros and ones, we get that 256 bit combinations or 2 to the power 8 can be stored in 1 byte. For example "0000001", "0000010" or "10110010" – each letter of the English alphabet can be represented in as 8 bits (1 byte).
How does the processor work?
You can't talk about memory without saying a few words about the processor. The processor and RAM are quite similar, since in both cases logical devices are used that can only take two states. However, the processor does arithmetic. For this purpose he has a control unit – it is our instructions that he receives, an arithmetic-logical device – and is responsible for all arithmetic operations (addition, subtraction, etc.) and registers.
In addition to RAM, the computer has a cache memory. If you are interested in this topic, you can study our current material.
Since the instructions received by the processor work with data from memory, this data must be stored somewhere. It is too long to take them out of RAM all the time, so that the processor has its own memory, which is represented in the form of several registers. This is the fastest memory in the computer.
What is a register? The register in the processor is shown in the form of a trigger that can store 1-bit information. A trigger is one of many logic elements in microchips. Thanks to its logic, it can store information. This is what the D trigger looks like:
The upper switch "D" in the D trigger changes the value of the bit and the lower "C" activates or deactivates its storage. You are probably wondering how this "D trigger" works. For more information on how triggers work, see the following video:
In addition to the D trigger, there are also RS triggers, JK triggers and others. This book is dedicated to more than one book. You can study the logic devices of microchips yourself. It would be nice to deal with the issue of quantum processors, because it is obvious that the future is with them.
What is RAM made of?
Back to our memory, it is a large group of registers that store data. There is SRAM (static memory) and DRAM (dynamic memory). In static memory, registers are shown in the form of triggers and in dynamic memory in the form of capacitors, which can lose charge over time. Nowadays RAM uses DRAM exactly, where each cell is a transistor and a capacitor, which lose all data when there is no power. Therefore, RAM is cleared when the computer is turned off. The computer stores all drivers and other important programs on the SSD when it is switched off and saves the necessary data in RAM when it is switched on.
You will probably be interested in knowing the types of RAM. We have excellent material on the subject.
As already mentioned above, the dynamic random access memory cell consists of a capacitor and a transistor and stores 1-bit information. More specifically, the capacitor itself stores the information and the transistor is responsible for switching the state. We can present the capacitor in the form of a small bucket that is filled with electrons when electricity is applied. We examined the operation of the dynamic random access memory 7 years ago. Little has changed in the principles of his work since then. If the capacitor is filled with electrons, its state is one, ie we have 1 bit information at the output. If not, then zero.
How does a computer save data in RAM?
A sequence of bits or 1 byte "01000001" written in RAM can mean everything – it can be the number "65", the letter "A" or the color of the picture. In order for the operating system to understand what these bits mean, different encodings for different data types were invented: MP3, WAV, MPEG4, ASCII, Unicode, BMP, JPEG. For example, let's try to write the Cyrillic letter "p" in our memory. To do this, you first have to translate it into the format of a Unicode character (hexadecimal number). The "p" in the Unicode table is "0440". Next we have to choose in which encoding we want to save the number, be it UTF-16. In the binary system, the Unicode character then has the form "00000100 01000000". And we can already write this value in RAM. It consists of two bytes. But if we took the English "s" it would look like "01110011" in binary form.
The fact is that the English alphabet only needs 1 byte because it fits in a number range from 0 to 255 when UTF encoded. In 256 combinations, numbers from 0 to 9 and the English alphabet fit quietly, but the rest of the characters are gone. For example, you need 2 bytes for Russian characters and 3 or even 4 bytes for Japanese or Chinese characters.
So we figured out how the RAM works and how you can write data to it. Do you like that stuff Share it with your friends and let's discuss it in our chat.