47 if(find(hwResetList.begin(), hwResetList.end(), hw) == hwResetList.end())
48 hwResetList.push_back(hw);
52 if(find(hwCycleList.begin(), hwCycleList.end(), hw) == hwCycleList.end())
53 hwCycleList.push_back(hw);
57 vector<Hardware*>::iterator element;
58 element=find(hwCycleList.begin(), hwCycleList.end(), hw);
59 if(element != hwCycleList.end())
60 hwCycleList.erase(element);
64 actualFilename = fname;
77 Pin *ret = allPins[name];
79 avr_error(
"unknown Pin requested! -> %s is not available", name);
86 dumpManager->unregisterAvrDevice(
this);
90 unsigned size = totalIoSpace - registerSpaceSize - iRamSize - eRamSize;
91 for(
unsigned idx = 0; idx < size; idx++)
92 delete invalidRW[idx];
96 for(
unsigned idx = 0; idx < registerSpaceSize; idx++)
98 size = registerSpaceSize + ioSpaceSize + iRamSize + eRamSize;
99 for(
unsigned idx = (registerSpaceSize + ioSpaceSize); idx < size; idx++)
104 delete statusRegister;
118 :
TraceValue(_ref->bits()+1, _name), ref(_ref) {}
121 change(ref->value()*2);
130 unsigned int IRamSize,
131 unsigned int ERamSize,
132 unsigned int flashSize,
133 unsigned int pcSize):
135 ioSpaceSize(_ioSpaceSize),
138 devSignature(numeric_limits<unsigned int>::max()),
142 abortOnInvalidAccess(false),
143 coreTraceGroup(this),
145 newIrqPc(0xffffffff),
148 flagIWInstructions(true),
149 flagJMPInstructions(true),
150 flagIJMPInstructions(true),
151 flagEIJMPInstructions(false),
152 flagLPMInstructions(true),
153 flagELPMInstructions(false),
154 flagMULInstructions(true),
155 flagMOVWInstruction(true),
192 avr_error(
"Not enough memory for HWSreg in AvrDevice::AvrDevice");
195 avr_error(
"Not enough memory for RWSreg in AvrDevice::AvrDevice");
203 avr_error(
"Not enough memory for Flash in AvrDevice::AvrDevice");
206 unsigned currentOffset = 0;
207 unsigned invalidRWOffset = 0;
211 if(
rw[currentOffset] ==
nullptr)
212 avr_error(
"Not enough memory for registers in AvrDevice::AvrDevice");
223 if(
invalidRW[invalidRWOffset] ==
nullptr)
224 avr_error(
"Not enough memory for io space in AvrDevice::AvrDevice");
231 for(
unsigned ii = 0; ii < IRamSize; ii++ ) {
233 if(
rw[currentOffset] ==
nullptr)
234 avr_error(
"Not enough memory for IRAM in AvrDevice::AvrDevice");
240 for(
unsigned ii = 0; ii < ERamSize; ii++ ) {
242 if(
rw[currentOffset] ==
nullptr)
243 avr_error(
"Not enough memory for io space in AvrDevice::AvrDevice");
249 for(; currentOffset <
totalIoSpace; currentOffset++, invalidRWOffset++) {
251 if(
invalidRW[invalidRWOffset] ==
nullptr)
252 avr_error(
"Not enough memory for fill address space in AvrDevice::AvrDevice");
268 for(
int len = sym.length(); len < 30;len++)
281 traceOut <<
"CPU-Hold by IO-Hardware ";
285 if(
BP.end() != find(
BP.begin(),
BP.end(),
PC)) {
287 traceOut <<
"Breakpoint found at 0x" << hex <<
PC << dec << endl;
288 if(nextStepIn_ns !=
nullptr)
290 untilCoreStepFinished = !(
cpuCycles > 0);
295 if(
EP.end() != find(
EP.begin(),
EP.end(),
PC)) {
350 if((
unsigned int)(PC << 1) >= (
unsigned int)
Flash->
GetSize() ) {
352 os <<
actualFilename <<
" Simulation runs out of Flash Space at " << hex << (
PC << 1);
377 if(nextStepIn_ns !=
nullptr)
385 untilCoreStepFinished = !((
cpuCycles > 0) || hwWait);
393 vector<Hardware *>::iterator ii;
404 BP.erase(
BP.begin(),
BP.end());
414 avr_error(
"Could not replace register in non existing IoRegisterSpace");
415 rw[offset] = newMember;
420 rw[offset] = newMember;
495 return (*(
rw[27]) << 8) + *(
rw[26]);
500 return (*(
rw[29]) << 8) + *(
rw[28]);
505 return (*(
rw[31]) << 8) + *(
rw[30]);
SystemClockOffset clockFreq
Period of a tick (1/F_OSC) in [ns].
DumpManager * dumpManager
void ELFLoad(const AvrDevice *core)
std::string GetSymbolAtAddress(unsigned int add)
void AddToCycleList(Hardware *hw)
const unsigned int ioSpaceSize
void RegisterTerminationSymbol(const char *symbol)
unsigned GetRegZ(void)
Get value of Z register (16bit)
SystemConsoleHandler sysConHandler
The SystemConsoleHandler instance for common usage.
RWMemoryMember * GetMemRegisterInstance(unsigned int offset)
Pin class, handles input and output to external parts.
TwiceTV(const std::string &_name, TraceValue *_ref)
std::vector< Hardware * > hwResetList
void SetReturnPoint(unsigned long stackPointer, Funktor *listener)
Subscribes a Listener for a return address.
AvrDevice(unsigned int ioSpaceSize, unsigned int IRamSize, unsigned int ERamSize, unsigned int flashSize, unsigned int pcSize=2)
unsigned int dataAddressMask
which bits in address are significant
bool ReplaceMemRegister(unsigned int offset, RWMemoryMember *)
void registerAvrDevice(AvrDevice *dev)
Add a device to devicelist.
Holds AVR flash content and symbol informations.
bool SetIORegBit(unsigned addr, unsigned bitaddr)
Set a bit value to lower IO register (without offset of 0x20!)
std::string actualFilename
bool SetRWMem(unsigned addr, unsigned char val)
Set a value to RW memory cell.
bool ClearIORegBit(unsigned addr, unsigned bitaddr)
Clear a bit value to lower IO register (without offset of 0x20!)
void DeleteAllBreakpoints(void)
Clear all breakpoints in device.
Memory on which access should be avoided! :-)
SystemClockOffset GetClockFreq()
unsigned char GetRWMem(unsigned addr)
Get a value of RW memory cell.
virtual unsigned int CpuCycle(void)
HWSreg * status
the status register itself
int cpuCycles
Count of cycles before next instruction is executed (i.e. countdown)
Build a register for TraceValue's.
bool SetIOReg(unsigned addr, unsigned char val)
Set a value to IO register (without offset of 0x20!)
DecodedInstruction * GetInstruction(unsigned int pc)
void trigger_change(void)
reflect a change, which comes from CPU core
TraceValueCoreRegister coreTraceGroup
virtual void cycle()
Called at least once for each cycle if this trace value is activated.
static SystemClock & Instance()
Returns the central SystemClock instance for the application.
void SetDeviceNameAndSignature(const std::string &name, unsigned int signature)
Set device signature and name.
static const unsigned int registerSpaceSize
unsigned int cPC
When mupti-cycle instruction is "processed" this holds its address, PC holds the next instruction...
RWMemoryMember ** invalidRW
hold invalid RW memory cells created by device
virtual void PushAddr(unsigned long addr)=0
Pushs a address to stack.
void IrqHandlerStarted(unsigned int vector_index)
unsigned GetRegX(void)
Get value of X register (16bit)
Member of any memory area in an AVR device.
Base class of core instruction.
unsigned int GetResetAddr(void)
Get reset address.
Data * data
a hack for symbol look-up
long long SystemClockOffset
std::vector< Hardware * > hwCycleList
Pin * GetPin(const char *name)
unsigned int GetNewPc(unsigned int &vector_index)
returns a new PC pointer if interrupt occurred, -1 otherwise.
void Stop()
Stop Run/Endless or Step asynchronously.
std::string devName
hold the device name, which this core simulate
unsigned char GetIOReg(unsigned addr)
Get a value from IO register (without offset of 0x20!)
int DebugRecentJumps[20]
Addresses of last few 'call' and 'jump' executed. For debugging.
unsigned int GetAddressAtSymbol(const std::string &s)
unsigned GetRegY(void)
Get value of Y register (16bit)
unsigned int GetMemTotalSize(void)
Get configured total memory space size.
unsigned int actualIrqVector
RWMemoryMember ** rw
The whole memory: R0-R31, IO, Internal RAM.
void SetClockFreq(SystemClockOffset f)
unsigned char GetCoreReg(unsigned addr)
Get a value from core register.
bool deferIrq
Almost always false.
void RemoveFromCycleList(Hardware *hw)
Removes from the cycle list, if possible.
void TraceNextLine(void)
Ends a trace line, performs reopen new filestream, if necessary.
bool SetCoreReg(unsigned addr, unsigned char val)
Set a value to core register.
unsigned long GetStackPointer() const
Returns current stack pointer value.
unsigned int devSignature
hold the device signature for this core
void Load(const char *n)
Load flash, eeprom, signature, fuses from elf file, wrapper for LoadBFD or LoadSimpleELF.
RWSreg * statusRegister
the memory interface for status
Hold data memory block and symbol informations.
void ReplaceIoRegister(unsigned int offset, RWMemoryMember *)
static DumpManager * Instance(void)
Singleton class access.
int Step(bool &untilCoreStepFinished, SystemClockOffset *nextStepIn_ns=0)
FlashProgramming * spmRegister
static const unsigned int totalIoSpace
void IrqHandlerFinished(unsigned int vector_index)
void AddToResetList(Hardware *hw)
int DebugRecentJumpsIndex
Index to address of the most recent jump.
void DebugOnJump()
When a call/jump/cond-jump instruction was executed. For debugging.