hades.models.pic
Class TurboPic16C84

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

public class TurboPic16C84
extends TurboPicCore
implements Wakeable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class hades.models.pic.TurboPicCore
TurboPicCore.ADDLW, TurboPicCore.ADDWF, TurboPicCore.ANDLW, TurboPicCore.ANDWF, TurboPicCore.BCF, TurboPicCore.BreakPoint, TurboPicCore.BSF, TurboPicCore.BTFSC, TurboPicCore.BTFSS, TurboPicCore.CALL, TurboPicCore.CLRF, TurboPicCore.CLRW, TurboPicCore.CLRWDT, TurboPicCore.COMF, TurboPicCore.DECF, TurboPicCore.DECFSZ, TurboPicCore.DECFSZ_NF, TurboPicCore.GOTO, TurboPicCore.INCF, TurboPicCore.INCFSZ, TurboPicCore.IORLW, TurboPicCore.IORWF, TurboPicCore.MOVF, TurboPicCore.MOVLW, TurboPicCore.MOVWF, TurboPicCore.NOP, TurboPicCore.OPTION, TurboPicCore.PicInstruction, TurboPicCore.PicMemoryEepromAdapter, TurboPicCore.PicMemoryEpromAdapter, TurboPicCore.PicMemoryRegbankAdapter, TurboPicCore.PicMemoryStackAdapter, TurboPicCore.PicRegAdapter, TurboPicCore.PicRegINTCONAdapter, TurboPicCore.PicRegPCAdapter, TurboPicCore.PicRegSTATUSAdapter, TurboPicCore.PicRegWAdapter, TurboPicCore.RETFIE, TurboPicCore.RETLW, TurboPicCore.RETURN, TurboPicCore.RLF, TurboPicCore.RRF, TurboPicCore.SLEEP, TurboPicCore.SUBLW, TurboPicCore.SUBWF, TurboPicCore.SWAPF, TurboPicCore.TRIS, TurboPicCore.XORLW, TurboPicCore.XORWF
 
Field Summary
(package private) static java.lang.Integer[] _integerTable
           
(package private)  double clk4Period
           
(package private)  double clk8Period
           
 PortStdLogic1164[] portA
           
 PortStdLogic1164[] portB
           
 PortStdLogic1164 portClkin
           
 PortStdLogic1164 portClkout
           
 PortString portINSTR
           
 PortInteger portINTCON
           
 PortStdLogic1164 portMclr
           
 PortInteger portPC
           
 PortInteger portSTATUS
           
 PortInteger portW
           
(package private)  double t_now
           
(package private)  double t_portdelay
           
 
Fields inherited from class hades.models.pic.TurboPicCore
_C, _cycle, _DC, _EEADR, _EECON1, _EECON2, _EEDATA, _EEIE, _FSR, _GIE, _INDF, _INTCON, _INTE, _INTF, _IRP, _nPD, _nTO, _OPTION, _PC, _PCL, _PCLATH, _period, _PORTA_LATCH, _PORTB_LATCH, _RA0, _RA1, _RA2, _RA3, _RA4, _RBIE, _RBIF, _RP0, _RP1, _SP, _STATUS, _T0IE, _T0IF, _TMR0, _TRISA, _TRISB, _W, _WDT, _WDT_PRESCALER, _Z, bank0BitNames, bank0Names, bank1BitNames, bank1Names, eeprom, EEPROM_SIZE, enableDebugSignals, enableGUI, enableIRQs, enableWDT, EPROM_SIZE, isResetOrSleep, labelTable, MAX_RAM, n_errors, needCheckIRQs, program, register, stack, STACK_DEPTH
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
TurboPic16C84()
           
 
Method Summary
 void configure()
          create and display a 'ConfigDialog' to set the parameters for a SimObject.
 void createGUI()
           
 void createPorts()
           
 void elaborate(java.lang.Object dummy)
          elaborate(): This method is called by the simulation engine to initialize the simulation object.
 void evaluate(java.lang.Object arg)
          this method is called in reaction to external simulation events, namely, when one of the input signals to the PIC microcontroller changes.
 double getClockFrequency()
          return the input clock period of this PIC.
 java.lang.String[] getExternalResources()
          return a String[] array of length 1 with the program ROM init file.
 java.lang.Integer getInteger(int i)
           
 java.awt.Component getPropertySheet()
          return a reference to the 'property sheet' or configuration window for this SimObject.
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a tool tip message (with the timing parameters)
 boolean initialize(java.lang.String s)
          initialize this PIC from String s, which contains the version ID (1001), the clock period (double value in seconds), and the resource name of the initial program ROM/HEX file.
 boolean needsExternalResources()
          we use one external resource: the program ROM initialization file.
 boolean nextExternalEventIsLate()
           
 int readPortA()
          read operation on PORT A.
 int readPortB()
          read operation on PORT B.
 void reset()
          reset the PIC processor
 void scheduleDebugSignals()
          generate simulation events with the current values of the PC, W, STATUS, INTCON, and INSTRUCTION (opcode/mnemonic) registers on the corresponding debug output signals.
 void setClockFrequency(double f)
          set the input clock period of this PIC.
 void singleStep()
          execute one PIC instruction
 void wakeup(java.lang.Object event)
          wakeup: called by the simulation engine after the instruction-cycle sleep period has elapsed.
 void write(java.io.PrintWriter ps)
           
 void writePortA(int value)
          write operation to PORT A.
 void writePortB(int value)
          write operation to PORT B.
 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.models.pic.TurboPicCore
