What is RAM? And how does it work?


Well, we might be knowing what is RAM, random access memory, well but what does it really mean.

For that let's look at what is the work of RAM, it holds data, so the CPU can access the data and process it. Well, an HDD also holds data, so what's the difference, well the RAM sticks which are inserted in DIMM slots are first of all are SDRAM, which is volatile and storage like HDDs or SSDs are nonvolatile, which means the data present on the RAM is not permanent as it needs electricity to store that data which means that the data needs to be sustained on the ram only when electricity is present for the RAM, in case the electricity goes out, the data which was present on the RAM will be lost, but in case of HDDs the data is stored on physical magnetic disks and is stored permanently and does not need electricity to keep the data.

Well, that's one difference between RAM and storage devices, a moment ago I mentioned SDRAM, what is it? It is a type of RAM, on-base level, there are two types of RAM, Dynamic random access memory(DRAM) and Static random access memory(SRAM).

BUT FIRST WHAT IS RANDOM ACCESS MEMORY?

A random access memory is in which memory is stored in semiconductor memory in locations that can be written or read from in any order despite the last memory location that was accessed, which just means data present at certain addresses can be accessed by the system regardless of the order.


WHAT IS DRAM?


Robert Dennard invented DRAM in 1966 at IBM, it consists of a capacitor and a transistor.
It reads data by charging and discharging a capacitor. When the capacitor is charged it represents '1' and when discharged it represents '0'.



When a bit is to be read or be written, the wordline goes high and the transistor connects the capacitor to the bitline. Whatever value is on the bitline '1' or '0' gets stored or retrieved from the capacitor. The sense amplifier reads the bit,  it can measure the minute difference in the capacitor's charge and reads high as 1 and low as 0. And as it reads the bit, it loses the charge as the bitline reads the capacitor, so to keep the data on the capacitor it is precharged by putting the value back into the capacitor. 

Another problem is that capacitors lose charge as they leak charge overtime for that, the capacitor needs to be refreshed periodically, so the data is not lost, it is refreshed dynamically, this is where the dynamic part of DRAM(dynamic random access memory) comes from, as it needs to be refreshed dynamically.

There is another type of RAM, called SDRAM, which is Synchronous DRAM, as the name says, SDRAM is synchronized with the system clock, traditional DRAM runs asynchronized to the processor's clock, only able to operate one operation at a time as it needs requests to perform. SDRAM is able to open two sets of addresses at a time also due to being synchronous cuts down the delays associated with asynchronous DRAM.

WHAT IS SRAM?
SRAM, it provides a direct interface with the CPU at very high speeds, 100x faster than DRAM, the cache present in the CPU is SRAM.
SRAM holds data statically which means it doesn't need to be refreshed, it can hold data in semiconductor memory as long as energy is being provided, it has bi-stable flip-flops, connected to circuitry, the two access transistors get closed while the cell is not addressed, keeping the data stable



A cell is accessed when the two access transistors are on, so it can connect the cell to internal circuitry, the two access transistors are connected to the wordline, the selected row will set at  Vcc, the bit lines are also called Y addresses. During reading these two bit lines are connected to two sense amplifiers that recognize if the logic data is 1 or 0, stored in the selected elementary cell. The sense amplifiers then transfer the logic state to the output buffer connected to the output pad. During writing, data comes in through the input pad and since the write circuitry drivers are stronger than flip-flop transistors in the cell, the data will be forced onto the cell and get written.

DRAM AND SRAM WORKING IN A SYSTEM-

The DDR4 RAM sticks as we know are SDRAM, they are inserted in the DIMM slots, they hold data for processing by the CPU; they store temporary data, it can be seen as the CPU's short term memory, storing data of programs which are in constant use by the system, if the CPU needs data from RAM, but it is not present on RAM, RAM can get it from storage and then provide it to CPU.

The cache inside the CPU is SRAM, there are three types of caches present inside a modern-day CPU, L1 cache, L2 cache, and L3 cache. These caches hold a very small amount of data, which is usually needed by the CPU, every core has its own L1 and L2 cache, and the L3 cache is shared amongst all the cores.



The L1 cache is the primary cache of the system and is the fastest memory and is the closest to the core, it speeds up the processing speed by a lot it is at least 100x faster than system memory, it can hold from 64Kb to 1Mb, depending on the CPU, L2 cache is located separated from the microprocessor core, it is slower than L1 cache but at least 25x faster than system memory, but it has more storage capacity than the L1 cache, and then L3 cache which is shared amongst all the cores is the slowest amongst the caches but can hold a lot of data compared to L1 and L2 cache.

When CPU needs some data, it works in a hierarchical system where it first asks L1 cache, if not found then asks L2 cache, then L3 cache, if it is not presenting the caches it then asks the slow DDR4 RAM.

Caches increase the system's speed significantly, and are a lot faster than DDR4 RAM, but what is DDR4 that I have been mentioning? That will be answered next time. So hold along the bars and wait.

Comments

Post a Comment