2. 1. - University Of Worcester

Download Report

Transcript 2. 1. - University Of Worcester

COMP 1321
Digital Infrastructure
Richard Henson
University of Worcester
October 2012
Week 2: CPUs and
Motherboards
Problem for Processor design
Data needs to be stored
 Memory consists of ‘cells’ (effectively
switches)

Recorded digitally
» either a “0” or a “1”
» no middle way
Binary Numbers


Base 2… based on 0 and 1
To represent binary, need “on/off” switches
 mechanical… too slow
 electronic… Ok if fast enough
» early electronic switches large and needed a lot of
energy
» Head of IBM (1950s) said that the world needed only
four of these computers anyway (!)
» use of transistors made the computer more widespread
Number Theory: decimal
representation of 2,314
2
Thousands
10x10x10
103
3
Hundreds
10x10
102
1
Tens
10
101
4
units
1
100
bracket form:
(2 x 103) + (3 x 102) + (1 x 101) + (4 x100 )
most significant digit
2
least significant digit
4
Some definitions…
binary digit
bit
0 or 1
 byte: a group of 8 bits
 (nibble: a group of 4 bits)
 word: a group of bits of a fixed length
(actual length of a word is rather
arbitrary)

Binary representation of the
four bit word 1101
1
1
0
1
2x2x2
2x2
2
1
23
22
21
20
bracket form:
(1 x 23) + (1 x 22) + (0 x 21) + (1 x20 )
8
+
4
+ 0
+ 1
= 13 in denary (decimal)
Binary representation of the
8 bit word 1011 0101
27
26
25
24
23
22
21
20
1
0
1
1
0
1
0
1
128 + 0 + 32 + 16 + 0 + 4+ 0 + 1
= 181
Q. How many different binary numbers can an 8
bit word hold?
A. 256 (= 28) ranging from
0000 0000 to 1111 1111
The 16 bit number
0000 0000 0011 0101

(a) To what decimal number is it equal?

(b) What is the value of the most
significant bit?

(c) How many different 16 bit binary
numbers can be represented?
The 16 bit number
0000 0000 0011 0101
(a) To what decimal number is it equal?
Answer: 32 + 16 + 0 + 4 + 0 + 1 = 53
 (b) What is the value of the most
significant bit?
Answer: 0
 (c) How many different 16 bit binary
numbers can be represented?
Answer: 216 = 65536 (which is 64 k)

Shorthand
Rows of 1s and 0s can be very
confusing
 Easy to make mistakes
 Solution: divide into blocks of 4 digits
use the decimal numbers
corresponding to each block
 Problem: confusion with 10 or more
 Solution: use letters for 10 to 15

Hexadecimal notation
Decimal
0
1
2
3
4
5
6
7
8
9
Binary
Hexadecimal
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
0
1
2
3
4
5
6
7
8
9
Hexadecimal notation
Decimal
10
11
12
13
14
15
Binary
1010
1011
1100
1101
1110
1111
Hexadecimal
A
B
C
D
E
F
Notation

Useful to know what type of number
we are dealing with e.g. “110”
use subscript at the end
11010 = 110 (denary)
1102 = 110 (binary) = 6 (denary)
110H or 11016 = 110 (hexadecimal)
= 272 (denary)

So now you know!
Now, let’s make a Computer
… at least the CPU …
Pentium 4
Ultra Sparc 1
Pentium 3
Opteron
Itanium 2 McKinley
21364
CPU with INPUT & OUTPUT
Computer
Program (Code)
1 do this…
2 do that
3 now this
4 goto 1
Plus Data…
Memory
CPU
Keyboard
VDU
Pentium
Data Cache
Code Cache
Instruction
Fetch
Instruction
Decode
Execution
Unit
Minimalist CPU
What is needed to build a CPU?
ALU (Arithmetic Logic Unit)
Memory (to store intermediate data)
Input Output
“Execution Unit”
A Good Name !
Arithmetic Logic Unit
Input A
Input B
ALU
(or Integer Execution Unit)
3
add
Output
2
5
3
sub
2
1
Processing Idea Nr. 1
Move data in and out of data memory store
1.Move data from memory
3
2. add
2
5
0
3
1
2
2
3
5
Memory
DRAM, Hard Disk ..
4
3. Move data into memory
Processing Idea Nr.2
Move instructions into CPU from code memory
Instruction Memory
(Code Memory)
mov 3 in from memory
3
mov 2 in from memory
IP
add the two numbers
add
2
5
0
3
1
2
2
3
mov the result to memory
4
Program
5
Registers
Registers are high-speed
memory on the CPU chip
Parking places for data on the
move
AX and BX are used for ALU
operations
AX
6
BX
8
0
6
1
8
MAR
4
MAR is memory address
register, here 4. So result,
6+8=14 will go into memory
cell address 4
4
Our computer so far …
0
1
Instruction
Memory
Data
Memory
mar
ip
4
A couple of extra bits
1.
Line of code goes in
2.
Electrical bit signals come out
Instruction Register
1.
Memory Data Register
add ax,bx
2.
Instruction
Memory
34
Data
•
•
•
Energize ax
Energize bx
Select ALU “add"
0
2
1
8
Data
Memory
2
Address
4
34
Moving data into Registers
For example …
mov ax , [1]
mov bx , [2]
Instruction
Memory
AX
8
BX
7
mar
0
5
1
8
2
7
3
6
4
1
mov ax , [1]
mov bx , [2]
Moving data into Memory
For example …
mov [3] , ax
mov [0] , bx
Instruction
Memory
AX
8
mov [3] , ax
mov [0], bx
BX
7
mar
0
7
5
1
8
2
7
3
8
6
4
1
Adding Numbers
For example …
Add ax,bx
Instruction
Memory
AX
BX
8
7
8
7
15
mar
0
5
1
8
2
7
3
6
4
1
add ax , bx
… this means ‘
add ax to bx,
put the answer
in ax’
So THAT’S how it works!

Next week: the programming!