 
format=0.1

#device=PIC16F59
# DOS: DOS-00425
# PS:  DS-41243
# DS:  DS-41213

vpp (range=10.000-12.000  dflt=11.000)
vdd (range=2.000-5.500  dfltrange=4.500-5.500  nominal=5.000)

pgming (memtech=ee tries=1 lvpthresh=0)
    wait (pgm=2000 lvpgm=2000 eedata=2000 cfg=2000 userid=2000 erase=10000 lverase=10000)
    latches(pgm=4 eedata=1 userid=1 cfg=1)

pgmmem (region=0x000-0x7FF)
cfgmem (region=0xFFF-0xFFF)
userid (region=0x800-0x803)
# I have no device ID yet.
#devid (region=0x2006-0x2006 idmask=0x3FE0 id=0x04A0)
#eedata (region=0x0-0x85)
testmem (region=0x800-0x83F)

NumBanks=8

MirrorRegs (0x0-0xF 0x20-0x2F 0x40-0x4F 0x60-0x6F 0x80-0x8F 0xA0-0xAF 0xC0-0xCF 0xE0-0xEF)

sfr (key=INDF addr=0x0 size=1 flags=i access='u u u u u u u u')
    reset (por='--------' mclr='--------')
    bit (names='INDF' width='8')
sfr (key=TMR0 addr=0x1 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='TMR0' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=w)
sfr (key=PCL addr=0x2 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='PCL' width='8')
    stimulus (scl=rwb regfiles=w pcfiles=rw)

# Q: Reset states are questionable.
sfr (key=STATUS addr=0x3 size=1 access='rw rw rw r r rw rw rw')
    reset (por='00011xxx' mclr='00011uuu')
    bit (names='PA nTO nPD Z DC C' width='3 1 1 1 1 1')

# Q: Reset states are questionable.
sfr (key=FSR addr=0x4 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='FSR' width='8')
    stimulus (scl=rwb regfiles=w pcfiles=rw)

