文档介绍:ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
1/29
ECE 313 - anization
Lecture 16 –异常处理
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
2/29
Outline - Multicycle Design
Overview
Datapath Design
Controller Design
Exceptions 3
Performance Considerations
Microprogramming
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
3/29
Exceptions-异常
定义: "unexpected change in control flow"
一些需要处理的运行时错误
Overflow
Undefined Instruction
Hardware malfunction-硬件故障
需要处理的外部事件, "service" functions
中断Interrupts –外部I/O设备的请求external I/O Device request
页故障Page fault - virtual memory
系统调用System call - user request for OS action
中断和异常的区分
许多体系结构不区分二者,一概用中断表示,如IA-32
在MIPS中,异常是指控制流中任何意外的改变;而中断是指由外部引起的事件
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
4/29
异常过程中发生什么?
保存用户状态-R的值等
采取行动处理异常
存储用户状态并且在可能的情况下继续执行程序
Exception:
undefined instruction
Return from
exception
user program
f0,f1,f2
srl r1,r2,2
beq r0,r1,L
sub r5,r3,r2
add r5,r4,r3
bne r4,r3,L2
add r3,r1,r2
Exception Handler
(System)
rfe
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
5/29
在多周期处理器中加入异常处理
这里实现两种异常:
Undefined instruction
Arithmetic overflow
在原有结构中加入R保存状态
异常程序计数器EPC –Exception Program Counter (32 bits)
原因寄存器Cause - records cause of exception (32 bits)
Undefined instruction: Cause <- 0
Arithmetic overflow: Cause <- 1
其他体系结构中使用的方法
在栈中保存PC的值
使用异常向量Exception Vector区分异常的类型。
异常向量对应地址,地址的不同区分出不同的异常类型
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
6/29
异常实现-MIPS
增加数据通路部件- Figure
ExceptionPC (EPC) - stores PC of offending instruction
Cause Register - records the cause of the exception
改变控制逻辑- Figures
Undefined Instruction - state 1 (Instruction decode)
Overflow - state 7 (R-pletion)
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
7/29
ECE 313 Fall 2006
Lecture 15 - Multicycle Design 2
8/29
在控制中加入对异常处理的支持-未定义指令
IntCause = 0
CauseWrite
ALUSrcA = 0
ALUSrcB = 01
ALUOp = 01
EPCWRITE
PCWrite
PCSource=11
State 10
Undefined
Instruction
State 0
ALUSrcA = 0
ALUS