disasm/sim: changed interface, branch => br, features++
[calu.git] / 3b_sim / cpmem.hpp
1 #ifndef __CPMEM_H__
2 #define __CPMEM_H__
3
4 template <typename T>
5 class CPMem;
6
7 #include "cdat.hpp"
8 #include <vector>
9 #include <stdexcept>
10 #include <stdlib.h>
11
12 #include "Iinstr.hpp"
13
14 typedef int MEMORY_ADDRESS;
15
16 /**
17  * Name:    CMem
18  * Purpose: Class representing the memory of our emulated machine
19  */
20 template <typename T>
21 class CPMem
22 {
23 private:
24         //MAX_MEMORY-1 zugreifbare Speicherzellen
25         const int MAX_MEMORY;
26         std::vector<T> m_memory;
27 public:
28         //wert aus referenz auslesen und in vetor speichern (index zugriff!)
29         //address 0 ist ProgramCounter
30         void set(const MEMORY_ADDRESS address, const T data);
31         //retuniert referenz eines cdat objekts mit dem Wert von address
32         T get(const MEMORY_ADDRESS address) const;
33         CPMem(int size) : MAX_MEMORY(size), m_memory(size, NULL) {};
34         ~CPMem();
35 };
36
37 #endif