Processor Memory

Memory Address 0x00Storing variables on registers is fine, but eventually another operation will need to happen and the contents needs to be moved somewhere else more permanent.

For this, the processor will also need memory.

Building on using flip flops for storing data for registers, I decided that if I could create an enable flag that could be AND’d with the value in the flip flop, I could create a logic gate sequence for each address as to whether the input address is valid for that block.

All other addresses won’t accept the address and so won’t output anything.


In the image is a basic design for reading two bits from memory. There are a total of four bits worth of memory, two bits on address 0x00, and two bits on address 0x01.

I’ve hardcoded the values contained within that memory into the flip flops. Using a series of logic gates, each address of memory enables the transistor to return the value from the flip flops.

Memory Address 0x01Using a unique logic gate sequence for each memory address means only one return set can be active at a time.

As you can see in the image to the right, changing the memory address to be 0x01 returns the data from the other flip flops.

I still need to add another input so I can write to memory as well, I could probably use the same data lines as the output and AND it with the write input flag.

How much RAM I haven’t decided yet, I think maybe 4 addresses worth might be enough for such a basic system. The nice thing about this system is that more can be added at any time.

Removable Storage Media

I was thinking about making a version of removable storage as well, the idea is based on reading data from CDs, a piece of memory with black and white markers that can be read by LDRs.

I could also add some kind of paper feed system, then it could random access previous pages.. heh pages.

Processor Register

Full AdderWith my full adder complete and working in emulation, I just need to build it on a breadboard to make sure it works in practice.

The next step would be to etch and build a prototype before outsourcing for eight of them to be made (my processor will be 8bit), I might use surface mount components to keep down costs and size.

Okay, so I can add two numbers together, but where do I get those numbers from, and where can I store the result. Now I need memory, specifically for registers.

Flip FlopFlip Flop

So how do I write and read bit states. The answer is a Flip Flop.

To read from it is easy, neither input should be set as high, and the output will be the value stored.

To write a state, first the Reset input must be set high, this sets the value stored to low, now before a new value is set, Reset must be set to low.

With reset set to low, the Set input should be set high to store a high value. One problem with however is that giving an input of low, will not store a low signal.

Flip Flop with Enable1-Bit Dynamic Memory

One way around this is to use a third input, Enable. We can AND this input with each input.

Now whenever we want to set a value, we must set the reset to high, then toggle the Enable input between high and low.

For setting a value, we set the Input to the value we want stored, and toggle the Enable input between high and low.

This will prevent accidentally setting the value stored until we are ready.

NOR GateThe NOR Gate

Now I just need to breakdown the logic gates in the flip flop into discrete components. The AND Gate I already have a circuit for, so all I need a NOR Gate.

A NOR Gate works in the reverse of an OR Gate, so I just switched the PNP for an NPN, however the voltage dropped again so I added another signal booster.

I only quickly put this circuit together and will look at reducing the amount of transistors being used for it later. For three registers, two for input and one for output, an 8-bit processor will need a total of 24 flip flops.

More Discrete Logic

XOR Gate FlawI have wondered why I haven’t found any other 2 transistor XOR Gates, and only now do I think I know the reason why.

There was a slight flaw in my Full Adder where one of the output bits was being set when it shouldn’t.

The cause, a slightly lower voltage caused by the diode in my OR Gate. Without the same voltage at the base of the PNP as in the emitter, one of the PNP will always remain active.

Because of this, I’m going to have to rework my OR gate as well, or the signal ‘booster’ circuit I added to my XOR gate to guarantee that it remains the same for both inputs.

AND Gate


Slightly modifying the AND gate, removing a resistor and replacing the right NPN with a PNP, I get a high signal whenever both inputs have enough voltage to trigger the NPN transistors.



OR Gate


The OR gate is similar to the AND gate, only either transistor should short circuit the base of the PNP to ground.


Discrete Logic continued

New XOR GateSee previous post Discrete Logic.

EDIT: There is a flaw with this XOR circuit, see More Discrete Logic.

In my previous post I used two PNP transistors to perform of the job of XOR gate, however after building and test, the drop in voltage was too much over just a single full-adder.

Using a circuit I got from the EEV Forums, I got help when I needed to supply 14V to my OLED but the open drain on my chip supply a maximum of 2.5V, the XOR will now supply 5V from its output when it is high.

The 1k resistor represents the load. I’ve also added diodes onto the inputs since I had a problem with my AND circuit getting power from the base of the PNPs.

It requires an additional NPN and PNP transistor and a couple more resistors.

Discrete Logic

EDIT: There is a flaw with the XOR circuit, see More Discrete Logic.

Continuing on from Sum of Two Bits, I now need to make logic using only discrete components. Addition of one bit requires two AND gates, two XOR gates, and one OR gate.

OR Gate

OR Gate

Originally I had planned to make the OR gates using transistors, I had already ordered 500 NPN and 500 PNP from Farnell so I have plenty to spare for a while. But with my new found love of pull down resistors, I realised that using diodes I could make OR gate.

If A or B are high then Out will be high too. If neither are high, then the pull down resister will pull Out down to ground.


AND GateAND Gate

When A and B are low, voltage on the right transistor will be pulled up to high, turning it ‘on’, causing Out to be grounded.

When both A and B are high, a circuit is formed and the base of the right transistor is grounded, turning it ‘off’, allowing Out to be pulled up to high.

If only A or only B is on, a circuit to ground won’t be formed so the right transistor will remain ‘on’.


This one I used iCircuit on iOS to design. It uses two PNP transistors.

If the left switch is high and the right switch is low, the left transistor is turned ‘on’. If the right switch is on, the left transistor turn off, with a pull down resister added it can be pulled to ground.

If both switches are high, neither transistor will allow the circuit to complete.