Sie sind auf Seite 1von 21

Continuing Professional Development

A-level Computing
Stepping up to AS

Logic Gates

Version 2.0

Permission to reproduce all copyright materials have been applied for. In some cases, efforts to contact copyright holders have been unsuccessful and AQA will be happy to rectify any omissions of acknowledgements in future documents if required.

LOGIC GATES Ver2.0

LOGIC GATES

INTRODUCTION ............................................................................................................... 2 NOT GATE.......................................................................................................................... 2 AND GATES ....................................................................................................................... 3 OR GATES .......................................................................................................................... 4 EXCLUSIVE OR GATES ................................................................................................... 5 NAND .................................................................................................................................. 5 NOR ..................................................................................................................................... 6 NAND INVERTER ............................................................................................................. 6 HOW DO I TEACH MY STUDENTS ABOUT LOGIC GATES? .................................... 7 HOW DO I DRAW LOGIC CIRCUITS? ........................................................................... 8 BIBLIOGRAPHY ................................................................................................................ 9 THE EXCEEDINGLY POWERFUL NAND GATE ........................................................ 10 WORKSHOP ACTIVITIES .............................................................................................. 11 JAN 2009 Q10 ................................................................................................................... 17 JUNE 2009 Q 4B (PART QUESTION) ........................................................................ 17 JUNE 2009 Q 4B CONTD. ............................................................................................ 18

LOGIC GATES Ver2.0

LOGIC GATES
INTRODUCTION
COMP2 3.2.2 FUNDAMENTAL HARDWARE ELEMENTS OF COMPUTERS

Logic gates
Construct Truth Tables for the following gates: NOT, AND, OR, XOR, NAND, NOR. Be familiar with drawing logic diagrams involving one or more of the above gates

In the mid 1800s an English Mathematician called George Boole introduced a new type of Algebra for logic that was originally proposed by the Greek Philosopher Aristotle. This new type of Algebra had little practical use until digital electronics and digital computers were invented in the 1940s. Although one or two early computers attempted to use a base 10 system, very soon base 2 triumphed i.e. binary electronic computers were invented. To teach logic gates of the type required at AS level, probably the easiest approach is to consider them as a black box with one output and one or more inputs.

NOT GATE

NOT

This is the simplest possible gate which is also called an inverter gate because it inverts the input. If there is a Logic 1 input, the output is logic 0 and vice versa. There are different drawing conventions but the sample AQA question shows that the ANSI system has probably been adopted.

The small open circle on the output shows that this is an Inverting type gate. You will come across this again later with NAND and NOR gates. You can use a truth table to show how it works. This is simply a table that shows the result of applying the logical function to all possible combinations of inputs. In this gate there is only one input with two possible states so we draw it as: Input A 0 1 Output Q 1 0 In Boolean Algebra: Q = A We pronounce it as: Q equals NOT A

Page / 2

LOGIC GATES Ver2.0

AND GATES
For a two input AND gate, the output Q is 1 If and Only If input A is 1 AND input B is a 1.

Input B 0 0 1 1

Input A 0 1 0 1

Output Q 0 0 0 1

Switch A

Switch B

+ battery Bulb (output)

Analogy of operation of an AND Gate using switches. The bulb will Light only if both switch A AND switch B are closed.

In Boolean Algebra: Q = A . B

This is the confusing part of Boolean Algebra, the dot . Is the Boolean operator meaning AND yet you might think it should be a + operator. Mathematicians use a different symbol but we need to use the one that AQA will probably use.

We pronounce it as: Q equals A AND B

Page / 3

LOGIC GATES Ver2.0

OR GATES
For a two input OR gate, the output Q is 1 If and Only If input A is 1 OR input B is a 1. (this includes the case when they are both 1).

Input B 0 0 1 1

Input A 0 1 0 1

Output Q 0 1 1 1

In Boolean Algebra: Q = A + B

This is another confusing part of Boolean Algebra, the plus + symbol is the Boolean operator meaning OR. Mathematicians again use a different symbol. We pronounce it as: Q equals A OR B .
Switch A

Switch B

Analogy of operation of an OR Gate using switches. The bulb will Light either if switch A OR switch B is closed.

+ battery bulb (output)

Page / 4

LOGIC GATES Ver2.0

EXCLUSIVE OR GATES
For a two input XOR gate, the output Q is 1 If and Only If input A is 1 OR input B is a 1 but not if they are both 1.

Input B 0 0 1 1

Input A 0 1 0 1

Output Q 0 1 1 0

In Boolean Algebra: Q = A B We pronounce it as: Q equals A XOR B

Sometimes called XOR, EOR or a non-equivalence gate

NAND
The NAND Boolean function is simply a combination of the AND function and the NOT inverter function. NOT AND is always abbreviated to NAND.
Input A

Input A Input B Output Q 0 0 1 0 1 1 1 0 1 1 1 0

Input B Output Q

Q A.B

Notice the small open circle shown on the output of the gate which shows that there is inversion.

Page / 5

LOGIC GATES Ver2.0

NOR
The NOR Boolean function is simply a combination of the OR function and the NOT inverter function. NOT OR is always abbreviated to NOR.

Q A B

NAND INVERTER
If you wire the two inputs of a 2-Input NAND gate together, you have produced a gate which is functionally equivalent to a (1-Input) NOT gate. Try it out and see.

Complete the Truth Table below.


Input A Input B Output Q

Page / 6

LOGIC GATES Ver2.0

HOW DO I TEACH MY STUDENTS ABOUT LOGIC GATES?


There are actually two ways of doing this (apart from whiteboards and pens): You could buy loads of electronic equipment including power supplies, meters, leads, Circuit boards or soldering irons etc. This creates lots of H & S issues and students tend to blow up the components; frequently a poor connection gives the wrong result in any case. This was how I was taught digital electronics in the late 60s / early 70s. (There was a simulator that I used which ran on the IBM 360 Mainframe but it could only analyse analogue circuits using transistors, resistors, capacitors and Inductors). A much better option is to acquire digital simulation software. Some of it is written as a java applet and it totally free and some can be downloaded onto pcs. It may be free but very limited in scope or cost about 15 US$ for a single user licence ( www.easysim.com ). The really professional applications such as National Instruments Electronics Workbench costs hundreds of pounds but a free 30 day trial exists (download this just before you are going to teach this topic). Talk nicely to your D & T department who may have licensed a suitable package called Crocodile Clips for D & T but recently renamed YENKA. There is a free download of the basic functions of switches and bulbs etc.

If you want to use Java Applets with your students in the classroom or for home assignments, one of the best that I have used is called LOGG-O which is a freely distributed Java Applet that was designed to accompany the text The Analytical Engine. An Introduction to Computer Science Using the Internet (Decker and Hirshfield 2003). You can access the applet from the publishers website www.course.com/downloads/computerscience/aeonline/7/1/index.html and at several American University websites as well. Alternatively you could use a Flash animation called Logicly.swf from the URL:
http://joshblog.net/projects/logic-gate-simulator/

Today, I will use another one also called LogicSim by Andreas Tetzl because it will run without Internet access. It is available at: www.tetzl.de and is totally free software available released under GPL. The only two things that I dont like about it are that there is no Copy to Clipboard option so you have to use Prt Scr to copy it into MS Word and then crop the picture. Secondly, the connecting lines initially link straight from the right side of one object to the left of another and it id fiddley to put right angle bends in. This is a small price to pay for free software! An alternative one for Apple Macs is LogicSim 3.0 (Masson 2002). This is available at www.sunsite.utk.edu/math_archives/LogicSim/LogicSim.sea.hqx. The BOOLE_DEUSTO application used previously also can be used to explore Digital Circuits and truth tables if you select the Combinational Circuits button instead of the FSM one. It takes you on to the use of V-K Mapping to minimise circuitry in digital design. This is way beyond the new specification (but not the NEAB pre 2000 syllabus!!). I wish that it had been available then.

Page / 7

LOGIC GATES Ver2.0

HOW DO I DRAW LOGIC CIRCUITS?


You could buy the very expensive stencil and drawing pen that I used when doing digital design in the early 80s or even purchase very specialised Letraset if it is still available. However, many of the above simulation packages allow you to create digital circuit diagrams and print them out as well as simulating the actual circuit. Some allow you to copy to the clipboard so you can easily create worksheets yourself in MS Word. You could create a set of Logic objects yourself using the various drawing objects in MS Word. I have included a document that you can use. In lines with this set of notes, I have used the LogicSim package from Andreas Tetzl but note the limitation that it is slightly tricky to draw right angled bends.

AND

NAND

OR

XOR

NOT

http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15251s04/Site/Materials/Directions/circuits/LogicGates.doc

You may also find the following link helpful if you arent used to drawing circuit diagrams.
http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15251-s04/Site/Materials/Directions/circuits/circuitguide.pdf

You could also use MS Visio professional edition to draw logic diagrams but this is expensive. Many other drawing packages such as SmartDraw or Corel Draw would also allow you to do this. However, I particularly like the totally free version of TinyCad downloadable from: http://tinycad.sourceforge.net/ It is important to understand that LogicSim by Andreas Tetzl is primarily a digital logic simulation program whereas TinyCAD is a schematic editor program which allows to draw digital (and Analogue) circuit diagrams. It comes complete with extensive symbol libraries to get you started. As well as being able to simply print off your designs, you can use TinyCAD to create logic circuit worksheets by copying and pasting straight into a Word document, or even Open Office. It cannot simulate digital circuits.

