hades.models.pic
Class TurboPicCore

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.pic.TurboPicCore
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable
Direct Known Subclasses:
TurboPic16C84

public class TurboPicCore
extends SimObject

See Also:
Serialized Form

Nested Class Summary
(package private)  class TurboPicCore.ADDLW
          ADDLW: add a literal to W, 0 < L <= 255; update C, DC, Z flags 1 clock period
(package private)  class TurboPicCore.ADDWF
          ADDWF F,D add W and register F (0 < F <= 127), store into W (D=0) or F (D=1) update C, DC, Z flags 1 clock period
(package private)  class TurboPicCore.ANDLW
          ANDLW: logical AND a literal to W, 0 < L <= 255 update Z flag 1 clock period
(package private)  class TurboPicCore.ANDWF
          ANDWF F,D logical AND W and register F (0 < F <= 127), store into W (D=0) or F (D=1) update Z flag 1 clock period
(package private)  class TurboPicCore.BCF
          BCF F,B clear bit B in register 0 < F <= 127 no flags are changed 1 clock period
(package private)  class TurboPicCore.BreakPoint
           
(package private)  class TurboPicCore.BSF
          BSF F,B clear bit B in register 0 < F <= 127 no flags are changed 1 clock period
(package private)  class TurboPicCore.BTFSC
          BTFSC F,B test bit B in register 0 < F <= 127, skip next instruction if clear no flags are changed 1 clock period
(package private)  class TurboPicCore.BTFSS
          BTFSS F,B test bit B in register 0 < F <= 127, skip next instruction if clear no flags are changed 1 clock period
(package private)  class TurboPicCore.CALL
          CALL addr call subroutine at "addr", update stack, PCLATH is not changed no flags are changed 2 clock period
(package private)  class TurboPicCore.CLRF
          CLRF F clear the register specified by 0 < F <= 127 set the Z (zero) flag 1 clock period
(package private)  class TurboPicCore.CLRW
          CLRW clear the W register (accumulator), set Z flag one clock period
(package private)  class TurboPicCore.CLRWDT
          CLRWDT clear the WDT register (watch dog timer) set nTO, nPD flags one clock period
(package private)  class TurboPicCore.COMF
          COMF F, D the contents of register 0 < F <= 127 are complemented, and the result is stored into W (D=0) or back into F (D=1) updates Z flag one clock period
(package private)  class TurboPicCore.DECF
          DECF F, D the contents of register 0 < F <= 127 are decremented, and the result is stored into W (D=0) or back into F (D=1) updates Z flag one clock period
(package private)  class TurboPicCore.DECFSZ
          DECFSZ F, D the contents of register 0 < F <= 127 are decremented, and the result is stored into W (D=0) or back into F (D=1).
(package private)  class TurboPicCore.DECFSZ_NF
           
(package private)  class TurboPicCore.GOTO
          GOTO goto instruction, final destination given by 11 bit argument and two bits from PCLATH register, no status bits are affected 2 clock periods
(package private)  class TurboPicCore.INCF
          INCF F, D the contents of register 0 < F <= 127 are incremented, and the result is stored into W (D=0) or back into F (D=1) updates Z flag one clock period
(package private)  class TurboPicCore.INCFSZ
          INCFSZ F, D the contents of register 0 < F <= 127 are decremented, and the result is stored into W (D=0) or back into F (D=1).
(package private)  class TurboPicCore.IORLW
          IORLW: logical OR a literal to W, 0 < L <= 255 update Z flag 1 clock period
(package private)  class TurboPicCore.IORWF
          IORWF F,D logical OR W and register F (0 < F <= 127), store into W (D=0) or F (D=1) update Z flag 1 clock period
(package private)  class TurboPicCore.MOVF
          MOVF F, D move the contents of register 0 < F <= 127 to the W register for (D=0) and to F itself for (D=1).
