avrora.sim
Class BaseInterpreter.StateImpl

java.lang.Object
  extended byavrora.sim.BaseInterpreter.StateImpl
All Implemented Interfaces:
State
Enclosing class:
BaseInterpreter

public class BaseInterpreter.StateImpl
extends java.lang.Object
implements State


Constructor Summary
BaseInterpreter.StateImpl()
           
 
Method Summary
 long getCycles()
          The getCycles() method returns the clock cycle count recorded so far in the simulation.
 byte getDataByte(int address)
          The getDataByte() method reads a byte value from the data memory (SRAM) at the specified address.
 boolean getFlag_C()
          The getFlag_C() method returns the current value of the C bit in the status register as a boolean.
 boolean getFlag_H()
          The getFlag_H() method returns the current value of the H bit in the status register as a boolean.
 boolean getFlag_I()
          The getFlag_I() method returns the current value of the I bit in the status register as a boolean.
 boolean getFlag_N()
          The getFlag_N() method returns the current value of the N bit in the status register as a boolean.
 boolean getFlag_S()
          The getFlag_S() method returns the current value of the S bit in the status register as a boolean.
 boolean getFlag_T()
          The getFlag_T() method returns the current value of the T bit in the status register as a boolean.
 boolean getFlag_V()
          The getFlag_V() method returns the current value of the V bit in the status register as a boolean.
 boolean getFlag_Z()
          The getFlag_Z() method returns the current value of the Z bit in the status register as a boolean.
 Instr getInstr(int address)
          The getInstr() can be used to retrieve a reference to the Instr object representing the instruction at the specified program address.
 InterruptTable getInterruptTable()
          The getInterruptTable() method gets a reference to the interrupt table, which contains information about each interrupt, such as whether it is enabled, posted, pending, etc.
 ActiveRegister getIOReg(int ioreg)
          The getIOReg() method is used to retrieve a reference to the actual IOReg instance stored internally in the state.
 byte getIORegisterByte(int ioreg)
          The getIORegisterByte() method reads the value of an IO register.
 int getPC()
          The getPC() retrieves the current program counter.
 byte getProgramByte(int address)
          The getProgramByte() method reads a byte value from the program (Flash) memory.
 byte getRegisterByte(Register reg)
          Read a general purpose register's current value as a byte.
 int getRegisterUnsigned(Register reg)
          Read a general purpose register's current value as an integer, without any sign extension.
 int getRegisterWord(Register reg)
          Read a general purpose register pair as an unsigned word.
 Simulator getSimulator()
          The getSimulator() method returns the simulator associated with this state instance.
 int getSleepMode()
          The getSleepMode() method returns an integer code describing which sleep mode the microcontroller is currently in.
 int getSP()
          The getSP() method reads the current value of the stack pointer.
 byte getSREG()
          The getSREG() method reads the value of the status register.
 byte getStackByte()
          The getStackByte() method reads a byte from the address specified by SP+1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseInterpreter.StateImpl

public BaseInterpreter.StateImpl()
Method Detail

getSimulator

public Simulator getSimulator()
The getSimulator() method returns the simulator associated with this state instance.

Specified by:
getSimulator in interface State
Returns:
a reference to the simulator associated with this state instance.

getInterruptTable

public InterruptTable getInterruptTable()
The getInterruptTable() method gets a reference to the interrupt table, which contains information about each interrupt, such as whether it is enabled, posted, pending, etc.

Specified by:
getInterruptTable in interface State
Returns:
a reference to the InterruptTable instance

getRegisterByte

public byte getRegisterByte(Register reg)
Read a general purpose register's current value as a byte.

Specified by:
getRegisterByte in interface State
Parameters:
reg - the register to read
Returns:
the current value of the register

getRegisterUnsigned

public int getRegisterUnsigned(Register reg)
Read a general purpose register's current value as an integer, without any sign extension.

Specified by:
getRegisterUnsigned in interface State
Parameters:
reg - the register to read
Returns:
the current unsigned value of the register

getRegisterWord

public int getRegisterWord(Register reg)
Read a general purpose register pair as an unsigned word. This method will read the value of the specified register and the value of the next register in numerical order and return the two values combined as an unsigned integer The specified register should be less than r31, because r32 (the next register) does not exist.

Specified by:
getRegisterWord in interface State
Parameters:
reg - the low register of the pair to read
Returns:
the current unsigned word value of the register pair

getSREG

public byte getSREG()
The getSREG() method reads the value of the status register. The status register contains the I, T, H, S, V, N, Z, and C flags, in order from highest-order to lowest-order.

Specified by:
getSREG in interface State
Returns:
the value of the status register as a byte.

getFlag_I

