Logic Gates Logic gates are used in electronic circuits when decisions need to be made. For example, suppose we make an intruder alarm for which we want the alarm to sound when the front door or back door are opened. This involves making decisions. · Is the front door open? Is the back door open? Are both doors open? Solving this type of problem is well suited to using logic gates. There are six types of logic gate, each of which works in a distinct way, making different kinds of decision. Like all electronic components logic gates have a circuit symbol, but to explain how they work we use what is called a Truth Table. Logic Gate Symbol Logic Gate Name A Z AND Gate B A Z OR Gate B A Z NAND Gate B A Z NOR Gate B A Z B A B Z 0 0 0 0 1 0 1 0 0 1 A 1 B 1 Z 0 0 0 0 1 1 1 0 1 1 1 1 A Z 0 1 1 0 A B Z 0 0 1 0 1 1 1 0 1 1 1 0 A B Z 0 0 1 0 1 0 1 0 0 1 1 0 A B Z 0 0 0 0 1 1 1 0 1 1 1 0 NOT Gate A Z Logic Gate Truth Table XOR Gate Boolean Expression A.B A+B A A.B A+B A + B Page 1 To explain what this all means, lets look in more detail at the AND logic gate. A Z A B Z 0 0 0 0 1 0 1 0 0 1 1 1 AND Gate B A.B Firstly the logic gate has two inputs, A and B, and one output, Z. The truth table shows us what the output (Z) will do when the inputs (A and B) change. The truth table shows all the possible arrangements for A and B with ‘0’ being the equivalent of off and ‘1’ being the equivalent of on. So, for example, when input A is off (0) and input B is on (1) the output is off (0), and likewise when input A is on (1) and input B is on (1) the output is on (1), and so on. Finally, the Boolean Expression is a shorthand way of writing that we are using an AND gate instead of having to draw the logic gate. So, can we think of an application in which an AND gate would provide a solution? ‘A primary school drilling machine is to have safety features added to it so that the children have less chance of being hurt. It is decided that the drilling machine must not start until the key is in the switch and the protective guard has been lowered’. This is an ideal example of using an AND gate, and indeed the clue to which gate to use is written in the problem. The drill should only start when the key is in the switch AND the protective guard has been lowered. So, a simplified circuit diagram for this problem would look like this. Key Switch Drill Motor Protective Guard Switch And a modified truth table would look like this. Key Switch Protective Guard Drill Motor Off Raised Off Off Lowered Off On Raised Off On Lowered On So, you can see that by using an AND gate we have easily been able to create a solution to what otherwise might seem a difficult problem to solve. And as you can see in the truth table above the drill motor will not start until the key switch is on AND the protective guard is lowered. Of course you would have to add the electronics needed for both switches and the drive to the drill motor. Page 2 To be able to create circuits using only NAND (or NOR) gates we need to know what the equivalent circuits for an AND, OR and NOT gate look like. These are shown below, and I will leave it to you to draw the truth tables to satisfy yourself that they are the same as single logic gate being created. Equivalents Using NAND Gates A1 A2 Z1 B1 Z2 AND Gate B2 A1 Z1 A3 B1 Z3 OR Gate B3 A2 Z2 B2 A1 Z1 NOT Gate B1 Equivalents Using NOR Gates A1 A2 Z2 Z1 OR Gate B2 B1 A1 Z1 B1 A3 Z3 A2 Z2 B3 AND Gate B2 A1 Z1 B1 NOT Gate In these NAND and NOR equivalent circuits you should see a lot of similarity between them. This will help you to be able to remember them. Page 3 Converting Logic Circuits to Use Only NAND Gates To show how to convert a logic circuit using AND, OR, NOT gates to a logic circuit using only NAND gates follow the example below that is based on the greenhouse problem we have already solved. Original Logic Circuit input 1 input 2 output input 3 You will see that I have not drawn in the resistors, switches etc. as these are not needed to perform the conversion. In the new circuit, using only NAND gates, these other components will remain exactly the same as before and no changes are needed to them. The first stage of the conversion is to redraw each of the logic gates in the diagram above but replace them with their NAND gate equivalent from the previous page. This is shown in the diagram below. input 1 input 2 output input 3 At first sight it looks as though all we have achieved is to make the circuit more complex, by replacing two logic gates with five. However, there is a second stage that we need to go through. The second stage is to remove logic gates where there are two NOT gates in a row. This is because to have two NOT gates one after each other is exactly the same as having no NOT gates at all. The example below illustrates this point. Logic 0 (OFF) Logic 1 (ON) NOT Gate Logic 1 (ON) NOT Gate The signal started out as a Logic 1 and having been through both NOT gates has ended up as a Logic 1. So we might as well remove both NOT gates completely and replace them with a connecting wire as the end result would be exactly the same. Logic 1 (ON) connecting wire Logic 1 (ON) Page 4 By removing consecutive NOT gates from our logic circuit we end up with the logic circuit shown in the diagram below. input 1 input 2 output input 3 It is worth noting that this logic circuit performs in exactly the same way as the original, and to make the complete circuit all we would need to do is to add the resistors, switches etc. in exactly the same places as we had in the original circuit using the AND and OR gates. However, once again it seems as if we have not made the circuit any simpler in that there are still three NAND gates in this new circuit compared with only two gates in the original circuit. But you will remember that logic gates come supplied in groups of four on a single IC and that you cannot buy different logic gates on the same IC. Because of this the original circuit used two IC’s, one for the AND gate and one for the OR gate. By performing the conversion to NAND gates we have reduced this to just one IC. So we have already reduced the number of IC’s by half, and this will make the resulting circuit easier to assemble as well as being physically smaller as less components are used. There is also another saving to be made, one of cost. The table below shows prices for the various different types of logic gate. Type Code 1+ 25+ 100+ 500+ NAND 74HC00 23p 16p 12p 8p NOR 74HC02 22p 16p 12p 10p AND 74HC08 22p 16p 12p 10p OR 74HC32 22p 16p 12p 11p All prices from Rapid Electronics 2003-2004 catalogue. So our original circuit using AND and OR gates would cost us 44p in logic gate IC’s. Our revised circuit using NAND gates would cost us 23p, a saving of 21p. Now 21p may not seem like a lot, and indeed it isn’t if we only make one circuit. But let us just consider if we were manufacturing 10,000 of these circuits. In this example I am assuming the cost per chip will be as for 500+ in the table above, although with quantities of 10,000 needed the cost would be cheaper in reality. AND, OR gate circuit Cost of IC’s 21p x 10,000 circuits = £2,100 NAND gate circuit Cost of IC 8p x 10,000 circuits = £800 This is a difference of £1,300. So by performing this conversion we have saved the company £1,300 in IC’s not to mention the cost savings in terms of needing less circuit board (there are less components) and the circuit board subsequently being quicker to assemble. More reasons for using NAND gates in logic circuits. Page 5 Originally I said that we could produce logic circuits using only NAND gates, which we have looked at, or only NOR gates. Well, the process for producing NOR gate only circuits is exactly the same as for the NAND gate only circuits, but in the first stage we replace the gates with their NOR gate equivalent. This is shown in the example below. input 1 input 2 output input 3 We would then perform the second stage as before, that of removing consecutive NOT gates, for example. Although in this example there are no examples of consecutive NOT gates, so the final circuit using only NOR gates would be the same as the circuit at the top of the page. This circuit uses five NOR gates, which with four NOR gates on an IC means that two IC’s would be needed, which is exactly the same as in our original AND, OR circuit. There is a slight cost saving to be made of 1p per circuit when making 500 or more circuits. So in this instance we would definitely opt to make our circuit using only NAND gates. However, there are equally times when using only NOR gates provides us with the cost and complexity savings that we desire, so if using only NAND gates does not make things simpler, then using only NOR gates probably will. Page 6
© Copyright 2026 Paperzz