Package mars.mips.hardware
Class Coprocessor0
java.lang.Object
mars.mips.hardware.Coprocessor0
Represents Coprocessor 0. We will use only its interrupt/exception registers.
- Version:
- August 2005
- Author:
- Pete Sanderson
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
static int
static int
static int
static int
static int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.static void
deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.static int
For getting the number representation of the register.static Register
getRegister(String rname)
Get register object corresponding to given name.static int
Coprocessor0 implements only selected registers, so the register number (8, 12, 13, 14) does not correspond to its position in the list of registers (0, 1, 2, 3).static Register[]
For returning the set of registers.static int
getValue(int num)
Returns the value of the register whose number is num.static void
Method to reinitialize the values of the registers.static void
Display the register values for debugging.static int
updateRegister(int num, int val)
Updates the register value whose number is num.static int
updateRegister(String n, int val)
Sets the value of the register given to the value given.
-
Field Details
-
VADDR
public static final int VADDR- See Also:
- Constant Field Values
-
STATUS
public static final int STATUS- See Also:
- Constant Field Values
-
CAUSE
public static final int CAUSE- See Also:
- Constant Field Values
-
EPC
public static final int EPC- See Also:
- Constant Field Values
-
EXCEPTION_LEVEL
public static final int EXCEPTION_LEVEL- See Also:
- Constant Field Values
-
DEFAULT_STATUS_VALUE
public static final int DEFAULT_STATUS_VALUE- See Also:
- Constant Field Values
-
-
Constructor Details
-
Coprocessor0
public Coprocessor0()
-
-
Method Details
-
showRegisters
public static void showRegisters()Display the register values for debugging. -
updateRegister
Sets the value of the register given to the value given.- Parameters:
n
- name of register to set the value of ($n, where n is reg number).val
- The desired value for the register.- Returns:
- old value in register prior to update
-
updateRegister
public static int updateRegister(int num, int val)Updates the register value whose number is num.- Parameters:
num
- Number of register to set the value of.val
- The desired value for the register.- Returns:
- old value in register prior to update
-
getValue
public static int getValue(int num)Returns the value of the register whose number is num.- Parameters:
num
- The register number.- Returns:
- The value of the given register. 0 for non-implemented registers
-
getNumber
For getting the number representation of the register.- Parameters:
n
- The string formatted register name to look for.- Returns:
- The number of the register represented by the string. -1 if no match.
-
getRegisters
For returning the set of registers.- Returns:
- The set of registers.
-
getRegisterPosition
Coprocessor0 implements only selected registers, so the register number (8, 12, 13, 14) does not correspond to its position in the list of registers (0, 1, 2, 3).- Parameters:
r
- A coprocessor0 Register- Returns:
- the list position of given register, -1 if not found.
-
getRegister
Get register object corresponding to given name. If no match, return null.- Parameters:
rname
- The register name, in $0 format.- Returns:
- The register object,or null if not found.
-
resetRegisters
public static void resetRegisters()Method to reinitialize the values of the registers. -
addRegistersObserver
Each individual register is a separate object and Observable. This handy method will add the given Observer to each one. -
deleteRegistersObserver
Each individual register is a separate object and Observable. This handy method will delete the given Observer from each one.
-