avrora.sim
Class GenInterpreter

java.lang.Object
  extended byavrora.sim.BaseInterpreter
      extended byavrora.sim.GenInterpreter
All Implemented Interfaces:
InstrVisitor
Direct Known Subclasses:
DBBCInterpreter

public class GenInterpreter
extends BaseInterpreter
implements InstrVisitor

The GenInterpreter class is largely generated from the instruction specification. The framework around the generated code (utilities) has been written by hand, but most of the code for each instruction is generated. Therefore it is not recommended to edit this code extensively.


Nested Class Summary
static class GenInterpreter.Factory
          The Factory() class implements an interpreter factory that can create a new interpreter for a new simulator instance with the given program.
 
Nested classes inherited from class avrora.sim.BaseInterpreter
BaseInterpreter.ErrorReporter, BaseInterpreter.StateImpl
 
Field Summary
static Register R0
           
static Register R1
           
static Register R10
           
static Register R11
           
static Register R12
           
static Register R13
           
static Register R14
           
static Register R15
           
static Register R16
           
static Register R17
           
static Register R18
           
static Register R19
           
static Register R2
           
static Register R20
           
static Register R21
           
static Register R22
           
static Register R23
           
static Register R24
           
static Register R25
           
static Register R26
           
static Register R27
           
static Register R28
           
static Register R29
           
static Register R3
           
static Register R30
           
static Register R31
           
static Register R4
           
static Register R5
           
static Register R6
           
static Register R7
           
static Register R8
           
static Register R9
           
static Register RX
           
static Register RY
           
static Register RZ
           
 
Fields inherited from class avrora.sim.BaseInterpreter
bootPC, C, clock, cyclesConsumed, delayCycles, exceptionWatch, flash, globalProbe, H, I, innerLoop, interruptBase, interrupts, ioregs, justReturnedFromInterrupt, N, nextPC, NUM_REGS, pc, RAMPZ, registers, S, shared_instr, shouldRun, simulator, sleeping, SPH_reg, SPL_reg, sram, sram_max, sram_start, sram_watches, SREG, SREG_C, SREG_H, SREG_I, SREG_N, SREG_reg, SREG_S, SREG_T, SREG_V, SREG_Z, state, T, V, Z
 
Constructor Summary
protected GenInterpreter(Simulator s, Program p, MicrocontrollerProperties pr)
          The constructor for the Interpreter class builds the internal data structures needed to store the complete state of the machine, including registers, IO registers, the SRAM, and the flash.
 
Method Summary
static byte bit(boolean val)
           
 void enterSleepMode()
          send the node to sleep
 int extended(int addr)
           
static byte high(int val)
           
 void leaveSleepMode()
          time to wake up
static byte low(int val)
           
 int popPC()
           
 void pushPC(int npc)
           
protected  void runLoop()
           
 int step()
          The step() method steps this node forward one instruction or one clock cycle.
