Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Electrical Engineering 1

Fundamental Ideas of Digital Electronics

1 Why do we use digital electronics?


Engineering systems generally have physical parameters that we need to manipulate in some useful
way. Example parameters include:
 position,
 velocity,
 angle,
 angular velocity,
 temperature,
 pressure,
 chemical concentration etc.
Manipulations could include
 Data acquisition and data logging
 Control: devising new inputs to the system that will push the measured physical parameter
toward a desired value (e.g. a thermostat controlling a heater, or positon sensors and motors
controlling the movement of a robot arm)
 Condition monitoring: monitoring a parameter (vibration, temperature etc.), in order to
identify a significant change which is indicative of a developing fault. This is used to predict
imminent failure in order to request preventative maintenance.

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.

1.1 A simple example control system


A control system looks like this:

Suppose we have a robot and we want to control the position of its forearm by rotating at the elbow.

Start position Desired final position

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.

1.2 Analogue and digital


There are two main approaches to devising an electronic system
 Analogue electronics normally works by forming a signal voltage (or current or charge) that is
proportional to the physical parameter that we are interested in. Since parameters such as
temperature, pressure, position, etc. are continuous variables, the electronic signals that represent
these parameters will be continuous and vary smoothly.
 Digital electronics works with voltages (or sometimes current or charge) that are quantized into
two values (e.g voltages that are HIGH or LOW; switches that are ON or OFF, …). These two
values are conventionally called 1 and 0.

Digital electronics has the following advantages compared to analogue:


 Low mass-production costs
 Implementation of complex algorithms with good accuracy
 No drift or ageing problems.
 Good immunity to noise and signal degradation.
 High resolution available, e.g. CD player 1 part in 65536

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).

Angle divided into zones Angles converted to binary

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.

2.1 Positional Number Systems


In everyday life, we use the denary (base 10) number system whose digits can take the values
0,1,2,3,4,5,6,7,8,9. An n-digit denary number with digits di is interpreted as having the value

 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:

Number Binary representation


0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

In general, an n-bit binary number can represent 2n different values.

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

2.3 Conversion from denary to binary


To convert denary to binary; we start by writing a table of powers of two:
Power of 2 (as 2n) 27 26 25 24 23 22 21 20
Power of 2 (as a number) 128 64 32 16 8 4 2 1
Digit of our number
Our task is now to find out the combination of 1s and 0s that go in the bottom row to give us the
number that we are looking for. As an example, let’s convert the denary number 105:
 We find the largest power of 2 which is not more than 105. It is 64. Subtract it: 105 - 64 = 41.
 Now we need to represent 41 as the sum of powers of 2. We continue as before: the biggest power
of two which is not more than 41 is 32. Subtract it: 41 - 32 = 9.
 The largest power of two which is not more than 9 is 8. Subtract it: 9 - 8 = 1.
 The largest power of two which is not more than 1 is 1. Subtract it: 1 - 1 = 0.
In our table, we now write a 1 for every power of two that we used for subtraction (64,32,8,1). For all
of the other powers of two (16,4,2) we write a 0. We get:
105 = (1×64) + (1×32) +(0×16) + (1×8) + (0×4) + (0×2) + (1×1)
So we can see that the binary representation of 105 is 1101001.

2.4 Leading zeroes


Without changing the meaning, we can put any number of 0s in front of the binary number. For
example, we could represent 105 as 01101001:
105 = (0×128) + (1×64) + (1×32) +(0×16) + (1×8) + (0×4) + (0×2) + (1×1)

2.5 Showing which number system we are using


Things can get confusing when we mix different number systems in the same paragraph. To help
avoid confusion we normally put the number in brackets and attach a subscript to the brackets to show
what number base we are using. For example

