Beruflich Dokumente
Kultur Dokumente
PC
Ins tru ct i on
ALU
Addr ess
Note: Some of the material in this lecture are COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGH RESERVED. Figures may be reproduced only for classroom or personal education use in conjunction with our text and only when the above line is included.
2/6/02 CSE 141 - Single Cycle Datapath
Starting today:
Single cycle processor:
Advantage: CPI = 1 Disadvantage: long cycle time
Processor Design
We're ready to implement the MIPS core
load-store instructions: lw, sw reg-reg instructions: add, sub, and, or, slt control flow instructions: beq
Address
Data In 32 Clk
3
DataOut 32
CSE 141 - Single Cycle Datapath
Processor Design
We're ready to implement the MIPS core
load-store instructions: lw, sw reg-reg instructions: add, sub, and, or, slt control flow instructions: beq
0
Write Enable
PC
Address
Data In 32 Clk
4
DataOut 32
0
Write Enable
PC
Address
Data In 32 Clk
5
DataOut 32
Address
DataOut 32
Add
4 PC Read addr ess Ins tru ct i on Instruc tion memory
26
0 immediate 16 bits
6 bits
1. Read register rs (and rt for store) 2. Feed rs and immed to ALU 3. Move data between mem and reg
21 rs 5 bits rt 5 bits 16 displacement 16 bits 0
BRANCH:
31 op
26 6 bits
Processor Design
Generic Implementation: all instruction read some registers all instructions use the ALU after reading registers memory accessed & registers updated after ALU
PC
Ins tru ct i on
ALU
Addr ess
rd, rs, rt
Ra, Rb, and Rw come from rs, rt, and rd fields ALUoperation signal depends on op and funct
31 op 6 bits 26 rs 5 bits
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a
21 rt 5 bits
16 rd 5 bits
11 shamt 5 bits
3
6 funct 6 bits
ALU ope r a t i on
Ze ro ALU r esu l t
RegWri t e
10 CSE 141 - Single Cycle Datapath
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a RegWri t e 16
3 Read da t a 1
ALU Read da t a 2
ALU r esu l t
Addr ess
Read da t a Da t a memory
MemRead
11
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a RegWri t e 16
3 Read da t a 1
ALU Read da t a 2
ALU r esu l t
Addr ess
Read da t a Da t a memory
MemRead
12
Combining datapaths
How do we allow different datapaths for different instructions??
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a 3 Read da t a 1 ALU Read da t a 2 ALU ope r a t i on
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a RegWri t e 3 Read da t a 1 Ze ro ALU Read da t a 2 Wri t e da t a 16 S ign ext end 32 ALU r esu l t Addr ess Read da t a Da t a memory ALU ope r a t i on MemWri t e
Ze ro ALU r esu l t
RegWri t e
MemRead
R-type
Store
13
Combining datapaths
How do we allow different datapaths for different instructions??
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a 3 Read da t a 1 ALU Read da t a 2 ALU ope r a t i on
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a RegWri t e 3 Read da t a 1 Ze ro ALU Read da t a 2 Wri t e da t a 16 S ign ext end 32 ALU r esu l t Addr ess Read da t a Da t a memory ALU ope r a t i on MemWri t e
Ze ro ALU r esu l t
RegWri t e
MemRead
Use a multiplexor!
ALUscr
Read r egi s t e r 1 Ins tru ct i on Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Wri t e da t a RegWri t e 16 S ign ext end 32 3 Read da t a 1 Ze ro ALU Read da t a 2 Wri t e da t a ALU r esu l t Addr ess ALU ope r a t i on
MemWri t e
Read da t a Da t a memory
MemRead
14
B r an c h t a rge t
Ins tru ct i on
Read da t a 1 Read r egi s t e r 2 Regist ers Wri t e r egi s t e r Read da t a 2 Wri t e da t a RegWri t e 16 Sign ext end 32
ALU Ze ro
To br an c h c on tro l l ogi c
15
16
Add 4 RegWri t e Ins tru ct i on [25 21] PC Read addr ess Ins tru ct i on [31 0] Instruc tion memory Ins tru ct i on [20 16] 1 M u Ins tru ct i on [15 11] x 0 RegDs t Ins tru ct i on [15 0] Read r egi s t e r 1 Read r egi s t e r 2 Shift left 2 ALU Add r esu lt
Read da t a 1
MemWri t e ALUSrc 1 M u x 0 Ze ro ALU ALU r esu l t Mem t oReg Addr ess Read da t a 1 M u x 0
Wri t e da t a
Da t a memory
ALU c on tro l
MemRead
17
Read da t a 1
MemWri t e ALUS rc 1 M u x 0 Ze ro ALU ALU r esu l t Mem t oReg Addr ess Read da t a 1 M u x 0
Wri t e da t a
Da t a memory
ALU c on tro l
MemRead
Need ALUsrc=1, ALUop=add, MemWrite=0, MemToReg=0, RegDst = 0, RegWrite=1 and PCsrc=1. 18 CSE 141 - Single Cycle Datapath
Add 4 RegWri t e Ins tru ct i on [2 5 2 1] PC Read addr ess Ins tru ct i on [3 1 0] Instruc tion memory Ins tru ct i on [2 0 1 6] 1 M u Ins tru ct i on [1 5 1 1] x 0 RegDs t Ins tru ct i on [15 0] Read r egi s t e r 1 Read r egi s t e r 2 Shift left 2 ALU Add r esu lt
Read da t a 1
MemWri t e ALUS rc 1 M u x 0 Ze ro ALU ALU r esu l t Mem t oReg Addr ess Read da t a 1 M u x 0
Wri t e da t a
Da t a memory
ALU c on tro l
MemRead
Add 4 RegWri t e Ins tru ct i on [2 5 2 1] PC Read addr ess Ins tru ct i on [3 1 0] Instruc tion memory Ins tru ct i on [2 0 1 6] 1 M u Ins tru ct i on [1 5 1 1] x 0 RegDs t Ins tru ct i on [15 0] Read r egi s t e r 1 Read r egi s t e r 2 Shift left 2 ALU Add r esu lt
Read da t a 1
MemWri t e ALUS rc 1 M u x 0 Ze ro ALU ALU r esu l t Mem t oReg Addr ess Read da t a 1 M u x 0
Wri t e da t a
Da t a memory
ALU c on tro l
MemRead
20
Add 4 RegWri t e Ins tru ct i on [2 5 2 1] PC Read addr ess Ins tru ct i on [3 1 0] Instruc tion memory Ins tru ct i on [2 0 1 6] 1 M u Ins tru ct i on [1 5 1 1] x 0 RegDs t Ins tru ct i on [15 0] Read r egi s t e r 1 Read r egi s t e r 2 Shift left 2 ALU Add r esu lt
Read da t a 1
MemWri t e ALUS rc 1 M u x 0 Ze ro ALU ALU r esu l t Mem t oReg Addr ess Read da t a 1 M u x 0
Wri t e da t a
Da t a memory
ALU c on tro l
MemRead
21
Key Points
CPU is just a collection of state and combinational logic We just designed a very rich processor, at least in terms of functionality Execution time = Insts * CPI * Cycle Time
where does the single-cycle machine fit in?
22
Example of creative architecture ~ 2000 built. Relatively inexpensive ( < $1620/month rental)