AvrDevice Class Reference

Basic AVR device, contains the core functionality. More...

#include <avrdevice.h>

Inheritance diagram for AvrDevice:
Inheritance graph
[legend]
Collaboration diagram for AvrDevice:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AvrDevice (unsigned int ioSpaceSize, unsigned int IRamSize, unsigned int ERamSize, unsigned int flashSize)
virtual ~AvrDevice ()
void AddToResetList (Hardware *hw)
void AddToCycleList (Hardware *hw)
void RemoveFromCycleList (Hardware *hw)
 Removes from the cycle list, if possible.
void Load (const char *n)
void ReplaceIoRegister (unsigned int offset, RWMemoryMember *)
bool ReplaceMemRegister (unsigned int offset, RWMemoryMember *)
RWMemoryMemberGetMemRegisterInstance (unsigned int offset)
void RegisterTerminationSymbol (const char *symbol)
PinGetPin (const char *name)
int Step (bool &untilCoreStepFinished, SystemClockOffset *nextStepIn_ns=0)
void Reset ()
void SetClockFreq (SystemClockOffset f)
SystemClockOffset GetClockFreq ()
void RegisterPin (const std::string &name, Pin *p)
void DeleteAllBreakpoints (void)
 Clear all breakpoints in device.
const std::string & GetFname (void)
 Return filename from loaded program.
unsigned int GetMemTotalSize (void)
 Get configured total memory space size.
unsigned int GetMemIOSize (void)
 Get configured IO memory space size.
unsigned int GetMemRegisterSize (void)
 Get configured register space size.
unsigned int GetMemIRamSize (void)
 Get configured internal RAM size.
unsigned int GetMemERamSize (void)
 Get configured external RAM size.
unsigned char GetRWMem (unsigned addr)
 Get a value of RW memory cell.
bool SetRWMem (unsigned addr, unsigned char val)
 Set a value to RW memory cell.
unsigned char GetCoreReg (unsigned addr)
 Get a value from core register.
bool SetCoreReg (unsigned addr, unsigned char val)
 Set a value to core register.
unsigned char GetIOReg (unsigned addr)
 Get a value from IO register (without offset of 0x20!).
bool SetIOReg (unsigned addr, unsigned char val)
 Set a value to IO register (without offset of 0x20!).
bool SetIORegBit (unsigned addr, unsigned bitaddr, bool val)
 Set a bit value to lower IO register (without offset of 0x20!).
unsigned GetRegX (void)
 Get value of X register (16bit).
unsigned GetRegY (void)
 Get value of Y register (16bit).
unsigned GetRegZ (void)
 Get value of Z register (16bit).
void DebugOnJump ()
 When a call/jump/cond-jump instruction was executed. For debugging.

Public Attributes

int trace_on
Breakpoints BP
Exitpoints EP
word PC
word cPC
 When mupti-cycle instruction is "processed" this holds its address, PC holds the next instruction.
int PC_size
AvrFlashFlash
FlashProgrammingspmRegister
HWEepromeeprom
Datadata
 a hack for symbol look-up
HWIrqSystemirqSystem
AddressExtensionRegisterrampz
 RAMPZ address extension register.
AddressExtensionRegistereind
 EIND address extension register.
bool abortOnInvalidAccess
 Flag, that simulation abort if an invalid access occured, default is false.
TraceValueCoreRegister coreTraceGroup
bool instructionSEIJustEnabledInterrupts
 Almost always false.