__fill, __formatBit, __formatFD, __formatLabel, __formatLiteral, __formatReg, __hex, __xhex, _d, _h, checkIRQs, clearLabels, createAndInitializeMemoryArrays, createDECFSZ, decode, dump, dumpProgram, error, isCodeBreakPoint, isNormalRegister, isSpecialRegister, loadProgram, loadProgramFormatHEX, loadProgramFormatROM, main, readReg, readRegRaw, setCodeBreakPoint, setEnableIRQs, setEnableWDT, steps, tinySelftest, writePCL, writeReg
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, copy, getBindkey, getClassLoader, getDebug, getEditor, getFullName, getName, getParent, getPort, getPorts, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, mousePressed, needsDynamicSymbol, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setSymbol, setVersionId, setVisible, tearDown, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hades.simulator.Simulatable
message
 

Field Detail

portClkin

public PortStdLogic1164 portClkin

portClkout

public PortStdLogic1164 portClkout

portMclr

public PortStdLogic1164 portMclr

portA

public PortStdLogic1164[] portA

portB

public PortStdLogic1164[] portB

portPC

public PortInteger portPC

portW

public PortInteger portW

portSTATUS

public PortInteger portSTATUS

portINTCON

public PortInteger portINTCON

portINSTR

public PortString portINSTR

clk4Period

double clk4Period

clk8Period

double clk8Period

t_now

double t_now

t_portdelay

double t_portdelay

_integerTable

static java.lang.Integer[] _integerTable
Constructor Detail

TurboPic16C84

public TurboPic16C84()
Method Detail

createPorts

public void createPorts()

elaborate

public void elaborate(java.lang.Object dummy)
Description copied from interface: Simulatable
elaborate(): This method is called by the simulation engine to initialize the simulation object.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject

wakeup

public void wakeup(java.lang.Object event)
wakeup: called by the simulation engine after the instruction-cycle sleep period has elapsed. Execute at least one instruction, or enter the turbo-execution loop until the next external simulation event time is reached.

Specified by:
wakeup in interface Wakeable

nextExternalEventIsLate

public boolean nextExternalEventIsLate()

evaluate

public void evaluate(java.lang.Object arg)
this method is called in reaction to external simulation events, namely, when one of the input signals to the PIC microcontroller changes. We do the following:

For changes on the RESET input pin, the model changes its wakeup() behaviour, to avoid spending unnecessary host CPU time. If the RESET pin goes low (StdLogic1164._0 or _L), we set the isSleepOrReset variable, which stops processor execution from the wakeup() loop on the next instruction. As soon as wakeup() goes high (StdLogic1164._1 or _H) again, we schedule a PIC wakeup() event for one processor clock period after the reset() signal value change.

For changes on PORTA4/T0CLKIN, we consult the current value of the T0 input selection bit in the _OPTION register. If T0 is driven by the extern PORTA4 pin, we check for and handle corresponding counter events. If T0 is disabled or set to internal clock, we ignore PORTA4 changes.

