Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / Memory.h
blob86e103c77a49ffe3faad66bbf086ec2b0189458d
1 #ifndef AVR_MEMORY_H
2 #define AVR_MEMORY_H
4 #include "Types.h"
6 namespace avr {
8 /**
9 * @author Tom Haber
10 * @date 21 April 2008
11 * @brief Abstraction of all types of memory.
13 * This class is an abstraction of all types of memory
14 * available on the chip: SRAM, ERAM, Flash.
16 * It allows read and write operations and maintains
17 * the raw data associated with the memory.
19 class Memory {
20 public:
21 Memory(unsigned int size);
22 virtual ~Memory();
24 public:
25 /**
26 * Reads \e size bytes of raw data from memory starting at
27 * offset \e offset. It returns a pointer to this data.
29 * \exception AccessViolation { When the data requested is
30 * not available, this exception is thrown }
32 const unsigned char *read(unsigned int offset, unsigned int size = 1) const;
34 /**
35 * Reads a single bytes of raw data from memory at
36 * offset \e offset.
38 * \exception AccessViolation { When the data requested is
39 * not available, this exception is thrown }
41 byte readByte(unsigned int offset) const;
43 /**
44 * Reads a word of raw data from memory starting at
45 * offset \e offset.
47 * \exception AccessViolation { When the data requested is
48 * not available, this exception is thrown }
50 word readWord(unsigned int offset) const;
52 /**
53 * Write \e size bytes of raw data to memory starting at
54 * offset \e offset. The data to be written is passed via
55 * the \e block variable.
57 * \exception AccessViolation { When the write exceeds
58 * amount of memory, this exception is thrown }
60 void write(unsigned int offset, unsigned char *block, unsigned int size = 1);
62 /**
63 * Fill the entire memory chunk with value \e val.
65 void fill(unsigned char val);
67 /**
68 * \returns the size of the memory chunk.
70 unsigned int size() const;
72 /**
73 * Dump the memory content to disk
75 void dump(const char *fname) const;
77 protected:
78 unsigned char *mem;
79 unsigned int siz;
82 inline unsigned int Memory::size() const {
83 return siz;
87 #endif /*AVR_MEMORY_H*/