Title: Computer Hardware
1Computer Hardware
2(No Transcript)
3Deeper
4Deeper
5Not that deep
6A simple Computer
Performs all calculations and decisions Add,
Subtract, gt, lt, decide what to do next
Central Processing Unit CPU
7A simple Computer
Memory
Central Processing Unit CPU
Stores most information Memory is a large array
of integers
8Memory - array of integers
- How does it store text?
- How does it store images?
- How does it store audio?
- How does it store a program?
9A simple Computer
Memory
Central Processing Unit CPU
Address
Wires that pass the index of the location in
memory that the CPU wants to get or change
10A simple Computer
Address
Memory
Central Processing Unit CPU
0
1
0
0
1
0
Wires that pass the index of the location in
memory that the CPU wants to get or change
11A simple Computer
Address
Memory
Central Processing Unit CPU
0
1
0
0
1
0
Number of wires number of bits Number of bits
range of possible indexes total
possible memory
12A simple Computer
Address
Memory
Central Processing Unit CPU
0
1
0
0
1
0
Twice as much memory adds how many more address
wires? 1 more
13A simple Computer
Memory
Central Processing Unit CPU
Address
Data
Wires that pass numbers from CPU to Memory or
from Memory to CPU
14A simple Computer
Memory RAM
Central Processing Unit CPU
Address
Data
RAM - Random Access Memory is the main memory of
a computer. The size of RAM is the length of the
array
15How to represent a program in memory
- Program is a series of simple instructions
- Each instruction is an integer
- CPU
- Goes to a location in memory
- Gets an instruction
- Does what the instruction says
- Moves to the next instruction
- Does this millions of times per second
16A simple fake computer
17Program Counter - address (index) of the next
instruction
18Registersprivate memory for the CPU
19Every instruction has a number
- OpCodes
- 0 - Halt
- 1 - Load
- 2 - Store
- 3 - Add
- 4 - Subtract
- 5 - Divide
- 6 - Multiply
- 7 - Is Greater Than 0?
- 8 - Goto
- 9 - Branch If Greater Than 0!
20OpCodes 0 - Halt 1 - Load 2 - Store 3 -
Add 4 - Subtract 5 - Divide 6 - Multiply 7 -
Is Greater Than 0? 8 - Goto 9 - Branch If
Greater Than 0!
- Instruction Format
- Digit 1 OpCode
- Digit 2 Register
- Digit 3-4 Memory Address
21OpCodes 0 - Halt 1 - Load 2 - Store 3 -
Add 4 - Subtract 5 - Divide 6 - Multiply 7 -
Is Greater Than 0? 8 - Goto 9 - Branch If
Greater Than 0!
- Instruction Format
- Digit 1 OpCode
- Digit 2 Register
- Digit 3-4 Memory Address
3 1 10
22OpCodes 0 - Halt 1 - Load 2 - Store 3 -
Add 4 - Subtract 5 - Divide 6 - Multiply 7 -
Is Greater Than 0? 8 - Goto 9 - Branch If
Greater Than 0!
- Instruction Format
- Digit 1 OpCode
- Digit 2 Register
- Digit 3-4 Memory Address
3 1 10
23Reg1Reg1Mem10
OpCodes 0 - Halt 1 - Load 2 - Store 3 -
Add 4 - Subtract 5 - Divide 6 - Multiply 7 -
Is Greater Than 0? 8 - Goto 9 - Branch If
Greater Than 0!
- Instruction Format
- Digit 1 OpCode
- Digit 2 Register
- Digit 3-4 Memory Address
3 1 10
24?
OpCodes 0 - Halt 1 - Load 2 - Store 3 -
Add 4 - Subtract 5 - Divide 6 - Multiply 7 -
Is Greater Than 0? 8 - Goto 9 - Branch If
Greater Than 0!
- Instruction Format
- Digit 1 OpCode
- Digit 2 Register
- Digit 3-4 Memory Address
4 2 30
25Reg2Reg2-Mem30
OpCodes 0 - Halt 1 - Load 2 - Store 3 -
Add 4 - Subtract 5 - Divide 6 - Multiply 7 -
Is Greater Than 0? 8 - Goto 9 - Branch If
Greater Than 0!
- Instruction Format
- Digit 1 OpCode
- Digit 2 Register
- Digit 3-4 Memory Address
4 2 30
26A simple program
1 0 07
Load location 7 into register 0
Reg0Mem7 PC PC1
27A simple program
1 2 08
Load location 8 into register 2
Reg2Mem8 PC PC1
28A simple program
3 0 07
Add location 7 to register 0
Reg0Reg0Mem7 PC PC1
29A simple program
8 2 00
GOTO the address stored in register 2
PC Reg2
30A simple program
3 0 07
Add location 7 to register 0
Reg0Reg0Mem7 PCPC1
31A simple program
8 2 00
GOTO the address stored in register 2
PC Reg2
32A simple program
3 0 07
Add location 7 to register 0
Reg0Reg0Mem7 PCPC1
33Clock speed of a processor
- Number of instructions per second that can be
performed - 100 MHz 100 Million times per second
- 1.5 GHz 1.5 Billion instructions per second
34So what is a program?
- A file of bytes
- Operating system copies the file into memory
- When select the program from Start menu
- When you double click on the program
- Operating system sets PC to address of first byte
of the program in memory - Program begins to run
35Programs and Data
Program (instructions)
What is the difference?
If the PC points to it then it is an instruction
36Review
- CPU - Central Processing Unit
- Does calculating and deciding
- Memory - RAM
- Stores data and programs
- Array of integers
- Size of RAM the length of this array
37Review
- Program
- List of instructions
- Each instruction is an integer that the CPU
decodes - Program counter (PC) is the address of the next
instruction - Copy program from file into memory
- Set PC to start of the program