|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--sim.Mips
Implements a simple MIPS simulator. There are two basic modes of operation:
(1) Bare mode: In this mode, the "bios" loader loads the OS loader (bootloader) into a location in high memory. This loader must be able to fit in a single 512 byte block and run in a location independent manner. Its job is to load the OS into low memory. The OS is standard-looking process (see the Linker class) and the loader can just slam it into memory starting at location zero. (Detail: the OS is linked as if it starts at location 24, because the top 6 words are always the executable descriptor -- the OS can reuse this space later, if it wishes. The OS should have its exception handling routines (trap handler) as the first thing in its text segment. The machine will automatically jump to location 24 on exceptions...) Once the kernel is loaded, the loader jumps to its entry point (as specified by the executable) and its off to the races. In this mode, memory mapped IO is used, and it's the kernels responsibility to provide system calls to read/write from these addresses to perform IO. If the kernel wishes to load/run other processes, it must manage the base & length registers accordingly to perform address translation for that process.
(2) System mode: In this mode, the simulator actually manages many of the system services, namely system calls. A set of system calls is provided to perform basic IO, which is all simply handled in software.
Memory mapped IO: By default, the machine has a single CharacterDevice, a single BlockDevice, and a single RAM. In bare mode, the user has to write code that uses these devices to do IO. In system mode, these devices are typically unused, in favor of doing IO through the system calls.
Limitations: Currently, there is no timer device, but this can/will be added.
Differences: The MULT and DIV instructions currently do not simulate the HI/LO registers as on a MIPS machine. MULT and DIV are encoded as normal R-type instructions, where the destination register takes the product (or quotient). Users wishing to implement modulus must do simulate the process in software.
R2000 Coprocessor 0: Simulates the coprocessor to some extent, with some differences from a real MIPS machine (base and length registers), the other 4 are the same. Currently reg 12 isn't used...
Linker
,
Memory
,
MemoryMap
,
BlockDevice
,
CharacterDevice
,
RAM
Nested Class Summary | |
(package private) class |
Mips.GlobalMemoryList
|
(package private) class |
Mips.InsMemoryList
|
(package private) class |
Mips.MemoryList
|
(package private) class |
Mips.RegList
|
(package private) class |
Mips.StackMemoryList
|
Field Summary | |
static int |
ADDRL
Bad address for load. |
static int |
ADDRS
Bad address for store. |
(package private) int |
arith
|
(package private) boolean |
bare
|
(package private) int |
branches
|
(package private) int |
branchesTaken
|
(package private) java.util.Map |
breakPoints
|
static int |
BRKPT
Breakpoint exception. |
static int |
COP_BADADDR
Cop0 BAD_ADDR register |
static int |
COP_BASE
Cop0 BASE register |
static int |
COP_CAUSE
Cop0 CAUSE register |
static int |
COP_EPC
Cop0 EPC register |
static int |
COP_LENGTH
Cop0 LENGTH register |
static int |
COP_STATUS
Cop0 STATUS register |
(package private) int[] |
cop0
|
static int |
DBUS
Bus error on store. |
(package private) Cache |
dCache
|
static int |
defaultBlockDevLoc
|
static int |
defaultMemSize
|
static int |
defaultTermDevLoc
|
(package private) int |
exeSize
|
(package private) int |
hi
|
static int |
IBUS
Bus error on load. |
(package private) Cache |
iCache
|
(package private) static java.io.BufferedReader |
in
|
(package private) long |
instructions
|
static int |
INT
External interrupt, such as IO completion. |
(package private) int |
jumps
|
(package private) int |
loads
|
(package private) int |
low
|
MemoryMap |
mem
|
static int |
OVF
Arithmetic overflow exception. |
int |
pc
|
(package private) RAM |
ram
|
(package private) int[] |
regs
|
static int |
RI
Reserved/illegal instruction. |
(package private) boolean |
running
|
(package private) int |
stores
|
static int |
SYSCALL
Syscall exception. |
(package private) int |
syscalls
|
(package private) boolean |
userMode
|
(package private) boolean |
verbose
|
Constructor Summary | |
Mips(int newPC,
int memSize)
|
Method Summary | |
void |
addBreakPoint(int address)
|
void |
biosLoad(java.lang.String fileName)
Just raw loads whatever is in the given file, and sets $k0 to be the size of physical memory. |
void |
debugger()
|
void |
deleteBreakPoint(int address)
|
void |
doSysCall()
|
void |
dumpMem(int addr,
int words)
|
void |
dumpState()
|
void |
exeLoad(java.lang.String fileName,
int atAddress)
Loads a real executable, as per the format described in the class Linker. |
java.util.Vector |
getBreakPoints()
|
javax.swing.ListModel |
getGlobalMemListModel()
|
javax.swing.ListModel |
getInsMemListModel()
|
javax.swing.ListModel |
getRegListModel()
|
javax.swing.ListModel |
getStackMemListModel()
|
void |
initialize(boolean breaks)
Initialize the state of the machine. |
static void |
main(java.lang.String[] args)
|
void |
msg(java.lang.String s)
|
void |
msgln(java.lang.String s)
|
void |
quit()
|
void |
raiseException(int type)
|
byte |
readByte(int virtual)
|
(package private) int |
readCop0(int reg)
|
int |
readWord(int virtual)
|
void |
run()
|
void |
step(int numCycles)
|
void |
writeByte(int virtual,
byte value)
|
(package private) void |
writeCop0(int reg,
int val)
|
void |
writeWord(int virtual,
int value)
|
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
int[] regs
int[] cop0
int hi
int low
public int pc
RAM ram
public MemoryMap mem
int exeSize
boolean verbose
java.util.Map breakPoints
boolean running
boolean userMode
boolean bare
long instructions
int loads
int stores
int arith
int branches
int jumps
int syscalls
int branchesTaken
Cache iCache
Cache dCache
public static int defaultMemSize
public static int defaultTermDevLoc
public static int defaultBlockDevLoc
static java.io.BufferedReader in
public static final int INT
public static final int ADDRL
public static final int ADDRS
public static final int IBUS
public static final int DBUS
public static final int SYSCALL
public static final int BRKPT
public static final int RI
public static final int OVF
public static final int COP_BASE
public static final int COP_LENGTH
public static final int COP_BADADDR
public static final int COP_STATUS
public static final int COP_CAUSE
public static final int COP_EPC
Constructor Detail |
public Mips(int newPC, int memSize)
Method Detail |
public void initialize(boolean breaks)
public static void main(java.lang.String[] args)
public void msg(java.lang.String s)
public void msgln(java.lang.String s)
public void raiseException(int type)
int readCop0(int reg)
void writeCop0(int reg, int val)
public int readWord(int virtual)
public byte readByte(int virtual)
public void writeWord(int virtual, int value)
public void writeByte(int virtual, byte value)
public void biosLoad(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public void exeLoad(java.lang.String fileName, int atAddress) throws java.io.IOException
java.io.IOException
public void dumpState()
public void doSysCall()
public void quit()
public void run()
public void step(int numCycles)
public void addBreakPoint(int address)
public void deleteBreakPoint(int address)
public java.util.Vector getBreakPoints()
public void dumpMem(int addr, int words)
public void debugger() throws java.io.IOException
java.io.IOException
public javax.swing.ListModel getInsMemListModel()
public javax.swing.ListModel getGlobalMemListModel()
public javax.swing.ListModel getStackMemListModel()
public javax.swing.ListModel getRegListModel()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |