Presentation2 - University of Worcester

Download Report

Transcript Presentation2 - University of Worcester

COMP 1321
Digital Infrastructure
Richard Henson
University of Worcester
October 2015
Week 2: Binary Numbers
and CPUs

Objectives:
Explain the CPU as the
fundamental part of the computer
Explain why binary numbers are
fundamental to computing
Convert between binary and
hexadecimal numbers
Explain the structure of typical CPU
Origins of the CPU
All about processing data
 Also needs a mechanism for

adding data (input)
removing processed data (output)
storing data outside the CPU

In early days (e.g. Bletchley Park) data
input, output, movement, storage all
paper-based… very slow!
Binary Numbers

Base 2… based on 0 and 1
 perfect fit with Boole & logic states

To represent binary in real world need
“on/off” switches
 mechanical… slow
 but gotta start somewhere…
Electrical Storage of Binary?

Possible using:
Relays
» on – magnet has current/off –
magnet no current
binary numbers
» relay off = 0
» relay on = 1
Shannon & Relays

1938: first scientist to use Boolean
Logic with relays: on/off 1/0
realised binary numbers could replace
decimal numbers & represent real data
values
Figured that relays could be wired
together to create logic gates and do
Boolean Algebra (!)
 Problem… relays slow

A Fast Switch
Electronic…
» called valves, but actually glass tubes
» Air taken out; near vacuum
» needed a lot of energy to work
» took up lots of space
But it was fast, and it did work…
» Head of IBM (1950s) said that the world needed only four
of these computers anyway (!)
More from Shannon (1948)

Demonstrated the essential unity of all
information media:
text
telephone signals
radio waves
pictures, film, etc…

All could be encoded in the universal
language of binary digits
used “bits” to describe them
Binary Logic and
CPU Design

Data stored as blocks of ‘cells’
(effectively switches)
voltage off/on
» in binary either “0” or “1”

If memory and data are binary…
so must the processing!
Number Systems

Number of different items…
“base” of number system

Examples:
base 2: binary (2 items)
base 10: decimal (10 items)
base 16: hexadecimal (16)
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!
Binary Logic & the CPU

Binary logic + Boolean algebra
logic gates
mathematically predictable effects of
combining them
documented as truth tables

Problem: valves wired together produce
pretty large, energy hungry logic gates:
» CPU would be very large & use a lot of energy!
Hey Presto… the Transistor

Same effect as valves



much smaller
use much less energy
Wonderful discovery


must have been very exciting for Shannon
computers could be much smaller than he expected
http://www.technologyreview.com/featuredstory/4011
12/claude-shannon-reluctant-father-of-the-digital-age
Miniaturisation

Transistors first used in radios
very popular with “teenagers”

Took some time to become part of more
sophisticated devices
 breakthrough: integrated circuits (ICs)
 many transistors on a single component
 first IC with enough transistors to be a CPU with
programmed instructions… Intel (1972)
Now, let’s make a Computer
… or at least the CPU
(millions of transistors)
Ultra Sparc 1
Pentium 4
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 do I need to build a CPU?
ALU (Arithmetic Logic Unit)
Memory (to store intermediate data))
Input Output
“Execution Unit”
A Good Name! Intel’s first was called…
“4004”… because it had a 4-bit bus!
Arithmetic Logic Unit (ALU)
Input A
(or… more sophisticated…
Integer Execution Unit)
Input B
3
add
Output
2
5
3
sub
How could these numbers
be represented as data that
passes into the ALU?
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
The computer so far …
0
1
Instruction
Memory
Data
Memory
mar
ip
4
A couple of extra bits..
Memory Data Register
Instruction Register
1.
add ax,bx
2.
34
Instruction
Memory
Data
•
•
•
Energize ax
Energize bx
Select ALU “add"
1. Line of code goes in…
0
2
1
8
Data
Memory
2
Address
2. Electrical bit signals come out
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
part!