Professional Documents
Culture Documents
Preliminary Computer Science I: COMP0001
Preliminary Computer Science I: COMP0001
COMP0001
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 1 / 82
2
Lecture 2
Functional components of a
computer system
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 2 / 82
Contents
3
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 3 / 82
Content
4
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 4 / 82
Types of memory and storage
5
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 5 / 82
Types of memory and storage
5
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 5 / 82
Internal Memory
6
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 6 / 82
Primary memory
7
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 7 / 82
Primary memory
7
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 7 / 82
Primary memory cont..
8
There are two types of RAM technology, dynamic RAM (DRAM) and
static RAM (SRAM)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 8 / 82
ROM
9
ROM
Another form of primary memory is the read-only memory (ROM). This
is similar to RAM in that it shares the same random access properties,
but it cannot be written to or changed. As the name suggests, ROM is
a read-only memory device.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 9 / 82
Difference between RAM and ROM
10
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 10 / 82
Embedded systems
11
Embedded systems
This involve installing microprocessors into devices to enable
operations to be controlled in a more efficient way.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 11 / 82
Secondary memory
12
Secondary Memory
storage devices that are not directly accessible by the CPU.
They are larger than primary memory, but data access time is
considerably slower than RAM and ROM.
All applications, the operating system, device drivers and general files
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 12 / 82
Hard Disk Drives
13
Hard disk
1 Data is stored in a digital format on the magnetic surfaces of the
disks (or platters, as they are frequently called)
2 Many applications require the read-write heads to constantly seek
for the correct blocks of data; this means a large number of head
movements.
3 The effects of latency then become very significant. Latency is
defined as the time it takes for a specific block of data on a data
track to rotate around to the read-write head.
4 Through time, the HDD will undergo numerous deletions and
editing, which leads to sectors becoming increasingly fragmented,
resulting in a gradual deterioration of the HDD performance.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 13 / 82
HDD Cont..
14
Solid State
The most common type of solid state storage devices store data by
controlling the movement of electrons within NAND chips.
They have no moving parts and all data is retrieved at the same rate.
Latency is reduced considerably.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 14 / 82
Content
15
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 15 / 82
16
Early computers were fed data while the machines were running. It
was not possible to store programs or data;
In 1940, John Von Neumann developed the concept of the stored
program computer.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 16 / 82
Components of the processor (CPU)
17
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 17 / 82
The ALU
18
The ALU
The ALU allows the required arithmetic or logic operations to be
carried out while a program is being run.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 18 / 82
The Control Unit (CU)
19
The CU
The CU reads an instruction from memory (the address of the location
where the instruction can be found is stored in the program counter
(PC)). This instruction is then interpreted. During that process, signals
are generated along the control bus to tell the other components in the
computer what to do.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 19 / 82
The Clock
20
The Clock
A system clock is used to produce timing signals on the control bus to
ensure this vital synchronisation takes place - without the clock the
computer would simply crash.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 20 / 82
Immediate access store (IAS)
21
The IAS
The IAS holds all the data and programs that the processor (CPU)
needs to access.
This is done because read/write operations carried out using the IAS
are considerably faster than read/write operations to backing store.
The IAS is another name for primary (RAM) memory.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 21 / 82
System buses
22
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 22 / 82
Content
23
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 23 / 82
RISC and CISC processors
24
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 24 / 82
CISC
25
CISC processor
CISC architecture is based on single complex instructions which need
to be converted by the processor into a number of sub-instructions to
carry out the required operation.
This methodology leads to shorter coding (than RISC) but may actually
lead to more work being carried out by the processor.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 25 / 82
RISC
26
RISC processor
RISC processors have fewer built-in instruction formats than CISC.
This can lead to higher processor performance. The RISC design
philosophy is built on the use of less complex instructions, which is
done by breaking up the assembly code instructions into a number of
simpler single-cycle instructions. Using the same example as above to
carry out the addition of two numbers A and B (this is the equivalent
operation to ADD A, B): LOAD X, A - this loads the value of A into a
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 26 / 82
CISC & RISC Features
27
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 27 / 82
Content
28
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 28 / 82
Logic gates
29
Several logic gates combined together form a logic circuit and these
circuits are designed to carry out a specific function.
The checking of the output from a logic gate or logic circuit can be
done using a truth table
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 29 / 82
Logic gates
29
Several logic gates combined together form a logic circuit and these
circuits are designed to carry out a specific function.
The checking of the output from a logic gate or logic circuit can be
done using a truth table
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 29 / 82
Types of Logic Gates
30
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 30 / 82
Truth tables
31
Truth tables are used to trace the output from a logic gate or logic
circuit.
The NOT gate is the only logic gate with one input; the other five gates
have two inputs.
For logic circuits, the number of inputs can be more than 2:
for example, three inputs give a possible 23 (8) binary combinations.
And for four inputs, the number of possible binary combinations is 24
(16). The number of possible binary combinations is a multiple of the
number 2 in every case.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 31 / 82
NOT gate
32
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 32 / 82
AND gate
33
Description
The output, X, is 1 if input A is 1 and input B is 1
How to write this
X = A AND B (logic notation) X = A.B (Boolean algebra)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 33 / 82
OR gate
34
Description
The output, X, is 1 if input A is 1 or input B is 1
How to write this
X = A OR B (logic notation) X = A + B (Boolean algebra)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 34 / 82
NAND gate (NOT AND)
35
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 35 / 82
NOR gate (NOT OR)
36
X= (Boolean algebra)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 36 / 82
XOR gate
37
Description
The output, X, is 1 if (input A is 1 AND input B is NOT 1) OR (input A is
NOT 1 AND input B is 1)
How to write this
X = A XOR B (logic notation)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 37 / 82
Content
38
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 38 / 82
Logic circuit
39
When logic gates are combined to carry out a particular function, such
as controlling a robot, they form a logic circuit.
The output from the logic circuit is checked using a truth table. The
following three examples show how to:
1 produce a truth table
2 design a logic circuit from a given logic statement/Boolean algebra
3 design a logic circuit to carry out an actual safety function.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 39 / 82
Example 1: Produce a truth table
40
Produce a truth table for the following logic circuit (note the use of at
junctions)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 40 / 82
Solution 1
41
There are three inputs to this logic circuit; therefore, there will be eight
possible binary values which can be input.
To show step-wise how the truth table is produced, the logic circuit has
been split up into three parts and intermediate values are shown as P,
Q and R.
Part 1
first task is to find the intermediate values P and Q.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 41 / 82
Solution Part 1 cont..
42
The value of P is found from the AND gate where the inputs are A and
B.
The value of Q is found from the NOR gate where the inputs are B and
C.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 42 / 82
Part II
43
The second part of the logic circuit has P and Q as inputs and the
intermediate output, R.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 43 / 82
Part III
44
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 44 / 82
Final Solution
45
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 45 / 82
Example 2
46
Example 2
A safety system uses three inputs to a logic circuit. An alarm, X,
sounds if input A represents ON and input B represents OFF, or if input
B represents ON and input C represents OFF. Produce a logic circuit
and truth table to show the conditions which cause the output X to be
1.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 46 / 82
Solution
47
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 47 / 82
Solution 2 Cont ..
48
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 48 / 82
Solution 2 Cont ...
49
Now, combining both parts with Part 2 (the OR gate) gives us:
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 50 / 82
Example 3 is Homework
51
A wind turbine has a safety system which uses three inputs to a logic
circuit. A certain combination of conditions results in an output, X, from
the logic circuit being equal to 1. When the value of X = 1, the wind
turbine is shut down. The following table shows which parameters are
being monitored and form the three inputs to the logic circuit.
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 52 / 82
Boolean algebra
53
Figure: The notation used in this course to represent these two Boolean
operators
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 53 / 82
Rules that govern Boolean algebra
54
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 54 / 82
Proofs of DeMorgan’s laws
55
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 55 / 82
Proofs of DeMorgan’s laws
56
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 56 / 82
Examples
57
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 57 / 82
Solution 1
58
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 58 / 82
Solution 2
59
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 59 / 82
60
Half Harder
The half adder circuit is the simplest circuit. This carries binary
addition on 2 bits generating two outputs
1 the sum bit (S)
2 the carry bit (C)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 60 / 82
Content
61
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 61 / 82
62
Full Harder
= 1 (S = 0).
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 62 / 82
Flip-flop circuits
63
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 63 / 82
SR flip-flops
64
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 64 / 82
65
The output from gate ‘X’ is Q and the output from gate ‘Y’ is Q.
The inputs to gate ‘X’ are R and Q (shown in red on Figure above)
the inputs to gate ‘Y’ are S and Q (shown in green on Figure).
The output from each NOR gate gives a form of positive feedback
(known as cross-coupling, as mentioned earlier).
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 65 / 82
66
consider the truth table to match our SR flip-flop using the initial states
of R = 0, S = 1 and Q = 1. The sequence of the stages in the process
is shown in Figure above
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 66 / 82
67
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 67 / 82
68
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 68 / 82
69
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 69 / 82
JK flip-flops
70
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 70 / 82
JK flip-flop representation
71
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 71 / 82
JK flip-flop Truth table
72
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 72 / 82
73
Use of JK flip-flops
1 Several JK flip-flops can be used to produce shift registers in a
computer.
2 A simple binary counter can be made by linking up several JK
flip-flop circuits (this requires the toggle function).
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 73 / 82
74
It is possible to use the truth table and apply the sum of products
(SoP), or the Boolean expression can be formed directly from the logic
circuit.
Example 1: Write down the Boolean expression to represent this logic
circuit.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 74 / 82
Solution
75
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 75 / 82
Example 2
76
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 76 / 82
Solution
77
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 77 / 82
Content
78
1 Computer memory
2 Processor Fundamentals
3 Processor architectures
4 Logic gates and logic circuits
5 Logic circuits
6 Boolean algebra
Half adder circuit and full adder circuit
7 Advanced logic circuits
Flip-flop circuits
Boolean algebra and logic circuits
8 Karnaugh maps (K-maps)
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 78 / 82
79
ACTIVITY: Find out the origin of Gray codes and other applications of
the code.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 79 / 82
Example
80
Produce a Boolean expression for the truth table for the NAND gate.
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 80 / 82
Solution
81
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 81 / 82
82
The values along the top and the bottom follow Gray code rules.
Only cells containing a 1 are taken account of.
Groups can be a row, a column or a rectangle.
Groups must contain an even number of 1s (2, 4, 6, and so on).
Groups should be as large as possible.
Groups may overlap within the above rules.
Single values can be regarded as a group even if they cannot be
combined with other values to form a larger group.
The final Boolean expression can only consider those values
which remain constant within the group (that is, remain a 1 or a 0
throughout the group).
Ilenius Ildephonce (The UWI, Five Islands) COMP0001-Lecture Week 2 September 26, 2021 82 / 82