Note that we use the internal signature counter _T0_SIGNATURE, which is incremented on each change to the _OPTION register T0 bits or write operations on the _T0 register, to avoid race conditions due to wakeup() events for timer0, which since have been replaced and outdated.

For changes on PORTB0/IRQ, the input change is compared with the current IRQ enable bits in INTCON and handled accordingly.

For changes on PORTB4..7, the current signal values are stored in the _PORTB_INPUT_LATCH register and compored with the values latched on the last _PORTB read operation. Any input change condition is detected and sets the corresponding bit in the _INTCON register, which in turns sets the checkIRQ flag when PORTB change interrupt is enabled.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - an arbitrary object argument

initialize

public boolean initialize(java.lang.String s)
initialize this PIC from String s, which contains the version ID (1001), the clock period (double value in seconds), and the resource name of the initial program ROM/HEX file.

Overrides:
initialize in class SimObject

write

public void write(java.io.PrintWriter ps)
Overrides:
write in class SimObject

needsExternalResources

public boolean needsExternalResources()
we use one external resource: the program ROM initialization file.

Overrides:
needsExternalResources in class SimObject

getExternalResources

public java.lang.String[] getExternalResources()
return a String[] array of length 1 with the program ROM init file.

Overrides:
getExternalResources in class SimObject

getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
construct a tool tip message (with the timing parameters)

Specified by:
getToolTip in interface ContextToolTip
Overrides:
getToolTip in class SimObject

setClockFrequency

public void setClockFrequency(double f)
set the input clock period of this PIC. Remember that an instruction cycle takes 4 clock periods on the PIC16Cxx. For example, calling setClockFrequency( 20E6 ) results in 5M instructions/sec.


getClockFrequency

public double getClockFrequency()
return the input clock period of this PIC. Remember that an instruction cycle takes 4 clock periods on the PIC16Cxx.


readPortA

public int readPortA()
read operation on PORT A.

Overrides:
readPortA in class TurboPicCore

readPortB

public int readPortB()
read operation on PORT B.

Overrides:
readPortB in class TurboPicCore

writePortA

public void writePortA(int value)
write operation to PORT A. We always store the written data into the data latch register. For all bits configured as outputs (via TRISA register), we also notify the corresponding HADES output signals.

Overrides:
writePortA in class TurboPicCore

writePortB

public void writePortB(int value)
write operation to PORT B. We always store the written data into the data latch register. For all bits configured as outputs (via TRISB register), we also notify the corresponding HADES output signals.

Overrides:
writePortB in class TurboPicCore

writeTrisA

public void writeTrisA(int value)
write operation on the TRIS A register. This writes the value to the _TRISA variable. Also, if the _TRISA value changed, we generate HADES events for all signals connected to the port. This should not be a major performance problem, as we expect that changes to the TRISA register are rare.

Overrides:
writeTrisA in class TurboPicCore

writeTrisB

public void writeTrisB(int value)
write operation on the TRIS B register. This writes the value to the _TRISB variable. Also, if the _TRISB value changed, we generate HADES events for all signals connected to the port. This should not be a major performance problem, as we expect that changes to the TRISB register are rare.

Overrides:
writeTrisB in class TurboPicCore

reset

public void reset()
Description copied from class: TurboPicCore
reset the PIC processor

Overrides:
reset in class TurboPicCore

singleStep

public void singleStep()
execute one PIC instruction

Overrides:
singleStep in class TurboPicCore

scheduleDebugSignals

public void scheduleDebugSignals()
generate simulation events with the current values of the PC, W, STATUS, INTCON, and INSTRUCTION (opcode/mnemonic) registers on the corresponding debug output signals.


getInteger

public java.lang.Integer getInteger(int i)

getPropertySheet

public java.awt.Component getPropertySheet()
Description copied from class: SimObject
return a reference to the 'property sheet' or configuration window for this SimObject. We cast the return value to an AWT Component, but typically you can expect either a hades.gui.PropertySheet or an java.awt.Window (Dialog or Frame).

Overrides:
getPropertySheet in class SimObject

configure

public void configure()
Description copied from class: SimObject
create and display a 'ConfigDialog' to set the parameters for a SimObject. The default ConfigDialog for the base class (SimObject) itself is empty except for the 'instance name' of the SimObject.

Overrides:
configure in class SimObject

createGUI

public void createGUI()