How Computers Remember

A brief explanation of Computer Memory

In the last post I explained how the ALU in your CPU works. As impressive as that is it doesn’t do very much good unless you can store the results. Which brings us to the problem of how can computers store memory. In general there are two types of memory that most computers employ. There is temporary memory and persistent memory. We will be spending our time explaining the temporary memory. Suffice it to say that persistent memory are things that are written to your hard drive or other storage device. Whereas the bulk of temporary memory is stored in your RAM(Random Access Memory). The difference is that when the power is removed from your RAM all the memory is effectively lost. With hard drives on the other hand the data persists even without power.


It turns out that sometimes by solving a problem at its smallest point you can simultaneously solve the problem at its largest point. So the smallest version of the problem of computer memory is how can we store a single bit? We need to be able to set a zero or one and for that zero or one to persist until we need it. It turns out there is a chip for that! It is called the single bit register. It uses mostly familiar parts with one new chip inside it.

The way this chip works is similar to other chips I have described. It has an input and a single control bit. If the “Load” bit is set to one the incoming bit from the “IN” input will be written to memory. The new chip that enables this to happen is the data flip flop chip. Before I explain to you what it is doing I have to introduce one more new idea which is the idea of having a clock. Up to this point I have described chips that react instantly without any concept of time. The Data Flip Flop Chip or DFF relies on this idea of a clock because it essentially stores it’s state for a single tick and then emits it out of the output. I am not going to dive into the details about how it is able to achieve this functionality because it gets a little too dry even for this post. But basically if you hand it a one for an input, in the next clock cycle the output will be one. Similarly if the output is one currently and you hand it a zero it will output a zero in the next cycle. This concept of “delay” allows us to hook up a sort of feed back loop where we can know what the state was last tick. The state of last tick will be pumped out of the DFF chip. We take that output and route it around to the A input of the Mux chip. That way if we are not loading anything this cycle that value will go through the Mux chip back into the DFF’s input. Conversely if the load bit is one the value from the B input of the Mux chip will be piped to the DFF chip thereby updating the value. As per usual this behavior will be easier to conceptualize with the following diagrams:

Lets think of it in steps. So lets say for the first step we set the inputs to the above values. At this point we don’t know the output of the DFF chip and since we don’t know it’s value we don’t know what the output for the single bit register is either.

We see there have been a couple changes to the chip from the previous step. The DFF chip now has a state of one and therefore the output of the single bit register is one. We also see that the Load bit has been set to zero and thereby routing the output of the DFF chip back into the input of the DFF.

The next step shows us that the output continues to be one even though the current input is zero. If you wanted you could keep it in this state for as long as you want. But lets update the value and see how the value propagates through the system.

We have now set the Load bit to one. Therefore the value being piped into the DFF is now from the input of the chip, which at this point is zero. But as you will notice the internal state is still one because it updates on a one step delay. Therefore the output of the chip is still one during this step.

Now the DFF outputs the input from the previous step and therefore the output of the chip has now been updated to zero. This is how our system is able to store a single bit. This single bit register is the foundational building block of the RAM. From here the implementation details are trivial so I will spare you the detailed explanation and instead gloss over the details. The first step is to convert the above chip into a 16 bit register.

We then group those together into a group of 8, 16 bit registers.

Why stop there ? Why not make a group of 8 of these group of 8- 16 bit registers?

This makes a RAM64 chip. Make 8 of those into a group and…

Thusly the RAM512 is constructed. If this process is repeated again you will get a RAM4K and again gives you 32,768- 16 bit registers to store all the numbers! This is a supremely small RAM but gives you some sense of scale of what those little sticks of RAM in your computer are actually up to as well as solving the question “How do computers remember?”

Leave a Comment