## Introduction: DIY SRAM

Static Random-Access Memory.  What is it?

SRAM is a type of memory that will store information, but lose it when power is disconnected, which is why it is RAM.  It is called static RAM because it doesn't need to be refreshed, unlike Dynamic RAM (DRAM) which has to be refreshed every few milliseconds to keep its data.  DRAM is common in computer memory, because of fast access times and it only requires 1 transistor and 1 capacitor per bit making it high density.  SRAM is common among microcontroller memory and some low power applications because it doesn't need to be refreshed, and uses less power.  It is slower than DRAM and has a lower density at 6 transistors per cell.

This instructable will show you how you can make a SRAM bit using the real design, not the register versions I previously demonstrated.  The SRAM is the 6t circuit, meaning that this version uses 6 transistors per bit (in reality, ours will need 8 per bit).

Why build such a device, when you can get an IC with a few thousand times more storage?
Because its cool to see how those little chips actually work.  Plus you can say that you made your own RAM... and maybe tell all your friends that your computer is running off of homemade RAM...

## Step 1: Get the Stuff

The parts list for this is nice and small.
• 8 2N7000 transistors - These are N-channel MOSFETs
• 4 BS250 transistors - These are P-channel MOSFETs
• 1 LED
• 1 Resistor to match LED current - 220 - 1K will be fine.  http://led.linear1.org/1led.wiz is a good calculator if you aren't sure
• 2 Buttons
• 2 Resistors 1k to 10k will work
• Wires
• A 5-ish Volt Power Supply

## Step 2: The Circuit

The 6t SRAM Circuit is relatively simple.  It is 2 CMOS inverters with an enable circuit on both sides.  The output of one inverter is connected to the input of the other and vice versa.  This creates a very simple latch because when one of the inputs is low, that inverter's output goes high, this makes the other inverter's input high, so its output is now low.  To change the inverters' states, you would pulse a high current on the low side AND a low current on the high side.  This pulse is enough to change the input of that inverter, so the output changes, and the circuit latches again, but in the opposite state.  It is bi-stable, and won't freely oscillate.  The enables connect and disconnect it from the rest of the circuit, so that it can't be accidentally changed when a bunch of them are connected together.

## Step 3: What on Earth Is CMOS

CMOS (see-moss) does NOT grow in water.  It is a type of logic that uses MOSFETs and it uses very little current.  CMOS stands for complementary metal-oxide semiconductor (The MOS part is also the same for the first part of MOSFET) This doesn't mean that the transistors compliment each other, but that they complement, as in the opposite, each other.  CMOS uses both an N-channel MOSFET and a P-channel MOSFET.

How does it work?
The N-channel MOSFET will turn on when it's gate is brought up to the supply voltage, typically 3.3v or 5v, and turn off when the gate it brought down to ground.
The P-channel MOSFET will turn on when it's gate is brought down to ground and turn off when it's gate is brought up to the supply.
What is neat is that when one is on, the other is off. The pictures above demonstrate how this works for the humble inverter (also known as a NOT gate)

## Step 4: The Enable Circuit

The first thing we have to tackle is the Enable Transistor.  The schematic shows that all you need is one N-channel MOSFET to be the enable.  That, however, is an ideal MOSFET.  An ideal MOSFET is a symmetrical device that can switch currents in both directions.  The 2N7000* is not an ideal MOSFET, there is a small diode built into it that is parallel with the actual FET.  This means that current can be switched on and off when flowing in one direction, but it will flow freely through the other direction whether the FET is on or off. I don't know why the MOSFETs are made that way, it is probably a manufacturing thing.  My guess is that for some reason, it is easier to make MOSFETs with a diode than without.

To counter this, we put 2 FETs together with their diodes facing opposite directions. That way, current can't flow in either direction freely UNLESS the MOSFET is switched on.  This is why our SRAM will need 8 transistors instead of 6.

*It should be noted that most discrete MOSFETs have a body diode, as its called, in them.

## Step 5: Our Circuit