sfr (key=PORTA addr=0x5 size=1 access='u u u r rw rw rw rw')
    reset (por='---xxxxx' mclr='---uuuuu')
    bit (names='- - - T0CKI RA3 RA2 RA1 RA0')
    bit (tag=scl names='RA' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTB addr=0x6 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0')
    bit (tag=scl names='RB' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTC addr=0x7 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0')
    bit (tag=scl names='RC' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTD addr=0x8 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0')
    bit (tag=scl names='RD' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTE addr=0x9 size=1 access='rw rw rw rw u u u u')
    reset (por='xxxx----' mclr='uuuu----')
    bit (names='RE7 RE6 RE5 RE4 - - - -')
    bit (tag=scl names='RE' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)


                               # -------------------#
#------------------------------# Configuration Bits #------------------------------------#
                               # -------------------#

# I pulled this from the PIC16F57 device file.  We'll have to revisit
# it.

cfgbits (key=CONFIG addr=0xFFF unused=0x0)
    field (key=OSC mask=0x3 desc="Oscillator")
        setting (req=0x3 value=0x3 desc="RC")
        setting (req=0x3 value=0x0 desc="LP")
        setting (req=0x3 value=0x1 desc="XT")
        setting (req=0x3 value=0x2 desc="HS")
    field (key=WDT mask=0x4 desc="Watchdog Timer")
        setting (req=0x4 value=0x4 desc="On")
        setting (req=0x4 value=0x0 desc="Off")
    field (key=CP mask=0x8 desc="Code Protect")
        setting (req=0x8 value=0x8 desc="Off")
            checksum (type=0x0 protregion=0x00-0x00)
        setting (req=0x8 value=0x0 desc="On")
            checksum (type=0x20 protregion=0x40-0x7FF)

                               #----------------------------#
#------------------------------# Nonmemory-Mapped Registers #------------------------------------#
                               #----------------------------#

# I pulled this from the PIC16F67 device file.  We'll have to revisit
# it.

nmmr (key=WREG addr=0x0 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='WREG' width='8')
nmmr (key=STKPTR addr=0x1 size=1 flags=h access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='STKPTR' width='8')
nmmr (key=TRISA addr=0x2 size=1 access='u u u r rw rw rw rw')
    reset (por='---11111' mclr='---11111')
    bit (names='- - - TRISA4 TRISA3 TRISA2 TRISA1 TRISA0')
nmmr (key=TRISB addr=0x3 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB1 TRISB0')
nmmr (key=TRISC addr=0x4 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0')
nmmr (key=OPTION_REG addr=0x5 size=1 access='u u rw rw rw rw rw rw')
    reset (por='--111111' mclr='--111111')
    bit (names='- - T0CS T0SE PSA PS' width='1 1 1 1 1 3')
nmmr (key=TRISD addr=0x7 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='TRISD7 TRISD6 TRISD5 TRISD4 TRISD3 TRISD2 TRISD1 TRISD0')
nmmr (key=TRISE addr=0x8 size=1 access='rw rw rw rw u u u u')
    reset (por='1111----' mclr='1111----')
    bit (names='TRISE7 TRISE6 TRISE5 TRISE4 - - - -')


                               #-------------#
#------------------------------# Peripherals #------------------------------------#
                               #-------------#
#--------------------------------------------------------------------------------
# 				PORTA
#--------------------------------------------------------------------------------
peripheral (key=PORTA sfrs='PORTA TRISA' type=port)
    iopin (key=RA0 dir=inout)
    iopin (key=RA1 dir=inout)
    iopin (key=RA2 dir=inout)
    iopin (key=RA3 dir=inout)
    iopin (key=RA4 dir=in)

#--------------------------------------------------------------------------------
# 				PORTB
#--------------------------------------------------------------------------------
peripheral (key=PORTB sfrs='PORTB TRISB' type=port)
    iopin (key=RB0 dir=inout)
    iopin (key=RB1 dir=inout)
    iopin (key=RB2 dir=inout)
    iopin (key=RB3 dir=inout)
    iopin (key=RB4 dir=inout)
    iopin (key=RB5 dir=inout)
    iopin (key=RB6 dir=inout)
    iopin (key=RB7 dir=inout)

#--------------------------------------------------------------------------------
# 				PORTC
#--------------------------------------------------------------------------------

peripheral (key=PORTC sfrs='PORTC TRISC' type=port)
    iopin (key=RC0 dir=inout)
    iopin (key=RC1 dir=inout)
    iopin (key=RC2 dir=inout)
    iopin (key=RC3 dir=inout)
    iopin (key=RC4 dir=inout)
    iopin (key=RC5 dir=inout)
    iopin (key=RC6 dir=inout)
    iopin (key=RC7 dir=inout)

#--------------------------------------------------------------------------------
# 				PORTD
#--------------------------------------------------------------------------------
peripheral (key=PORTD sfrs='PORTD TRISD' type=port)
    iopin (key=RD0 dir=inout)
    iopin (key=RD1 dir=inout)
    iopin (key=RD2 dir=inout)
    iopin (key=RD3 dir=inout)
    iopin (key=RD4 dir=inout)
    iopin (key=RD5 dir=inout)
    iopin (key=RD6 dir=inout)
    iopin (key=RD7 dir=inout)

#--------------------------------------------------------------------------------
# 				PORTE
#--------------------------------------------------------------------------------
peripheral (key=PORTE sfrs='PORTE TRISE' type=port)
    iopin (key=RE4 dir=inout)
    iopin (key=RE5 dir=inout)
    iopin (key=RE6 dir=inout)
    iopin (key=RE7 dir=inout)

#--------------------------------------------------------------------------------
# 				TIMERs
#--------------------------------------------------------------------------------
peripheral (key=TMR0 sfrs='TMR0')
    pinfunc (key=T0CKI port=RA4 dir=in)

