





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















MIPS terminology
Exception: any unexpected change in the internal
control flow
Interrupt: event is externally caused
I/O device request
Tracing instruction execution
Breakpoint (programmer-requested interrupt)
Exceptions in MIPS
stage Problem exceptions
occurring
IF Page fault on IF, misaligned memory
access, memory protection violation
ID Undefined or illegal opcode
EX Arithmetic exception
MEM Page fault on data fetch, misaligned
memory access, memory protection
violation
WB None
normal control flow:
sequential, jumps, branches, calls, returns
Exception
System
Exception
Handler
return from
exception
user program
Consider two types of exceptions:
First save the address of the offending instruction in
Exception Program Counter ( EPC ).
Transfer control to the operating system ( OS ) to
some specified address.
OS provides some service.
OS can stop the program or restart the program using
A single entry point 8000 0180
hex
is used for all
exceptions.
The OS is decoding the status register to find the
cause.
Two registers are added to the data-path
EPC : 32-bit holding the address of the affected instruction.
It is required for vectored exceptions too.
Cause : 32-bit recording the exception cause (some bits
unused).
In this example LSB of Cause encodes the exception.
EPC must trim 4 from PC.
Exception in pipelined architecture
A 32-bit register
Holds the address of the offending instruction
A 32-bit register
Records the cause of the exception
interrupts mask and enable bits that determines
what exceptions can occur.
Additions to MIPS ISA
Exceptions example
40 hex sub $11, $2, $
44 hex and $12, $2, $
48 hex or $13, $2, $
4Chex add $1, $2, $1; // arithmetic overflow
50 hex slt $15, $6, $
54 hex lw $16, 50($7)
80000240 hex sw $25, 1000($0)
80000244 hex sw $12, 1004($0)
: Exception handling program
Clock 6
overflow detected
flush ID
flush IF
nop
deasserting add
flush EX
Clock 7
first instruction of
exception routine
user mode
kernel mode