Ok, so we have the SRAM circuit in the middle, but what the heck is all of the rest of that stuff?

The LED is simple, it is the output, so we know what the bit is set to.  The write enable switch turns on the enables, allowing you to write to the SRAM.  The Bit Line Switch is used to write the data to the SRAM. These switches need the pull-down resistors because the gates of MOSFETs are slightly capacitive, meaning that if you disconnect them from anything, they may hold their charge and stay switched on.  The ~BL inverter is used to invert the signal to go to the NOT Bit Line.  Then the BL inverter reverts the signal to its original state.  The reason for this second inverter is that the Pull-Down resistor doesn't draw enough current to switch the SRAM latch (more on this in step 13) so to counter this, we just use another inverter.

## Step 6: Let's Start the Fun Part

Ok, well the fun part also happens to be the tricky part.  I took a lot of pictures so, hopefully, it won't be a scary, daunting task.  The circuit starts out simple, but gets scary rather quickly.  A picture is worth a thousand words (actually a 10MP picture is about 10 million 32-bit words), so I plan on a few words and a lot of pictures.

To start we are going to make the two inverters.  They are simply a BS250 and a 2N7000 with their drains connected together.  To do this, the BS250 goes on the left, and the 2N7000 goes on the right.  Both should have the rounded side facing you. WARNING: if the rounded side is facing away, then the body diodes will short the supply and ground, and the transistors will release their blue smoke! Also, the rightmost pin (pin 3) of the BS250 and the leftmost pin (pin 1) of the 2N7000 should be connected together.

## Step 7: Connect Them Together

Now we are going to connect the inverters together.  The output of one is connected to the input of the other.  To do this, connect a wire to pin 2 of a transistor on the left inverter and connect it to the output of the other transistor.  The output of the inverter is where pin 3 of the BS250 and pin 1 of the 2N7000 are connected together.  Repeat this, but with the input of the right inverter and the output of the left one.

If you are confused, refer to the picture.

## Step 8: Add the Enable

The enable is simple.  One 2N7000 has its rounded side facing you, the other has its flat side facing you.  The right-most pin of the left transistor is connected to the left-most pin of the right transistor. Confused? The picture says it all, and then some.  Next, the gates get connected together via a wire.  Lastly, we need to connect the enable to the SRAM bit.  To do this, put a wire on either the very left or very right pin. Next, put the other end of the wire on the gate of the closest inverter.

## Step 9: The Full Cell

Make another enable on the other side of the circuit, and connect it up (if you connect both enables to the gate on both sides, you will guarantee that they aren't connected to the same side of the circuit).  Now you have a full SRAM cell.  Connect the gates of the enables together then connect another wire from ground to one of the gates.

Add the LED and resistor by putting a resistor on the output or gate of one inverter then to the positive lead of the LED and ground the negative lead of the LED. Now you may want to test in.

Plug in your power supply and watch for the blue smoke!  Actually, a better idea is to keep one hand on the switch, and touch the transistors with the other to make sure they don't get hot.  If it passes that test, set one enable input to ground and the other to +5v (or whatever you are using) turn the supply on, and enable the circuit by disconnecting the gates from ground and setting to +5v.  The LED should turn on, or off.  If it hold its state, disable the circuit and switch the wires around, as in the input that was grounded should be set high and vice versa.  If the LED still doesn't change, check your circuit.

## Step 10: Buttons and Input Inverters

Wiring up the buttons is fairly straight forward. One pin gets tied to +5v and the other is tied to ground through a resistor. The output of the button is the pin that is tied to ground.  The Write Enable button output connected to the enable gates.  The output of the Bit Line button is connected to the first inverter's input.  It's output goes to the enable and to the second inverter's gate.  It's output goes to the other enable.  I'm not going into detail on building the inverters, because I already covered that.

## Step 11: It's Finished

Now, its time to turn the power supply on again and try out your new RAM! If all goes well, you should be able to change the LED's state when the write enable is high, but it should latch when the write enable it low.

Build a few thousand more of these, add some decoding logic and you have your own SRAM chip!