Page / 8

LOGIC GATES Ver2.0

BIBLIOGRAPHY
http://en.wikipedia.org/wiki/George_Boole http://en.wikipedia.org/wiki/Boolean_logic (You will find this quite a mathematical URL reference using Mathematicians logic operators) http://www.cimt.plymouth.ac.uk/projects/mepres/alevel/discrete_ch11.pdf

Electronics for Today and Tomorrow, Tom Duncan, Pub John Murray Visualizing DeMorgans Laws using Logic Simulation Software Mathematics Teacher Vol. 100 No. 3 October 2006 AS Computing by Kevin Bond and Sylvia Langfield, Pub Nelson Thornes Electronics Circuits and Systems, Owen Bishop, Pub Newnes Understanding Computer Science for Advanced Level, Ray Bradley, 4th edition Pub Nelson Thornes Ltd ISBN 0748705635 (This is an old edition but may be available in Libraries) Computer Science, C S French Pub Thomson Learning 5th edition (1 Jan 1996) ISBN: 082645460 (This is also an old edition but may still be available in Libraries) Roth, Charles H., Jr. (2004). Fundamentals of Logic Design. Thomson-Engineering, 364367. There are additional ideas for logic circuit questions in the various Discrete Mathematics books and websites.

Page / 9

LOGIC GATES Ver2.0

THE EXCEEDINGLY POWERFUL NAND GATE


In digital design, the NAND gate is considered to be one of the most powerful gates available. Using TTL series, the 7400 gate with 14 pins comprises four 2-Input NAND Gates. The remaining two pins are simply the +5v and 0v power supply pins. In this TTL (Transistor-Transistor Logic) device diagram, the inputs are labelled 1A, 1B etc and the corresponding Outputs are 1 Y etc. Vcc simply means the +ve supply pin of 5 volts and GND is the ground or 0 volt supply pin.

A NOT Gate made from a NAND Gate

AND Gate made from two NAND

Gates

OR Gate from three NAND Gates

NOR Gate from four NAND Gates

XOR Gate from four NAND Gates

As you can see, the NAND Gate really is the Universal Gate because it is often cheaper to use Quad 2-input NAND Gates in digital design rather than having to use lots of different Gates such as NOT, AND, OR and XOR etc. The XNOR Gate is less common but is called a parity or equivalence gate. Logic chips only contain one type of gate within their package. Joining more than one logic gate together creates a combinatorial circuit.

Page / 10

LOGIC GATES Ver2.0

WORKSHOP ACTIVITIES
1. Write down the truth tables for the NOT, AND and OR Boolean functions. Verify that these are correct by using the circuit simulation program of your choice. Draw up the truth table for the XOR gate. Examine it to help you explain why it is sometimes called a non-equivalence gate. Refer to the previous section on the Universal NAND gate. Simulate all of the circuits given which use NAND gates to synthesise each of the other main 2-Input gates using the Logic Simulator Application. Experiment and write down the truth tables for inputs A and B with the output Q.

2.

3.

4.

Using your previous truth tables for NOT, AND and OR Gates, predict the logic states at points C, D and the Output Q for the above logic circuit. Complete the table below and compare these answers with what you actually observed during simulation.

N.B. There are only two inputs A and B to the system. A and B can only represent the two states 0 and 1 so there are a total of 4 combinations. These are: 0 0 1 1 0 1 0 1

Input A 0 0 1 1

Input B 0 1 0 0

Output Q

We will use this result again in the final session of the day on DeMorgans theorem.

Page / 11

LOGIC GATES Ver2.0

HOW TO USE THE TETZLs LOGIC SIMULATOR


When you download the application from the website given earlier, the folder contains an executable .jar folder. Just double click on the icon to launch the application.

Select circuit objects from the list on the left side and place them on the work panel. To connect click on an output of a circuit (right side) and draw the wire to an input of a circuit. Hold down shift while clicking somewhere on a wire to connect a new wire to this point. Circuit Objects and Wires can be activated by clicking on them and then deleted with the DEL key. You can change settings on some circuits (clock, TextLabel) by selecting "Properties" in their contextmenus by right clicking. It is possible to change the number of inputs for some circuits (AND, OR, XOR, etc) with combo box below the circuits list but you probably only need to use the 2-Input Gates for this AS course. To create the T join and the other right angle bend: Place the Switch, NOT gate and the OR gate components on the grid.

Click on the right hand line of the switch near X and then click near Z.

Now click again near X but you will have to press shift first and then click again on the Left side at the top contact of the OR gate.