(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

to hexadecimal, we turn it into an 8-bit number:


(00101001)2

and then we convert groups of 4 bits. (0010)2 is (2)16 and (1001)2 is (9)16
(00101001)2 = (29)16

3.2 Gray codes


Why would we need anything other than binary for our number codes? Suppose we want to measure
the angle of a rotation (for example, the elbow of our robot from lecture 1). A common solution is to
use an encoder disk to represent the bits of a binary number (black=0, white=1). We then use light
sensors attached to the moving part to read the pattern of black/white on the encoder as a number, so
we know angular position of the moving part. We would get a result that looks something like this:
6
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
Now suppose our light sensors are slightly misaligned and the readout of the bits is imperfectly
synchronised. Some very big errors in position are briefly reported when moving between two
successive numbers that have many bits that differ. For example, going from 011 to 100 would briefly
get a result of 000 if the sensor for the most significant bit lagged the other two sensors.

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

The themes of the digital part of the module are:


 Theme 1: Fundamental ideas of combinational logic
 Theme 2: Synthesis of combinational logic
 Theme 3: Sequential logic
 Theme 4: Putting it all together to look at programmable systems, such as the microcontrollers
(tiny single chip computers) that are embedded inside all sorts of engineering systems, for
example in motor cars to regulate engine timing, advanced braking systems and traction control

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.

4.2 Our basic building blocks: logic gates


The basic building blocks for digital circuits are logic gates. In this session we will introduce the most
important logic gates and start to develop the algebra that will be used to represent the circuits that we
will design.

4.2.1 The AND gate


As an example, suppose we are designing an alarm system for our home. We have a switch that can
detect when the window is open. We also have a switch that enables the alarm system. When we go
out of the house we will switch the alarm on so that it will raise an alert if the window is open.
We represent this as two input signals:
A) Window is open? 1=yes 0=no
B) Alarm is enabled? 1=yes 0=no
We have one output signal:
C) Sound the alarm? 1=yes 0=no
The behaviour we want is
(Sound the alarm) = (Window is open) AND (Alarm is enabled)
8
One way we describe the behaviour of a logic system is a truth table. This is a list of all the possible
combinations of input condition and the corresponding condition that we require at the output. For our
simple alarm it looks like this:

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

4.2.2 The OR gate


Now we want to extend our system to check for the upstairs window being open as well as the
downstairs. That gives us two input signals:
A) Upstairs window is open? 1=yes 0=no
B) Downstairs window is open? 1=yes 0=no
We have one output signal:
B) A window is open? 1=yes 0=no
The behaviour required is

(A window is open) = (Upstairs window open) OR (Downstairs window open)

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

This function is called an OR function. A OR B is normally written as A+B. This operation is


sometimes referred to as the logical sum of A and B.

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:

OR C=A+B XOR C=A⊕B


A B C A B C
0 0 0 0 0 0
0 1 1 0 1 1
1 0 1 1 0 1
1 1 1 1 1 0
Inclusive OR Exclusive OR

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.

4.2.4 The Inverter


Sometimes we need to reverse the value of a logic signal. Suppose we want to generate a signal that is
1 if the window is open. But we the only switches that we have available out a 1 when the window is
closed.

We can solve this with a device that has an input:


A) Window is closed? 1=yes 0=no
and an output:
B) Window is open? 1=yes 0=no

The behaviour required is

(Window is open) = NOT (Window is closed)

Its truth table, logic symbol and Boolean algebra representation are:

NOT
A B B=A
0 1
A B
1 0

The device is called an inverter (sometimes known as a NOT gate).

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

4.3.1 Inversion bubbles


The small circle at the output of an inverter is interpreted as a NOT operation and is called an
inversion bubble. We can use this in other locations in our diagrams to indicate the inversion of a
signal. For example, our alarm circuit can be represented like this:

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.

5.1 Truth table for the circuit


A more thorough way to do this is to draw up the truth table. There are 3 inputs to the system, so there
are 23=8 possible input conditions.

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

Finally D is 1 in the rows where both A=1 and Z=1

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.

5.2 Algebraic description of the circuit


