Title: CS 2200 Presentation 4
1CS 2200Presentation 4
2drum roll...
LC-2200
3LC2200
- 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.
4Accessible 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
5LC-2200 Instruction Set
Assembler Examples add s0, s1, s2 s0 ? s1
s2 nand s0, s1, s2 s0 ? (s1 s2)
6LC-2200 Instruction Set
7LC-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
8Question
- 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?
9LC-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
10LC-2200 Instruction Set
Function
Halt processor
Do nothing
31 28
27 24
23 20
19 0
Op Code
Unused
Assembler Examples halt Stop
execution
11LC-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"
12More 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
13More 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
14More 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
15What'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?
16Questions?
17Five Classic Components
Recall
Processor
Memory
Control
Datapath
18Lets take a closer look...
Processor
Control
Datapath
19Big 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?
20LC-2200 Datapath
PC
21LC-2200 Datapath
PC
22LC-2200 Datapath
PC
IR
23LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
24LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
LdA
25LC-2200 Datapath
PC
registers 16x 32 bits
Din
WrREG
4
?
IR
regno
Dout
A
B
LdB
26LC-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
27QuestionDid you understand the preceding
explanation of adding?
- 1 Crystal Clear
- 2 Sort of
- 3 We were adding?
28PC
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
29PC
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
30MAR
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
31MAR
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
32Making 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
33Bus
Functional Unit
Functional Unit
Functional Unit
Functional Unit
34BusOnly One Functional Unit at a time can drive
bus
Functional Unit
Functional Unit
Functional Unit
Functional Unit
35BusAny (and all) functional units can access bus
Functional Unit
Functional Unit
Functional Unit
Functional Unit
36Question
- 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
37Questions?
38LC-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
39Recall our basic add instruction
40LC-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?
41Need to increment PC!
42LC-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
43LC-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
44LC-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
45LC-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
46LC-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
47LC-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
48LC-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
49Basic Algorithm
50Question
- 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
51Questions?
52(No Transcript)