29 October 2013 Birkbeck College, U. London 1
Introduction to Computer Systems
Lecturer: Steve MaybankDepartment of Computer Science and
Information [email protected]
Autumn 2013
Week 5b: CPU and the Machine Cycle
29 October 2013 Birkbeck College, U. London 2
Action of a Computer 1
Recall Tom and his boxes
Instruction: add the contents of box a and box b, put the result in box c.
The part of a computer corresponding to Tom is the central processing unit (CPU)
10a cb d e f g
5 12 -3 -1 111
29 October 2013 Birkbeck College, U. London 3
Action of a Computer 2
Tom has to:
Read the contents 10 of box a and the contents 5 of box b.
Add together 10 and 5 to get 15.
Write 15 in box c.
10a cb d e f g
5 12 -3 -1 111
29 October 2013 Birkbeck College, U. London 4
Summary of the Actions of the CPU
Obtain an instruction
Read data from memory
Calculate
Write data to memory
The CPU requires its own memory for storing instructions and data
29 October 2013 Brookshear, Section 2.1 5
Parts of a Computer
arithmetic/logicunit
register unit
central processing unit
:
registers
bus
mainmemory
control unit
29 October 2013 Brookshear, Section 2.1 6
Central Processing Unit
Register: small amount of very fast read/write memory, e.g. enough to store one number.
Arithmetic/Logic Unit: operates on data in registers, e.g. addition, subtraction.
Control Unit: controls the ALU.
ALU
ControlUnit
Register Unit
.
.
.
29 October 2013 Brookshear, Section 2.1 7
Concepts Places for storing bit strings:
registers, main memory. Transfer of bit strings from one
place to another. Operations on bit strings: produce
a new bit string from one or more given bit strings.
29 October 2013 Brookshear, Section 2.1 8
Some Actions of a Computer
ALUCPU
registers
busmain
memory
1. Take a bit string from main memory and put it in a register.2. Take a bit string from a register and put it in main memory.3. Move a bit string from one register to another.4. Take bit strings bi from registers Ri, i=1, 2. Interpret b1, b2 as two’s complement representations of integers, add them and put the result in the register R3.
control unit
29 October 2013 Brookshear, Section 2.1 9
Bus
Wires connecting CPU to main memory. Read: CPU sends read signal and
address of memory cell. Write: CPU sends write signal, address,
and data to be written. Length ~15cm. Speed of light = 30cm
in 1 ns. Time for CPU to access a register ~ 2.5 ns.
29 October 2013 Brookshear, Section 1.2 10
Logical Structure of Main Memory
List of cells or words addressed from 0 to 2n-1, where n is a large integer.
All cells contain the same number of bytes, e.g. 1 byte.
Example: if a register contains 16 bits then the largest memory that can be addressed using the register has 216 cells.
29 October 2013 Birkbeck College, U. London 11
Memory Access Times
Access Time
Size
CPU registers
2.5ns 256 bit
RAM 60 ns ~1 GB
Hard disk
15 ms 2 TB
Tape 10min 10 TB
29 October 2013 Brookshear, Section 2.1 12
Stored Program Concept The program is stored in main memory
along with the data. The control unit reads both instructions
and data from the main memory. This is the von Neumann architecture.
Advantage: the program can be changed easily.
Disadvantage: high traffic on the bus. This is the von Neumann bottleneck.
29 October 2013 Brookshear, Section 2.3 13
The Machine Cycle
Fetch nextinstruction frommemory to CPU
Decode thebit pattern
Execute theinstruction
FetchDecodeExecute
29 October 2013 Brookshear, Section 2.3 14
CPU and Main Memory in More Detail
Address | Cells
00
01
.
.
FF
Arithmetic/logic unit
control unit
Registers
.
.
0
F
1Program counter
Instruction register
Bus
Main memoryCentral processing unit
29 October 2013 Brookshear, Section 2.3 15
Special Registers
Program counter: contains the address of the next instruction to be executed.
Instruction register: holds the instruction which is being executed.
29 October 2013 Brookshear, Section 2.3 16
Adding Values Stored in Memory
1. Get the first value from memory and place it in a register.
2. Get the second value from memory and place it in another register.
3. Activate the addition circuitry with the registers in 1 and 2 providing the inputs and another register to hold the result.
4. Store the result in memory.5. Stop.
29 October 2013 Brookshear, Section 2.1 17
Cache Memory High speed memory in the CPU. Size
~100 KB. Stores data and instructions recently
accessed from main memory. Cache read/write is faster than main
memory read/write. Disadvantage: overhead of keeping the
cache consistent with main memory.
29 October 2013 Brookshear, Section 2.3 18
System Clock
Circuit generating pulses at regular intervals.
The computer’s activities are in step with the pulses, e.g. 5 pulses for an addition.
Current clock speeds ~ 2 GHz. (=2 pulses per nanosecond).
Clock speed only a rough guide to performance, e.g. instructions per second.
29 October 2013 Brookshear, Section 2.1 19
Motherboard
Main circuit board of the PC. Contains the central processing unit
(CPU) and the bus. Components, e.g. memory, hard drive
interface, plug into the motherboard to obtain power and communicate with the CPU.
29 October 2013 Birkbeck College, U. London 20
Example of a Motherboard
http://en.wikipedia.org/wiki/Motherboard
Top Related