Lecture 09 - Memory
Goals
- Build a memory that is addressable and can store multiple values
All of the circuits for this lecture are included as sub circuits in the above Logisim file. To download, right click and choose “Save link as…” or the equivalent
Registers
With the D flip flop we now have the ability to save a single bit of memory.
To save something useful, like a number, we need more than a single bit. We can chain a collection of D flip flops together to get a register.

while this isn’t large enough to really store something very useful, we can see how it could be extended out to store a good sized value
We do have one significant issue however – I’ve made our “write enable” line into the clock
As I said last time, the clock signal is an essential part of keeping the elements in our system in sync… but if we use this as it currently stands, it will write into the register on every clock cycle
To give you some perspective on this – registers are , essentially, where the variables in your programs are actually stored (with some hand waving to be addressed later)
we don’t assign to all variables on every line of our program. So, we need some additional control
Adding a write enable
We are going to go back to the flip flop and add a little circuit that allows us to control when we will accept a write

As with our D flip flop, this is such an important circuit that Logisim includes one – the register (in truth, Logisim’s register can handle multiple bits, but we will stick with the one bit version for the time being)
Returning to our register:

Memory
Now that we have our updated register, we can make a simple memory with it
Our memory needs a few things - we want the ability to store multiple values - we want to be able to specify which value we are currently reading - we want to be able to specify which value we are currently updating
How do we know how many bits we need for the addresses? We need a unique address for each addressable unit
In this case, we have three 4-bit values, so we need an address space of 3
address space - the number of addressable units supported by the memory
We will frequently refer to the number of bits required to store the addresses, so might say this has a 2-bit address space
Why do I say addressable units, why not values? In this case, the two are synonymous. However, modern machines tend to be byte_addressable, which is to say we can refer to each byte in a value individually
Inputs - data_in, 4-bits - data_out, 4-bits - clk, 1-bit - write_addr, 2-bits - read_addr, 2-bits
Okay, now that we have a good idea what we are building, we can start putting this together
We can start with the enable lines. We want to just enable the register corresponding to the address provided. This sounds like a job for a decoder.
For the outputs, we have three values and we need to show the one indicated by the read_addr
So we need something for picking between a collection of different values… a multiplexer

Mechanical level
vocabulary - address space
Skills