## Part 2 - Combining logic gates and creating custom elements

In this next part we will start to look at combining gates to make more complex logic elements.

If you haven't yet read

If you haven't yet read

__Breadboard initial setup__, I would go do that now.The above truth table is for a 2-input NOR gate. The "N" in NOR means NOT or inverted. So, a NOR gate is an OR gate but with the output logic level inverted.

The 7402 IC is a Quad 2-input NOR gate device. Look at the image on the right that shows the internal pin connections and notice that whilst the power pins are in the same place as the 7432 used previously, the gates are actually backwards. You MUST always check the data sheets when using the 74 ICs as often the gates are arranged in strange patterns.

Now NOR gates are really useful and from them, you can construct any of the other type of logic elements.

For example, by using two NOR gates, you can construct an OR gate.

The 7402 IC is a Quad 2-input NOR gate device. Look at the image on the right that shows the internal pin connections and notice that whilst the power pins are in the same place as the 7432 used previously, the gates are actually backwards. You MUST always check the data sheets when using the 74 ICs as often the gates are arranged in strange patterns.

Now NOR gates are really useful and from them, you can construct any of the other type of logic elements.

For example, by using two NOR gates, you can construct an OR gate.

The layout above makes use of two of the gates within a 7402 quad 2-input NOR IC. The switches are again connected to the gate inputs (pins 8 and 9) and also have the two pull down 2.2k resistors. The output of the gate (pin 10) is connected to pins (11 and 12) which are the inputs of another NOR gate. The output of this second NOR gate is connected to the LED.

Below is the electrical circuit diagram of what is on the breadboard - diagrams are much easier to read especially when things start getting complicated.

Below is the electrical circuit diagram of what is on the breadboard - diagrams are much easier to read especially when things start getting complicated.

Look closely at IC1.4 (which means it's the 4th gate with the IC). Notice how pins 11 and 12; the gates inputs, are connected together. This means that the gate is operating as if it only had one input, and in this case means it's working now as an inverter. Whatever logic level is presented at it's input is inverted and then presented at the output. The truth table for the combination of the two gates is that of a 2-input OR gate.

I stated previously that you can use multiple NOR gates to create just about any logic gate.

Here are two NOR gate circuits to create AND and NAND logic elements.

I stated previously that you can use multiple NOR gates to create just about any logic gate.

Here are two NOR gate circuits to create AND and NAND logic elements.

## AND Gate

## NAND Gate

We've already looked at how to construct an OR gate, but what about an XOR gate. This is it's truth table:

Just like any logic element, it can be constructed from NOR gates if required.

Notice in all of the above examples, whilst outputs are connected to inputs, and even inputs are connected to inputs, outputs are NEVER connected to outputs. The problem with doing this is if one output tries to go to logic low, and the other tries to go to logic high, you end up with a virtual short circuit and eventually one or more of the gates or ICs will be damaged. DONT DO IT !!

## Designing logic elements

For completeness, I thought I'd share with you a technique I use for designing and checking logic elements like that of the XOR above.

The circuit above is the same as that for the XOR used previously, but I've added a number to the output of each gate.

First I draw out a blank truth table and complete the input columns, A and B in this case with all possible combinations. With two inputs there are only four possible combinations.

Next I work out the value at point 1 for each of the four input combinations.

Next I work out the value at point 1 for each of the four input combinations.

Next proceed to calculate the logic states at each of the other points.

Finally, you can calculate the output of element.

Now you could ask "why" would you want to go to the trouble of constructing an XOR gate (or any other logic element for that matter) from multiple gates when, in the case of the XOR gate, you could just use a 7486 IC, which is a Quad 2-input XOR IC.

Well, there are times when you may not have a suitable IC handy, or you may want to construct a logic element that has no associated IC available.

The XNOR gate for example, which is actually an XOR gate with an inverter or NOT function on it's output. There is (that I know of), no corresponding 74 series IC that can provide this function, and it's important that you learn how to design and test your own logic elements.

We will come back to this subject in part 5.

Well, there are times when you may not have a suitable IC handy, or you may want to construct a logic element that has no associated IC available.

The XNOR gate for example, which is actually an XOR gate with an inverter or NOT function on it's output. There is (that I know of), no corresponding 74 series IC that can provide this function, and it's important that you learn how to design and test your own logic elements.

We will come back to this subject in part 5.