Bug fix: check if vm exists
[avr-sim.git] / Flash.h
blobb0d40310fa6317387d50c9c40de2f19e16e9913e
1 #ifndef AVR_FLASH_H
2 #define AVR_FLASH_H
4 #include "Memory.h"
5 #include <vector>
7 namespace avr {
9 class Instruction;
11 /**
12 * \author Tom Haber
13 * \date 21 April 2008
15 * This class representes the Flash memory in the chip.
17 * It allows read and write operations and decodes
18 * instructions.
20 class Flash : public Memory {
21 public:
22 Flash(unsigned int size);
23 ~Flash();
25 public:
26 /**
27 * Write \e size bytes of raw data to memory starting at
28 * offset \e offset. The data to be written is passed via
29 * the \e block variable.
31 * \exception RuntimeException { When the write exceeds
32 * amount of memory, this exception is thrown }
34 void write(unsigned int offset, unsigned char *block, unsigned int size = 1);
36 private:
37 void decode(unsigned int offset, unsigned int size);
39 private:
40 // Decoded memory
41 std::vector<Instruction *> decodedMem;
45 #endif /*AVR_FLASH_H*/