-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory_manage_data.h
90 lines (68 loc) · 2.66 KB
/
memory_manage_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//Copyright 2019 Hust.
//Author: HYL
//Descriptor:
/*This is a head file of manage Data area
*/
#include <unordered_map>
#include <iostream>
#include <vector>
#include <string>
#include "memory_manage.h"
#ifndef _MEMORY_MANAGE_DATA_H_
#define _MEMORY_MANAGE_DATA_H_
using namespace::std;
class MemoryManage;
class DataAreaManage : public MemoryManage {
public:
static DataAreaManage* getInstance() { //only one instance
if(data_manage_instance == NULL)
data_manage_instance = new DataAreaManage();
return data_manage_instance;
}
void InitialRomRange(vector<string>&, string&);
//Core fun to allocate data area to val.
DataStoreInfo CoreAllocateDataAreaFun(string, string, int);
//allocate data area to val, then call CreateDataAreaMapForVal
//to create map in data_area_addr_map
//the first parameter: is the variable name
//the second parameter: is the type of this variable name, now we
//just think this type is for array. if the type is struct, then
//there are more than one type.
//the third parameter: is the elem number of this variable
void AllocateDataAreaToVal(string, string, int);
void AllocateDataAreaToVal_2DArray(string, string, int, int, int);
//put DataStoreInfo data into data_area_addr_map
void CreateDataAreaMapForVal(string, DataStoreInfo);
//get actual addr via para str
vector<string> GetActualAddrFromVal(string, int);
vector<string> GetAllActualAddrFromVal(string);
//since difference type own difference number reg,
//now we want to get a whole addr from vector<string>
//addr.Return string result.
string IntegrateVectorAddr(vector<string>&);
vector<string> SplitStringAddrToVector(string);
//GetValueFromGiveDataAreaAddr is get the actual value(not addr
//name) from given data area. GetActualAddrFromVal is get the
//actual addr from data area
void GetValueFromGivenDataAreaAddr(string, int);
DataStoreInfo GetAllInfoFromVal(string);
private:
DataAreaManage(); //prohibit create object
static DataAreaManage* data_manage_instance; //single object
//---
//string initalAddr("3E00H"); //begin addr of data area
//string endAddr("3FFFH"); //end addr of data area
static long int begin_addr_dataArea;// = 15872;
static long int end_addr_dataArea;// = 16384;
//the total size of data area
const int kTotalArea = 512;
//available used data area addr
static int available_data_area_addr;// = 512;
//how many addr have been used
static int have_used_data_area_addr;// = 0;
/*data_addr_map stores the map between the virtual reg
*like constant array and actual data area like 3E00H
*/
static unordered_map<string, DataStoreInfo> data_area_addr_map;
};
#endif