Professional Documents
Culture Documents
Digital Fundamentals Notes
Digital Fundamentals Notes
Electronics is particularly well suited to these kinds of manipulation of signals; it is widely used in
engineering systems for measurement, communication and control. A device that translates a physical
parameter to an electrical signal is called a sensor. A device that uses an electrical signal to drive a
system parameter is called an actuator. Sensors and actuators are examples of transducers.
Suppose we have a robot and we want to control the position of its forearm by rotating at the elbow.
1
The physical system that we are trying to control is the forearm. The physical parameter is the angle at
the elbow. The target value is the angle that we want to move to: in this example 40° above the
horizontal. The control system has to use the different between the actual angle and the desired angle
to compute an output that is used to drive the movement of the forearm.
In order for this system to work well we need an accurate, reliable and stable measurement of the
angle, and the ability for our control system to accurately perform some complicated calculations.
All electrical signals can become degraded or corrupted as they are processed/transmitted/stored.
Causes include thermal fluctuations in the components, and the effects of electric or magnetic fields in
the vicinity inducing an unwanted signal in our system. These unwanted signal components are called
noise. Here is an example for an analogue signal:
In an analogue system, it is often impossible to remove the noise from the desired signal. With a
digital system we are simply thresholding the voltage to decide if it is high or low; noise removal
happens automatically whenever we process a signal. For example, here is a digital signal corrupted
with noise being fed into an inverter (a device that outputs a low voltage when the input is high, and
vice versa). We get a completely clean output signal:
2
1.3 Making our simple example digital
An analogue control system would use a transducer to form a voltage proportional to angle of the
elbow. We would also have some way to create a voltage that expresses the angle that we want to
move to. Then we would have to build some kind of circuit that subtracts the two voltages, amplifies
the result and sends it to the mechanism that drives the arm. This is complicated to do and requires a
good grasp of electronic circuit theory, but the result may not be very accurate or consistent in its
control of position.
A digital solution would instead see the angle as divided up into a series of zones, and give each zone
a number, in this example 0 to 7. We can only manipulate 1s and 0s, so we then need to convert the
numbers 0 to 7 into binary (we’ll see how to do this in lecture 2).
Our control system just reads in the angle as a number (starting angle is in zone 1) and knows the
number that we want to move to (target angle is zone 5). It then just has to perform arithmetic on
numbers to compute the drive signal for the movement mechanism. This is easy to do, and can be
accomplished by building a special purpose circuit, or by programming a standard single chip
computer called a microcontroller. The digital way of doing things will can give a more accurate
result and is cheaper than the analogue approach. Most of the time, the digital approach doesn’t
require any understanding of voltages or currents: it just thinks in terms of the abstract symbols 1 and
0.
One final point to note: the diagram above simplifies things to make it easy to visualise, so the angle
has only been divided into 8 zones. This would actually give us terrible accuracy, because zone 5
stretches all the way from an angle of 22.5° to 45° above the horizontal. The control system would
move the arm into somewhere in this zone, but we couldn’t control exactly where, so we couldn’t
move to exactly 40°. In a real-world system, we would divide the angle into a much larger number of
zones (at least 256) and this would give us much more precise control over the angle.
3
2 The Binary Number System
A single HIGH/LOW signal (a bit) isn’t often much use by itself. Coding provides us with ways to take
a group of bits that collectively form a more useful number. Binary coding is one obvious method to
build a wide range of numbers from 1s and 0s. (Indeed the word “bit” is short for binary digit.)
However binary has its disadvantages, so there are other coding methods (e.g. Gray codes) that we
will need.
d 10
i 0, n 1
i
i
So, for example, the number 365 has three digits: d2=3, d1=6 and d0=5. Its value is
3 100 + 6 10 + 5 1, which is
3 102 + 6 101 + 5 100
For binary numbers, the number base is 2 and the binary digits (bits) can take the values 0,1. An n-bit
binary number has the value
d 2
i 0 , n 1
i
i
So, for example, the denary number 5 equates to the 3-bit binary number 101, which has digits d2=1,
d1=0 and d0=1. Its value is
1 4 + 0 2 + 1 1, which is
1 22 + 0 21 + 5 20
The leftmost bit has the highest weighting and is called the most significant bit (msb). The rightmost
bit has the lowest weighting and is called least significant bit (lsb). The largest number that we can
represent depends on the number of bits that we use. For example, if we use 3 bits to represent a
number, then there are 8 different values that can be represented:
A group of eight bits is called a byte. A group of bits that we use to represent our data items is known
as a word. Typical word lengths are 8, 16, 32, 64 bits.
4
2.2 Conversion from binary to denary
Suppose we have a binary number, say 1101001, and we want to convert it to denary. This is just
1 26 + 1 25 + 0 24 + 1 23 + 0 22 + 0 21 +1 20
= 1 64 + 1 32 + 0 16 + 1 8 + 0 4 + 0 2 +1 1
= 105
(1101001)2 = (105)10
Binary Denary
5
3 Other Useful Coding Schemes
3.1 The hexadecimal number system
Binary numbers can be long and hard to read. A more succinct representation is given by using base-
16, or hexadecimal (hex for short). 16 digits are now required, so as well as 0-9, the letters A-F are
also used to represent the digits ten to fifteen, as follows:
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
Denary 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
For example, consider the hexadecimal number, (69)16:
(69)16 = 6×161 + 9×160 = 6×16 + 9×1 = (105)10
Conversion from hexadecimal to binary and back again is much simpler than decimal to binary
conversion. The 4-bit binary representation of the number 6 is 0110, and of 0 is 1001. The 8-bit
representation of 69 is just 0110 followed by 1001, giving 01101001. So you can think of hex as a
form of shorthand for binary. Each group of 4 bits of the binary number becomes one hex digit.
As another example, consider the hexadecimal number (2D3)16. Remembering that D is the
hexadecimal digit that represents 13, we get
(2D3)16 = 2×162 + 13 ×161 + 3×160 = 2×256 + 13 ×16 + 3 = (723)10
Now suppose we want to convert (2D3)16 to binary. Each hex digit contains the same information as 4
binary bits. We substitute 2 by its 4-bit binary representation 0010, D by its 4-bit binary representation
1101 and 3 by its 4-bit representation 0011. So
(2D3)16 = (001011010011)2
You can see from this example that hex values are much more succinct and easy to read and
remember than their binary counterpart.
Conversion from binary to hexadecimal is also easy: we convert each group of 4 bits to its
hexadecimal counterpart. If the number of bits in the binary number is not a multiple of 4, then we put
enough zeroes in from of the binary number to get a number of bits that is a multiple of 4. So, for
example, if we want to convert the 6-bit binary number
(101001)2
and then we convert groups of 4 bits. (0010)2 is (2)16 and (1001)2 is (9)16
(00101001)2 = (29)16
6 7 Base-10
0
Binary
000
5 1 001
2 010
4 3 011
3 4
5
100
101
2 6
7
110
111
1 0
Gray codes are ways of encoding numbers that ensure that successive numbers differ only in one bit
position. A 3-bit Gray code looks like this:
Number Binary representation Gray code
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100
A Gray coded rotary encoder belt is shown below. A misalignment of the light sensors does not cause
any spurious position indications to be generated :
6 7 Base-10
0
Gray
000
5 1 001
2 011
4 3 010
3 4
5
110
111
2 6
7
101
100
1 0
7
4 Building Logic Circuits
4.1 Road map for the digital part of the module
We will now start our treatment of how to design digital circuits that fulfil useful purposes. There are
two types of logic system:
Combinational logic produces an output that is determined only by the state of the input at
that point in time. If we know what the present input is, then we know immediately what the
present output must be. An example is a standard up/down light switch.
Sequential logic produces an output that is determined not only by the present input but also
by the device’s past history. An example would be a pull-cord light switch in a bathroom. If
we pull the cord (the input) when the light is off, then the light (the output) will turn on. If we
pull the cord when the light is on, then the light will turn off.
There are two types of activity we will need to know how to do:
Analysis means we are given a circuit design and we must figure out what it would do and
how it would behave
Synthesis means we are given a required function and we have to design the circuit that will
fulfil this function
Boolean algebra is a mathematical description of systems built from components that can take 2
possible signal values. Mastery of Boolean algebra enables us to take a requirement for the system
behaviour and translate it into a circuit design. It also gives us ways to ensure that our circuit designs
are efficient. Boolean algebra was originally developed to deal with problems in logic that considered
two-value propositions that are TRUE or FALSE, and only later became used for digital electronics.
Because of this basis in Boolean algebra, digital electronic systems are often referred to as logic
systems.
A B C
0 0 0
0 1 0
1 0 0
1 1 1
This function is called an AND function. This operation is sometimes referred to as the logical
product of A and B, because it is very similar to a 1-bit multiplication. Logic design uses special
circuits (called logic gates) that implement the basic logic functions. This example is an AND gate. Its
logic symbol and Boolean algebra representations are:
AND
A B C
0 0 0
A
0 1 0 C C = A.B
1 0 0 B
1 1 1
For this case, the truth table, symbol and algebraic formula are:
OR
A B C
0 0 0 A
0 1 1 C C = A+B
1 0 1 B
1 1 1
9
4.2.3 Inclusive OR, exclusive OR
The word “or” in the English language has two meanings
Inclusive OR: one or the other or both
o “See a doctor if you have vomiting or diarrhoea”
o If you have both vomiting and diarrhoea should you see a doctor? Yes.
Exclusive OR: either one or the other
o “You can have a side of chips or salad with your burger”
o Can you have both chips and salad? No.
Normally in the English language we just figure out from the context whether the inclusive or
exclusive version is required. A mathematical representation requires greater precision and we regard
these as two completely different logical operations. The truth tables for these different functions are:
Our OR gate implements the inclusive OR function. There is a logic gate that implements the XOR
function, but it is less fundamental than the OR gate and we’ll leave its consideration until later.
Its truth table, logic symbol and Boolean algebra representation are:
NOT
A B B=A
0 1
A B
1 0
10
4.3 Putting it all together
Now we’ll design our alarm system.
Alarm enabled?
Upstairs window closed? Sound the alarm
Downstairs window closed?
The interface with the real world will be three input switches:
A) Alarm is enabled? 1=yes 0=no
B) Upstairs window is closed? 1=yes 0=no
C) Downstairs window closed? 1=yes 0=no
We have one output signal:
D) Sound the alarm? 1=yes 0=no
The required behaviour is that the alarm should be sounded if (the alarm is enabled and (the upstairs
window is not closed or the downstairs window is not closed))
It should be easy to see that a circuit that will accomplish this function is:
A
D
B
C
A
D
B
C
The two different representations that we have seen are identical in their meaning.
11
5 Circuit analysis: figuring out what a circuit does
We have come up with a design for our burglar alarm circuit.
A
X D
B
C Z
Y
Now let’s analyse the circuit to make sure that it behaves in the way we expect. To help us with the
analysis we have given names to the additional circuit nodes X, Y, Z.
To see how the circuit responds to inputs, we could give it a set of input values, e.g. A=1, B=0, C=0
then work forward from the input to the output evaluating X, Y, Z, D. Evaluating the output of the
inverters tells us that X=1 and Y=1. Evaluating the OR gate’s response to these values of X and Y
tells us that Z=1. Finally we evaluate the AND gate’s response to the input Z=1, A=1 tells us that
D=1. So this set of values at the input will cause the alarm to sound.
A B C X Y Z D
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
We then move from the inputs toward the output, evaluating the columns. We start with X, which is
the inverse of B, and Y, which is the inverse of C:
A B C X Y Z D
0 0 0 1 1
0 0 1 1 0
0 1 0 0 1
0 1 1 0 0
1 0 0 1 1
1 0 1 1 0
1 1 0 0 1
1 1 1 0 0
Now we can fill in the column for Z: it is 1 in any row where we see X=1 or Y=1
12
A B C X Y Z D
0 0 0 1 1 1
0 0 1 1 0 1
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 1 1 1
1 0 1 1 0 1
1 1 0 0 1 1
1 1 1 0 0 0
A B C X Y Z D
0 0 0 1 1 1 0
0 0 1 1 0 1 0
0 1 0 0 1 1 0
0 1 1 0 0 0 0
1 0 0 1 1 1 1
1 0 1 1 0 1 1
1 1 0 0 1 1 1
1 1 1 0 0 0 0
This final truth table lists every possible input condition, and tells us what the output D would do in
each case.
We use brackets, for example (X+Y) to show that we need first to perform the operation X OR Y and
then take the result of this operation and AND it with the value of A.
If we then want to evaluate the result for a particular set of inputs (say A=1, B=0, C=0) we substitute
these values into the equation.
𝐷 = 𝐴. (𝐵 + 𝐶̅ )
𝐷 = 1. (0 + 0)
𝐷 = 1. (1 + 1)
𝐷 = 1.1
𝐷=1
13
6 Boolean Algebra
So far, we have looked at simple examples. To tackle more complicated situations, we will need to
understand Boolean algebra. In this lecture we will look at some of the main rules of Booelan algebra.
We then put these rules to work in the next lecture to look at some examples of circuit simplification.
6.1.2 Commutativity
In our normal everyday arithmetic some operations don’t care which way round we write the
operands. For example 2×3 is the same as 3×2. We say that multiplication is commutative. Other
operations are not commutative, for example 2 3 is not the same as 3 2.
A quick inspection of the truth tables for AND and OR shows that both of these operations are
commutative:
A B
B
A.B = A
B.A
A B
B
A+B = A
B+A
6.1.3 Associativity
An associative operator means that if we have several occurrences of the same operator, we get the
same result regardless of how we group them. So in everyday arithmetic:
(2+3)+4 = 2+(3+4)
(2×3)×4 = 2×(3×4)
Addition and multiplication are associative. Because it doesn’t matter how we group, we normally
just say 2+3+4 or 2×3×4 without any brackets.
We are only free to change the groupings if all of the operations are the same. If the operators are
different, we are not allowed to change the grouping:
(2×3)+4 ≠ 2×(3+4)
It is easy to prove from the truth tables that AND and OR operations are associative:
(A.B).C = A.(B.C)
(A+B)+C = A+(B+C)
A A
A.B A.(B.C)
B = B
(A.B).C
C C B.C
14
A A+B A
A+(B+C)
B = B
(A+B)+C
C C B+C
As a result, we would normally just say A.B.C, A+B+C without using brackets. These can be
represented as 3-input versions of the AND gate and the OR gate:
A 3-input OR gate
B A+B+C Output is 1 when any input is 1
C
Of course, if the operations are different, then we can’t change the grouping without changing the
meaning:
(A.B)+C ≠ A.(B+C)
Similarly, in Boolean expressions AND has higher precedence than OR. So if we have
A+B.C
this should be interpreted as
A+B.C=A+(B.C)
This isn’t a consequence of any fundamental property of AND, OR. It’s just a way to save ourselves
from having to always write brackets all of the time.
15
A=
C=
B=1
It is clear that the output C will just be a copy of the input A. The logic gate is unnecessary, and can
be replaced with a wire connecting A to C. On the other hand, if we set the B input to 0 we get a 0 at
the output
A=
C=0
B=0
Once again, the logic gate is unnecessary. We can just replace it with a wire connecting C to 0.
A
A
A
0
The two inputs to the AND gate will be doing exactly the opposite to each other, so they can never be
1 at the same time. This means that the AND gate will output a 0. We can just replace the gate with a
wire connecting C to 0.
A.A=A
A. A=0
A=
C=
B=0
16
If we put a constant 1 at the B input, the output is just 1.
A=
C=1
B=1
The OR gate could be replaced by a wire connecting C to 1. We can summarise these results as:
A+0=A
A+1=1
To complete our survey of the OR gate, we consider the other two possibilities. We could take the
input and apply it to both inputs of the OR gate. Both inputs will then be going high and low at
exactly the same time. When the inputs are 1, the OR gate will output a 1. When the inputs are 0 the
output will be 0.
A
A
A
1
The two inputs to the OR gate will be doing exactly the opposite to each other, so one or the other will
always be 1. So the output of the OR gate is always 1. We can summarise these as:
A+A=A
A+A=1
A A
This sounds unremarkable, but actually will turn out to be very useful when we look at cases where
the single variable A is replaced by a more complicated formula that generates A.
17
7 Circuit simplification
Now that we have learned the basics of Boolean algebra, we need to do something useful with it. One
important application is circuit simplification. Often when we have a proposed design for a circuit, we
will wonder if our circuit is as good as it could be, or whether our design is unnecessarily
complicated. The process of taking a complicated circuit and finding an equivalent simpler circuit that
performs the same function is called circuit simplification. As we go through these examples, we will
find some more useful rules of Boolean algebra.
A
C
B
Is this design as simple as it can possibly be, or can we find a simpler equivalent circuit?
We start off by giving the internal nodes names to help us in our Boolean algebra analysis:
A X
Y C
Z
B
So we have found a much simpler circuit that achieves the identical function:
A
C
B
If we want to convince ourselves that these two circuits are indeed the same, then we can check by
forming the truth tables for the two circuits, and checking that the output C is the same for all
combinations of inputs:
18
7.2 How do we measure the quality of a circuit design?
If we are trying to optimise a circuit to be as good as it could be, we need to have some idea of what
measure of goodness we are using. There are several measures that we can use:
Circuit complexity: the number of logic gate inputs
Circuit speed
To get an estimate of hardware resource requirement it is tempting to just count the number of logic
gates. However, a four input AND gate normally requires twice as much hardware to build as a 2-
input AND gate. (The reason for this is the internal structure of a logic gate is made of switches called
transistors. Each separate input drives a separate transistor, so doubling the number of inputs doubles
the number of transistors used to build the gate.) So it makes more sense to count the total number of
inputs to logic gates and use this as our measure of hardware complexity.
To do a really accurate calculation of speed is tough, as the exact switching speed of gates depends on
many factors. However, we can usually get a pretty accurate ballpark estimate by assuming that each
logic gate has the same delay, normally denoted by the letter . We the estimate the overall speed of
the circuit by finding the slowest path from the inputs to the output (i.e. the one that travels through
the most logic gates):
A X A
Y C
Z C B
B
Gate input count=7; Delay=4 Gate input count=2; Delay=
The slowest path for the design on the left is when an input change on A results in a change at Z
(delay of ) then Y (total delay 2) then X (total 3) then C (total 4).
A A
D=A.(B+C) B
B D=A.B+A.C
C C
In the Boolean algebra, we expanded out the bracket to generate a new circuit with the same function.
This result feels intuitive from our everyday experience of normal algebra and arithmetic.
19
We can prove the truth of the relation by drawing up the truth tables for the two to show that A.(B+C)
has identical behaviour to AB+A.C for all possible combinations of inputs:
Alternatively, we can use an intuitive example to convince ourselves. Let’s go back to our burglar
alarm example:
A) Alarm enabled? 1=yes 0=no
B) Upstairs window open? 1=yes 0=no
C) Downstairs window open? 1=yes 0=no
D) Sound the alarm? 1=yes 0=no
(Alarm enabled AND Upstairs window open) OR (Alarm enabled AND Downstairs window open)
A A
D=A+(B.C) B
B D=(A+B).(A+C)
C C
Unlike the result of the previous section, this is not immediately intuitive from our experience of
“normal algebra”. We can prove this result it by truth table:
20
7.3.4 Absorption method
A useful trick in in simplifying Boolean algebra equations (and their corresponding logic circuits) is
known as absorption. Suppose we have the following equation
𝐶 = 𝐴 + 𝐴. 𝐵
𝐶=𝐴
We can understand this intuitively by reasoning that A.B can only be 1 when A is 1. But if A is 1, then
(because A appears as the first input to the OR function) C=1 regardless of the state of B. Conversely,
if A=0 then A.B must be 0, so C=0). We can prove this by truth table:
A B A.B A+A.B
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
𝐶 = 𝐴 + 𝐴. 𝐵
𝐶 = 𝐴. 1 + 𝐴. 𝐵
𝐶 = 𝐴. (1 + 𝐵)
𝐶 = 𝐴. 1
𝐶 =𝐴
21
8 Summary of Digital Fundamentals
The key ideas that you should understand are:
The meanings of the terms transducer, sensor, actuator
Why digital systems are popular for measurement, control and data logging applications
How to use the binary and hexadecimal numbers systems, and how to convert between them
When Gray codes should be preferred to binary codes
The use of truth tables to show circuit function
The fundamental logic gates used to build circuits: AND, OR, NOT
How to convert between Boolean algebra equations and logic gates
How to apply Boolean algebra to the simplification of complex circuits into simpler
counterparts that perform exactly the same function.
22
Index
23