|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--misim.MachineState
MachineState stores the information about the microcontroller being emulated - its stack, registers and EEPROM. It manages listeners for events generated by an instruction being emulated, such as PortListeners, and ClockListeners. The Processor class extends MachineState to provide functions to run an emulation - executing a sequence of instructions.
Field Summary | |
protected Aliases |
aliases
The Aliases object that defines any instruction aliases for this machine |
static int |
carryBit
The value of the carry flag bit in the status register |
int[] |
chipData
The device EEPROM memory |
protected ClockListener |
clockListener
The end of the chain of clock listeners, this handles interrupts for the device |
protected long |
clockRate
The speed, in MHz that the processor should be run at. |
long |
clocks
The current clock cycle count |
static int |
CONFIG_CP
Bit flag indicating that this device can be configured with Code protection Enabled(0) or Disabled(1) |
static int |
CONFIG_DP
Bit flag indicating that this device can be configured with Data protection Enabled(0) or Disabled(1) |
static int |
CONFIG_OSC4
Bit flag indicating that this device can be configured with a RC(11), HS(10), XT(01) or LP(00) Oscillator |
static int |
CONFIG_PWRTE
Bit flag indicating that this device can be configured with a Power-up Timer Enabled(1) or Disabled(0) |
static int |
CONFIG_PWRTEI
Bit flag indicating that this device can be configured with a Power-up Timer Enabled(0) or Disabled(1) |
static int |
CONFIG_WDTE
Bit flag indicating that this device can be configured with a Watchdog Timer Enabled(1) or Disabled(0) |
int |
configStart
The start address of config/test memory - note that this is stored as the byte address |
static int |
decimalBit
The value of the decimal carry flag bit in the status register |
protected int |
deviceId
The device ID (unique within the processor implementation of a family of devices) for this device |
int |
eepromStart
The Start address of EEPROM memory - note that this is stored as the byte address |
protected InstructionSet |
instructionSet
The instruction set for this machine |
static int |
PACKAGE_DIP
Indicates that this device is available in a DIP package - may be OR'd with other package types |
static int |
PACKAGE_PLCC
Indicates that this device is available in a PLCC package - may be OR'd with other package types |
static int |
PACKAGE_QFP
Indicates that this device is available in a QFP package - may be OR'd with other package types |
static int |
PACKAGE_SOIC
Indicates that this device is available in a SOIC package - may be OR'd with other package types |
static int |
PARAM_BANK_SIZE
Parameter ID for getParameter() - Returns the size of each memory bank (byte offset to next bank start) |
static int |
PARAM_BANKS
Parameter ID for getParameter() - Returns the number of memory banks |
static int |
PARAM_BIT_CP0
Parameter ID for getParameter() - Returns the bit mask for the Config code protection bit 0 |
static int |
PARAM_BIT_DP0
Parameter ID for getParameter() - Returns the bit mask for the Data code protection bit 0 |
static int |
PARAM_BIT_FOSC0
Parameter ID for getParameter() - Returns the bit mask for the Config oscillator selection bit 0 |
static int |
PARAM_BIT_FOSC1
Parameter ID for getParameter() - Returns the bit mask for the Config oscillator selection bit 1 |
static int |
PARAM_BIT_PWRTE
Parameter ID for getParameter() - Returns the bit mask for the Config power-up timer flag |
static int |
PARAM_BIT_PWRTEI
Parameter ID for getParameter() - Returns the bit mask for the Config power-up timer flag (inverted sense) |
static int |
PARAM_BIT_WDTE
Parameter ID for getParameter() - Returns the bit mask for the Config watchdog timer flag |
static int |
PARAM_CONFIG_ADDR
Parameter ID for getParameter() - Returns the address of the config data |
static int |
PARAM_CONFIG_START
Parameter ID for getParameter() - Returns the start address for the config/test program memory area |
static int |
PARAM_CONFIG_WORD
Parameter ID for getParameter() - Returns the bit flags indicating the CPU features that can be configured by the first config word |
static int |
PARAM_DATA_SIZE
Parameter ID for getParameter() - Returns the size of data memory (bytes) |
static int |
PARAM_DEVICES
Parameter ID for getParameter() - Returns the number of devices supported by this processor implementation |
static int |
PARAM_EEPROM_SIZE
Parameter ID for getParameter() - Returns the size of EEPROM memory (bytes) |
static int |
PARAM_EEPROM_START
Parameter ID for getParameter() - Returns the start address for the eeprom data memory area |
static int |
PARAM_ID_ADDR
Parameter ID for getParameter() - Returns the start address of the ID data (words) |
static int |
PARAM_ID_SIZE
Parameter ID for getParameter() - Returns the number of ID data words |
static int |
PARAM_ID_WIDTH
Parameter ID for getParameter() - Returns the how many bits of each ID word are valid |
static int |
PARAM_INSTR_WIDTH
Parameter ID for getParameter() - Returns the instruction bit width |
static int |
PARAM_PACKAGES
Parameter ID for getParameter() - Returns the bit flags for the package types this device is supplied in |
static int |
PARAM_PINS
Parameter ID for getParameter() - Returns the number of pins for this device |
static int |
PARAM_PROG_SIZE
Parameter ID for getParameter() - Returns the size of program memory (words) |
static int |
PARAM_STACK_SIZE
Parameter ID for getParameter() - Returns the stack size |
int |
pc
The Program Counter |
int |
regOffset
The offset into the current register bank |
Register[] |
regs
The register memory array |
static int |
RESET_AS_PROGRAMMED
Flag to indicate a reset to the full original programmed values |
static int |
RESET_MCLR
Flag to indicate a reset on MCLR |
static int |
RESET_POWER_UP
Flag to indicate a reset on power up |
static int |
RESET_WATCHDOG
Flag to indicate a reset on the watchdog timer |
boolean |
sleep
The Sleep flag |
int[] |
stack
The call stack |
int |
stackPtr
The Stack Pointer |
int |
trisBankOffset
The offset of the tris register bank, used by tris instructions |
int |
w
The W register |
long |
wdTimer
The watchdog timer value |
static int |
zeroBit
The value of teh zero flag bit in the status register |
Constructor Summary | |
MachineState(java.lang.String deviceName,
InstructionSet instructionSet,
Aliases aliases)
MachineState constructor. |
Method Summary | |
void |
addClockListener(ChainedClockListener newListener)
Add a chained clock listener to this machine. |
java.util.Vector |
addPortListener(PortListener portListener,
java.lang.String aPortName)
Add a port listener.. |
java.util.Vector |
addPortListener(PortListener portListener,
java.util.Vector whichPorts)
Add a port listener.. |
void |
addResetListener(ResetListener resetListener)
Add a reset listener to this device, to respond to reset events |
java.lang.String |
addressName(int addr,
int length,
boolean emptyOk)
Return the name (label) for this address. |
java.lang.String |
disassemble(Instruction instr)
Return a String representation of the given instruction |
abstract void |
enableGlobalInterrupts()
This is called at the end of the RETFIE instruction, and should re-enable global interrupts. |
void |
eraseEeprom()
Set the EEPROM contents to zero |
Aliases |
getAliases()
Return the definition for any instruction aliases defined for this processor |
java.util.Hashtable |
getAvailablePorts()
Return the hashtable that maps the names of the ports that this chip supports (a String) to the port implementations (a misim.register.Port) |
long |
getClockRate()
Get the clock rate, in hz for emulation. |
long |
getClocks()
Get the current clock cycle count. |
int |
getDeviceId()
Return the deviceID for this device. |
abstract java.lang.String |
getDeviceName(int deviceId)
Return the names of the devices supported by this processor. |
InstructionSet |
getInstructionSet()
Get the InstructionSet object that defines the instructions for this processor |
Instruction |
getNewInstruction(int opcode)
Return an initialised instruction for the given opcode |
int |
getNthRegAddress(int index)
Return the address of the Nth named register. |
java.lang.String |
getNthRegName(int index)
Return the name for the Nth named register. |
int |
getParameter(int paramId)
Return a given statistic for this machineState implementation. |
abstract int |
getParameter(int paramId,
int deviceId)
Return a given statistic for the given device for this machineState implementation. |
int |
getPC()
Get the current value for the Program Counter |
abstract java.lang.String |
getPinName(int pinNo,
int deviceId,
int packageType)
Return the name of the given pin for this device |
Port |
getPort(java.lang.String aPortName)
Return a Named port |
abstract int |
getPortPin(java.lang.String portName,
int bitNo)
Return the pin number that the given port bit is connected to |
int |
getReg(int regNumber)
Return the value of the given register or -1 if the register is not implemented. |
long |
getTicks(long time)
Return the number of clock ticks for the given time interval, assuming the current CPU clock rate.. |
int |
getW()
Read the W register. |
boolean |
isNamed(int address)
Return true if this register has a name, false otherwise. |
int |
namedRegisters()
Return the number of registers that have been named. |
char |
regChar(int regNumber)
Return the contents of the given register as a character. |
java.lang.String |
regName(int address)
Get the name of a processor register. |
java.lang.String |
regString(int regNumber)
Return the value of the register as a String. |
void |
removeClockListener(ChainedClockListener aListener)
Remove a chained clock listener from this machine.. |
void |
removePortListener(PortListener portListener)
Remove port listener - this asks all ports to remove the given port listener. |
void |
removeResetListener(ResetListener resetListener)
Remove a ResetListener from this device |
void |
resetMachine(int resetType)
Reset the machineState registers according to the given reset type |
abstract void |
resetRegs(Register[] regs,
int resetType)
Reset all registers to their power-on values |
void |
setAddresses(int[] addrArray,
int count)
Initialise the address label hashtable with default labels for the given set of 'important' addresses. |
void |
setAddressName(int addr,
java.lang.String label)
|
void |
setAliases(Aliases aliases)
Set the Aliases object that defines any aliases for this processor |
void |
setClockListener(ClockListener clockListener)
Set the clock listener for this machine. |
void |
setClockRate(long clockRate)
Set the clock rate, in hz for emulation. |
void |
setClocks(long clocks)
Set the current clock cycle count. |
void |
setInstructionSet(InstructionSet instructionSet)
Set the InstructionSet object that defines the instructions for this processor |
void |
setPC(int pc)
Set a new value for the Program Counter. |
void |
setReg(int regNumber,
int value)
Set the value of a given register. |
abstract void |
setRegisters(Register[] regs,
java.lang.String[] regNames,
java.util.Hashtable portHash)
Create and assign the registers that the device implements. |
void |
setRegName(int address,
java.lang.String name)
Set the name for a given register. |
void |
setW(int w)
Set a new value for the W register |
boolean |
validReg(int regNumber)
Check to see if this register is implemented |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public Register[] regs
public int[] stack
public int[] chipData
public int eepromStart
public int configStart
public int w
public int pc
public int stackPtr
public int regOffset
public long clocks
public long wdTimer
public boolean sleep
protected long clockRate
protected ClockListener clockListener
protected InstructionSet instructionSet
protected Aliases aliases
public static final int zeroBit
public static final int carryBit
public static final int decimalBit
public int trisBankOffset
protected int deviceId
public static final int RESET_POWER_UP
public static final int RESET_MCLR
public static final int RESET_WATCHDOG
public static final int RESET_AS_PROGRAMMED
public static final int PACKAGE_DIP
public static final int PACKAGE_SOIC
public static final int PACKAGE_PLCC
public static final int PACKAGE_QFP
public static final int CONFIG_WDTE
public static final int CONFIG_PWRTE
public static final int CONFIG_PWRTEI
public static final int CONFIG_CP
public static final int CONFIG_OSC4
public static final int CONFIG_DP
public static final int PARAM_DEVICES
public static final int PARAM_BANKS
public static final int PARAM_BANK_SIZE
public static final int PARAM_STACK_SIZE
public static final int PARAM_INSTR_WIDTH
public static final int PARAM_EEPROM_SIZE
public static final int PARAM_PROG_SIZE
public static final int PARAM_DATA_SIZE
public static final int PARAM_CONFIG_ADDR
public static final int PARAM_CONFIG_WORD
public static final int PARAM_ID_ADDR
public static final int PARAM_ID_SIZE
public static final int PARAM_ID_WIDTH
public static final int PARAM_CONFIG_START
public static final int PARAM_EEPROM_START
public static final int PARAM_PINS
public static final int PARAM_PACKAGES
public static final int PARAM_BIT_FOSC0
public static final int PARAM_BIT_FOSC1
public static final int PARAM_BIT_WDTE
public static final int PARAM_BIT_PWRTE
public static final int PARAM_BIT_PWRTEI
public static final int PARAM_BIT_CP0
public static final int PARAM_BIT_DP0
Constructor Detail |
public MachineState(java.lang.String deviceName, InstructionSet instructionSet, Aliases aliases) throws MiSimException
Method Detail |
public int getDeviceId()
public int getParameter(int paramId)
paramId
- The identifier for the required statisticpublic void setInstructionSet(InstructionSet instructionSet)
instructionSet
- The InstructionSet object for this processorpublic InstructionSet getInstructionSet()
public void setAliases(Aliases aliases)
aliases
- The Aliases object for this processorpublic Aliases getAliases()
public java.lang.String disassemble(Instruction instr)
public Instruction getNewInstruction(int opcode) throws MiSimException
opcode
- The opcode to encodeMiSimException
- If any errors occur during decodepublic abstract int getParameter(int paramId, int deviceId)
paramId
- The identifier for the required statisticdeviceId
- The ID for the device being examinedpublic abstract void setRegisters(Register[] regs, java.lang.String[] regNames, java.util.Hashtable portHash)
regs
- The memory space to populate with registersregNames
- An array of the names of each registerportHash
- A hashtable mapping the (String) port name to the (Port) object itselfpublic abstract void resetRegs(Register[] regs, int resetType)
regs
- The register array to resetresetType
- The type of resetpublic abstract java.lang.String getDeviceName(int deviceId)
deviceId
- The Index of the device name requiredpublic abstract java.lang.String getPinName(int pinNo, int deviceId, int packageType)
pinNo
- The pin number being requesteddeviceId
- Which specific device is being consideredpackageType
- The package type, eg. PACKAGE_DIPpublic abstract int getPortPin(java.lang.String portName, int bitNo)
portName
- The name of the required portbitNo
- The bt number for the portpublic abstract void enableGlobalInterrupts()
public void eraseEeprom()
public void setClockListener(ClockListener clockListener)
clockListener
- The clock listener for this machinepublic void addClockListener(ChainedClockListener newListener)
newListener
- The clock listener to add to the chain..public void removeClockListener(ChainedClockListener aListener)
aListener
- The event handler to remove to the chain..public void resetMachine(int resetType)
resetType
- The type of the rest that has occurredpublic void addResetListener(ResetListener resetListener)
resetListener
- The resetListener to addpublic void removeResetListener(ResetListener resetListener)
resetListener
- The resetListener to removepublic int getW()
public void setW(int w)
w
- The new value for Wpublic int getPC()
public void setPC(int pc) throws MiSimException
pc
- The new value for the program counterMiSimException
- never.public long getClocks()
public long getClockRate()
public void setClockRate(long clockRate)
clockRate
- The new clock rate, in hzpublic void setClocks(long clocks)
clocks
- The new value for the clock cycle countpublic long getTicks(long time)
time
- Time to convert, in uS (microseconds)public java.util.Hashtable getAvailablePorts()
public Port getPort(java.lang.String aPortName)
aPortName
- The name of the port to returnpublic java.util.Vector addPortListener(PortListener portListener, java.lang.String aPortName)
portListener
- The port listener to add.aPortName
- The name of the port we wish to listen topublic java.util.Vector addPortListener(PortListener portListener, java.util.Vector whichPorts)
portListener
- The port listener to add.whichPorts
- A Vector of the port names to add this listener topublic void removePortListener(PortListener portListener)
portListener
- The port listener to removepublic int getReg(int regNumber)
regNumber
- The number of the register to readpublic boolean validReg(int regNumber)
regNumber
- The number of the register to readpublic java.lang.String regString(int regNumber)
regNumber
- The number of the register to readpublic char regChar(int regNumber)
regNumber
- The number of the register to readpublic void setReg(int regNumber, int value)
regNumber
- The number of the register to setvalue
- The new value for the register.public java.lang.String regName(int address)
address
- The address of the registerpublic void setRegName(int address, java.lang.String name)
address
- The address of the registername
- The new name for the register, or null to unset.public boolean isNamed(int address)
address
- The address of the register to examine.public int namedRegisters()
public java.lang.String getNthRegName(int index)
index
- The index for the required named registernamedRegisters()
public int getNthRegAddress(int index)
index
- The index for the required named registernamedRegisters()
public void setAddresses(int[] addrArray, int count)
addrArray
- An array of important addressescount
- The number of addresses in the array that are validpublic java.lang.String addressName(int addr, int length, boolean emptyOk)
addr
- The address that we want the name forlength
- The length to pad the text toemptyOk
- If True, return an empty (padded) string for unset addresses.public void setAddressName(int addr, java.lang.String label)
|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |