Beruflich Dokumente
Kultur Dokumente
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
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
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
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
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.
Page / 3
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.
Page / 4
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
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 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
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.
Page / 6
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
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
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
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
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
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
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
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
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
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
6.
Design and draw a circuit using appropriate logic gates to represent the following logic expressions: a) P Q b) (X Y) . X
P Q a)
PQ
P+Q
b)
(X Y) . X
7.
A Question
Specimen
Page / 16
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.
Page / 17
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