v3 A-Level Presentation - 01 Computer Architecture Auto-Saved Auto-Saved
v3 A-Level Presentation - 01 Computer Architecture Auto-Saved Auto-Saved
A-level
Computer architecture
teachcomputerscience.com
2
Lesson Objectives
Students will learn about:
Various components of a computer such as memory and
processor.
How are these components connected?
How data is accessed from memory? How are contents copied
to memory?
How are programs executed?
Interrupts
teachcomputerscience.com
1.
Content
teachcomputerscience.com
4
Introduction
Systems architecture refers to the structure of the internal components of
a computer system.
teachcomputerscience.com
Introduction 5
teachcomputerscience.com
Comparison - Harvard (HA) & Neumann architectures (NA)
10
HA uses separate memory units & buses for instructions & data i.e. both memories can be accessed
simultaneously. This minimises the issue of keeping the processor waiting while loading or saving data
into memory, helps increases the processor performance. NA uses the same address & data buses for
both instructions & data - both instructions & data share the same pathways.
In HA each memory can be adapted to meet the needs of a particular system: the instruction & data
memories can be different sizes, different word lengths, or implemented using a different type of
technology. E.g. for systems with a predetermined use (such as embedded systems), the instruction
memory can be implemented as a ROM which protects the programs from accidental or deliberate
changes by hacking. NA allows for the instructions & data to be saved in the same memory, which can be
exploited by hackers who could disguise instructions (malware) as data that the processor may execute
unknowingly when attempting to read the data.
HA is commonly used in embedded systems, i.e. computer systems that are designed purposefully to
perform a specific set of operations & are used in situations where the speed of operation is very
important e.g. embedded systems such as traffic-control cameras are required to process large amounts
of data in real time.
NA enables a more flexible use of the main memory - allows the processor to run a variety of programs
that are not known in advance. NA is commonly used in general-purpose computers that are expected to
accommodate the varying needs of the end users e.g run numerous applications & switch between
different tasks. teachcomputerscience.com
11
Internal components of a computer
The internal components of a computer system consist of the hardware
required to process data & to allow the processor to communicate with other
devices such as secondary storage, display screens, and printers.
teachcomputerscience.com
The processor or Central Processing Unit (CPU)
12
teachcomputerscience.com
It would appear that we have
reached the limits of what it is
possible to achieve with computer
technology, although one should be
careful with such statements, as they
tend to sound pretty silly in 5 years.
-John von Neumann
14 teachcomputerscience.com
15
The buses
Buses connect components of a computer system together . A
bus - communication system that is used to transfer data btn
components.
• System bus - set of parallel connections that allow internal
components to communicate with each other & exchange
data.
• External buses - used to connect the peripherals to the
processor. These can be serial or parallel connections.
architecture
von Neumann architecture shows the components of a
computer in detail.
It shows the connection btn the CPU, memory & I/O controllers
using buses.
Three different kinds of buses are the address bus, control bus
and data bus.
teachcomputerscience.com
A model of the system bus - von Neumann 17
architecture
The following diagram illustrates an abstract model of the connections
teachcomputerscience.com
Buses 18
Type of
Function Direction of bus
bus
Transmits the address Unidirectional: From
Address from the CPU to the processor to
bus memory or I/O memory & I/O
controller controllers to devices
teachcomputerscience.com
Address bus (AB) 19
Used to specify the address of a memory location to either read (i.e. load)
data from or write (i.e. store) data to that memory location.
The width of the address bus refers to its number of parallel lines, which
determines the number of bits that can be used to form an address of
a memory location. It is typically a multiple of a byte (e.g. 8, 16, 32, or 64
bits).
• If width of AB is 8 bits - 28 numbers that can be used to address memory
locations
• If width of AB is 16 bits - 216 numbers that can be used to address memory
locations teachcomputerscience.com
20
Address bus (AB)
teachcomputerscience.com
21
Data bus (DB)
Used to transfer data & instructions. It is bidirectional, i.e. it
allows a two-way connection btn internal components of the
system — allowing values to be written to or read from a
location.
• Data is transferred to & from the processor
• Data is transferred to & from main memory
• Data is transferred to & from the I/O controllers
• Instructions are carried from main memory into the CPU
(to be decoded & executed)
teachcomputerscience.com
Data bus (DB) 22
teachcomputerscience.com
Control bus (CB) 23
Memory Unit
Memory device is a device to which we store binary info & this info
is stored in order to be retrieved at a later time to be used.
Therefore, the memory is the unit which info available for
processing when needed and as needed
The memory unit is a collection of cells that are capable of storing
very large amounts of binary info.
In digital systems we distinguish 2 types of memory i.e. RAM
(Random-access memory) and Read-only memory (ROM)
The process of transferring new info into the RAM memory is
called READ operation and the process of transferring info out of
the memory is called the WRITE operation
teachcomputerscience.com
26
Memory Unit and Data storage
A binary digit (or bit) is the fundamental unit of data storage, and
will have a value of 0, or 1. A group of eight bits is called a byte. Four-
bit numbers are called a nibble.
teachcomputerscience.com
Memory Unit and Data storage 27
12
terabyte TB 10 1,000,000,000,000 bytes
30 3
gibibyte GiB 2 1024 = 1,073,741,824 bytes
40 4
tebibyte TiB 2 1024 = 109,951,162,776 bytes
teachcomputerscience.com
Memory Unit & Data storage: How many numbers?
28
teachcomputerscience.com
29
Try it for yourself?
teachcomputerscience.com
30
Memory Unit
The most fundamental unit of the computer memory is the bit. The Address Contents
bit can only take one of two values: 1’s & 0’s
11010000 10010001
Memory words: the word is a group of 1’s & 0’s & it may represent a
11010001 11110101
number character(s) (A, B, C, D), instruction of a program or other
binary coded info 11010010 11100011
Memory unit consists of a number of partitions. 11010011 10101010
Each partition consists of data (contents) & an address. . .
Data is represented on modern storage media using the binary . .
numeral system.
The address uniquely identifies every location in memory & the
contents are in binary form.
. .
An example of data & addresses stored in a memory unit is shown. 11011110 11011011
Most computer memories use words that are multiple of 8 bits 11011111 11001100
(byte). So usually we find the words 8bits, 16bits, 32bits or 64bits etc
32bits (bytes) word memory is very common
teachcomputerscience.com
READ operation
31
To read the contents from any location, the registers MAR (Memory
Address Register) & MDR (Memory Data Register) are used. To read the
contents from the address 11010000, the address is copied to MAR.
Register Contents
MAR 1 1 0 1 0 0 0 0
A read signal is sent by the processor to the memory. The contents are
then copied to the MDR (Memory Data Register).
Register Contents
MDR 1 0 0 1 0 0 0 1
teachcomputerscience.com
32
WRITE operation
To write data into a particular address, the data is first written to the MDR.
Let us consider writing the data 10111011 to the address 11101110.
Register Contents
MDR 1 0 1 1 1 0 1 1
Register Contents
MAR 1 1 0 1 1 1 1 0
A write signal is sent by the processor to the memory unit through the
control bus & the location is written with the data in MDR.
teachcomputerscience.com
33
Processor (CPU)
The processor or Central Processing Unit (CPU) is the internal hardware
component of the computer that is responsible for executing the
instructions of programs.
teachcomputerscience.com
34
Processor: ALU
The ALU is responsible for performing arithmetic calculations & logical
operations that include:
• Addition, subtraction, multiplication, division
• Logical bitwise operations, such as AND, OR, NOT, & XOR
• Comparisons btn values, such as greater than, less than, equal to
• Shifting binary patterns to the left or right
The Accumulator (ACC) is the register that stores the result of arithmetic
and logical operations performed by a processor.
teachcomputerscience.com
35
Processor: CU
The CU (or program control unit) organises the sequence in which
program instructions are executed, followed by decoding the
instructions.
• Uses control signals to determine the operation the ALU will carry out
at each instance
teachcomputerscience.com
Clock 37
The clock rate, clock frequency, or clock speed is calculated as the number of clock
cycles that can be completed in one second. Measured in Hz, MHz & GHz. It is the inverse
of the clock period, i.e. clock frequency=1/clock period.
Clock cycles per operation
In the model of a computer, a data transfer is generally described as one operation. In
reality, it can take many clock cycles to achieve a data transfer from one component to
another.
• If processor needs to read a memory location, it sends a read request via CB, along with
the address of the memory location via AB. These operations happen at the same time (i.e.
in the same clock cycle).
• Depending on how long it takes to access the memory, processor then receives the
contents of that memory location via the DB, after a number of clock cycles.
• If processor needs to write to a memory location, it sends a write request via the CB,
along with the address of that memory location via the AB & the data that needs to be
stored via the DB.
teachcomputerscience.com
39
Registers
Registers are locations of computer memory within the
processor that provide extremely fast access.
General-purpose registers
Having to access the main memory can slow down the execution
of instructions.
Therefore, the processor uses registers to temporarily store &
access the results of operations.
The ALU is connected to a set of general-purpose registers that
are used to keep the results of the intermediate calculations that
are produced as part of a larger computation.
teachcomputerscience.com
40
Registers
Dedicated/special-purpose registers
Dedicated or special-purpose registers are processor-based
registers that are used for a specific purpose.
teachcomputerscience.com
Registers 41
teachcomputerscience.com
Registers
42
teachcomputerscience.com
44
Input-Output Devices
▪ An input device like a keyboard or mouse converts the signals sent by
humans into a form that can be understood by the computer.
▪ Output devices such as printers, monitors, etc. convert the information
from the computer into a form that is understandable by humans.
teachcomputerscience.com
45
I/O controller
I/O controller is a device that interfaces an input or output device with the
processor.
Each device has its own controller which is connected to a control bus. I/O
controller is responsible for receiving the requests from the processor &
sending control signals to the device specified for that operation.
It consists of:
• An interface to connect it to the system or I/O bus
• a set of data, command & status registers
• an interface that connects it to the cable connecting the device & the
processor.
teachcomputerscience.com
The fetch-decode-execute (FDE) cycle 46
teachcomputerscience.com
The fetch-decode-execute cycle: Fetch stage 49
2. Once the address of the instruction is on the AB,
the CU instructs a memory read operation to allow
the contents of the memory location to be
transferred to CPU. The instruction that is stored
at that address is transferred using the DB from
the RAM to the CPU, & is saved in the MBR/MDR.
teachcomputerscience.com
The fetch-decode-execute cycle: Fetch stage 50
3. The contents of the MDR are copied to the
CIR. This ensures that the current
instruction is kept safe so that the MDR can
be used during the execute stage, in order
to store additional data that is needed.
teachcomputerscience.com
The fetch-decode-execute cycle: Decode stage51
The CU decodes the instruction that is
kept in the CIR. This involves splitting
the instruction into operand & opcode
to determine what type of instruction
needs to be carried out, checking if
additional data are required from
memory, & figuring out where these
are kept in RAM.
teachcomputerscience.com
The fetch-decode-execute cycle: Execute stage
52
teachcomputerscience.com
Summary of fetch-decode-execute cycle 53
teachcomputerscience.com
Clock cycles per operation 54
It can take many clock cycles to achieve a data transfer from one component
to another.
• If CPU needs to read a memory location, it sends a read request via the CB,
along with the address of the memory location via the AB. These operations
happen at the same time (i.e. in the same clock cycle
• Depending on how long it takes to access the memory, the CPU then
receives the contents of that memory location via the DB, after a number of
clock cycles.
teachcomputerscience.com
55
What is an interrupt?
An interrupt is a signal sent from a device or software to the
processor.
The processor will temporarily stop its current process & will
service the interrupt signal.
E.g.: When paper is jammed in a printer, the CPU prompts the
user to check the status.
teachcomputerscience.com
56
Interrupts
§ Interrupts allow the computer to carry out
many tasks at the same time.
§ When the interrupt is serviced, the status of
the current job is saved. The contents of
registers PC & CIR are saved on to the system
stack.
§ Once the interrupt is serviced using the
interrupt service routine, the current job is
serviced according to its status when it was
saved before the interrupt service.
teachcomputerscience.com
57
teachcomputerscience.com
58
Interrupts
▪ Sometimes, when an interrupt is being serviced, another interrupt may
occur.
▪ The CPU may save the status of the current interrupt processing &
proceed to service the new interrupt.
▪ Another methodology that can be used is to use priorities. Based on the
priority of the interrupts, it can be decided whether the current interrupt
service should be paused or not.
▪ E.g., an interrupt that notifies the user that the battery of a laptop is
running low must be given the highest priority.
teachcomputerscience.com
59
teachcomputerscience.com
2.
Activities
teachcomputerscience.com
61
teachcomputerscience.com
62
Activity-2
Duration: 10 minutes
teachcomputerscience.com
63
Activity-3
Duration: 15 minutes
Address Contents
1. Data stored in a part of the memory 98 78
unit is given in the table. 99 65
A. In the box, explain how the content at 9A 81
the memory location 9D can be read? 9B 2F
9C 3E
B. In the box, explain how the data 76
9D 19
can be written to memory location 9E D4
99?
teachcomputerscience.com