CS 2200 Presentation 4 - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

CS 2200 Presentation 4

Description:

RB RA Offset. LC-2200 Instruction Set. Assembler Examples. addi $s0, ... RB: 4-bit register number to control logic. RA: 4-bit register number to control logic ... – PowerPoint PPT presentation

Number of Views:211
Avg rating:3.0/5.0
Slides: 53
Provided by: BillL161
Category:
Tags: presentation | rb

less

Transcript and Presenter's Notes

Title: CS 2200 Presentation 4


1
CS 2200Presentation 4
  • Datapath

2
drum roll...
  • Introducing the

LC-2200
3
LC2200
  • The LC is a 32-bit computer with 16 general
    registers plus a separate program counter (PC)
    register. All addresses are word addresses.
    Register 0 is wired to zero it always reads as
    zero and writes to it are ignored.

4
Accessible Registers
  • Reg Name Use
    Callee Save?
  • ----- ---- -------------------------
    -----------
  • 0 zero always zero (by hardware)
    n.a.
  • 1 at reserved for assembler
    n.a.
  • 2 v0 return value
    no
  • 3 a0 argument or temporary
    no
  • 4 a1 argument or temporary
    no
  • 5 a2 argument or temporary
    no
  • 6 a3 argument or temporary
    no
  • 7 a4 argument or temporary
    no
  • 8 s0 saved register
    YES
  • 9 s1 saved register
    YES
  • 10 s2 saved register
    YES
  • 11 s3 saved register
    YES
  • 12 k0 reserved for OS/traps
    n.a.
  • 13 sp stack pointer
    YES
  • 14 fp frame pointer
    YES
  • 15 ra return address
    YES

5
LC-2200 Instruction Set
Assembler Examples add s0, s1, s2 s0 ? s1
s2 nand s0, s1, s2 s0 ? (s1 s2)
6
LC-2200 Instruction Set
7
LC-2200 Instruction Set
Assembler Examples addi s0, a0, 14 s0 ?
a0 14 lw s0, 8(s1) s0 ? MEMs1
8 sw s0, -4(s1) MEMs1 - 4 ? s0 beq
a0, a1, label if a0a1
PC ? PC 1 Offset
8
Question
  • beq s0, s1, label line 1
  • add a0, a1, a2
  • nand s2, s3, a3
  • label
  • addi s1, s1, 6
  • What value is in the offset field of the
    instruction generated in line 1?

9
LC-2200 Instruction Set
Assembler Examples jalr s0, ra ra ? PC
1 PC ? s0 jalr s0, s0 s0 ? PC 1
PC ? s0 (PC 1) jalr ra, zero PC ? ra
10
LC-2200 Instruction Set
Function
Halt processor
Do nothing
31 28
27 24
23 20
19 0
Op Code
Unused
Assembler Examples halt Stop
execution
11
LC-2200 Pseudo-Ops
Assembler Examples nop Do
nothing .word 32 Fill current
location with 32 .word label Fill
current location with value
of the symbol "label"
12
More Assembler Examples
  • Add A and B and put result in C
  • start lw a0, A(zero)
  • lw a1, B(zero)
  • add a0, a0, a1
  • sw a0, C(zero)
  • A .fill 42
  • B .fill 37
  • C .fill 0

13
More Assembler Examples
Loop until a0 0
  • loop beq a0, zero, break
  • addi a0, a0, -1
  • beq zero, zero, loop
  • break

0x0030 0x53000002 0x0031 0x233fffff 0x0032
0x500ffffd 0x0033
14
More Assembler Examples
  • start lw a0, A(zero)
  • lw a1, B(zero)
  • addi s0, zero, addem
  • jalr s0, ra
  • sw v0, C(zero)
  • halt
  • addem add v0, a0, a1
  • jalr ra, zero
  • A .fill 27
  • B .fill 92
  • C .fill 0

15
What's Missing?
  • How do you do a NOP?
  • How do you subtract?
  • How do you branch on an inequality? (e.g. BLT)
  • Multiply/divide/shifts
  • Data types other than 32-bit words?

16
Questions?
17
Five Classic Components
Recall
Processor
Memory
Control
Datapath
18
Lets take a closer look...
Processor
Control
Datapath
19
Big Picture
  • Fetch the instruction from memory
  • Decode the instruction and decide what to do
  • Execute the instruction
  • Repeat.
  • What do we need to add 2 registers together and
    store the result in a third?

20
LC-2200 Datapath
PC
21
LC-2200 Datapath
PC
22
LC-2200 Datapath
PC
IR
23
LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
24
LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
LdA
25
LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdB
26
LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdA
LdB
2
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
27
QuestionDid you understand the preceding
explanation of adding?
  • 1 Crystal Clear
  • 2 Sort of
  • 3 We were adding?

28
PC
Consider the LW instruction lw s0, 4(s1)
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdA
LdB
2
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
29
PC
Consider the LW instruction lw s0, 4(s1)
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdA
LdB
2
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
30
MAR
PC
Consider the LW instruction lw s0, 4(s1)
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdA
LdB
2
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
31
MAR
PC
Consider the LW instruction lw s0, 4(s1)
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdA
LdB
2
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
32
Making it more real...
  • This is getting very complicated!!!
  • For reasons involving implementation details, the
    simplest (lowest cost, lowest performance)
    technique is to use a single bus to connect all
    the various functional units

33
Bus
Functional Unit
Functional Unit
Functional Unit
Functional Unit
34
BusOnly One Functional Unit at a time can drive
bus
Functional Unit
Functional Unit
Functional Unit
Functional Unit
35
BusAny (and all) functional units can access bus
Functional Unit
Functional Unit
Functional Unit
Functional Unit
36
Question
  • What happens if two functional units try to drive
    the bus at the same time?
  • Data is corrupted
  • Smoke and possibly flames issue forth
  • Processor shuts down
  • Core dump

37
Questions?
38
LC-2200 Datapath
32
A
LdA
B
LdB
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
39
Recall our basic add instruction
40
LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdA
LdB
2
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
Did we leave anything out?
41
Need to increment PC!
42
LC-2200 Datapath
32
A
LdA
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
43
LC-2200 Datapath
32
A
LdA
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
44
LC-2200 Datapath
32
A
LdA
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
45
LC-2200 Datapath
32
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
46
LC-2200 Datapath
32
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
47
LC-2200 Datapath
32
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
48
LC-2200 Datapath
32
10
memory 1024x 32 bits
Addr Din
registers 16x 32 bits
Din
IR31..0
WrREG
WrMEM
2
4
ALU 00 ADD 01 NAND 10 A - B 11 A 1
func
IR19..0
regno
20
Dout
Dout
sign extend
0?
RA 4-bit register number to control logic
IR27..24
1
RB 4-bit register number to control logic
IR23..20
RD 4-bit register number to control logic
IR3..0
OP 4-bit opcode to control logic
IR31..28
1
Z 1-bit boolean to control logic
49
Basic Algorithm
  • Lather
  • Rinse
  • Repeat

50
Question
  • I understand the basic operation of the LC-2200
    datapath
  • Very well, sir, may I have another!
  • Sorta, kinda
  • A clue
  • Somewhat confused
  • Lost in the jungles of Borneo

51
Questions?
52
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com