static int uword(byte low, byte high)
           
 void visit(Instr.ADC i)
           
 void visit(Instr.ADD i)
           
 void visit(Instr.ADIW i)
           
 void visit(Instr.AND i)
           
 void visit(Instr.ANDI i)
           
 void visit(Instr.ASR i)
           
 void visit(Instr.BCLR i)
           
 void visit(Instr.BLD i)
           
 void visit(Instr.BRBC i)
           
 void visit(Instr.BRBS i)
           
 void visit(Instr.BRCC i)
           
 void visit(Instr.BRCS i)
           
 void visit(Instr.BREAK i)
           
 void visit(Instr.BREQ i)
           
 void visit(Instr.BRGE i)
           
 void visit(Instr.BRHC i)
           
 void visit(Instr.BRHS i)
           
 void visit(Instr.BRID i)
           
 void visit(Instr.BRIE i)
           
 void visit(Instr.BRLO i)
           
 void visit(Instr.BRLT i)
           
 void visit(Instr.BRMI i)
           
 void visit(Instr.BRNE i)
           
 void visit(Instr.BRPL i)
           
 void visit(Instr.BRSH i)
           
 void visit(Instr.BRTC i)
           
 void visit(Instr.BRTS i)
           
 void visit(Instr.BRVC i)
           
 void visit(Instr.BRVS i)
           
 void visit(Instr.BSET i)
           
 void visit(Instr.BST i)
           
 void visit(Instr.CALL i)
           
 void visit(Instr.CBI i)
           
 void visit(Instr.CBR i)
           
 void visit(Instr.CLC i)
           
 void visit(Instr.CLH i)
           
 void visit(Instr.CLI i)
           
 void visit(Instr.CLN i)
           
 void visit(Instr.CLR i)
           
 void visit(Instr.CLS i)
           
 void visit(Instr.CLT i)
           
 void visit(Instr.CLV i)
           
 void visit(Instr.CLZ i)
           
 void visit(Instr.COM i)
           
 void visit(Instr.CP i)
           
 void visit(Instr.CPC i)
           
 void visit(Instr.CPI i)
           
 void visit(Instr.CPSE i)
           
 void visit(Instr.DEC i)
           
 void visit(Instr.EICALL i)
           
 void visit(Instr.EIJMP i)
           
 void visit(Instr.ELPM i)
           
 void visit(Instr.ELPMD i)
           
 void visit(Instr.ELPMPI i)
           
 void visit(Instr.EOR i)
           
 void visit(Instr.FMUL i)
           
 void visit(Instr.FMULS i)
           
 void visit(Instr.FMULSU i)
           
 void visit(Instr.ICALL i)
           
 void visit(Instr.IJMP i)
           
 void visit(Instr.IN i)
           
 void visit(Instr.INC i)
           
 void visit(Instr.JMP i)
           
 void visit(Instr.LD i)
           
 void visit(Instr.LDD i)
           
 void visit(Instr.LDI i)
           
 void visit(Instr.LDPD i)
           
 void visit(Instr.LDPI i)
           
 void visit(Instr.LDS i)
           
 void visit(Instr.LPM i)
           
 void visit(Instr.LPMD i)
           
 void visit(Instr.LPMPI i)
           
 void visit(Instr.LSL i)
           
 void visit(Instr.LSR i)
           
 void visit(Instr.MOV i)
           
 void visit(Instr.MOVW i)
           
 void visit(Instr.MUL i)
           
 void visit(Instr.MULS i)
           
 void visit(Instr.MULSU i)
           
 void visit(Instr.NEG i)
           
 void visit(Instr.NOP i)
           
 void visit(Instr.OR i)
           
 void visit(Instr.ORI i)
           
 void visit(Instr.OUT i)
           
 void visit(Instr.POP i)
           
 void visit(Instr.PUSH i)
           
 void visit(Instr.RCALL i)
           
 void visit(Instr.RET i)
           
 void visit(Instr.RETI i)
           
 void visit(Instr.RJMP i)
           
 void visit(Instr.ROL i)
           
 void visit(Instr.ROR i)
           
 void visit(Instr.SBC i)
           
 void visit(Instr.SBCI i)
           
 void visit(Instr.SBI i)
           
 void visit(Instr.SBIC i)
           
 void visit(Instr.SBIS i)
           
 void visit(Instr.SBIW i)
           
 void visit(Instr.SBR i)
           
 void visit(Instr.SBRC i)
           
 void visit(Instr.SBRS i)
           
 void visit(Instr.SEC i)
           
 void visit(Instr.SEH i)
           
 void visit(Instr.SEI i)
           
 void visit(Instr.SEN i)
           
 void visit(Instr.SER i)
           
 void visit(Instr.SES i)
           
 void visit(Instr.SET i)
           
 void visit(Instr.SEV i)
           
 void visit(Instr.SEZ i)
           
 void visit(Instr.SLEEP i)
           
 void visit(Instr.SPM i)
           
 void visit(Instr.ST i)
           
 void visit(Instr.STD i)
           
 void visit(Instr.STPD i)
           
 void visit(Instr.STPI i)
           
 void visit(Instr.STS i)
           
 void visit(Instr.SUB i)
           
 void visit(Instr.SUBI i)
           
 void visit(Instr.SWAP i)
           
 void visit(Instr.TST i)
           
 void visit(Instr.WDR i)
           
 
Methods inherited from class avrora.sim.BaseInterpreter
advanceClock, commit, delay, disableInterrupts, enableInterrupts, getDataByte, getInstr, getInstrSize, getInterruptBase, getInterruptTable, getInterruptVectorAddress, getIOReg, getIORegisterByte, getMainClock, getPC, getProgramByte, getRegisterByte, getRegisterByte, getRegisterUnsigned, getRegisterUnsigned, getRegisterWord, getRegisterWord, getSimulator, getSP, getSREG, insertExceptionWatch, insertIORWatch, insertProbe, insertProbe, insertWatch, installIOReg, popByte, pushByte, removeIORWatch, removeProbe, removeProbe, removeWatch, setBootPC, setEnabled, setInterruptBase, setPosted, setSP, start, stop, storeProgramMemory, writeDataByte, writeFlashByte, writeIORegisterByte, writeRegisterByte, writeRegisterByte, writeRegisterWord, writeRegisterWord, writeSREG
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

