RAM is short for Random Access Memory. It stores data while the computer is powered and running but loses that data when the computer is reset or powered off. RAM is a crucial component of any computer. It allows the computer to store data temporarily and then access later on in program execution. Today we are going to use NPN transistors to construct one bit of RAM. I use three breadboards but you can squash everything together on half or less than half a breadboard, you can even use the prototyping board to reduce the size even further. I recommend you have a decent knowledge of electronics' before attempting. Here's what we need:
A 5v power source (as usual I will use an Arduino Board)
Plenty of Jumper Wire's
4 150ohm resistor's
8 500ohm resistor's
As usual, we need to connect the power rails of all the breadboard's we are going to use together with wire's and then connect 5v to the (+) terminal and ground to the (-) terminal.
Here a schematic of how our RAM will work we have a Data connection that goes into one AND gate and goes through an inverter into another and gate simultaneously. They enable connection goes into both gates as well. The output of both AND gate's go into two different NOR gates. The other input for both the NOR gate comes from the output of the opposite NOR gate. This sounds complicated but it's not, make sure you have looked at and understand the truth tables of the logic gate's we are building here. This is called a D latch and it's near perfect for building RAM. Q is our main output and Q with the line above it is called 'not Q', it is just the opposite of Q.
In the below image I have connected a button to 5v on one side and to a 500-ohm resistor on the other side, the 500ohm resistor then goes to the base terminal of a transistor to create an inverter. We also connect the collector terminal of the transistor to 5v through a 500-ohm resistor. The emitter terminal will be connected to ground and the output of this inverter comes from the 500-ohm resistor going into the collector. This input will be our data input and the button on the opposite side will be our enable input.
Here is a close look at our data input and the inverter.
You can see if we connect an LED to the output of the inverter it will be on when the button is off this means it works. Similarly, it will be off if the button is on.
Now let's move on to building our two AND gate's we need to arrange the two transistors like below. There is a detailed description of how to build AND, NAND, OR, NOR and INVERTERS in the link above. Connect the collector of the first AND gate to 5v without a resistor. Connect a 150-ohm resistor to ground from the emitter terminal of the last transistor the collector of the second transistor should be connected to the emitter of the first transistor.
Now connect the output of the inverter we built to the base of the first transistor(red wire) and the output of the enable button need's to be connected to the base of the second transistor through a 500-ohm resistor. The output of the AND gate comes from the emitter of the second transistor. Connect a wire to the same breadboard lane as the 150-ohm resistor.
Here is the output of the enable button with a 500-ohm resistor.
Now we need to build the second AND gate. Do the same as before with the transistor's and 150-ohm resistor and connect the collector of the first transistor to 5v. connect two 500 ohm resistors to the base terminals of both transistors. These will be our inputs.
Connect our data input to the first 500ohm resistor. This comes directly from the output of the button NOT from the inverter. We then need to connect the same enable input to the other 500-ohm resistor. Then, like before, our output will be the emitter of the second transistor.
If we connect two LEDs to the outputs of our AND gate's we can see if we are getting the correct output. If you only press enable then the green led should light up. If you press both then the led should light up. If you just press the data button or neither then nothing should light up.
Now we need to move on to building our NOR gates. This is the slightly trickier part. We need two transistors per NOR gate but DO NOT connect them as we do with AND gates. Get a 150-ohm resistor and connect it to 5v and then to an empty breadboard rail. Do the same for the other NOR gate.
Connect the output of the first AND gate to the base of the first transistor of the first NOR gate(quite the mouth-full). Do the same for the output of the other AND gate but connect it to the other NOR gate.
Next, we need to connect the emitter's of all the transistors to the ground. The black wire's in the image below are the ground wires. Try color code you NOR gate because it will become a bird's nest of wire's in a minute.
Use red wire's to connect the collector terminals of both transistors in the first NOR gate to the 150 oh resistor. Do the same for the other NOR gate but make sure they are connected to the other 150-ohm resistor.
The two blue wires are going to be our output. Connect the blue wires to both 150-ohm resistors and the two blank breadboard rail's.
Now here is the mind-bending part for certain people. You need to connect 500-ohm resistors to the outputs and connect a white wire from the top output's resistor to the base of the second transistor in the second nor gate. Then connect a green wire from the bottom output resistor to the base of the second transistor of the first NOR gate. That is how we LATCH a value.
Connect the LEDs to ground and then to the blue wire's. I mixed up the position of my gate's so in my case the green bottom LED is the Q output. That does not affect the RAM itself it just looks different than the schematic.
Here's an overview of the entire 1 bit of ram. You can reduce the size and squash them down or even put them on the prototyping board. Make eight of these to build a byte of RAM.