Worksheet 3. Digital Circuits (1)

SKE Computer Science Course 2013
Worksheet 3. Digital Circuits (1)
[CBPrice. 19-06-13]
Color Coding for this Worksheet
Information
Instructed Learning
Inquiry based Learning
Challenges
Homework
Purpose
(a) To learn how computer hardware can represent numbers.
(b) To revise 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 memory and adders.
Resources
(a) This session will make extensive use of the freely downloadable logic simulator “Multimedia Logic”.
(b) Scanned “mini-lecture” notes.
Activities
1
Thinking about the data bus
You have a data bus comprising two wires.
(a) Write down a table of all possible states of the two wire bus. How many entries do you have?
(b) Now you add a third wire to your bus. Write down a table of all of the possible states now. How
many entries do you have now?
(c) By what factor has your answer to (a) increased?
(d) If one wire has 2 states, 2 wires has 2x2=4 states and three wires have 2x2x2=8 states then how
many states does five wires have?
(e) How many states does n wires have? (Bit of maths here!)
2
Representing numbers and characters on the data bus
Use your answers to the above question to help you with this one.
(a) How many numbers can be represented on a data bus comprising 2 wires?
(b) What are the smallest and the largest denary number that can be represented?
(c) How many numbers can be represented on a data bus comprising 8 wires? What is the largest
denary number that can be represented?
(d) What is the largest number that can be represented on a bus containing n wires?
(e) Modern desktops are either 32-bit or 64-bit. Assuming that a bit is a wire, what is the largest
number that can be represented by both desktops?
(f) How many wires are needed to represent the lower-case characters from ‘a’ to ‘z’? Hint:
calculate the maximum number of characters that can be represented by 1,2,3,4, … wires ….
4
Basic Digital Gates.
Use multimedia logic to complete the truth tables for the following gates
AND
OR
XOR
NAND
NOT
Now use multimedia logic to complete the truth table for the “missing gate” !
5.
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.
6.
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.
7.
From Truth Tables to Digital Circuits (1)
Let’s attack the problem discussed in the mini-lecture, the car situation where an alarm will sound
if one seat-belt 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).
8.
From Truth Tables to Digital Circuits (2)
Consider the following truth table where A and B are inputs and O is the output.
A
0
0
1
1
B
0
1
0
1
O
0
1
1
0
(a) Create a digital logic circuit for the second line which has a true output. Start with two inputs
labelled A and B and get the output O for this line. Remember a line needs an AND gate.
(b) Create a digital logic circuit for the third line which has a true output. Start with two inputs
labelled A and B and get the output O for this line.
(c) Now combine both outputs from (a) and (b) using an OR gate to generate the circuit for the
whole truth table.
(d) Spend some time simplifying your circuit. You need two inputs A and B and one output. I
guess you should have 5 gates.
(e) Use multimedia logic to test your circuit.
9.
From Truth Tables to Digital Circuits (3)
Use your understanding from activities 7 and 8 to solve this problem.
You have a burglar alarm system in your house which is activated when you are on holiday. Door
D has a sensor which returns true when this door is closed. Door E has a sensor which returns
true when this door is closed. There is a pressure pad P inside the house which returns true when
someone steps on it. The burglar alarm A sounds off (is true) when both doors are closed and when
the pressure pad is activated. In other words the burglar has broken in through the windows.
Generate a digital logic circuit to solve this problem. Hint: What are the inputs, what is the output?
10.
A Simple Memory Circuit
Look at the following circuit which is a simple form of memory. It is called the “Set-Reset” latch.
It’s rather interesting since the output of the top gate is fed into the input of the bottom gate. So
there seems to be a sort of feedback loop here. Well, there is!
There are two inputs S (“Set”) and R (“Reset”) and two outputs Q and T. Let’s think about this
using pencil and paper before we get into a simulation.
(a) The circuit uses NAND gates, so write down (from memory) the truth table for the NAND gate.
(b) Let’s consider an input pair S = 1, R = 0 and let’s assume that the second input to the top gate is
1. Work out its output (using the truth table), feed this into the first input of the bottom gate, and
together with the input R work out the output of the lower gate. Feed this back into the second
input of the top gate and see if it agrees with our assumed value of 1. It should!
(c) Repeat this for input pairs {S = 0, R = 1}, {S = 0, R = 0}, {s = 1, R = 1}. You should discover
that there are only two stable states
11.
A Realistic Memory Circuit
Build the multimedia logic circuit below which has two inputs, a “toggle switch” and a “push”
switch.
(a) Start the simulation with the input (toggle) set to 0. Press the “push” switch, The outputs should
settle.
(b) Now change the input (toggle) several times and note what happens to the outputs. Nothing!
The circuit has remembered the input when “push” was pushed!
(c) Investigate and make sure you understand the behaviour of this circuit!
12.
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
1 First number A
1 Second Number B
0 Sum and Carry
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.
13.
Writing a Challenge for your fellow students
Create a simple problem like the car seat-belts or the burglar alarm where there are two (or
possibly three) inputs and one output. Use a real-world situation which would be familiar to your
students in school. Solve the problem (for yourself) according to the approach presented in this
session, and give this to your peers.
HW
You should work on your portfolio. Perhaps you may also like to explore multimedia logic a little
more?