To build up a Boolean logic representation of this circuit, we proceed as follows. The inverters give us
𝑋=𝐵
𝑌 = 𝐶̅
The OR gate gives us
𝑍 = 𝑋 + 𝑌 = 𝐵 + 𝐶̅
The AND gate gives us
𝐷 = 𝐴. (𝑋 + 𝑌) = 𝐴. (𝐵 + 𝐶̅ )

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 Properties of AND, OR, NOT

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 and A+B = B+A

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 AND gate


B A.B.C
C Output is 1 when all inputs are 1

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)

6.1.4 Operator precedence


In everyday arithmetic we may come across an expression like this:
2+3×4
Do we interpret this as (2+3)×4 or as 2+(3×4)? Mathematicians could have made the decision that
people should always use brackets, and disallow unbracketed expressions like 2+3×4. However,
that’s not the choice that was made. Instead the convention is that we allow unbracketed expressions
and interpret them by giving multiplication a higher precedence (i.e. we do it first). So
2+3×4 should be interpreted as 2+(3×4)
This isn’t a consequence of any fundamental property of multiplication and addition. It’s just a way to
save ourselves from having to always write brackets all of the time.

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.

6.2 Functions of a single variable


We continue our survey of Boolean algebra by looking at how our logic gates perform when we have
only one input that is variable (free to change between 0 and 1) and all other inputs are constant.

6.2.1 AND gate functions


Suppose we have a digital signal (making transitions between 1 and 0 as time goes by) and we apply it
to the A input of an AND gate. The output C is 1 when both inputs are 1, and 0 at all other times.
Suppose the B input is fixed at 1 and will never change.

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.

We can summarise these as


 A.1=A
 A.0=0
What other ways can we apply an input signal A to an AND gate? We could connect A to both inputs
of the AND gate. Both inputs will then be going high and low at exactly the same time. When the
inputs are 1, the AND gate will output a 1. When the inputs are 0 the output will be 0.

A
A

The gate is unnecessary and can be replaced by a wire connecting A to C.

Finally we could invert the value of A and feed it to the B input:

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

6.2.2 OR gate functions


The OR gate outputs a 1 when any of its inputs have a value of 1. Suppose we apply a constant value
of 0 at the B input, then the signal C will just be a copy of A. The OR gate is unnecessary and could
be replaced by a wire connecting A to C.

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

Finally we could invert the value of A and feed it to the B input:

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

6.2.3 Inverter functions


It should be reasonably obvious that if we take a variable A and invert it, and then we invert it again
the output will be a copy of A.

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.

6.3 Summary of functions of a single variable


We can summarise these relationship as:

AND relations Inverter relations OR relations


A.1=A A+1=1
A.0=0 𝐴̅=A A+0=A
A.A=A A+A=A
A.A=0 A+A=1

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.

Suppose we are given a design for a circuit:

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

Then we build up the Boolean logic equation for this circuit:


𝐶 =𝑋+𝐵
𝐶 = 𝐴. 𝑌 + 𝐵
𝐶 = 𝐴. (𝐴 + 𝑍) + 𝐵
𝐶 = 𝐴. (𝐴 + 𝐴̅) + 𝐵

Now we look for simplifications:


𝐴 + 𝐴̅ = 1 so our circuit becomes 𝐶 = 𝐴. 1 + 𝐵
𝐴. 1 = 𝐴 so our circuit becomes 𝐶 = 𝐴 + 𝐵

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:

The original circuit The simplified circuit


A B Z Y X C A B C
0 0 1 1 0 0 0 0 0
0 1 1 1 0 1 0 1 1
1 0 0 1 1 1 1 0 1
1 1 0 1 1 1 1 1 1

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).

7.3 Useful simplifications using Boolean Algebra:

7.3.1 Expanding out brackets (distributive property)


