CS2200 Presentation 2 - PowerPoint PPT Presentation

1 / 55
About This Presentation
Title:

CS2200 Presentation 2

Description:

Processor Design Goals. Easy to Build. Hardware. Easy to Build. Compiler(s) Maximize. Performance ... Influences on Processor Design. Cost of hardware. Cost of memory ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 56
Provided by: BillL161
Category:

less

Transcript and Presenter's Notes

Title: CS2200 Presentation 2


1
CS2200Presentation 2
  • Processors

2
Announcements
  • Office Hour Update
  • Dan Lerner Update
  • Mike Niemier's slides
  • Homework 1 Posted
  • Having problems?

3
Our Road Map
Processor
Memory Hierarchy
I/O Subsystem
Parallel Systems
Networking
4
Five Classic Components
Processor
Memory
Control
Datapath
5
What does the processor do?
  • Knows where it is in program
  • Can get and put data into memory
  • Can do some arithmetic
  • Can make tests and take different paths depending
    on the results
  • Do you need a language to make a computer run?

6
A Little History
7
A Little History
8
A Little History
  • First computers programmed by hand
  • 1000110010100000
  • Somewhat tedious, so invented
  • Assembler
  • add A,B
  • If we can convert from Assembly Language to
    machine code why not from some higher level
    language to Assembler?
  • A B

9
Back to the Instruction Set Architecture
  • 1000110010100000
  • Why study at this level?
  • Common focal point

10
Instruction Set Architecture
C
Fortran
Ada
etc.
Basic
Java
Compiler
Compiler
Byte Code
Assembly Language
Assembler
Interpreter
Executable
HW Implementation 1
HW Implementation N
HW Implementation 2
11
Instructions
  • Language of the machine
  • Vocabulary is the instruction set
  • Two levels
  • Human readable
  • Machine readable
  • Most are similar
  • What are the goals?

12
Processor Design Goals
13
Beyond Mips
  • The textbook (PH) tends to focus on the design
    of the Mips processor with the eventual goal of
    producing a pipelined design (more later).
  • Many other architectures have been developed and
    used over the last 50 years
  • Why?

14
Beyond Mips
  • Influences on Processor Design
  • Cost of hardware
  • Cost of memory
  • Sophistication of compiler and language design
  • Real world experience
  • Design techniques/collaboration

15
Instruction Set Classification
  • One way
  • Number of operands for typical arithmetic
    instruction
  • add s1, s2, s3
  • What are the possibilities?
  • Will use this C statement as an example
  • a b c
  • Assume a, b and c are in memory

16
Zero Address Machine
0
  • a.k.a. Stack Machines
  • PUSH b Push b onto stack
  • PUSH c Push c onto stack
  • ADD Add top two items
  • on stack and replace
  • with sum
  • POP a Remove top of stack
  • and store in a

17
One Address Machine
1
  • a.k.a. Accumulator Machine
  • One operand is implicitly the accumulator
  • LOAD b ACC ? b
  • ADD c ACC ? ACC c
  • STORE a a ? ACC

18
Two Address Machine
21
  • a.k.a. Register-Memory Instruction Set
  • One operand may be a value from memory (unlike
    Mips)
  • Machine has n general purpose registers
  • 0 through n-1
  • LOAD 1, b 1 ? Mb
  • ADD 1, c 1 ? 1 Mc
  • STORE 1, a Ma ? 1

19
Two Address Machine
22
  • a.k.a. Memory-Memory Machine
  • Another possibility do stuff in memory!
  • These machines have registers used to compute
    memory addresses
  • MOVE a, b Ma ? Mb
  • ADD a, c Ma ? Ma Mc

20
Two Address Machine
23
  • a.k.a. Load-Store Instruction Set or
    Register-Register Instruction Set
  • Typically can only access memory using load/store
    instructions
  • LOAD 1, b 1 ? Mb
  • LOAD 2, c 2 ? Mc
  • ADD 1, 2 1 ? 1 2
  • STORE 1, a Ma ? 1

