Professional Documents
Culture Documents
move
add
add
move
rotate
...
flour,bowl
milk,bowl
egg,bowl
bowl,mixer
mixer
3/9/00
Factorial Engine
1
ASEL
ALE
0
1
L.E. A
ANSWER
N
BSEL
BLE
0
1
L.E. B
=0?
ASEL
BSEL
ALE
BLE
-1
Control
FSM
A=1, B=N
A=A*B, B=B-1
done
3/9/00
3/9/00
Internal storage
Anatomy of an Interpreter
Data
Paths
control
status
Control
Unit
data
instructions
MEMORY
+1
dest
PC
1101000111011
R1 R2+R3
asel
bsel
fn
ALU
Ccs
Questions to be answered:
Data path questions:
how much internal storage?
what are the ALU functions?
provision for constant operands?
how does data get to/from memory?
width (in bits) are the registers/ALU?
Control unit questions:
how should instructions be encoded?
low-level (eg, ctl signals for data path)
next
fn
3/9/00
Long-term Goals
dont get steamrollered by changes in technology
density (2x every 1.5 years)
speed (2x every 3 years)
access time (30% in 10 yr)
3/9/00
NREGS = 0?
Why not fetch operands and store results directly from/to main memory?
memories are large sizeof(address) = sizeof(data)
For example, in a 32-bit architecture C = A + B would require
96+ bits of instruction to produce a single 32-bit result!
memories have long access latency
A 1GHz processor can execute 40 instructions in the time it takes
to get data from a memory with 40ns access time
most memories arent designed for parallel operation
N operands N memory accesses
values are often used shortly after they are computed then discarded
Dont bother to hang up the clothes youre about to put on
3/9/00
NREGS = 1?
An accumulator is a specially-designated register that supplies
one instruction operand and receives the result.
implicit use of accumulator saves instruction bits
On an accumulator machine C = A + B might be implemented as
LOAD(A)
ADD(B)
STORE(C)
3/9/00
NREGS =
// overhead!
// operators POP operand(s), PUSH result(s)
3/9/00
3/9/00
10
3/9/00
11
Constant Operands
3/9/00
12
3/9/00
13
3 2 1
0x100
0x104
0x108
a
int a[100]:
calculated offset from base
a[0] <base>
a[2] <base + 8>
a[i] <base + 4*i>
6.004 - Spring 2000
8 bits
word
byte
0x10C
0x110
0x114
0x118
0x11C
0x120
a[0]
0x124
a[1]
0x128
a[2]
0x12C
a[3]
0x130
Byte addressing
3/9/00
14
Autoincrement: (Rx)+
Value = Mem[Reg[x]]
Use: pointer accesses
Displacement: constant(Rx)
Autodecrement: -(Rx)
Scaled: constant(Rx)[Ry]
Value = Mem[Reg[x] + c + d*Reg[y]]
Use: array accesses (base+index)
3/9/00
15
3/9/00
16
3/9/00
17
load/store instructions:
3/9/00
18
JT
PCSEL
PC
A
Instruction
Memory
D
+4
Ra <20:16>
Rb: <15:11>
Rbc <25:21>
RA2SEL
C: <25:21>
Register
File
RA1
Rc <25:21>
WA
WA
RD1
RA2
WD
RD2
WE
WERF
JT
<PC>+4
C: <15:0>
ASEL
BSEL
Op Fn: <29:26>
Control
logic
A
FN
B
WD
ALU
Data Memory
Adr
3/9/00
R/W
RD
WDSEL
19
Model of Computation
Processor State
PC
Main Memory
00
3
r0
r1
r2
1 0
32 bits
(4 bytes)
32 bits
next instr
r31
Fetch/Execute Loop:
Fetch Mem[PC]
PC PC + 4
Execute instruction
(may change PC!)
Repeat!
always 0
3/9/00
20
rc
ra
rb
unused
rc
ra
const
16
(signed)
Arithmetic/logical ops:
w ADD, ADDC, SUB, SUBC, MUL, MULC, DIV, DIVC
w AND, ANDC, OR, ORC, XOR, XORC
What? No SAL?
w SHL, SHR, SAR (shift left/right/right arithmetic)
6.004 - Spring 2000
3/9/00
21
LD(ra, C, rc)
OP
rc
ra
const
16
(signed)
Reg[c] Mem[Reg[a] + C]
ST(rc, C, ra)
Mem[Reg[a] + C] Reg[c]
3/9/00
22
Instruction Classes
Memory access
Flow of control
Number crunching
conditional branches
unconditional jumps
call/return
Miscellaneous
security/OS support
input/output
synchronization of parallel
execution
saving/restoring machine
state
3/9/00
23
Instruction Mix
Gcc
espresso
Spice
Nasa7
Data
transfer
42%
31%
34%
32%
Integer
arithmetic
28%
32%
34%
36%
Logic
operations
7%
16%
4%
3%
FP data
transfer
0%
0%
7%
13%
FP
arithmetic
0%
0%
6%
13%
Flow of
control
23%
21%
14%
4%
3/9/00
24
Speedup
Speedup== Execution time for entire task using enhancement where possible
3/9/00
25
3/9/00
26
Direct-execute ISAs
MIPS =
Clock Frequency
Clocks per Instruction
3/9/00
27
High-level ISAs
ISA is not directly executed:
translated before execution
Java byte codes by just-in-time compilers
Pentium/Athlon convert x86 on-the-fly to RISC
emulation
Portability (eg, Scheme)
Compact implementation (eg, embedded environments)
High-level functionality (eg, Postscript)
Support for legacy architectures (eg, Symbolics Lispms)
3/9/00
28