Upload
peter-owens
View
222
Download
0
Embed Size (px)
DESCRIPTION
CPU Overview Computer Organization II 3 February 2009 © McQuain & Ribbens CPU Overview
Citation preview
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
1IntroductionCPU performance factors
– Instruction count Determined by ISA and compiler
– CPI and Cycle time Determined by CPU hardware
We will examine two MIPS implementations– A simplified version– A more realistic pipelined version
Simple subset, shows most aspects– Memory reference: lw, sw– Arithmetic/logical: add, sub, and, or, slt– Control transfer: beq, j
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
2Instruction Execution
PC instruction memory, fetch instruction
Register numbers register file, read registers
Depending on instruction class– Use ALU to calculate
Arithmetic result Memory address for load/store Branch target address
– Access data memory for load/store– PC target address or PC + 4
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
3CPU Overview
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
4Need for Selection Mechanisms
Compute address for sequential execution.
Compute address for conditional branch.
Must choose which one goes back to PC. BUT, you cannot just
join wires together to achieve this…
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
5Multiplexor
An 2n x 1 multiplexor receives 2n input bits and n selector bits, and outputs exactly one of the input bits, determined by the pattern of the selector bits.
2 x 1 multiplexor
C A S B S
4 x 1 multiplexor
103102101100 SSISSISSISSIOut
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
6Need for Control Logic
There must be a combinational circuit that determines which input should be selected and passed through to the PC.
The 2x1 multiplexor must have a 1-bit control line to select between the two inputs.
So, under when should the conditional address be used?
… if we're executing a conditional branch instruction and the condition has evaluated to true.
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
7Control Questions
What goes here? What control settings will the ALU need?
What's the logic for controlling the other MUXes?
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
8Logic Design Basics
Information encoded in binary– Low voltage = 0, High voltage = 1– One wire per bit– Multi-bit data encoded on multi-wire buses
Combinational elements– Operate on data– Output is purely a function of input
State (sequential) elements– Store information– Output/state depends on input and on previous state
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
9Combinational Elements
AND-gate– Y = A & B
AB Y
I0I1 Y
Mux
S
Multiplexer– Y = S ? I1 : I0
A
BY+
A
B
YALU
F
Adder– Y = A + B
Arithmetic/Logic Unit– Y = F(A, B)
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
10Sequential Elements
Register: stores data in a circuit– Uses a clock signal to determine when to update the stored value– Edge-triggered: update when Clk changes from 0 to 1
D
Clk
QClk
D
Q
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
11Sequential Elements
Register with write control– Only updates on clock edge when write control input is 1– Used when stored value is required later
D
Clk
QWrite
Write
D
Q
Clk
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
12Clocking MethodologyCombinational logic transforms data during clock cycles
– Between clock edges– Input from state elements, output to state element– Longest delay determines clock period
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
13Building a Datapath
Datapath– Elements that process data and addresses
in the CPU Registers, ALUs, mux’s, memories, …
We will build a MIPS datapath incrementally– Refining the overview design
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
14Instruction Fetch
32-bit register
Increment by 4 for next instruction
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
15R-Format Instructions
Read two register operandsPerform arithmetic/logical operationWrite register result
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
16Load/Store InstructionsRead register operandsCalculate address using 16-bit offset
– Use ALU, but sign-extend offsetLoad: Read memory and update registerStore: Write register value to memory
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
17Branch Instructions
Read register operandsCompare operands
– Use ALU, subtract and check Zero outputCalculate target address
– Sign-extend displacement– Shift left 2 places (word displacement)– Add to PC + 4
Already calculated by instruction fetch
CS@VT February 2009 ©2006-09 McQuain & Ribbens
CPU Overview
Computer Organization II
18Branch Instructions
Justre-route
wires
Sign-bit wire replicated