WKSDigitalLogic

advertisement
Elements of Computer Science
Workshop4. Digital Logic Circuits
[CBPrice. 18-10
-13]
Color Coding for this Worksheet
Information
Instructed Learning
Inquiry based Learning. May be useful for Portfolio
Purpose
(a) To learn how computer hardware can represent numbers.
(b) To learn about the behaviour and use of logic gates.
(c) To create a digital circuit which can implement a design presented as a truth table
(d) To learn basic computational circuits such as adders.
Resources
(a) This session will make extensive use of the freely downloadable logic simulator “Multimedia Logic”.
Activities
1
Basic Digital Gates.
Use multimedia logic to write down the truth tables for the following gates
AND
2.
OR
XOR
NAND
NOT
Combination of Gates
(a) Use multimedia logic to complete the truth table for this combination of gates:
This is equivalent to one of the basic gates you looked at in 4. Which gate? Why?
(b) Now use multimedia logic to investigate this combination of gates
Which gate is this equivalent to? We shall come back to this result in a later session.
3.
The Ubiquitous NAND gate
It turns out that any digital electronic circuit (memory, CPU, etc.) can be built from a number of
NAND gates. So I suggest the NAND gate is “primordial”.
The circuits below only use NAND gates. Investigate them using multimedia logic and find out
which of the basic gates they emulate.
4.
From Truth Tables to Digital Circuits (1)
Let’s review the problem discussed in the mini-lecture, the car situation where an alarm will sound
if the seatbelt (there is only one) is off and the engine is running. Let’s agree on the following
symbols
S – the seatbelt is on
E – the engine is running
A – the alarm is sounding
(a) Write down the truth table for this situation where S and E are the two inputs and A is the
output.
(b) You should find that there is only one line in the truth table where A is 1. Construct a digital
circuit to create true output
(c) Test your circuit with multimedia logic, creating a truth table and comparing it with what you
found in (a).
5.
From Truth Tables to Digital Circuits (3)
You have a conveyor belt where blocks arrive from the left. There are two sensors A and B as
shown below
Each sensor outputs true only if a block lies on top of the sensor.
(a) We need an output signal only if a block lies over A or over B but not both. Write down the
truth table for this situation, with inputs A and B and output O.
(b) Construct a complete digital circuit for this case. Remember start with a partial circuit for each
line of the table, then combine the outputs of these circuits to make the output O.
(c) Test your circuit using multimedia logic, and revise if you got it wrong.
(d) Now consider the situation where the output signal is generated if either (i) there are no blocks
over either sensor or (ii) both sensors have a block. Create a truth table, a digital circuit and test it.
6.
From Truth Tables to Digital Circuits (5)
A section of road contains three sensors A,B,C underneath the road surface. When a car lies over
the sensor, then it outputs a logical ‘1’, else a ‘0’. Here’s the situation.
(a) Working as above, construct a digital circuit which will give an output only if there is a car at
A, there is no car at B and there is a car at C. You will need a truth table with three inputs and one
output and 8 rows. Test.
(b) Construct a digital circuit which will give an output if any two sensors (no more, no less) detect
a car. Test.
Notation
This is the basic notation used in Boolean algebra.
(i) 𝐴
not-A
(ii) A.B
A and B
(iii) A + B A or B
7.
Boolean Algebra (1)
(a) Build circuits for the left and right hand side of the following boolean expression and get the
truth tables for each circuit. They should be the same if the expression is true
𝑨 + 𝑨. 𝑩 = 𝑨 + 𝑩
(b) Now repeat for the following expression
𝑨. 𝑩 = 𝑨 + 𝑩
(c) Finally test if this is true
𝑨. (𝑨 + 𝑩) = 𝑨. 𝑩
8.
Boolean Algebra (2)
Build circuits for the following Boolean expressions and try to find the right hand side of the
equality
(a) 𝑨 + 𝑨 =
(b) 𝑨. 𝑩 + 𝑨. 𝑩 =
(c) 𝑨 + 𝑨. 𝑩 =
9.
A Digital Circuit to Add two numbers (“Half-Adder”)
Let’s say we wish to add two one bit numbers A and B. Here’s a table to show how we do the
addition, it’s like the tables you learned in primary school, but instead of 1000’s, 100’s, 10’s and
1’s (units), we have 8’s, 4’s, 2’,s and 1’s. But since we are only adding one-bit numbers, we shall
only need the 2’s and 1’s.
Take the example of adding 1 (first number A) to 0 (second number B). Then we have
8 4
2
1
1 First number A
0 Second Number B
1 Sum and Carry
Clearly the sum is 1 and there is no carry into the 2. If we added 0 to 1 then we would get the same.
But when we add 1 to 1 then this is a binary bit 2 so the addition looks like this
8 4
2
1
1 First number A
1 Second Number B
0 Sum and Carry
1
The sum is zero but now we have a carry over into the 2’s.
(a) Now let’s build up a truth table for this addition. Here’s a partially complete table, your task is
to fill in the sum and carry columns.
A B Sum
0
0
0
1
1
0
1
1
Carry
(b) Use the method you have learned to convert a general truth table into a digital logic circuit to
produce two circuits, (i) one to generate the sum and (ii) one to generate the carry.
(c) Verify that your circuit works using multimedia logic.
Download