bool flagIWInstructions
 ADIW and SBIW instructions are available (not on most tiny's!).
bool flagJMPInstructions
 CALL and JMP instructions are available (only on devices with bigger flash).
bool flagIJMPInstructions
 ICALL and IJMP instructions are available (not on attiny1x devices).
bool flagEIJMPInstructions
 EICALL and EIJMP instructions are available (only on some devices with bigger flash).
bool flagLPMInstructions
 LPM and SPM instructions are available (not on some tiny devices).
bool flagELPMInstructions
 ELPM instructions are available (only on devices with bigger flash).
bool flagMULInstructions
 (F)MULxx instructions are available
bool flagMOVWInstruction
 MOVW instruction is available.
bool flagTiny10
 core is a tiny4/5/9/10, change used clocks on some instructions and disables instructions
bool flagTiny1x
 core is a tiny1x (but not tiny10!), change used clocks on some instructions and disables instructions
bool flagXMega
 core is a XMEGA device, change used clocks on some instructions
int DebugRecentJumps [20]
 Addresses of last few 'call' and 'jump' executed. For debugging.
int DebugRecentJumpsIndex
 Index to address of the most recent jump.
RWMemoryMember ** rw
 The whole memory: R0-R31, IO, Internal RAM.
HWStackstack
HWSregstatus
 the status register itself
RWSregstatusRegister
 the memory interface for status
HWWadowado
 WDT timer.
std::vector< Hardware * > hwResetList
std::vector< Hardware * > hwCycleList
DumpManagerdump_manager

Protected Attributes

SystemClockOffset clockFreq
 Period of a tick (1/F_OSC) in [ns].
std::map< std::string, Pin * > allPins
std::string actualFilename
int cpuCycles
 Count of cycles before next instruction is executed (i.e. countdown).

Private Attributes

RWMemoryMember ** invalidRW
 hold invalid RW memory cells created by device
const unsigned int ioSpaceSize
const unsigned int iRamSize
const unsigned int eRamSize

Static Private Attributes

static const unsigned int totalIoSpace = 0x10000
static const unsigned int registerSpaceSize = 32

Detailed Description

Basic AVR device, contains the core functionality.

Definition at line 56 of file avrdevice.h.


Constructor & Destructor Documentation

AvrDevice::AvrDevice ( unsigned int  ioSpaceSize,
unsigned int  IRamSize,
unsigned int  ERamSize,
unsigned int  flashSize 
)
AvrDevice::~AvrDevice (  )  [virtual]

Definition at line 280 of file avrdevice.cpp.

References data, dump_manager, eRamSize, Flash, invalidRW, ioSpaceSize, iRamSize, registerSpaceSize, rw, status, statusRegister, totalIoSpace, and DumpManager::unregisterAvrDevice().

Here is the call graph for this function:


Member Function Documentation

void AvrDevice::AddToCycleList ( Hardware hw  ) 

Adds to the list of parts to cycle per clock tick. If already in that list, does nothing.

Definition at line 55 of file avrdevice.cpp.

References hwCycleList.

Referenced by FlashProgramming::FlashProgramming(), HWAd::HWAd(), HWPrescaler::HWPrescaler(), HWUart::HWUart(), HWWado::HWWado(), BasicTimerUnit::SetClockMode(), HWEeprom::SetEecr(), and HWSpi::SetSPCR().

Here is the caller graph for this function:

void AvrDevice::AddToResetList ( Hardware hw  ) 

Adds to the list of parts to reset. If already in that list, does nothing.

Definition at line 50 of file avrdevice.cpp.

References hwResetList.

Referenced by Hardware::Hardware().

Here is the caller graph for this function:

void AvrDevice::DebugOnJump (  ) 
void AvrDevice::DeleteAllBreakpoints ( void   ) 

Clear all breakpoints in device.

Definition at line 553 of file avrdevice.cpp.

References BP.

Referenced by GdbServer::InternalStep().

Here is the caller graph for this function:

SystemClockOffset AvrDevice::GetClockFreq (  ) 

Definition at line 269 of file avrdevice.cpp.

References clockFreq.

Referenced by GdbServer::Step().

Here is the caller graph for this function:

unsigned char AvrDevice::GetCoreReg ( unsigned  addr  ) 

Get a value from core register.

Definition at line 608 of file avrdevice.cpp.

References registerSpaceSize, and rw.

Referenced by GdbServer::gdb_read_register(), GdbServer::gdb_read_registers(), ThreadList::OnCall(), avr_op_SWAP::operator()(), avr_op_SUBI::operator()(), avr_op_SUB::operator()(), avr_op_ST_Z_incr::operator()(), avr_op_ST_Z_decr::operator()(), avr_op_ST_Y_incr::operator()(), avr_op_ST_Y_decr::operator()(), avr_op_ST_X_incr::operator()(), avr_op_ST_X_decr::operator()(), avr_op_ST_X::operator()(), avr_op_STS::operator()(), avr_op_STD_Z::operator()(), avr_op_STD_Y::operator()(), avr_op_SPM::operator()(), avr_op_SBRS::operator()(), avr_op_SBRC::operator()(), avr_op_SBIW::operator()(), avr_op_SBCI::operator()(), avr_op_SBC::operator()(), avr_op_ROR::operator()(), avr_op_PUSH::operator()(), avr_op_OUT::operator()(), avr_op_ORI::operator()(), avr_op_OR::operator()(), avr_op_NEG::operator()(), avr_op_MULSU::operator()(), avr_op_MULS::operator()(), avr_op_MUL::operator()(), avr_op_MOVW::operator()(), avr_op_MOV::operator()(), avr_op_LSR::operator()(), avr_op_INC::operator()(), avr_op_FMULSU::operator()(), avr_op_FMULS::operator()(), avr_op_FMUL::operator()(), avr_op_ESPM::operator()(), avr_op_EOR::operator()(), avr_op_DEC::operator()(), avr_op_CPSE::operator()(), avr_op_CPI::operator()(), avr_op_CPC::operator()(), avr_op_CP::operator()(), avr_op_COM::operator()(), avr_op_BST::operator()(), avr_op_BLD::operator()(), avr_op_ASR::operator()(), avr_op_ANDI::operator()(), avr_op_AND::operator()(), avr_op_ADIW::operator()(), avr_op_ADD::operator()(), and avr_op_ADC::operator()().

const std::string& AvrDevice::GetFname ( void   )  [inline]

Return filename from loaded program.

Definition at line 157 of file avrdevice.h.

References actualFilename.

Referenced by HWIrqSystem::ClearIrqFlag(), HWIrqSystem::IrqHandlerFinished(), HWIrqSystem::IrqHandlerStarted(), operator<<(), and HWIrqSystem::SetIrqFlag().

Here is the caller graph for this function:

unsigned char AvrDevice::GetIOReg ( unsigned  addr  ) 

Get a value from IO register (without offset of 0x20!).

Definition at line 619 of file avrdevice.cpp.

References ioSpaceSize, registerSpaceSize, and rw.

Referenced by avr_op_SBIS::operator()(), avr_op_SBIC::operator()(), and avr_op_IN::operator()().

Here is the caller graph for this function:

unsigned int AvrDevice::GetMemERamSize ( void   )  [inline]

Get configured external RAM size.

Definition at line 168 of file avrdevice.h.

References eRamSize.

unsigned int AvrDevice::GetMemIOSize ( void   )  [inline]

Get configured IO memory space size.

Definition at line 162 of file avrdevice.h.

References ioSpaceSize.

Referenced by HWStackSram::Reset().

Here is the caller graph for this function:

unsigned int AvrDevice::GetMemIRamSize ( void   )  [inline]

Get configured internal RAM size.

Definition at line 166 of file avrdevice.h.

References iRamSize.

Referenced by HWStackSram::Reset().

Here is the caller graph for this function:

RWMemoryMember * AvrDevice::GetMemRegisterInstance ( unsigned int  offset  ) 

Definition at line 571 of file avrdevice.cpp.

References rw, and totalIoSpace.

unsigned int AvrDevice::GetMemRegisterSize ( void   )  [inline]

Get configured register space size.

Definition at line 164 of file avrdevice.h.

References registerSpaceSize.

Referenced by HWStackSram::Reset().

Here is the caller graph for this function:

unsigned int AvrDevice::GetMemTotalSize ( void   )  [inline]

Get configured total memory space size.

Definition at line 160 of file avrdevice.h.

References totalIoSpace.

Referenced by GetRWMem(), and SetRWMem().

Here is the caller graph for this function:

Pin * AvrDevice::GetPin ( const char *  name  ) 
unsigned AvrDevice::GetRegX ( void   ) 

Get value of X register (16bit).

Definition at line 641 of file avrdevice.cpp.

References rw.

Referenced by avr_op_ST_X_incr::operator()(), avr_op_ST_X_decr::operator()(), avr_op_ST_X::operator()(), avr_op_LD_X_incr::operator()(), avr_op_LD_X_decr::operator()(), and avr_op_LD_X::operator()().

Here is the caller graph for this function:

unsigned AvrDevice::GetRegY ( void   ) 

Get value of Y register (16bit).

Definition at line 646 of file avrdevice.cpp.

References rw.

Referenced by avr_op_ST_Y_incr::operator()(), avr_op_ST_Y_decr::operator()(), avr_op_STD_Y::operator()(), avr_op_LD_Y_incr::operator()(), avr_op_LD_Y_decr::operator()(), and avr_op_LDD_Y::operator()().

Here is the caller graph for this function:

unsigned AvrDevice::GetRegZ ( void   ) 
unsigned char AvrDevice::GetRWMem ( unsigned  addr  ) 
void AvrDevice::Load ( const char *  n  ) 

Definition at line 117 of file avrdevice.cpp.

References actualFilename, Memory::AddSymbol(), avr_error, avr_warning, data, eeprom, Flash, HWEeprom::WriteMem(), and AvrFlash::WriteMem().

Referenced by avr_create_tf(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void AvrDevice::RegisterPin ( const std::string &  name,
Pin p 
) [inline]
void AvrDevice::RegisterTerminationSymbol ( const char *  symbol  ) 

Definition at line 577 of file avrdevice.cpp.

References EP, Flash, and Memory::GetAddressAtSymbol().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void AvrDevice::RemoveFromCycleList ( Hardware hw  ) 

Removes from the cycle list, if possible.

Does nothing if the part is not in the cycle list.

Definition at line 60 of file avrdevice.cpp.

References hwCycleList.

Referenced by HWEeprom::CpuCycle(), BasicTimerUnit::SetClockMode(), and HWSpi::SetSPCR().

Here is the caller graph for this function:

void AvrDevice::ReplaceIoRegister ( unsigned int  offset,
RWMemoryMember newMember 
)

Definition at line 557 of file avrdevice.cpp.

References avr_error, ioSpaceSize, registerSpaceSize, and rw.

Referenced by main().

Here is the caller graph for this function:

bool AvrDevice::ReplaceMemRegister ( unsigned int  offset,
RWMemoryMember newMember 
)

Definition at line 563 of file avrdevice.cpp.

References rw, and totalIoSpace.

void AvrDevice::Reset (  ) 
void AvrDevice::SetClockFreq ( SystemClockOffset  f  ) 

Definition at line 265 of file avrdevice.cpp.

References clockFreq.

Referenced by main().

Here is the caller graph for this function:

bool AvrDevice::SetCoreReg ( unsigned  addr,
unsigned char  val 
)

Set a value to core register.

Definition at line 613 of file avrdevice.cpp.

References registerSpaceSize, and rw.

Referenced by GdbServer::gdb_write_register(), GdbServer::gdb_write_registers(), avr_op_SWAP::operator()(), avr_op_SUBI::operator()(), avr_op_SUB::operator()(), avr_op_ST_Z_incr::operator()(), avr_op_ST_Z_decr::operator()(), avr_op_ST_Y_incr::operator()(), avr_op_ST_Y_decr::operator()(), avr_op_ST_X_incr::operator()(), avr_op_ST_X_decr::operator()(), avr_op_SBIW::operator()(), avr_op_SBCI::operator()(), avr_op_SBC::operator()(), avr_op_ROR::operator()(), avr_op_POP::operator()(), avr_op_ORI::operator()(), avr_op_OR::operator()(), avr_op_NEG::operator()(), avr_op_MULSU::operator()(), avr_op_MULS::operator()(), avr_op_MUL::operator()(), avr_op_MOVW::operator()(), avr_op_MOV::operator()(), avr_op_LSR::operator()(), avr_op_LPM_Z_incr::operator()(), avr_op_LPM::operator()(), avr_op_LPM_Z::operator()(), avr_op_LD_Z_decr::operator()(), avr_op_LD_Z_incr::operator()(), avr_op_LD_Y_incr::operator()(), avr_op_LD_Y_decr::operator()(), avr_op_LD_X_incr::operator()(), avr_op_LD_X_decr::operator()(), avr_op_LD_X::operator()(), avr_op_LDS::operator()(), avr_op_LDI::operator()(), avr_op_LDD_Z::operator()(), avr_op_LDD_Y::operator()(), avr_op_INC::operator()(), avr_op_IN::operator()(), avr_op_FMULSU::operator()(), avr_op_FMULS::operator()(), avr_op_FMUL::operator()(), avr_op_ESPM::operator()(), avr_op_EOR::operator()(), avr_op_ELPM::operator()(), avr_op_ELPM_Z_incr::operator()(), avr_op_ELPM_Z::operator()(), avr_op_DEC::operator()(), avr_op_COM::operator()(), avr_op_BLD::operator()(), avr_op_ASR::operator()(), avr_op_ANDI::operator()(), avr_op_AND::operator()(), avr_op_ADIW::operator()(), avr_op_ADD::operator()(), and avr_op_ADC::operator()().

bool AvrDevice::SetIOReg ( unsigned  addr,
unsigned char  val 
)

Set a value to IO register (without offset of 0x20!).

Definition at line 624 of file avrdevice.cpp.

References ioSpaceSize, registerSpaceSize, and rw.

Referenced by avr_op_OUT::operator()().

Here is the caller graph for this function:

bool AvrDevice::SetIORegBit ( unsigned  addr,
unsigned  bitaddr,
bool  val 
)

Set a bit value to lower IO register (without offset of 0x20!).

Todo:
Have to be reimplemented, if IO bit set feature is implemented. Compare differences in datasheets, for example ATMega16 and ATMega48, on CBI and SBI usage at IO registers, which have special behaviour, if bit will be set to 1

Definition at line 630 of file avrdevice.cpp.

References registerSpaceSize, and rw.

Referenced by avr_op_SBI::operator()(), and avr_op_CBI::operator()().

Here is the caller graph for this function:

bool AvrDevice::SetRWMem ( unsigned  addr,
unsigned char  val 
)
int AvrDevice::Step ( bool &  untilCoreStepFinished,
SystemClockOffset nextStepIn_ns = 0 
) [virtual]

Member Data Documentation

Flag, that simulation abort if an invalid access occured, default is false.

Definition at line 89 of file avrdevice.h.

Referenced by InvalidMem::get(), and InvalidMem::set().

std::string AvrDevice::actualFilename [protected]

Definition at line 69 of file avrdevice.h.

Referenced by GetFname(), Load(), and Step().

std::map< std::string, Pin *> AvrDevice::allPins [protected]

Definition at line 68 of file avrdevice.h.

Referenced by GetPin(), and RegisterPin().

Period of a tick (1/F_OSC) in [ns].

Definition at line 67 of file avrdevice.h.

Referenced by GetClockFreq(), SetClockFreq(), and Step().

When mupti-cycle instruction is "processed" this holds its address, PC holds the next instruction.

Definition at line 80 of file avrdevice.h.

Referenced by AvrDevice(), Reset(), and Step().

int AvrDevice::cpuCycles [protected]

Count of cycles before next instruction is executed (i.e. countdown).

Definition at line 72 of file avrdevice.h.

Referenced by Reset(), and Step().

a hack for symbol look-up

Definition at line 85 of file avrdevice.h.

Referenced by AvrDevice(), Load(), and ~AvrDevice().

Addresses of last few 'call' and 'jump' executed. For debugging.

Definition at line 104 of file avrdevice.h.

Referenced by DebugOnJump().

Index to address of the most recent jump.

Definition at line 105 of file avrdevice.h.

Referenced by AvrDevice(), and DebugOnJump().

Definition at line 117 of file avrdevice.h.

Referenced by AvrDevice(), Step(), and ~AvrDevice().

EIND address extension register.

Definition at line 88 of file avrdevice.h.

Referenced by AvrDevice(), avr_op_EIJMP::operator()(), and avr_op_EICALL::operator()().

Definition at line 77 of file avrdevice.h.

Referenced by RegisterTerminationSymbol(), and Step().

const unsigned int AvrDevice::eRamSize [private]

Definition at line 64 of file avrdevice.h.

Referenced by GetMemERamSize(), and ~AvrDevice().

EICALL and EIJMP instructions are available (only on some devices with bigger flash).

Definition at line 96 of file avrdevice.h.

Referenced by lookup_opcode().

ELPM instructions are available (only on devices with bigger flash).

Definition at line 98 of file avrdevice.h.

Referenced by AvrDevice_atmega128::AvrDevice_atmega128(), and lookup_opcode().

ICALL and IJMP instructions are available (not on attiny1x devices).

Definition at line 95 of file avrdevice.h.

Referenced by lookup_opcode().

ADIW and SBIW instructions are available (not on most tiny's!).

Definition at line 93 of file avrdevice.h.

Referenced by lookup_opcode().

LPM and SPM instructions are available (not on some tiny devices).

Definition at line 97 of file avrdevice.h.

Referenced by lookup_opcode().

MOVW instruction is available.

Definition at line 100 of file avrdevice.h.

Referenced by AvrDevice_at90s4433::AvrDevice_at90s4433(), AvrDevice_at90s8515::AvrDevice_at90s8515(), and lookup_opcode().

core is a tiny1x (but not tiny10!), change used clocks on some instructions and disables instructions

Definition at line 102 of file avrdevice.h.

Referenced by lookup_opcode().

Definition at line 115 of file avrdevice.h.

Referenced by AddToCycleList(), RemoveFromCycleList(), and Step().

Definition at line 114 of file avrdevice.h.

Referenced by AddToResetList(), and Reset().

Almost always false.

Definition at line 91 of file avrdevice.h.

Referenced by avr_op_BSET::operator()(), and Step().

hold invalid RW memory cells created by device

Definition at line 59 of file avrdevice.h.

Referenced by AvrDevice(), and ~AvrDevice().

const unsigned int AvrDevice::ioSpaceSize [private]

Definition at line 60 of file avrdevice.h.

Referenced by AvrDevice(), GetIOReg(), GetMemIOSize(), ReplaceIoRegister(), SetIOReg(), and ~AvrDevice().

const unsigned int AvrDevice::iRamSize [private]

Definition at line 63 of file avrdevice.h.

Referenced by GetMemIRamSize(), and ~AvrDevice().

const unsigned int AvrDevice::registerSpaceSize = 32 [static, private]
const unsigned int AvrDevice::totalIoSpace = 0x10000 [static, private]

The documentation for this class was generated from the following files:
Generated on Sun Feb 12 16:49:42 2012 for Simulavr by  doxygen 1.6.3