public boolean getFlag_I()
The getFlag_I() method returns the current value of the I bit in the status register as a boolean.

Specified by:
getFlag_I in interface State
Returns:
the value of the flag

getFlag_T

public boolean getFlag_T()
The getFlag_T() method returns the current value of the T bit in the status register as a boolean.

Specified by:
getFlag_T in interface State
Returns:
the value of the flag

getFlag_H

public boolean getFlag_H()
The getFlag_H() method returns the current value of the H bit in the status register as a boolean.

Specified by:
getFlag_H in interface State
Returns:
the value of the flag

getFlag_S

public boolean getFlag_S()
The getFlag_S() method returns the current value of the S bit in the status register as a boolean.

Specified by:
getFlag_S in interface State
Returns:
the value of the flag

getFlag_V

public boolean getFlag_V()
The getFlag_V() method returns the current value of the V bit in the status register as a boolean.

Specified by:
getFlag_V in interface State
Returns:
the value of the flag

getFlag_N

public boolean getFlag_N()
The getFlag_N() method returns the current value of the N bit in the status register as a boolean.

Specified by:
getFlag_N in interface State
Returns:
the value of the flag

getFlag_Z

public boolean getFlag_Z()
The getFlag_Z() method returns the current value of the Z bit in the status register as a boolean.

Specified by:
getFlag_Z in interface State
Returns:
the value of the flag

getFlag_C

public boolean getFlag_C()
The getFlag_C() method returns the current value of the C bit in the status register as a boolean.

Specified by:
getFlag_C in interface State
Returns:
the value of the flag

getStackByte

public byte getStackByte()
The getStackByte() method reads a byte from the address specified by SP+1. This method should not be called with an empty stack, as it will cause an exception consistent with trying to read non-existent memory.

Specified by:
getStackByte in interface State
Returns:
the value on the top of the stack

getSP

public int getSP()
The getSP() method reads the current value of the stack pointer. Since the stack pointer is stored in two IO registers, this method will cause the invocation of the .read() method on each of the IOReg objects that store these values.

Specified by:
getSP in interface State
Returns:
the value of the stack pointer as a byte address

getPC

public int getPC()
The getPC() retrieves the current program counter.

Specified by:
getPC in interface State
Returns:
the program counter as a byte address

getInstr

public Instr getInstr(int address)
The getInstr() can be used to retrieve a reference to the Instr object representing the instruction at the specified program address. Care should be taken that the address in program memory specified does not contain data. This is because Avrora does have a functioning disassembler and assumes that the Instr objects for each instruction in the program are known a priori.

Specified by:
getInstr in interface State
Parameters:
address - the byte address from which to read the instruction
Returns:
a reference to the Instr object representing the instruction at that address in the program

getDataByte

public byte getDataByte(int address)
The getDataByte() method reads a byte value from the data memory (SRAM) at the specified address.

Specified by:
getDataByte in interface State
Parameters:
address - the byte address to read
Returns:
the value of the data memory at the specified address
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the specified address is not the valid memory range

getProgramByte

public byte getProgramByte(int address)
The getProgramByte() method reads a byte value from the program (Flash) memory. The flash memory generally stores read-only values and the instructions of the program. Care should be taken that the program memory at the specified address does not contain an instruction. This is because, in general, programs should not read instructions as data, and secondly, because no assembler is present in Avrora and therefore the actual byte value of an instruction may not be known.

Specified by:
getProgramByte in interface State
Parameters:
address - the byte address at which to read
Returns:
the byte value of the program memory at the specified address
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the specified address is not the valid program memory range

getIORegisterByte

public byte getIORegisterByte(int ioreg)
The getIORegisterByte() method reads the value of an IO register. Invocation of this method causes an invocatiobn of the .read() method on the corresponding internal IOReg object, and its value returned.

Specified by:
getIORegisterByte in interface State
Parameters:
ioreg - the IO register number
Returns:
the value of the IO register

getIOReg

public ActiveRegister getIOReg(int ioreg)
The getIOReg() method is used to retrieve a reference to the actual IOReg instance stored internally in the state. This is generally only used in the simulator and device implementations, and clients should probably not call this memory directly.

Specified by:
getIOReg in interface State
Parameters:
ioreg - the IO register number to retrieve
Returns:
a reference to the ActiveRegister instance of the specified IO register

getCycles

public long getCycles()
The getCycles() method returns the clock cycle count recorded so far in the simulation.

Specified by:
getCycles in interface State
Returns:
the number of clock cycles elapsed in the simulation

getSleepMode

public int getSleepMode()
The getSleepMode() method returns an integer code describing which sleep mode the microcontroller is currently in.

Specified by:
getSleepMode in interface State
Returns:
an integer code representing the current sleep mode