Académique Documents
Professionnel Documents
Culture Documents
Spring 2012
EECS150 - Lec07-MIPS
Page 1
Spring 2012
EECS150 - Lec07-MIPS
Page 2
Therefore with the help of a compiler (and assembler), to run applications all we need is a means to interpret (or execute) machine instructions. Usually the application calls on the operating system and libraries to provide special functions.
Spring 2012 EECS150 - Lec07-MIPS Page 3
Abstraction Layers
Architecture: the programmers view of the computer
Defined by instructions (operations) and operand locations
Microarchitecture: how to implement an architecture in hardware (covered in great detail later) The microarchitecture is built out of logic circuits and memory elements (this semester). All logic circuits and memory elements are implemented in the physical world with transistors.
Spring 2012 EECS150 - Lec07-MIPS Page 4
Otherwise
opcode tells what instruction it is
Spring 2012
EECS150 - Lec07-MIPS
Page 7
Controller
Spring 2012
EECS150 - Lec07-MIPS
Page 8
2. Select set of datapath components and establish clocking methodology 3. Assemble datapath meeting requirements 4. Analyze implementation of each instruction to determine setting of control points that effects the data transfer. 5. Assemble the control logic.
Spring 2012 EECS150 - Lec07-MIPS Page 9
The different fields are: op: operation (opcode) of the instruction rs, rt, rd: the source and destination register specifiers shamt: shift amount funct: selects the variant of the operation in the op field address / immediate: address offset or immediate value target address: target address of jump instruction
Spring 2012 EECS150 - Lec07-MIPS
Page 10
lw, sw
lw rt,rs,imm16 sw rt,rs,imm16
31 26 op 6 bits 21 rs 5 bits 16 rt 5 bits immediate 16 bits 0
beq
beq rs,rt,imm16
31
26 op 6 bits
21 rs 5 bits
Spring 2012
EECS150 - Lec07-MIPS
inst
add
sub
or slt
lw
sw
beq
Register Transfers
R[rd] R[rs] + R[rt];
R[rd] R[rs] R[rt];
R[rd] R[rs] | R[rt]; R[rd] (R[rs] < R[rt]) ? 1 : 0;
R[rt] DMEM[ R[rs] + sign_ext(Imm16)];
PC PC + 4 PC PC + 4 PC PC + 4 PC PC + 4 PC PC + 4
DMEM[ R[rs] + sign_ext(Imm16) ] R[rt]; PC PC + 4 if ( R[rs] == R[rt] ) then PC PC + 4 + {sign_ext(Imm16), 00} else PC PC + 4
EECS150 - Lec07-MIPS Page 12
Spring 2012
Microarchitecture
Multiple implementations for a single architecture:
Single-cycle
Each instruction executes in a single clock cycle.
Multicycle
Each instruction is broken up into a series of shorter steps with one step per clock cycle.
Spring 2012
EECS150 - Lec07-MIPS
Page 13
Spring 2012
EECS150 - Lec07-MIPS
Page 14
Several significant advantages over single cycle execution: Unused stages in a particular instruction can be skipped OR instructions can be pipelined (overlapped).
Spring 2012 EECS150 - Lec07-MIPS Page 15
Note: for these state elements, clock is used for write but not for read (asynchronous read, synchronous write).
Spring 2012 EECS150 - Lec07-MIPS Page 16
Spring 2012
EECS150 - Lec07-MIPS
Page 17
Spring 2012
EECS150 - Lec07-MIPS
Page 18
Spring 2012
EECS150 - Lec07-MIPS
Page 19
Spring 2012
EECS150 - Lec07-MIPS
Page 20
STEP 5: Read data from memory and write it back to register file
Spring 2012
EECS150 - Lec07-MIPS
Page 21
Spring 2012
EECS150 - Lec07-MIPS
Page 22
Single-Cycle Datapath: sw
DMEM[ R[rs] + sign_ext(Imm16) ] R[rt]
Spring 2012
EECS150 - Lec07-MIPS
Page 23
Spring 2012
EECS150 - Lec07-MIPS
Page 24
Determine whether values in rs and rt are equal Calculate branch target address: BTA = (sign-extended immediate << 2) + (PC+4)
Spring 2012
EECS150 - Lec07-MIPS
Page 25
Spring 2012
EECS150 - Lec07-MIPS
Page 26
Review: ALU
F2:0 000 001 010 011 100 101 110 111
Spring 2012 EECS150 - Lec07-MIPS
Control Unit
Spring 2012
EECS150 - Lec07-MIPS
Page 28
Meaning Add Subtract Look at Funct Not Used ALUControl2:0 010 (Add) 110 (Subtract) 010 (Add) 110 (Subtract) 000 (And) 001 (Or)
Page 29
XXXXXX XXXXXX 100000 (add) 100010 (sub) 100100 (and) 100101 (or)
1X
Spring 2012
EECS150 - Lec07-MIPS
Page 30
R-type lw sw beq
1 1 0 0
1 0 X X
0 1 1 0
0 0 0 1
0 0 1 0
0 0 X X
10 00 00 01
Spring 2012
EECS150 - Lec07-MIPS
Page 31
Spring 2012
EECS150 - Lec07-MIPS
Page 32
Spring 2012
EECS150 - Lec07-MIPS
Page 33
1 1 0 0
1 0 X X
0 1 1 0
0 0 0 1
0 0 1 0
0 1 X X
10 00 00 01
Spring 2012
EECS150 - Lec07-MIPS
Page 34
1 1 0 0 1
1 0 X X 0
0 1 1 0 1
0 0 0 1 0
0 0 1 0 0
0 1 X X 0
10 00 00 01 00
Spring 2012
EECS150 - Lec07-MIPS
Page 35
Extended Functionality: j
Spring 2012
EECS150 - Lec07-MIPS
Page 36
1 1 0 0
1 0 X X
0 1 1 0
0 0 0 1
0 0 1 0
0 1 X X
10 00 00 01
0 0 0 0
Spring 2012
EECS150 - Lec07-MIPS
Page 37
1 1 0 0 0
1 0 X X X
0 1 1 0 X
0 0 0 1 X
0 0 1 0 0
0 1 X X X
10 0 0 1 XX
0 0 0 0 1
Spring 2012
EECS150 - Lec07-MIPS
Page 38
Spring 2012
EECS150 - Lec07-MIPS
Page 39
Single-Cycle Performance
TC is limited by the critical path (lw)
Spring 2012
EECS150 - Lec07-MIPS
Page 40
Single-Cycle Performance
Single-cycle critical path:
Tc = tpcq_PC + tmem + max(tRFread, tsext + tmux) + tALU + tmem + tmux + tRFsetup
Spring 2012
EECS150 - Lec07-MIPS
Page 41
Tc = tpcq_PC + 2tmem + tRFread + tmux + tALU + tRFsetup = [30 + 2(250) + 150 + 25 + 200 + 20] ps = 925 ps
Spring 2012 EECS150 - Lec07-MIPS Page 43
Execution Time =
Spring 2012
EECS150 - Lec07-MIPS
Page 44
Spring 2012
EECS150 - Lec07-MIPS
Page 45
Spring 2012
EECS150 - Lec07-MIPS
Page 46
Spring 2012
EECS150 - Lec07-MIPS
Page 47
Spring 2012
EECS150 - Lec07-MIPS
Page 48
Spring 2012
EECS150 - Lec07-MIPS
Page 49
Pipelined Control
Page 50
Pipeline Hazards
Occurs when an instruction depends on results from previous instruction that hasnt completed. Types of hazards:
Data hazard: register value not written back to register file yet Control hazard: next instruction not decided yet (caused by branches)
Spring 2012
EECS150 - Lec07-MIPS
Page 51
Pipelining Abstraction
Spring 2012
EECS150 - Lec07-MIPS
Page 52