14 * @brief Memory Mapping Unit
16 * Manages address decoding for memory accesses: maps the different
17 * regions to the correct classes.
21 MMU(unsigned int ioSpaceSize
, unsigned int ramSize
, ERam
*eram
= 0);
25 void addIOReg(unsigned int address
,
26 const std::string
& name
, byte initial
= 0);
27 const Register
& getR(int r
) const { return R
[r
]; }
29 Register
& reg(int r
);
30 const Register
& reg(int r
) const;
32 byte
statusReg() const;
34 IORegister
& getIoreg(unsigned int offset
);
35 const IORegister
& getIoreg(unsigned int offset
) const;
36 IORegister
*getIoreg(const std::string
& name
);
41 unsigned int ioregs() const { return regs
.size(); }
42 const std::string
& registerName(byte addr
) const;
46 * Reads a single bytes of raw data from memory at
49 * \exception AccessViolation { When the data requested is
50 * not available, this exception is thrown }
52 byte
readByte(unsigned int offset
) const;
55 * Reads a word of raw data from memory starting at
58 * \exception AccessViolation { When the data requested is
59 * not available, this exception is thrown }
61 word
readWord(unsigned int offset
) const;
64 * Reads a single bytes of raw data from memory at
67 * \exception AccessViolation { When the data requested is
68 * not available, this exception is thrown }
70 void writeByte(unsigned int offset
, byte val
);
73 * Reads a word of raw data from memory starting at
76 * \exception AccessViolation { When the data requested is
77 * not available, this exception is thrown }
79 void writeWord(unsigned int offset
, word val
);
81 const unsigned char *readRam(unsigned int offset
, unsigned int size
) const;
82 void writeRam(unsigned char *data
, unsigned int offset
, unsigned int size
);
85 static const unsigned int registerSpaceSize
= 32;
88 Register R
[registerSpaceSize
];
95 inline IORegister
& MMU::getIoreg(unsigned int offset
) {
96 return regs
.getIoreg(offset
);
99 inline const IORegister
& MMU::getIoreg(unsigned int offset
) const {
100 return regs
.getIoreg(offset
);
103 inline IORegister
*MMU::getIoreg(const std::string
& name
) {
104 return regs
.getIoreg(name
);
107 inline byte
MMU::statusReg() const {
108 return regs
.getIoreg("SREG")->getAddress() - registerSpaceSize
;
111 inline void MMU::reset() {
112 for(unsigned int i
= 0; i
< registerSpaceSize
; ++i
)
119 #endif /*AVR_MMU_H_*/