Professional Documents
Culture Documents
Social Media
Social Media
(1860-1929) and built for the U.S. Census Bureau. These machines were first used in compiling the 1890
Census. Hollerith's patents were acquired by the Computing-Tabulating-Recording Co. (which later became
IBM), and this work became the basis of the IBM Punched Card System. The first "tabulator" used simple
clock-like counting devices. When an electrical circuit is closed (through a punched hole in a predetermined
position on the card), each counter is actuated by an electromagnet. The unit's pointer (clock hand) moves
one step each time the magnet is energized. The circuits to the electromagnets are closed by means of a
hand-operated press type card reader. The operator places each card in the reader, pulls down a lever, and
removes the card after each punched hole is counted.
- IBM Archives (http://www-03.ibm.com/ibm/history/exhibits/attic/attic_071.html)
COMP 206:
Computer Architecture and
Implementation
Montek Singh
Jan 27-29, 2009
2
Approaching an ISA
Instruction Set Architecture
Defines set of operations, instruction format, hardware
supported data types, named storage, addressing modes,
sequencing
Meaning of each instruction is described by RTL on
architected registers and memory
3
Moving Toward Design
Given technology constraints assemble adequate datapath
Architected storage mapped to actual storage
Function units to do all the required operations
Possible additional storage (eg. MAR)
Interconnect to move information among regs and FUs
4
Datapath vs Control
Datapath Controller
signals
Control Points
5
Contents
Design objectives
Information representation
Endian-ness, aligned access
Organization of Instructions
Encoding
6
Instruction Set Design Objective #1
Code size (code density):
Depends on:
size of MM/cache
access time of cache (on-chip/off-chip)
CPU-MM bandwidth
Frequently used instructions should be short
Implies variable-length instructions
But there are negatives to this
7
Instruction Set Design Objective #2
Execution speed (performance) :
Only frequently executed instructions should be included in the instruction set
Infrequently executed instructions slow down the others
Complex and long instructions tend to be used infrequently
Defining hardware-software interface
Frequently executed instructions should be fast
Pipelining should be made as easy as possible
Overlapped execution lowers CPI value
Single instruction length, simple instruction formats, and few addressing
modes for easy decoding
Three (register) address instructions decouple CPU and memory
8
Instruction Set Design Objective #3
Minimize size and complexity of hardware
(ALU/Control)
Implementing infrequently executed instructions ties down
hardware that is rarely used, and could be used for some
other purpose with greater advantage
9
Instruction Set Design Objective #4
Instruction set as a programming language
Needs of a human programmer (less important today)
Several desirable properties of instruction sets have been recognized and described,
such as orthogonality (each operand can be specified independently of the others)
and consistency (being able to predict the remainder of an architecture given partial
knowledge of the system)
Needs of an optimizing compiler
Simple instructions are more suitable for code optimizations
Optimizing compilers try to find the shortest or fastest code sequence that
implements the semantics of a HLL program. To make code reorganization
tractable, an instruction set is needed that makes:
– the size of each instruction easy to calculate;
– the execution time of each instruction easy to calculate;
– the interactions between instructions easy to figure out.
ISA features such as complex addressing modes, variable length instructions,
special-purpose registers provide too many ways of doing the same thing and lead to
combinatorial explosion
10
Notations for Information Representation
64 bits
8 bytes
2 words
1 doubleword
9 6 2 1 7 6 6
Most
MostSignificant
SignificantDigit
Digit(MSD)
(MSD) Least
LeastSignificant
SignificantDigit
Digit(LSD)
(LSD)
“Big End”
“Big End” “Little End”
“Little End”
“On holy wars and a plea for peace”, Danny Cohen, IEEE Computer 14(10), pages 49-54, Oct 1981
11
Why Is Numbering Important?
English text is written left-to-right and the characters are numbered left-
to-right
Numbers can be numbered in two different ways
Memory locations are numbered (addresses)
Consequences of numbering
Data is stored in memory according to byte numbering (the lower-numbered byte goes
into a byte in memory with a smaller address)
Data is sent through a bit-serial communication channel according to bit numbering (bit 0
goes first, followed by bit 1, etc.)
When displaying computer representation for humans
Numbers are written in the usual way (MSD on left, LSD on right)
Text is written in such a way as to match the numbering of numbers
12
Odds and Ends about Numbering
The Little Endian notation is compatible with mathematical
conventions of positional notation
The Little Endian notation has the disadvantage that is
displays English text in reverse
To overcome this, manuals for Little Endian machines usually display character
strings vertically
Example machines
Little Endian: PDP-11, VAX, 80x86
Big Endian: IBM 370, MIPS, DLX, SPARC
Mixed: Motorola 68000, Z8000
Big Endian byte ordering
Little Endian bit ordering
13
Alignment of Words in Memory
Mem Mem Mem Mem
Bank Bank Bank Bank
Memory 00 01 10 11
Controller
8 8 8 8
32 bits
14
Sub-Word Accesses
Mem Mem Mem Mem
Bank Bank Bank Bank
Memory 00 01 10 11
Controller
8 8 8 8
CPU
Register
32 bits File
(32 bits)
SPEC2000
16
Organization of an Instruction
Arithmetic
Logical
M a c h in e in s tru c tio n
Shift
S yn ta x S e m a n tics
18
Classification by Operands
Stack Accumulator General Purpose Register
Load/Store Reg/Mem Mem/Mem
ALU operations 0 address
1 address 3 address 2 (or 1.5) address 3 address
Explicit operands (1,1) (0,3) (1,2), (1, 3), (2, 2) (3, 3)
Instruction size Short Short 4 bytes 2/4/6 bytes variable
Needs separate Load/Store Load/Store Load/Store Store
Early examples Burroughs PDP-8 CDC 6600 IBM S/360 DEC VAX-11/780
B5000- Intel 8086 IBM S/370
B7500 Motorola 6809
Current examples Transputer All RISC machines IBM 3033, IBM S/390
Amdahl V
Hitachi, Fujitsu
Orthogonality Farthest from Intermediate Closest to
Pipelining Easiest Intermediate Hardest
19
Registers versus Cache
Similarities
Both small, fast, and expensive (flip-flops)
Both used to increase execution speed of CPU
Both operate based on locality of reference
Differences
Registers are visible in ISA; caches are not (except for instructions for invalidation,
prefetch, or flushing)
Number of registers is fixed by instruction format; size of cache is easily changeable
Registers have higher BW: 3 words/cycle, and are random-access; caches have lower
BW: 1 word/cycle, and are associative
Register access time is fixed; cache access time is statistical
Register allocation is explicit by compiler; cache allocation is automatic
Registers require fewer bits to address; caches require full memory addresses
Registers create no I/O problems; caches do
20
Organization of Registers
One general-purpose set (all interchangeable, “typeless”)
One general-purpose set (a few with dedicated uses)
PDP-11: eight 16-bit registers (R6: stack pointer, R7: PC)
VAX 11/780: sixteen 32-bit registers (four special-purpose, R14: stack pointer, R15: PC)
Two sets
Motorola 68000: eight 32-bit data, eight 32-bit address
IBM 370: sixteen 32-bit integer, four 64-bit FP
DLX, MIPS: 31 32-bit integer, 32 32-bit FP
Three sets
CDC 6600: eight 18-bit integer, eight 18-bit address, eight 60-bit FP
Many registers with dedicated use
Intel 80x86
21
Addressing Modes
Name
Name Example
Example Meaning
Meaning When
Whenused used
Register
Register add
addr4,
r4,r3r3 R[r4]
R[r4]:=:=R[r4]+R[r3]
R[r4]+R[r3] When
Whenvalue
valueisisininregister
register
Immediate
Immediate add
addr4,
r4,#3#3 R[r4]
R[r4]:=:=R[r4]+3
R[r4]+3 For
Forconstants
constants
Displacement
Displacement add
addr4,
r4,100(r1)
100(r1) R[r4]
R[r4]:=:=R[r4]+M[100+R[r1]]
R[r4]+M[100+R[r1]] Accessing
Accessinglocal
localvariables
variables
Register
Registerdeferred
deferred add
addr4,
r4,(r1)
(r1) R[r4]
R[r4]:=:=R[r4]
R[r4]++M[R[r1]]
M[R[r1]] Pointer,
Pointer,computed
computedaddressaddress
Indexed
Indexed add r3, (r1+r2)
add r3, (r1+r2) R[r3] := R[r3]+M[R[r1]+R[r2]]
R[r3] := R[r3]+M[R[r1]+R[r2]] Array addressing
Array addressing
Direct
Direct add
addr1,
r1,(1001)
(1001) R[r1]
R[r1]:=:=R[r1]+M[1001]
R[r1]+M[1001] Static
Staticdata
data
Memory
Memoryindirect
indirect add
addr1,
r1,@(r3)
@(r3) R[r1]
R[r1]:=:=R[r1]+M[M[R[r3]]]
R[r1]+M[M[R[r3]]] Pointer
Pointerdereferencing
dereferencing
Autoincrement
Autoincrement add
addr1,
r1,(r2)+
(r2)+ R[r1]
R[r1]:=:=R[r1]+M[R[r2]];
R[r1]+M[R[r2]];R[r2]R[r2]:=:=R[r2]+
R[r2]+dd Stepping
Steppingthrough
througharray array
Autodecrement
Autodecrement add r1, -(r2)
add r1, -(r2) R[r2]
R[r2]:=:=R[r2]-d
R[r2]-d; ;R[r1]
R[r1]:=:=R[r1]+M[R[r2]]
R[r1]+M[R[r2]] Stepping through
Stepping through arrayarray
Scaled
Scaled add
addr1,
r1,100(r2)[r3]
100(r2)[r3] R[r1]
R[r1] := R[r1]+M[100+R[r2]+d*R[r3]]
:= R[r1]+M[100+R[r2]+d *R[r3]] Array
Arrayindexing
indexing
R : the register file
M: the memory address space
d : the size of the data item being accessed (1, 2, 4, 8
bytes)
22
Frequency of Addressing Modes
SPEC2000
23
Address Displacement Sizes
This type of data would help you decide how much space to
allocate to displacement. Tested on a machine w/ 16 bits of
displacement, so can’t evaluate more.
SPEC2000
24
Use of Immediate Operands
25
Length of Immediate Oper.
27
Code Generation Examples for Branches
Register r3 contains y
Register r3 contains y
Register r4 contains z
Register r4 contains z
Register r5 contains a
Register r5 contains a
Register r6 contains b
Register r6 contains b
Register r7 contains x
Register r7 contains x
28
Classification of Branches
29
Evaluating Branch Conditions
30
Branch Distance
31
Instruction Encoding
32
“Typical” RISC ISA
32-bit fixed format instruction (3 formats)
32 32-bit GPR (R0 contains zero, DP take pair)
3-address, reg-reg arithmetic instruction
Single address mode for load/store:
base + displacement
no indirection
Simple branch conditions
Delayed branch
Register-Register
31 26 25 21 20 16 15 11 10 6 5 0
Op Rs1 Rs2 Rd Opx
Register-Immediate
31 26 25 21 20 16 15 0
Op Rs1 Rd immediate
Branch
31 26 25 21 20 16 15 0
Op Rs1 Rs2/Opx immediate
Jump / Call
31 26 25 0
Op target
34
Next Time
Pipelining
35