In everyday arithmetic, we are used to taking expressions like this:
2×(3+4)
and expanding out the bracket:
2×(3+4) = (2×3)+ (2×4)
We say that multiplication is distributive over addition. Not all operations have this property. So, for
example
2 (3+4) ≠ (23)+ (24)
We say that division is not distributive over addition.

7.3.2 AND is distributive over OR


These two circuits have the same function:

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:

A B C B+C A.(B+C) A B C A.B A.C A.B+A.C


0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 1 0 0 0
0 1 0 1 0 0 1 0 0 0 0
0 1 1 1 0 0 1 1 0 0 0
1 0 0 0 0 1 0 0 0 0 0
1 0 1 1 1 1 0 1 0 1 1
1 1 0 1 1 1 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1

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

If you think about it a little, it should be clear that the condition:

Alarm enabled AND (Upstairs window open OR Downstairs window open)

Means exactly the same thing as

(Alarm enabled AND Upstairs window open) OR (Alarm enabled AND Downstairs window open)

7.3.3 OR is distributive over AND


These two circuits perform the same function:

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:

A B C B.C A+(B.C) A B C A+B A+C (A+B).(A+C)


0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 1 0 1 0
0 1 0 0 0 0 1 0 1 0 0
0 1 1 1 1 0 1 1 1 1 1
1 0 0 0 1 1 0 0 1 1 1
1 0 1 0 1 1 0 1 1 1 1
1 1 0 0 1 1 1 0 1 1 1
1 1 1 1 1 1 1 1 1 1 1

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

𝐶 = 𝐴 + 𝐴. 𝐵

This can be simplified to just

𝐶=𝐴

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

We also can prove it by Boolean algebra like this:

𝐶 = 𝐴 + 𝐴. 𝐵
𝐶 = 𝐴. 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.

The key things that you should be able to do are:


 Convert numbers between binary and denary form
 Convert numbers between binary and hexadecimal form
 Explain what is the defining property of a Gray code
 Use a truth table to work out the behaviour of a logic circuit
 Convert a logic circuit into Boolean equation
 Convert a Boolean equation into a logic circuit
 Use the rules of Boolean algebra to simplify an inefficient design for a logic circuit, and
quantify how much improvement is achieved

22
Index

1 Why do we use digital electronics? 1


1.1 A simple example control system 1
1.2 Analogue and digital 2
1.3 Making our simple example digital 3
2 The Binary Number System 4
2.1 Positional Number Systems 4
2.2 Conversion from binary to denary 5
2.3 Conversion from denary to binary 5
2.4 Leading zeroes 5
2.5 Showing which number system we are using 5
3 Other Useful Coding Schemes 6
3.1 The hexadecimal number system 6
3.2 Gray codes 6
4 Building Logic Circuits 8
4.1 Road map for the digital part of the module 8
4.2 Our basic building blocks: logic gates 8
4.2.1 The AND gate 8
4.2.2 The OR gate 9
4.2.3 Inclusive OR, exclusive OR 10
4.2.4 The Inverter 10
4.3 Putting it all together 11
4.3.1 Inversion bubbles 11
5 Circuit analysis: figuring out what a circuit does 12
5.1 Truth table for the circuit 12
5.2 Algebraic description of the circuit 12
6 Boolean Algebra 14
6.1 Properties of AND, OR, NOT 14
6.1.2 Commutativity 14
6.1.3 Associativity 14
6.1.4 Operator precedence 15
6.2 Functions of a single variable 15
6.2.1 AND gate functions 15
6.2.2 OR gate functions 16
6.2.3 Inverter functions 17
6.3 Summary of functions of a single variable 17
7 Circuit simplification 18
7.2 How do we measure the quality of a circuit design? 19
7.3 Useful simplifications using Boolean Algebra: 19
7.3.1 Expanding out brackets (distributive property) 19
7.3.2 AND is distributive over OR 19
7.3.3 OR is distributive over AND 20
7.3.4 Absorption method 21
8 Summary of week 2 22

23

You might also like