21
Three Address Machine
3
  • a.k.a. Load-Store Instruction Set or
    Register-Register Instruction Set
  • Typically can only access memory using load/store
    instructions
  • LOAD 1, b 1 ? Mb
  • LOAD 2, c 2 ? Mc
  • ADD 3, 1, 2 3 ? 1 2
  • STORE 3, a Ma ? 3

22
History
Hardware Expensive Memory Expensive Accumulators
EDSAC IBM 701
Hardware Less Expensive Memory Expensive Register
Oriented Machines (2 address) Register-Memory
IBM 360 DEC
PDP-11 Also Fringe Element Stack Machines
Burroughs B-5000 (Banks)
Hardware and Memory Cheap Microprocessors Compile
rs getting good CISC VAX
Motorola 68000 Intel
80x86 RISC Berkley RISC?Sparc
Dave Patterson Stanford MIPS ?SGI
John Hennessy IBM 801
1940 1950
1960 1970
1980 1990
23
Questions?
24
AddressingModes
circa 1975
25
Questions?
26
Warning
  • We will be discussing processors using
  • The MIPS architecture
  • The LC2200 architecture

27
What do we have to support?
  • What constructs in C must we be able to convert
    into executable code?

28
Typical Operation
  • add a,b,c a b c
  • What if we want to do a bcde?
  • (Try it!)
  • add a,b,c
  • add a,a,d
  • add a,a,e

29
Whats the answer?
  • (56) - (34)
  • How did you do it?
  • e (ab) - (cd)
  • add t1,a,b
  • add t2,c,d
  • sub e,t1,t2

30
Operands
  • add a,b,c
  • Where are a, b and c?
  • Memory?
  • I/O Device?
  • Registers (in processor)?
  • ???
  • How does the data get in and out of the
    registers?
  • load
  • store

31
Common Operations
  • g h A8
  • load s0,8(s3)
  • actually
  • lw s0,8(s3) lw dest, offset(base)
  • add s1, s2, s0 add dst, src1, src2
  • Notice Registers contain data or addresses!!

32
Why lw not load
  • The byte (8 bits) is very useful so most
    architectures support byte operations.
  • (The LC2200 does not!)
  • Thus, each byte has an address.
  • However, for efficiency, a 32-bit machine can
    also move 4-byte words around.
  • Thus, each word has an address
  • Typically word addresses are multiples of ?
  • Unfortunately, this leads to...

33
Endianess
  • No, were not making this up.
  • at word address 100 (assume a 4-byte word)
  • long a 0x11223344
  • big-endian (MSB at word address) layout
  • 100 11 22 33 44
  • 0 1 2 3
  • little-endian (LSB at word address) layout
  • 11 22 33 44 100
  • 3 2 1 0

Who cares?
34
  • string layout starting at word addr 100
  • char a12 RAMACHANDRAN
  • char b12 WAMACHANDRAN

35
Perception Check
  • What exactly are we doing?
  • HLL (C) ? Assembler
  • Assembler ? Machine Instructions
  • Goals
  • See how HLL translate to Assembler
  • Understand hardware designs, constraints, goals,
    etc.

36
Slightly more complex
  • A12 h A8
  • Compile it?
  • lw s0, 8(s3)
  • add s0, s2, s0
  • sw s0, 12(s3)

37
Historical Note
  • Early machines often had a register called an
    index register
  • load addr(index)
  • Address space was small
  • Today
  • lw s1, offset(base)
  • Base address are much larger...need to be in a
    register
  • Often offsets are small but if not...

38
Variable Array Index?
  • g h Ai
  • add a0, s2, s3 i addr(A)
  • lw a1, 0(a0) a1 ? Ai
  • add s0, s1, a1 g ? h Ai

39
How many registers?
  • Early machines had about 1 (Accumulator)
  • PDP-11 series had 8
  • Typical 32 bit processors today have 32.
  • Why not more?
  • What happens when there are more variables than
    registers?
  • Spillage Putting less commonly used variables
    back into memory.

