In this tutorial, we’re going to briefly explain two essential storage units: registers and random access memory (RAM).
We’ll also talk about the working principle of these storage units.
2. The Need for a Memory
Building sophisticated systems is pointless and impossible without the ability to store information. That’s actually where the computer memory comes on the stage. Before looking at how to store one-bit information using logic gates, let’s take a look at the abstraction of memory systems in computing:
Registers are the memory locations that the CPU can access directly. The registers contain operands or the instructions that the processor is currently accessing. Registers are the smallest data storage unit integrated into the CPU.
Registers are defined in bits and a processor may contain registers that are 16-bit, 32-bit, or 64-bit. The number of register bits determines the CPU clock and speed. Before diving into details of how these registers store information, let’s try to understand how to store 1-bit information using logic gates.
3.1. AND-OR Latch and Gated Latch
The figure below shows an AND-OR latch. It’s the first step to allow us to create 1-bit memory. It has two inputs set, and reset. The set input sets the output to a 1 and the reset input resets the output to a 0. If set and reset are both 0, the circuit just outputs whatever was the last put in it. Actually, it remembers a single bit of information. So we can call it a 1-bit memory:
We call it a “latch” because it “latches” a specific value and stays that way. Getting data from the memory is called “reading”, and putting data into the memory is called “writing”. In order to create such a mechanism, we need a single wire to input data, that we can set to either 0 or 1 to store the value.
Furthermore, we’ll need a wire that enables the memory to be either available for writing or not. By adding a few more logic gates, we can build this circuit. We call it a Gated Latch. Because its gate can be opened or closed:
Now, we have a one-bit computer memory. However, as we guess, it’s not very useful. If we put 8 latches side-by-side, we can store 8 bits of information like an 8-bit number. A group of latches working like this is called a register which can hold a number.
While early computers had 8-bit registers, then 16, 32, and today, most of the computers have 64-bits registers.
If we put latches into a grid matrix instead of putting them side-by-side, we can save much more wires and we can scale up the memory that we’ve built. We call this kind of larger memory as RAM. By using hundreds and thousands of Gated Latches we can have gigabytes or a billion bytes of memory.
We can access any memory location, at any time, in random order. That’s why we call it a random access memory or RAM. RAM is also known as primary memory and it is volatile. It means that the data in the RAM exists when the system is powered on and disappears when the system is turned off. We can see an example of RAM in the picture below:
It actually stores data that will be needed by the presently running application in the CPU. If the processor requires data that is not in the RAM, the data is moved from the secondary storage such as hard drive, and then fetched by the CPU.
There is more than one type of RAM which are SRAM (Static Random Access Memory), DRAM, NVRAM, and flash memory. Even though they’re really similar to each other, they use different circuits to store the bits. For example, they use different logic gates, charge traps, or capacitors.
In this article, we’ve shortly given details about registers and RAM. We’ve tried to explain how registers and memory work under the hood with logic gates.