(package private)  class TurboPicCore.MOVLW
          MOVLW l move a literal to W, 0 < l <= 255 no flags are affected 1 clock period
(package private)  class TurboPicCore.MOVWF
          MOVWF F move the contents of W to register 0 < F <= 127.
(package private)  class TurboPicCore.NOP
          NOP don't change the processor state one clock period
(package private)  class TurboPicCore.OPTION
          OPTION load OPTION register with contents of W.
(package private)  class TurboPicCore.PicInstruction
          common base class for the PIC instructions
(package private)  class TurboPicCore.PicMemoryEepromAdapter
           
(package private)  class TurboPicCore.PicMemoryEpromAdapter
           
(package private)  class TurboPicCore.PicMemoryRegbankAdapter
           
(package private)  class TurboPicCore.PicMemoryStackAdapter
           
(package private)  class TurboPicCore.PicRegAdapter
           
(package private)  class TurboPicCore.PicRegINTCONAdapter
           
(package private)  class TurboPicCore.PicRegPCAdapter
           
(package private)  class TurboPicCore.PicRegSTATUSAdapter
           
(package private)  class TurboPicCore.PicRegWAdapter
           
(package private)  class TurboPicCore.RETFIE
          RETFIE return from interrupt (the PC value is taken from the stack).
(package private)  class TurboPicCore.RETLW
          RETLW l return from a subroutine, and put literal l into W no flags are affected 2 clock periods
(package private)  class TurboPicCore.RETURN
          RETURN l return from a subroutine no flags are affected 2 clock periods
(package private)  class TurboPicCore.RLF
          RLF F, D the contents of register 0 < F <= 127 are rotated one bit left through the carry flag.
(package private)  class TurboPicCore.RRF
          RRF F, D the contents of register 0 < F <= 127 are rotated one bit right through the carry flag.
(package private)  class TurboPicCore.SLEEP
          SLEEP don't change the processor state one clock period
(package private)  class TurboPicCore.SUBLW
          SUBLW l the W register value is subtracted from 8-bit literal l, and the result is placed in W.
(package private)  class TurboPicCore.SUBWF
          SUBWF F,D subtract the W value from register 0 < F <= 127, and store into W (D=0) or F (D=1) update C, DC, Z flags 1 clock period
(package private)  class TurboPicCore.SWAPF
          SWAPF F,D the upper and lower nibbles of register f are exchanged, and the result is stored into W (D=0) or F (D=1) no flags are affected 1 clock period
(package private)  class TurboPicCore.TRIS
          TRIS f load TRIS register 5 <= f <= 7with contents of W.
(package private)  class TurboPicCore.XORLW
          XORLW: logical XOR a literal to W, 0 < L <= 255 update Z flag 1 clock period
(package private)  class TurboPicCore.XORWF
          XORWF F,D logical XOR W and register F (0 < F <= 127), store into W (D=0) or F (D=1) update Z flag 1 clock period
 
Field Summary
static int _C
           
(package private)  long _cycle
           
static int _DC
           
(package private)  int _EEADR
           
(package private)  int _EECON1
           
(package private)  int _EECON2
           
(package private)  int _EEDATA
           
static int _EEIE
           
(package private)  int _FSR
           
static int _GIE
           
(package private)  int _INDF
           
(package private)  int _INTCON
           
static int _INTE
           
static int _INTF
           
static int _IRP
           
static int _nPD
           
static int _nTO
           
(package private)  int _OPTION
           
(package private)  int _PC
           
(package private)  int _PCL
           
(package private)  int _PCLATH
           
(package private)  double _period
           
(package private)  int _PORTA_LATCH
           
(package private)  int _PORTB_LATCH
           
static int _RA0
           
static int _RA1
           
static int _RA2
           
static int _RA3
           
static int _RA4
           
static int _RBIE
           
static int _RBIF
           
static int _RP0
           
static int _RP1
           
(package private)  int _SP
           
(package private)  int _STATUS
           
