00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef AVRDEVICE
00027 #define AVRDEVICE
00028
00029 #include "systemclocktypes.h"
00030 #include "simulationmember.h"
00031 #include "pin.h"
00032 #include "net.h"
00033 #include "breakpoint.h"
00034 #include "traceval.h"
00035 #include "flashprog.h"
00036
00037 #include <string>
00038 #include <map>
00039
00040
00041 class HWSreg;
00042 class RWSreg;
00043
00044 class AvrFlash;
00045 class HWEeprom;
00046 class HWStack;
00047 class HWWado;
00048 class Data;
00049 class HWIrqSystem;
00050 class RWMemoryMember;
00051 class Hardware;
00052 class DumpManager;
00053 class AddressExtensionRegister;
00054
00056 class AvrDevice: public SimulationMember, public TraceValueRegister {
00057
00058 private:
00059 RWMemoryMember **invalidRW;
00060 const unsigned int ioSpaceSize;
00061 static const unsigned int totalIoSpace;
00062 static const unsigned int registerSpaceSize;
00063 const unsigned int iRamSize;
00064 const unsigned int eRamSize;
00065
00066 protected:
00067 SystemClockOffset clockFreq;
00068 std::map < std::string, Pin *> allPins;
00069 std::string actualFilename;
00070
00072 int cpuCycles;
00073
00074 public:
00075 int trace_on;
00076 Breakpoints BP;
00077 Exitpoints EP;
00078 word PC;
00079
00080 word cPC;
00081 int PC_size;
00082 AvrFlash *Flash;
00083 FlashProgramming * spmRegister;
00084 HWEeprom *eeprom;
00085 Data *data;
00086 HWIrqSystem *irqSystem;
00087 AddressExtensionRegister *rampz;
00088 AddressExtensionRegister *eind;
00089 bool abortOnInvalidAccess;
00090 TraceValueCoreRegister coreTraceGroup;
00091 bool instructionSEIJustEnabledInterrupts;
00092
00093 bool flagIWInstructions;
00094 bool flagJMPInstructions;
00095 bool flagIJMPInstructions;
00096 bool flagEIJMPInstructions;
00097 bool flagLPMInstructions;
00098 bool flagELPMInstructions;
00099 bool flagMULInstructions;
00100 bool flagMOVWInstruction;
00101 bool flagTiny10;
00102 bool flagTiny1x;
00103 bool flagXMega;
00104 int DebugRecentJumps[20];
00105 int DebugRecentJumpsIndex;
00106
00107 RWMemoryMember **rw;
00108
00109 HWStack *stack;
00110 HWSreg *status;
00111 RWSreg *statusRegister;
00112 HWWado *wado;
00113
00114 std::vector<Hardware *> hwResetList;
00115 std::vector<Hardware *> hwCycleList;
00116
00117 DumpManager *dump_manager;
00118
00119 AvrDevice(unsigned int ioSpaceSize, unsigned int IRamSize, unsigned int ERamSize, unsigned int flashSize);
00120 virtual ~AvrDevice();
00121
00124 void AddToResetList(Hardware *hw);
00125
00128 void AddToCycleList(Hardware *hw);
00129
00131
00132 void RemoveFromCycleList(Hardware *hw);
00133
00134 void Load(const char* n);
00135 void ReplaceIoRegister(unsigned int offset, RWMemoryMember *);
00136 bool ReplaceMemRegister(unsigned int offset, RWMemoryMember *);
00137 RWMemoryMember *GetMemRegisterInstance(unsigned int offset);
00138 void RegisterTerminationSymbol(const char *symbol);
00139
00140 Pin *GetPin(const char *name);
00144 int Step(bool &untilCoreStepFinished, SystemClockOffset *nextStepIn_ns =0);
00145 void Reset();
00146 void SetClockFreq(SystemClockOffset f);
00147 SystemClockOffset GetClockFreq();
00148
00149 void RegisterPin(const std::string &name, Pin *p) {
00150 allPins.insert(std::pair<std::string, Pin*>(name, p));
00151 }
00152
00154 void DeleteAllBreakpoints(void);
00155
00157 const std::string &GetFname(void) { return actualFilename; }
00158
00160 unsigned int GetMemTotalSize(void) { return totalIoSpace; }
00162 unsigned int GetMemIOSize(void) { return ioSpaceSize; }
00164 unsigned int GetMemRegisterSize(void) { return registerSpaceSize; }
00166 unsigned int GetMemIRamSize(void) { return iRamSize; }
00168 unsigned int GetMemERamSize(void) { return eRamSize; }
00169
00171 unsigned char GetRWMem(unsigned addr);
00173 bool SetRWMem(unsigned addr, unsigned char val);
00175 unsigned char GetCoreReg(unsigned addr);
00177 bool SetCoreReg(unsigned addr, unsigned char val);
00179 unsigned char GetIOReg(unsigned addr);
00181 bool SetIOReg(unsigned addr, unsigned char val);
00183
00187 bool SetIORegBit(unsigned addr, unsigned bitaddr, bool val);
00189 unsigned GetRegX(void);
00191 unsigned GetRegY(void);
00193 unsigned GetRegZ(void);
00194
00196 void DebugOnJump();
00197 };
00198
00199 #endif