COMP 1321 COMP 1321 Digital Infrastructure Digital Infrastructure Richard Henson Richard Henson University of Worcester University of Worcester October October 2012 2012
COMP 1321 COMP 1321 Digital InfrastructureDigital Infrastructure
Richard HensonRichard Henson
University of WorcesterUniversity of Worcester
OctoberOctober 20122012
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 slowelectronic… 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
bracket form:(2 x 103) + (3 x 102) + (1 x 101) + (4 x100 )most significant digit 2 least significant digit 4
2 3 1 4
Thousands Hundreds Tens units
10x10x10 10x10 10 1
103 102 101 100
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 notationDecimal Binary Hexadecimal
0 0000 01 0001 12 0010 23 0011 34 0100 45 0101 56 0110 67 0111 78 1000 89 1001 9
Hexadecimal notation
Decimal Binary Hexadecimal
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
Notation Useful to know what type of number
we are dealing with e.g. “110”use subscript at the end11010 = 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
Pentium 3
Opteron
Ultra Sparc 1
21364Itanium 2 McKinley
CPU
Memory
Keyboard
VDU
Computer Program (Code)
1 do this…
2 do that
3 now this
4 goto 1
Plus Data…
CPU with INPUT & OUTPUTCPU with INPUT & OUTPUT
Minimalist CPU
What is needed to build a CPU?
“Execution Unit”
ALU (Arithmetic Logic Unit)
Memory (to store intermediate data)
Input Output
A Good Name !
5
3 2
add
0
1
2
3
4
3
2
5
Processing Idea Nr. 1
Move data from memory
Move data into memory3.
2.
1.
Memory DRAM, Hard Disk ..
Move data in and out of data memory store
5
3 2
add
0
1
2
3
4
3
2
5
Processing Idea Nr.2
IP
(Code Memory)
mov 3 in from memory
mov 2 in from memory
add the two numbers
mov the result to memory
Instruction Memory
Program
Move instructions into CPU from code memory
Registers
0
1
4
6 8
6
8
4
Registers are high-speed memory on the CPU chip
Parking places for data on the move
AX and BX are used for ALU operations
MAR is memory address register, here 4. So result, 6+8=14 will go into memory cell address 4
AX BX
MAR
Instruction
Memory
A couple of extra bits
Data Memory
0
1
4
Instruction Register
Memory Data Register 2
8
34
34
2
Data
Address
add ax,bx
1. Line of code goes in
2. Electrical bit signals come out
2.
1.
• Energize ax• Energize bx• Select ALU “add"
Moving data into Registers
Instruction
Memory
0
1
2
mar 3
4
mov ax , [1]
85
8
7
6
1
BXAXmov ax , [1] mov bx , [2]mov bx , [2] 7
For example …
Moving data into Memory
Instruction
Memory
0
1
2
mar 3
4
mov [3] , ax
85
8
7
6
1
BXAXmov [3] , axmov [0], bx
mov [0] , bx 7
For example …
8
7
Adding Numbers
Instruction
Memory
0
1
2
mar 3
4
add ax , bx
85
7
6
1
BXAXAdd ax,bx
7
For example …
… this means ‘ add ax to bx,
put the answer in ax’8
8 7
15