16 * TODO move all the memory related parts to MMU to reduce the interface size
28 Core(Bus
& bus
, unsigned int ioSpaceSize
,
29 unsigned int ramSize
, unsigned int flashSize
,
30 word stackMask
, int pcBytes
= 2, ERam
*eram
= 0);
35 void loadFlash(unsigned char *data
, unsigned int offset
, unsigned int size
);
40 void reset(unsigned int type
);
43 * Executes a single cpu cycle.
47 void setDebugInterface(DebugInterface
*dbgi
);
50 void addIOReg(unsigned int address
,
51 const std::string
& name
, byte initial
= 0);
52 const Register
& getR(int r
) const { return R
[r
]; }
53 IORegister
& getIoreg(unsigned int offset
);
54 IORegister
*getIoreg(const std::string
& name
);
57 byte
readRegister(int r
) const;
58 void writeRegister(int r
, byte val
);
59 byte
readStatus() const;
60 void writeStatus(byte val
);
61 byte
readIORegister(int r
) const;
62 void writeIORegister(int r
, byte val
);
63 byte
readByte(unsigned int addr
) const;
64 void writeByte(unsigned int addr
, byte val
);
65 byte
readFlash(unsigned int addr
) const;
66 int writeFlash(unsigned int addr
, word data
);
70 int pcBytes() const { return pc_bytes
; }
73 void jump(sbyte offset
, bool push
= false);
75 void call(dword address
, bool push
= true);
76 void ret(bool interrupt
= false);
80 bool interrupt(unsigned int vector
, unsigned int addr
);
95 static const unsigned int registerSpaceSize
= 32;
96 Register R
[registerSpaceSize
];
103 SLEEP_MODE_ADC_REDUX
= 1,
104 SLEEP_MODE_PWR_DOWN
= 2,
105 SLEEP_MODE_PWR_SAVE
= 3,
106 SLEEP_MODE_reserved1
= 4,
107 SLEEP_MODE_reserved2
= 5,
108 SLEEP_MODE_STANDBY
= 6,
109 SLEEP_MODE_EXT_STANDBY
= 7
113 std::list
<Analyzer
*> analyzers
;
116 DebugInterface
*dbgi
;
119 friend class DebugInterface
;
122 inline void Core::loadFlash(unsigned char *data
, unsigned int offset
, unsigned int size
) {
123 flash
.write(offset
, data
, size
);
126 inline void Core::setDebugInterface(DebugInterface
*dbgi
) {
130 inline IORegister
& Core::getIoreg(unsigned int offset
) {
131 return regs
.getIoreg(offset
);
134 inline IORegister
*Core::getIoreg(const std::string
& name
) {
135 return regs
.getIoreg(name
);
140 #endif /*AVR_CORE_H*/