static int _T0IE
           
static int _T0IF
           
(package private)  int _TMR0
           
(package private)  int _TRISA
           
(package private)  int _TRISB
           
(package private)  int _W
           
(package private)  int _WDT
           
(package private)  int _WDT_PRESCALER
           
static int _Z
           
static java.lang.String[][] bank0BitNames
           
static java.lang.String[] bank0Names
           
static java.lang.String[][] bank1BitNames
           
static java.lang.String[] bank1Names
           
(package private)  int[] eeprom
           
static int EEPROM_SIZE
           
(package private)  boolean enableDebugSignals
           
(package private)  boolean enableGUI
           
(package private)  boolean enableIRQs
           
(package private)  boolean enableWDT
           
static int EPROM_SIZE
           
(package private)  boolean isResetOrSleep
           
(package private)  java.util.Hashtable labelTable
           
static int MAX_RAM
           
(package private)  long n_errors
           
(package private)  boolean needCheckIRQs
           
(package private)  TurboPicCore.PicInstruction[] program
           
(package private)  int[] register
           
(package private)  int[] stack
           
static int STACK_DEPTH
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
TurboPicCore()
           
 
Method Summary
 java.lang.String __fill(java.lang.String s, int n_chars)
           
 java.lang.String __formatBit(int register, int bit)
           
 java.lang.String __formatFD(int f, int d)
           
 java.lang.String __formatLabel(int address, int n_chars)
           
 java.lang.String __formatLiteral(int literal)
           
 java.lang.String __formatReg(int register)
           
 java.lang.String __hex(int value, int n_chars)
           
 java.lang.String __xhex(int value, int n_chars)
           
 java.lang.String _d(int i)
          format a register value
 java.lang.String _h(int i)
           
 void checkIRQs()
           
 void clearLabels()
           
 void createAndInitializeMemoryArrays()
           
 TurboPicCore.PicInstruction createDECFSZ(int _f, int _d)
           
 TurboPicCore.PicInstruction decode(int opcode)
          return the PicInstruction subclass corresponding to the given opcode
 void dump()
          dump PIC state
 void dumpProgram(java.io.OutputStream OS)
           
 void error(java.lang.String s)
          raise a Runtime exception (Error), due to some internal error
 boolean isCodeBreakPoint(int addr)
           
 boolean isNormalRegister(int addr)
           
 boolean isSpecialRegister(int addr)
           
 void loadProgram(java.lang.String resourcename)
           
 void loadProgramFormatHEX(java.io.InputStream IS)
          load a program from a file in Microchip/Intel HEX16format, as produced by the MPASM assembler and toolkit.
 void loadProgramFormatROM(java.io.InputStream IS)
          load a program from a file in ROM format, which contains (addr_hex opcode_hex) and (#label addr_hex label_name) lines.
static void main(java.lang.String[] argv)
          main: simple selftest and performance test for the TurboPicCore
 int readPortA()
          read operation on PORT A.
 int readPortB()
          read operation on PORT B.
 int readReg(int _addr7)
          read the PIC file register selected by 7-bit parameter _addr7.
 int readRegRaw(int _addr9)
          read a register specified by its full PIC16XX family (9-bit) file address.
 void reset()
          reset the PIC processor
 void setCodeBreakPoint(int addr)
           
 void setEnableIRQs(boolean b)
           
 void setEnableWDT(boolean b)
           
 void singleStep()
          execute one PIC instruction
 void steps(int N)
          execute N PIC instructions
(package private)  void tinySelftest()
           
 void writePCL(int value)
          write PCL pseudo register: this writes the lower 8 bits of the _PC program counter register, while the upper 5 bits are taken from _PCH.
 void writePortA(int value)
          write operation to PORT A.
 void writePortB(int value)
          write operation to PORT B.
 void writeReg(int _addr7, int value)
           
 void writeTrisA(int value)
          write operation on the TRIS A register.
 void writeTrisB(int value)
          write operation on the TRIS B register.
 
Methods inherited from class hades.simulator.SimObject
configure, constructDynamicSymbol, copy, elaborate, evaluate, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getPropertySheet, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getToolTip, getVersionId, initialize, isVisible, keyPressed, message, mousePressed, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setSymbol, setVersionId, setVisible, tearDown, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_period

double _period

_cycle

long _cycle

n_errors

long n_errors

enableWDT

boolean enableWDT

enableIRQs

boolean enableIRQs

isResetOrSleep

boolean isResetOrSleep

enableGUI

boolean enableGUI

enableDebugSignals

boolean enableDebugSignals

needCheckIRQs

boolean needCheckIRQs

register

int[] register

stack

int[] stack

eeprom

int[] eeprom

program

TurboPicCore.PicInstruction[] program

labelTable

java.util.Hashtable labelTable

_PC

int _PC

_W

int _W

_SP

int _SP

_WDT

int _WDT

_WDT_PRESCALER

int _WDT_PRESCALER

_INDF

int _INDF

_TMR0

int _TMR0

_PCL

int _PCL

_STATUS

int _STATUS

_FSR

int _FSR

_PORTA_LATCH

int _PORTA_LATCH

_PORTB_LATCH

int _PORTB_LATCH

_EEDATA

int _EEDATA

_EEADR

int _EEADR

_PCLATH

int _PCLATH

_INTCON

int _INTCON

_OPTION

int _OPTION

_TRISA

int _TRISA

_TRISB

int _TRISB

_EECON1

int _EECON1

_EECON2

int _EECON2

bank0Names

public static final java.lang.String[] bank0Names

bank1Names

public static final java.lang.String[] bank1Names

bank0BitNames

public static final java.lang.String[][] bank0BitNames

bank1BitNames

public static final java.lang.String[][] bank1BitNames

MAX_RAM

public static final int MAX_RAM
See Also:
Constant Field Values

EEPROM_SIZE

public static final int EEPROM_SIZE
See Also:
Constant Field Values

EPROM_SIZE

public static final int EPROM_SIZE
See Also:
Constant Field Values

STACK_DEPTH

public static final int STACK_DEPTH
See Also:
Constant Field Values

_C

public static final int _C
See Also:
Constant Field Values

_DC

public static final int _DC
See Also:
Constant Field Values

_Z

public static final int _Z
See Also:
Constant Field Values

_nPD

public static final int _nPD
See Also:
Constant Field Values

_nTO

public static final int _nTO
See Also:
Constant Field Values

_RP0

public static final int _RP0
See Also:
Constant Field Values

_RP1

public static final int _RP1
See Also:
Constant Field Values

_IRP

public static final int _IRP
See Also:
Constant Field Values

_RBIF

public static final int _RBIF
See Also:
Constant Field Values

_INTF

public static final int _INTF
See Also:
Constant Field Values

_T0IF

public static final int _T0IF
See Also:
Constant Field Values

_RBIE

public static final int _RBIE
See Also:
Constant Field Values

_INTE

public static final int _INTE
See Also:
Constant Field Values

_T0IE

public static final int _T0IE
See Also:
Constant Field Values

_EEIE

public static final int _EEIE
See Also:
Constant Field Values

_GIE

public static final int _GIE
See Also:
Constant Field Values

_RA0

public static final int _RA0
See Also:
Constant Field Values

_RA1

public static final int _RA1
See Also:
Constant Field Values

_RA2

public static final int _RA2
See Also:
Constant Field Values

_RA3

public static final int _RA3
See Also:
Constant Field Values

_RA4

public static final int _RA4
See Also:
Constant Field Values
Constructor Detail

TurboPicCore

public TurboPicCore()
Method Detail

createAndInitializeMemoryArrays

public void createAndInitializeMemoryArrays()

clearLabels

public void clearLabels()

setEnableWDT

public void setEnableWDT(boolean b)

setEnableIRQs

public void setEnableIRQs(boolean b)

isSpecialRegister

public boolean isSpecialRegister(int addr)

isNormalRegister

public boolean isNormalRegister(int addr)

setCodeBreakPoint

public void setCodeBreakPoint(int addr)

isCodeBreakPoint

public boolean isCodeBreakPoint(int addr)

readReg

public int readReg(int _addr7)
read the PIC file register selected by 7-bit parameter _addr7. This function uses the page bits (STATUS.RP1 and STATUS.RP0) to select the full 9-bit memory file address, and should behave like the PIC. For example, reading INDF will use indirect addressing, reading INDF(0) will return 0, and reading unimplemented addresses will return 0.


readRegRaw

public int readRegRaw(int _addr9)
read a register specified by its full PIC16XX family (9-bit) file address. This method is used for the GUI and debuggers, which may want to read *all* file addresses directly without using the STATUS register page mode bits. For example, calling readRegRaw( 0x86 ) will return the value of the TRISB register without consulting the page mode bits.

Reading INDF will still use the PIC indirect addressing method via FSR.


readPortA

public int readPortA()
read operation on PORT A.


readPortB

public int readPortB()
read operation on PORT B.


writePortA

public void writePortA(int value)
write operation to PORT A. This dummy implementation just writes to _PORTA_LATCH, without further I/O activity.


writePortB

public void writePortB(int value)
write operation to PORT B. This dummy implementation just writes to _PORTB_LATCH, without further I/O activity.


writeTrisA

public void writeTrisA(int value)
write operation on the TRIS A register. This writes the value to the _TRISA variable.


writeTrisB

public void writeTrisB(int value)
write operation on the TRIS B register.


writePCL

public void writePCL(int value)
write PCL pseudo register: this writes the lower 8 bits of the _PC program counter register, while the upper 5 bits are taken from _PCH.


writeReg

public void writeReg(int _addr7,
                     int value)

checkIRQs

public void checkIRQs()

error

public void error(java.lang.String s)
raise a Runtime exception (Error), due to some internal error


createDECFSZ

public TurboPicCore.PicInstruction createDECFSZ(int _f,
                                                int _d)

loadProgramFormatROM

public void loadProgramFormatROM(java.io.InputStream IS)
load a program from a file in ROM format, which contains (addr_hex opcode_hex) and (#label addr_hex label_name) lines.


loadProgramFormatHEX

public void loadProgramFormatHEX(java.io.InputStream IS)
load a program from a file in Microchip/Intel HEX16format, as produced by the MPASM assembler and toolkit.


loadProgram

public void loadProgram(java.lang.String resourcename)

dumpProgram

public void dumpProgram(java.io.OutputStream OS)

decode

public TurboPicCore.PicInstruction decode(int opcode)
return the PicInstruction subclass corresponding to the given opcode


_d

public java.lang.String _d(int i)
format a register value


_h

public java.lang.String _h(int i)

__formatReg

public java.lang.String __formatReg(int register)

__formatFD

public java.lang.String __formatFD(int f,
                                   int d)

__hex

public java.lang.String __hex(int value,
                              int n_chars)

__xhex

public java.lang.String __xhex(int value,
                               int n_chars)

__formatBit

public java.lang.String __formatBit(int register,
                                    int bit)

__formatLabel

public java.lang.String __formatLabel(int address,
                                      int n_chars)

__fill

public java.lang.String __fill(java.lang.String s,
                               int n_chars)

__formatLiteral

public java.lang.String __formatLiteral(int literal)

dump

public void dump()
dump PIC state


reset

public void reset()
reset the PIC processor


singleStep

public void singleStep()
execute one PIC instruction


steps

public void steps(int N)
execute N PIC instructions


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
main: simple selftest and performance test for the TurboPicCore

Throws:
java.lang.Exception

tinySelftest

void tinySelftest()