dell may have shipped infected motherboards
DESCRIPTION
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 19 CPU Design: The Single-Cycle II & Control 2010-07-22. Instructor Paul Pearce. Dell may have shipped infected motherboards . - PowerPoint PPT PresentationTRANSCRIPT
CS61C L19 CPU Design: The Single-Cycle II & Control (1) Pearce, Summer 2010 © UCB
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures
Lecture 19CPU Design: The Single-Cycle II & Control
2010-07-22
Dell may have shipped infected motherboards
http://www.theregister.co.uk/2010/07/21/dell_server_warning/
Instructor Paul Pearce
Dell is warning customers that its PowerEdge R410 rack-mount server may
have shipped with spyware onboard in the embedded system management software
(firmware). Good luck getting Norton McAfee to clean that.
CS61C L19 CPU Design: The Single-Cycle II & Control (2) Pearce, Summer 2010 © UCB
How to Design a Processor: step-by-step
1. Analyze instruction set architecture (ISA) => datapath requirements
• meaning of each instruction is given by the register transfers
• datapath must include storage element for ISA registers• datapath must support each register transfer
2. Select set of datapath components and establish clocking methodology
3. Assemble datapath meeting requirements4. Analyze implementation of each instruction to
determine setting of control points that effects the register transfer.
5. Assemble the control logic
CS61C L19 CPU Design: The Single-Cycle II & Control (3) Pearce, Summer 2010 © UCB
Clocking Methodology
• Storage elements clocked by same edge• Being physical devices, flip-flops (FF) and
combinational logic have some delays • Gates: delay from input change to output change • Signals at FF D input must be stable before active clock
edge to allow signal to travel within the FF (set-up time), and we have the usual clock-to-Q delay
• “Critical path” (longest path through logic) determines length of clock period
Clk
.
.
.
.
.
.
.
.
.
.
.
.
CS61C L19 CPU Design: The Single-Cycle II & Control (4) Pearce, Summer 2010 © UCB
Register-Register Timing: One complete cycleClk
PC
Rs, Rt, Rd, etc
ALUctr
Instruction Memory Access Time
Old Value New Value
RegWr Old Value New Value
Delay through Control Logic
busA, BRegister File Access Time
Old Value New Value
busWALU Delay
Old Value New Value
Old Value New Value
New ValueOld Value
Register WriteOccurs Here
32
ALUctr
clk
busW
RegWr
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs Rt
AL
U
5Rd
CS61C L19 CPU Design: The Single-Cycle II & Control (5) Pearce, Summer 2010 © UCB
3c: Logical Operations with Immediate• R[rt] = R[rs] op ZeroExt[imm16]
op rs rt immediate
016212631
6 bits 16 bits5 bits5 bits
immediate
016 1531
16 bits16 bits
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
32
ALUctr
clk
busW
RegWr
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs RtA
LU
5Rd
But we’re writing to Rt register??
CS61C L19 CPU Design: The Single-Cycle II & Control (6) Pearce, Summer 2010 © UCB
3c: Logical Operations with Immediate• R[rt] = R[rs] op ZeroExt[imm16] ]
op rs rt immediate
016212631
6 bits 16 bits5 bits5 bits
immediate
016 1531
16 bits16 bits
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
• Already defined 32-bit MUX; Zero Ext?
What about Rt register read??
32
ALUctr
clk
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
Rd
ZeroE
xt 3216imm16
ALUSrc
01
0
1
AL
U
5
RegDst
CS61C L19 CPU Design: The Single-Cycle II & Control (7) Pearce, Summer 2010 © UCB
3d: Load Operations• R[rt] = Mem[R[rs] + SignExt[imm16]]Example: lw rt,rs,imm16
op rs rt immediate
016212631
6 bits 16 bits5 bits5 bits
32
ALUctr
clk
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
Rd
ZeroE
xt 3216imm16
ALUSrc
01
0
1
AL
U
5
RegDst
CS61C L19 CPU Design: The Single-Cycle II & Control (8) Pearce, Summer 2010 © UCB
3d: Load Operations• R[rt] = Mem[R[rs] + SignExt[imm16]]Example: lw rt,rs,imm16
op rs rt immediate
016212631
6 bits 16 bits5 bits5 bits
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der 3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In
32
MemWr01
0
1
AL
U 0
1
WrEn Adr
DataMemory
5
?
CS61C L19 CPU Design: The Single-Cycle II & Control (9) Pearce, Summer 2010 © UCB
3e: Store Operations• Mem[ R[rs] + SignExt[imm16] ] = R[rt]
Ex.: sw rt, rs, imm16
op rs rt immediate016212631
6 bits 16 bits5 bits5 bits
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der 3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In
32
MemWr01
0
1
AL
U 0
1
WrEn Adr
DataMemory
5
CS61C L19 CPU Design: The Single-Cycle II & Control (10) Pearce, Summer 2010 © UCB
3e: Store Operations• Mem[ R[rs] + SignExt[imm16] ] = R[rt]
Ex.: sw rt, rs, imm16
op rs rt immediate016212631
6 bits 16 bits5 bits5 bits
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der 3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In
32
MemWr01
0
1
AL
U 0
1
WrEn Adr
DataMemory
5
CS61C L19 CPU Design: The Single-Cycle II & Control (11) Pearce, Summer 2010 © UCB
3f: The Branch Instruction
beq rs, rt, imm16• mem[PC] Fetch the instruction from memory
• Zero = R[rs] - R[rt] Calculate branch condition
• if (Zero) Calculate the next instruction’s address PC = PC + 4 + ( SignExt(imm16) x 4 )
else PC = PC + 4
op rs rt immediate016212631
6 bits 16 bits5 bits5 bits
CS61C L17 Combinational Logic Blocks and Intro to CPU Design (12) Pearce, Summer 2010 © UCB
Datapath for Branch Operations• beq rs, rt, imm16Datapath generates condition (zero)
op rs rt immediate016212631
6 bits 16 bits5 bits5 bits
Already have mux, adder, need special sign extender for PC, need equal compare (sub?)imm16
clk
PC
00
4nPC_sel
PC
Ext
Ad
derA
dder
Mu
x
Inst Address
32
ALUctr
clk
busW
RegWr
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs Rt
AL
U
5
z
Zero
CS61C L17 Combinational Logic Blocks and Intro to CPU Design (13) Pearce, Summer 2010 © UCB
Putting it All Together:A Single Cycle Datapath
imm16
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der
3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In32
MemWrZero
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
clk
PC
00
4
nPC_sel
PC
Ext
Adr
InstMemory
Ad
derA
dder
Mu
x
01
0
1
z
AL
U 0
1
WrEn Adr
DataMemory
5
CS61C L19 CPU Design: The Single-Cycle II & Control (14) Pearce, Summer 2010 © UCB
An Abstract View of the Implementation
DataOut
clk
5
Rw Ra Rb
RegisterFile
Rd
Data In
DataAddr Ideal
DataMemory
Instruction
InstructionAddress
IdealInstruction
Memory
PC
5Rs
5Rt
32
323232
A
B
Nex
t A
dd
ress
Control
Datapath
Control Signals Conditions
clk clk
AL
U
CS61C L19 CPU Design: The Single-Cycle II & Control (15) Pearce, Summer 2010 © UCB
An Abstract View of the Critical Path Critical Path (Load Instruction) =
Delay clock through PC (FFs) + Instruction Memory’s Access Time + Register File’s Access Time, + ALU to Perform a 32-bit Add + Data Memory Access Time + Stable Time for Register File Write
clk
5
Rw Ra Rb
RegisterFile
Rd
Data In
DataAddr Ideal
DataMemory
Instruction
InstructionAddress
IdealInstruction
Memory
PC
5Rs
5Rt
32
323232
A
B
Nex
t A
dd
ress
clk clk
AL
U(Assumes a fast controller)
CS61C L19 CPU Design: The Single-Cycle II & Control (16) Pearce, Summer 2010 © UCB
Administrivia• HW 7 due Saturday
• Specification update now online. Be sure to check it out. The changes are designed to make integration with project 2 easier. They are very minor.
• Project 2 online now!
• Reminder: Midterm regrades due Monday.
• Paul will be gone on Monday. Noah will be giving the lecture.
• Paul will have OH on Monday (barring flight delays)
• Be prepared for a kinetic learning activity
CS61C L19 CPU Design: The Single-Cycle II & Control (17) Pearce, Summer 2010 © UCB
Review: A Single Cycle Datapath
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der
3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In32
MemWrzero
01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel instrfetchunitclk
• We have everything but the values of control signals
CS61C L19 CPU Design: The Single-Cycle II & Control (18) Pearce, Summer 2010 © UCB
Recap: Meaning of the Control Signals• nPC_sel: “+4” 0 PC <– PC + 4
“br” 1 PC <– PC + 4 + {SignExt(Im16) , 00 }
• Later in lecture: higher-level connection between mux and branch condition
“n”=next
imm16
clk
PC
00
4nPC_sel
PC
Ext
Ad
derA
dder
Mu
x
Inst Address
0
1
CS61C L19 CPU Design: The Single-Cycle II & Control (19) Pearce, Summer 2010 © UCB
Recap: Meaning of the Control Signals• ExtOp: zero, sign
• ALUsrc: 0 reg; 1 imm
• ALUctr: ADD, SUB, OR
° MemWr: 1 write memory° MemtoReg: 0 alu; 1 mem° RegDst: 0 rt; 1 rd° RegWr: 1 write register
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der 3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In
32
MemWr01
0
1
AL
U 0
1
WrEn Adr
DataMemory
5
CS61C L19 CPU Design: The Single-Cycle II & Control (20) Pearce, Summer 2010 © UCB
RTL: The Add Instruction
add rd, rs, rt•MEM[PC] Fetch the instruction
from memory
•R[rd] = R[rs] + R[rt] The actual operation
•PC = PC + 4 Calculate the next instruction’s address
op rs rt rd shamt funct
061116212631
6 bits 6 bits5 bits5 bits5 bits5 bits
CS61C L19 CPU Design: The Single-Cycle II & Control (21) Pearce, Summer 2010 © UCB
Instruction Fetch Unit at the Beginning of Add• Fetch the instruction from Instruction memory: Instruction = MEM[PC]
• same for all instructions
imm16
clk
PC
00
4nPC_sel
PC
Ext
Ad
derA
dder
Mu
x
Inst Address
InstMemory Instruction<31:0>
CS61C L19 CPU Design: The Single-Cycle II & Control (22) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Add
R[rd] = R[rs] + R[rt]op rs rt rd shamt funct
061116212631
32
ALUctr=ADD
clk
busW
RegWr=1
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=rd
Exten
der
3216imm16
ALUSrc=regExtOp=x
MemtoReg=ALU
clk
Data In32
MemWr=0
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel=+4 instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (23) Pearce, Summer 2010 © UCB
Instruction Fetch Unit at the End of Add• PC = PC + 4
• This is the same for all instructions except: Branch and Jump
imm16
clk
PC
00
4nPC_sel=+4
PC
Ext
Ad
derA
dder
Mu
x
Inst Address
InstMemory
CS61C L19 CPU Design: The Single-Cycle II & Control (24) Pearce, Summer 2010 © UCB
Single Cycle Datapath during Or Immediate?
op rs rt immediate
016212631
• R[rt] = R[rs] OR ZeroExt[Imm16]
32
ALUctr=
clk
busW
RegWr=
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=
Exten
der
3216imm16
ALUSrc=ExtOp=
MemtoReg=
clk
Data In32
MemWr=
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel= instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (25) Pearce, Summer 2010 © UCB
• R[rt] = R[rs] OR ZeroExt[Imm16]op rs rt immediate
016212631
Single Cycle Datapath during Or Immediate?
32
ALUctr=OR
clk
busW
RegWr=1
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=rt
Exten
der
3216imm16
ALUSrc=immExtOp=zero
MemtoReg=alu
clk
Data In32
MemWr=0
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel=+4 instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (26) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Load?
• R[rt] = Data Memory {R[rs] + SignExt[imm16]}op rs rt immediate
016212631
32
ALUctr=
clk
busW
RegWr=
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=
Exten
der3216
imm16
ALUSrc=ExtOp=
MemtoReg=
clk
Data In32
MemWr=
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel= instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (27) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Load
• R[rt] = Data Memory {R[rs] + SignExt[imm16]}op rs rt immediate
016212631
32
ALUctr=ADD
clk
busW
RegWr=1
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=rt
Exten
der3216
imm16
ALUSrc=immExtOp=sign
MemtoReg=mem
clk
Data In32
MemWr=0
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel=+4 instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (28) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Store?
op rs rt immediate
016212631
• Data Memory {R[rs] + SignExt[imm16]} = R[rt]
32
ALUctr=
clk
busW
RegWr=
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=
Exten
der3216
imm16
ALUSrc=ExtOp=
MemtoReg=
clk
Data In32
MemWr=
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel= instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (29) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Store
• Data Memory {R[rs] + SignExt[imm16]} = R[rt]op rs rt immediate
016212631
32
ALUctr=ADD
clk
busW
RegWr=0
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=x
Exten
der3216
imm16
ALUSrc=immExtOp=sign
MemtoReg=x
clk
Data In32
MemWr=1
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel=+4 instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (30) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Branch?
• if (R[rs] - R[rt] == 0) then Zero = 1 ; else Zero = 0op rs rt immediate
016212631
32
ALUctr=
clk
busW
RegWr=
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=
Exten
der3216
imm16
ALUSrc=ExtOp=
MemtoReg=
clk
Data In32
MemWr=
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel= instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (31) Pearce, Summer 2010 © UCB
The Single Cycle Datapath during Branch
• if (R[rs] - R[rt] == 0) then Zero = 1 ; else Zero = 0op rs rt immediate
016212631
32
ALUctr=SUB
clk
busW
RegWr=0
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst=x
Exten
der3216
imm16
ALUSrc=regExtOp=x
MemtoReg=x
clk
Data In32
MemWr=0
zero01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel=br instrfetchunitclk
CS61C L19 CPU Design: The Single-Cycle II & Control (32) Pearce, Summer 2010 © UCB
Instruction Fetch Unit at the End of Branch• if (Zero == 1) then PC = PC + 4 + SignExt[imm16]*4 ;
else PC = PC + 4
op rs rt immediate
016212631
• What is encoding of nPC_sel?
• Direct MUX select?
• Branch inst. / not branch
• Let’s pick 2nd option
• nPC_sel = +4 0
• nPC_sel = br 1nPC_sel zero? MUX
0 x 01 0 01 1 1
Adr
InstMemory
nPC_selInstruction<31:0>
Zero
nPC_sel
Q: What logic gate?
imm16 clk
PC
00
4
PC
Ext
Ad
derA
dder
Mu
x
0
1
MUX ctrl
CS61C L19 CPU Design: The Single-Cycle II & Control (33) Pearce, Summer 2010 © UCB
Peer Instruction
12a) FFb) FTc) TFd) TT
CS61C L19 CPU Design: The Single-Cycle II & Control (34) Pearce, Summer 2010 © UCB
Peer Instruction Answer
12a) FFb) FTc) TFd) TT
1) Memory has by far a higher access time than combinational logic. TRUE
2) Let’s look back at the datapath. Take a sw instructions. Can we also write to a register? If so, which reg? What value? TRUE
CS61C L19 CPU Design: The Single-Cycle II & Control (35) Pearce, Summer 2010 © UCB
Summary: A Single Cycle Datapath
32
ALUctr
clk
busW
RegWr
32
32busA
32
busB
5 5
Rw Ra Rb
RegFile
Rs
Rt
Rt
RdRegDst
Exten
der
3216imm16
ALUSrcExtOp
MemtoReg
clk
Data In32
MemWrzero
01
0
1
Z
AL
U 0
1
WrEn Adr
DataMemory
5
Instruction<31:0><21:25>
<16:20>
<11:15>
<0:15>
Imm16RdRtRs
nPC_sel instrfetchunitclk
• We have everything! Now we just need to know how to BUILD
CONTROL
CS61C L19 CPU Design: The Single-Cycle II & Control (36) Pearce, Summer 2010 © UCB
°5 steps to design a processor• 1. Analyze instruction set datapath requirements• 2. Select set of datapath components & establish clock
methodology• 3. Assemble datapath meeting the requirements• 4. Analyze implementation of each instruction to
determine setting of control points that effects the register transfer.
• 5. Assemble the control logic• Formulate Logic Equations• Design Circuits
Summary: Single-cycle Processor
Control
Datapath
Memory
ProcessorInput
Output