Lecture 09 - Memory

Goals
  • Build a memory that is addressable and can store multiple values

Registers revisited

Last time, we built a four bit register

4-bit 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

Flipflop with write enable

Logisim circuit

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:

4-bit register with write enable

Logisim circuit

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

%%see if they can come up with these%%

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

%%start with the partial_mem that gives us the registers with a couple of lines hooked up%%

We can start with the output 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 multiplexor

Now we need to worry about the enable lines We want to just enable the register corresponding to the address provided So this time we want a decoder

4 by 3 memory circuit Logisim circuit

Mechanical level

vocabulary

  • address space

Skills


Last updated 04/05/2023