Add two points to the X Y line and two points to the X Z line. These will
appear as Black Squares. Finally, you can click on the little black squares to rubber band the lines to create nice right-angled junctions.

Page / 12

LOGIC GATES Ver2.0

LOGIC CIRCUIT QUESTIONS


In the following questions, you may assume that where two wires cross at right angles, they are not connected but where wires meet at a T junction, they are connected. Some drawing packages allow a black dot where connection is intended.

NOT CONNECTED 1.

CONNECTED

Write down the truth table for the digital circuit below which has inputs A and B and Outputs P and Q.

ANSWER A B P Q 0 0 1 0 0 1 1 1 1 0 0 0 1 1 1 0

2.

Write down the truth table for the circuit below including the intermediate states C, D, E and F.

Check out your answers using the simulator. The colour of the connecting wires are black if there is a logic 0 and red if there is a logic 1.

Page / 13

LOGIC GATES Ver2.0

ANSWER A B C 0 0 1 0 1 1 1 0 0 1 1 0

D 1 0 1 0

E 1 1 0 1

F 0 1 0 0

G 1 1 0 1

3.

A gas central heating system which is represented by the diagram below has digital electronic control. The gas valve turns on the gas supply to the boiler when the output from the logic gate is high. This is only true when both of the following conditions hold. i. The output from the thermostat is high indicating that the room temperature has fallen below the set value.
also

ii.

The output from the pilot flame sensor is high meaning that the pilot light is safely lit.

room temperature

thermostat manual setting pilot flame sensor Logic gate gas valve

heat from pilot

boiler

What type of logic gate is needed? Complete the truth table below: Input from thermostat Input from Pilot Flame sensor Output from Logic Gate

Page / 14

LOGIC GATES Ver2.0

4.

From your knowledge of truth tables for the various logic gates used in the circuit below, predict the outputs at points D, E and Z for the circuit. Ignore the logic chip pin numbers 1,2 and 3. Draw the truth table for the three inputs, two intermediate outputs and the final output. Consider all possible combinations of the three inputs.

(I have drawn this using TinyCAD and imported it into MS Word as an exercise in its own right) You can check your answers by using the Logic Simulator package as before.

A 1
..

1 2

D
3

1 3 2

3 2

5.

Derive a simple Boolean equation for Z in terms of X and Y for the circuit which comprises four identical NAND Gates as shown below.

Your working should show the function at the output of each of the gates.

Page / 15

LOGIC GATES Ver2.0

6.

Design and draw a circuit using appropriate logic gates to represent the following logic expressions: a) P Q b) (X Y) . X

Draw up the truth table for each circuit. ANSWER

P Q a)
PQ

P+Q

b)

(X Y) . X

7.

A Question

Specimen

Page / 16

LOGIC GATES Ver2.0

JAN 2009 Q10


(a) (b i)
Solution See earlier notes
Q=A.B+B.C

1 mark for A . B or for B . C 2 marks for Q = A . B + B . C A AND instead of Operator . A OR instead of Operator + (b ii) 1 mark for each gate with correct inputs ;;;; Allow two lines from B (instead of junction)

Examiner comments:
Most candidates had no difficulty completing the truth tables. It was pleasing to see that a large number of candidates correctly expressed the given scenario as a Boolean equation. A few candidates mixed up the symbols for AND and OR. Many candidates correctly completed the logic gate diagram, even if they did not write down the correct Boolean expression. Each gate that had been given the correct inputs was awarded a mark. Some candidates drew very neat diagrams and helped themselves by writing the equation on the output of each gate. A few candidates missed out on marks because they had not connected the gates to each other.

JUNE 2009 Q 4B (PART QUESTION)


4 (b) An interior light in a two-door car is controlled by two switches that the driver can turn on or off and two sensors, one per door. The switches are named A and B. The door sensors are named C and D. The interior light is named L. If a door is open the output of its sensor is on. If a door is closed the output of its sensor is off. If both switches A and B are off then the light L is always off. If switch A is on the light L is always on. If switch B is on and switch A is off then: o the light L turns on if one or more of the car doors is opened o the light L turns off if both of the doors are closed.

Page / 17

LOGIC GATES Ver2.0

JUNE 2009 Q 4B CONTD.

An analogue switches representation

See full Mark Scheme which is printed separately for some of the possible valid solutions.

Examiner Comments Question 4 b The logic circuit question was well answered with many candidates getting two or three of the three available marks. Most realised that it was not necessary to NOT the A and AND it with B, although candidates were not penalised if they did this. Diagrams were usually drawn clearly. Many candidates were able to state a correct Boolean expression that represented the logic circuit. Some introduced unnecessary brackets into the expression, but these were not penalised if they did not affect the expressions logic.

Page / 18

Das könnte Ihnen auch gefallen