R0

public static final Register R0

R1

public static final Register R1

R2

public static final Register R2

R3

public static final Register R3

R4

public static final Register R4

R5

public static final Register R5

R6

public static final Register R6

R7

public static final Register R7

R8

public static final Register R8

R9

public static final Register R9

R10

public static final Register R10

R11

public static final Register R11

R12

public static final Register R12

R13

public static final Register R13

R14

public static final Register R14

R15

public static final Register R15

R16

public static final Register R16

R17

public static final Register R17

R18

public static final Register R18

R19

public static final Register R19

R20

public static final Register R20

R21

public static final Register R21

R22

public static final Register R22

R23

public static final Register R23

R24

public static final Register R24

R25

public static final Register R25

R26

public static final Register R26

R27

public static final Register R27

R28

public static final Register R28

R29

public static final Register R29

R30

public static final Register R30

R31

public static final Register R31

RX

public static final Register RX

RY

public static final Register RY

RZ

public static final Register RZ
Constructor Detail

GenInterpreter

protected GenInterpreter(Simulator s,
                         Program p,
                         MicrocontrollerProperties pr)
The constructor for the Interpreter class builds the internal data structures needed to store the complete state of the machine, including registers, IO registers, the SRAM, and the flash. All IO registers are initialized to be instances of RWIOReg. Reserved and special IO registers must be inserted by the getIOReg() and writeIOReg() methods.

Parameters:
s - The simulator attached to this interpreter
p - the program to construct the state for
pr - the properties of the microcontroller being simulated
Method Detail

runLoop

protected void runLoop()
Specified by:
runLoop in class BaseInterpreter

step

public int step()
Description copied from class: BaseInterpreter
The step() method steps this node forward one instruction or one clock cycle. The node may execute an instruction, execute events, wake from sleep, take an interrupt, etc. In the case of multi-cycle instructions, the node will execute until the end of the instruction. The number of cycles consumed is returned by this method.

Specified by:
step in class BaseInterpreter
Returns:
the number of cycles consumed in executing one instruction or waking from an interrupt, etc

visit

public void visit(Instr.ADC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ADD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ADIW i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.AND i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ANDI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ASR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BCLR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BLD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRBC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRBS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRCC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRCS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BREAK i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BREQ i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRGE i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRHC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRHS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRID i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRIE i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRLO i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRLT i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRMI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRNE i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRPL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRSH i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRTC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRTS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRVC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BRVS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BSET i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.BST i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CALL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CBI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CBR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLH i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLN i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLT i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLV i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CLZ i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.COM i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CPC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CPI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.CPSE i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.DEC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.EICALL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.EIJMP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ELPM i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ELPMD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ELPMPI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.EOR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.FMUL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.FMULS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.FMULSU i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ICALL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.IJMP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.IN i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.INC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.JMP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LDD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LDI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LDPD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LDPI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LDS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LPM i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LPMD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LPMPI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LSL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.LSR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.MOV i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.MOVW i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.MUL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.MULS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.MULSU i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.NEG i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.NOP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.OR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ORI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.OUT i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.POP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.PUSH i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.RCALL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.RET i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.RETI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.RJMP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ROL i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ROR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBCI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBIC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBIS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBIW i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBR i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBRC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SBRS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SEC i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SEH i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SEI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SEN i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SER i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SES i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SET i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SEV i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SEZ i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SLEEP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SPM i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.ST i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.STD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.STPD i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.STPI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.STS i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SUB i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SUBI i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.SWAP i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.TST i)
Specified by:
visit in interface InstrVisitor

visit

public void visit(Instr.WDR i)
Specified by:
visit in interface InstrVisitor

pushPC

public void pushPC(int npc)

popPC

public int popPC()

low

public static byte low(int val)

high

public static byte high(int val)

bit

public static byte bit(boolean val)

uword

public static int uword(byte low,
                        byte high)

extended

public int extended(int addr)

enterSleepMode

public void enterSleepMode()
send the node to sleep


leaveSleepMode

public void leaveSleepMode()
time to wake up