40
Factoid
  • accumulator Archaic term for a register. On-line
    use of it as a synonym for register is a fairly
    reliable indication that the user has been around
    for a while.
  • Eric Raymond, The New Hackers Dictionary, 1991

41
Note the speed
  • Register ops access two regs and perform an
    operation
  • Memory ops access one location and dont do
    anything to it!
  • What do you think about the speed of memory
    versus registers?

42
Mips Registers
Name
R
Usage
Preserved on Call
zero
0
The constant value 0
n.a.
at
1
Reserved for assembler
n.a.
v0-v1
2-3
Values for results and expression evaluation
no
a0-a3
4-7
Arguments
no
t0-t7
8-15
Temporaries
no
s0-s7
16-23
Saved
yes
t8-t9
24-25
More temporaries
no
k0-k1
26-27
Reserved for use by operating system
n.a.
gp
28
Global pointer
yes
sp
29
Stack pointer
yes
fp
30
Frame pointer
yes
ra
31
Return address
yes
43
LC2200 Registers
Name
R
Usage
Preserved on Call
zero
0
The constant value 0
n.a.
at
1
Reserved for assembler
n.a.
v0
2
Return value
no
a0-a4
3-7
Argument or temporary
no
s0-s3
8-11
Saved general purpose registers
yes
k0
12
Reserved for OS/traps
n.a.
sp
13
Stack pointer
yes
fp
14
Frame pointer
yes
ra
15
Return address
yes
44
Decisions, decisions...
  • What distinguishes a computer from a simple
    calculator is its ability to make decisions.
    Some smart guy.
  • Typical implementation
  • Branch if equal
  • Branch if not equal
  • Sometimes check one value (register) versus 0,
    others compare two items (registers)

45
if statement
  • if (i j) goto L1
  • f g h
  • L1 f f - i
  • beq s3, a4, L1 if ij goto L1
  • add s0, s1, s2 f g h
  • L1 sub s0, s0, s3 f f - i

46
Did we just use a go to???
47
if statement
  • if (i ! j)
  • f g h
  • f f - i
  • beq s3, a4, L1
  • add s0, s1, s2
  • L1 sub s0, s0, s3

48
if-then-else
  • if (i j)
  • f g h
  • else
  • f g - h
  • beq s3, a4, Then if opp is T
  • add s0, s1, zero f g h
  • beq zero, zero, Exit
  • Then add s0, s1, s2 f g h
  • Exit

The LC2200 has no BNE
49
Loop with Variable Array Index
  • Loop g g Ai
  • i i j
  • if (i ! h) goto Loop

Loop add a1, s2, a0 lw a1,
0(a1) add s0, s0, a1 add
s2, s2, s3 beq s2, s1, Exit
beq zero, zero, Loop Exit
Plus some temps
50
While Loop
  • while (savi k)
  • i i j
  • Loop add a1, s1, s0
  • lw a2, 0(a1)
  • beq a2, s3, Skip
  • beq zero, zero, Exit
  • Skip add s1, s1, s2
  • beq zero, zero, Loop
  • Exit

51
Case/Switch
  • switch (k)
  • case 0 f i j break
  • case 1 f g h break
  • case 2 f g - h break
  • case 3 f i - j break
  • slt t3, s5, zero If k lt 0
  • bne t3, zero, Exit Exit
  • slt t3, s5, t2 If k gt 4
  • beq t3, zero, Exit Exit
  • add t1, s5, s5 mpy k by 4
  • add t1, t1, t1

Mips
52
Case/Switchcontinued
  • switch (k)
  • case 0 f i j break
  • case 1 f g h break
  • case 2 f g - h break
  • case 3 f i - j break

Jmptbl Address(L0) Address(L1) Address(L2)
Address(L3)
53
Case/Switchcontinued
  • switch (k)
  • case 0 f i j break
  • case 1 f g h break
  • case 2 f g - h break
  • case 3 f i - j break

add t1, t1, t4 t1 Jmptabk lw t0,
0(t1) jr t0 jump based
on reg t0 L0 add s0, s3, s4 j
Exit etc...
54
Questions?
55
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com