|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--misim.MachineState | +--misim.Processor
The Processor class extends MachineState to provide functions for managing the contents of the microcontroller's program memory and running the emulation. The Processor essentially manages the overall knowledge of the microcontroller's architecture - the instruction set, program memory and execution of instructions in sequence.
The Processor class must be extended by a specific Processor implementation to provide details unique to that Processor - such as memory space, instruction set and so on.
Field Summary | |
int |
programMemorySize
This specifies the instruction memory size |
static int |
RUN_ACCURATELY
Constant that defines that the processor should attempt to emulate a specific clock speed. |
static int |
RUN_FAST
Constant that defines that the processor should run as fast as possible, at the cost of some accuracy |
static int |
RUN_OVER
Constant that defines that the processor should emulate a single instruction, or in the case of a CALL instruction, a single called routine |
static int |
RUN_SPEED
Constant that defines that the processor should attempt to emulate a specific clock speed. |
static java.lang.String |
SETTING_CLOCK
|
static java.lang.String |
SETTING_FAST_LOOP
|
static java.lang.String |
SETTING_INTERRUPT
|
static java.lang.String |
SETTING_RUN_TYPE
|
static int |
STATE_CLEAR
|
static int |
STATE_HALTED
|
static int |
STATE_LOADED
|
static int |
STATE_RUNNING
|
static int |
STATE_STOPPED
|
Constructor Summary | |
Processor(SettingsGroup settings,
java.lang.String deviceName,
InstructionSet instructionSet,
Aliases aliases)
Constructor for the processor, Creates eeprom areas for instructions and data, and resets the machine state |
Method Summary | |
void |
addProcessorListener(ProcessorListener pl)
Add a processor listener to this processor. |
int |
addressWidth(int address)
Return the bit width of the given address word. |
java.lang.String |
disassemble(int address)
Return a disassembly of the instruction at the given address. |
void |
eraseAll()
Set all memory back to a null state. |
boolean |
fastLoop()
|
int |
getConfig()
Get the configuration word for this device |
int |
getCpuSpeed()
Returns the cpu speed, in KHz, achieved during the last run. |
int |
getDataSize()
Returns the size of array needed to store the eeprom data loaded. |
int |
getMemSize()
Returns the size of array needed to store the instructions loaded. |
int |
getRunType()
Get the run type, one of the RUN_ constants. |
int |
getState()
Method to retrieve the state of this processor |
boolean |
interruptOnStep()
Return the value of the Interrupt On Step flag, which indicates if interrupts should be emulated for the Step and Over functions. |
boolean |
isAddressValid(int address)
Return true if this address is valid - ie. |
int |
loadBinary(java.io.InputStreamReader input,
LogListener logging)
Read a binary file, initialising the processor memory and instruction arrays as appropriate |
void |
optimise()
Optimise the loaded binary by looking for 'shortcuts' for emulation. |
void |
overPic()
Single step the processor, unless the command is a call, in which case execute the entire called routine. |
Instruction |
readInstruction(int address)
Read an instruction from the given address. |
void |
removeProcessorListener(ProcessorListener pl)
Remove a processor listener from this processor. |
void |
reset(int resetType)
Reset the processor, including the data stored in the eeprom, to the values originally loaded. |
void |
resetData()
|
void |
run()
Execute some pic instructions depending on the current run type. |
void |
runAccurately()
Try to run full emulation at an accurate speed, including any clock listeners. |
void |
runFastest()
Run the emulator as fast as possible, at the expense of some accuracy. |
void |
runOver()
Run the emulator until a given breakpoint is reached. |
void |
runPic()
Initialise the emulator to run for an indefinite time, then call startThread() to run the emulator in a separate thread. |
void |
runToSpeed()
This method attempts to run the processor at a given clock speed. |
void |
setConfig(int configWord)
Set the configuration word for this device |
void |
setEeprom(int address,
Instruction instr)
|
void |
setFastLoop(boolean newValue)
|
void |
setInterruptOnStep(boolean newValue)
Set the value of the Interrupt On Step flag, which indicates if interrupts should be emulated for the Step and Over functions. |
void |
setPC(int pc)
Set a new value for the Program Counter. |
void |
setRunType(int runType)
Set the run type for emulation, one of the RUN_ constants. |
void |
setState(int newState)
Set the processor state to a new value |
protected void |
startThread()
Start the processor running in a separate thread. |
void |
stepPic()
Single step the processor, executing a single instruction. |
void |
stopThread()
|
void |
validateAddress(int address)
Validate that the given address has been initialised correctly. |
boolean |
writeData(int address,
int value)
Write byte data to the chip. |
void |
writeInstruction(int address,
Instruction instruction)
Write an instruction to the given address in this processor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int programMemorySize
public static final int STATE_CLEAR
public static final int STATE_LOADED
public static final int STATE_RUNNING
public static final int STATE_STOPPED
public static final int STATE_HALTED
public static final java.lang.String SETTING_CLOCK
public static final java.lang.String SETTING_RUN_TYPE
public static final java.lang.String SETTING_INTERRUPT
public static final java.lang.String SETTING_FAST_LOOP
public static final int RUN_FAST
public static final int RUN_SPEED
public static final int RUN_ACCURATELY
public static final int RUN_OVER
Constructor Detail |
public Processor(SettingsGroup settings, java.lang.String deviceName, InstructionSet instructionSet, Aliases aliases) throws MiSimException
Method Detail |
public void eraseAll()
public void reset(int resetType)
public void resetData()
public void setPC(int pc) throws MiSimException
setPC
in class MachineState
pc
- The new value for the program counterMiSimException
- if the new address is invalidpublic void setEeprom(int address, Instruction instr)
public void addProcessorListener(ProcessorListener pl)
pl
- - The processor listener to be addedpublic void removeProcessorListener(ProcessorListener pl)
pl
- - The processor listener to be removedpublic int getState()
public void setState(int newState)
newState
- The new state for the processorgetState()
public boolean interruptOnStep()
public void setInterruptOnStep(boolean newValue)
newValue
- True if interrupts should be emulatedpublic boolean fastLoop()
public void setFastLoop(boolean newValue)
public void setConfig(int configWord)
public int getConfig()
public boolean writeData(int address, int value)
address
- The byte address of data to writevalue
- The byte of data to writepublic int addressWidth(int address)
address
- The word address to find the bit widthpublic void writeInstruction(int address, Instruction instruction)
address
- The word address of the instructioninstruction
- The instruction to writepublic void validateAddress(int address) throws MiSimException
address
- The word address to validate.public Instruction readInstruction(int address)
address
- The word address of the instructionpublic int loadBinary(java.io.InputStreamReader input, LogListener logging) throws MiSimException, java.io.FileNotFoundException
input
- The file InputStreamReaderMiSimException
- If an error is found in the filejava.io.FileNotFoundException
- If the file cannot be loadedpublic int getMemSize()
public int getDataSize()
public int getCpuSpeed()
public void optimise()
public int getRunType()
public void setRunType(int runType)
runType
- The new run typepublic void run()
run
in interface java.lang.Runnable
public void runFastest()
Note that the calling method must catch SleepExceptions and any other unexpected Exceptions that might occur. The latter can be caused by plugins that are called during the emulation, so we cannot presume that they will not occur.
public void runOver()
public void runToSpeed()
It tries to do this by executing a number of instructions that should complete in a known time. Then, the real time elapsed is checked, and the system pauses until the time elapsed is correct for the clock count. This should mean that the processor will always run at approximately the correct speed regardless of how fast the JVM executes. However, it also means that emulation is 'choppy', and the emulated clock speed is only accurate on average.
public void runAccurately()
public void stepPic()
public void overPic()
public void runPic()
startThread()
protected void startThread()
public void stopThread()
public java.lang.String disassemble(int address)
address
- The address to disassemblepublic boolean isAddressValid(int address)
address
- The address to validate
|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |