Introduction: How to Make RAM With a Controller
hi there and welcome to my first instructable :D
i am going to show you how to make some 4-bit RAM memory along with a controller, allowing you to save several different nibbles of information in the same system.
I will warn you now, i live in the UK and use European electronic symbols so if you dont understand anything don't hesitate to ask!
Step 1: System Planning
for this instructable i am going to make 3 seperate nibbles (4 bit) of ram. these will all be connected to the same data bus. a two bit address bus will controll which nibble of RAM is connected to the data bus. the entire system is capable of storing three 4-bit words. for my coursework, i used it to store a 3 digit security code in a security system, which is compared, digit by digit, to what was input at the keypad. the security code could be changed, as i used ram memory.
Step 2: Flip-flops
The RAM i will be showing you how to make is made from two main components. D type flip flops and tristates. the tristates are optional but if you do not use them then you need a seperate read and write bus for each RAM module (in this case that would mean 6 read and write busses!), instead of a common data bus. this is because when writing words to the RAM, we use the tristates to stop the output of the flip flop interfering with the new input.
we are using flip flops, as the clock allows a short pulse to freeze the input at D to the output at Q untill the next clock pulse. for example, i could make the input at D be high, and then pulse the clock high for a short period of time (for a D type flip flop it is the rising edge, not the pulse that triggers the clock) then the output, Q, would become high. it will remain high untill either the reset input goes high, or the input at D is low and the clock is pulsed again. for the Ram we will use the D input to input the bit to be written to the memory, and Q as the output for reading the stored bit. to write a bit to the memory we will need to pulse high at the clock to create a rising edge (or a falling edge if you have falling edge triggered flipflops.
The second picture shows a simple RAM system made only from flip-flops. for some projects this will be more than sufficient so fell free to stop reading here :)
there are however some disadvantages of using this simple RAM system. it has seperate input and outputs, which, when using breadboards and pcb's, where space is a large factor, this is an inefficient use of wiring. for a single module of RAM it is fine, but when you start to get multiple modules you start to use lots of space in just wiring. in the next step we will ad an extra component to the RAM, and we will only have one data bus for both inputs and outputs
Step 3: Tristates
Tristates are usefull, as they block the input untill the activate input (X in my diagram) is high. now looking at the first picture below some of you are probably thinking, "that is the same truth table as an AND gate. and you would be right. Let us look at the second picture. Just substituting an AND gate into our RAM circuit wouldnt work, as when the and gate has an output of zero, it sinks current. So, if i wanted to write something to the RAM and the And gate output is zero - no matter what the input is the AND gate, when its output is low will sink the current away.
The third picture shows the same system but implemented with Tristates (or if you dont have tristates you could use an AND gate with a diode). this way is much better as we now only have a single wire for inputs and outputs, and you really see the benefits of using the tristates in pictures 4 and 5.
Step 4: RAM Controller
So, for our three 4-bit RAM modules, we have the design below. the input data is placed at the data bus, and then written to the memory ny pulsing the appropriate input high. the contents of each nibble canbe read as long as the appropriate read nibble is high. For my security system however i needed to automatically switch from one nibble to the next when a new digit was input by the user. for this i made a RAM controller. it de-multiplexes a single read and a single write signal to the appropriate nibble of ram, depending on the 2 bit address input.
The second picture shows my RAM controller. when a Rising edge is present at the clock of the first flip-flop, the counter counts up by one (as d is connected to NOT Q). for each pulse it counts up by one. when the counter output is 11, the output of the reset logic becomes high, making the reset inputs of the counter high. this makes the counter reset back to 00. the counter output controlls which output that the de-multiplexers are connected to. for example, if the counter output is 01 then the de-multiplexer would be connected to the output second from the top (where the arrow points in the diagram is allways the multiplexer state at 00). you no only have one read and one write input - plus the counter input. you could - if you dont mind the RAM allways reading its contents to the output except when writing make the Write input equal to 'NOT Read' with a not gate (or a NAND gate with both inputs tied together if you are using NAND logic)
Now we have the RAM controller we have got a fully functioning one and a half bytes of 4-bit RAM! imagine trying to make enough for a modern computer this way D:
Step 5: The End
I hope you have enjoyed my first instructable and found it informative. i actually quite enjoyed writing it and it is good revision for my upcoming exams. when i assembled my RAM in my coursework it worked flawlessly first time, which i was very pleased with because if it had not i would have had to spend a VERY long time fault finding. i hope that some of you wil try to make your own RAM, there is something satisfying about building something which can remember stuff you tell it ;3.
We have a be nice policy.
Please be positive and constructive.