1 | #ifndef ENVIRONMENT_CACHE_PARAMETERS_H |
---|
2 | #define ENVIRONMENT_CACHE_PARAMETERS_H |
---|
3 | |
---|
4 | #include <iostream> |
---|
5 | #include <math.h> |
---|
6 | |
---|
7 | #include "Cache_MultiLevel_Parameters.h" |
---|
8 | |
---|
9 | namespace environment { |
---|
10 | namespace cache { |
---|
11 | |
---|
12 | class Parameters |
---|
13 | { |
---|
14 | public : uint32_t nb_cache_dedicated; |
---|
15 | public : uint32_t nb_iport; |
---|
16 | public : uint32_t nb_dport; |
---|
17 | |
---|
18 | public : cache_multilevel::Parameters ** param_icache_dedicated; |
---|
19 | public : cache_multilevel::Parameters ** param_dcache_dedicated; |
---|
20 | public : cache_multilevel::Parameters * param_cache_shared; |
---|
21 | |
---|
22 | public : Parameters (uint32_t nb_cache_dedicated , |
---|
23 | uint32_t * icache_dedicated_nb_level , |
---|
24 | uint32_t * icache_dedicated_nb_port , |
---|
25 | uint32_t ** icache_dedicated_nb_line , |
---|
26 | uint32_t ** icache_dedicated_size_line , |
---|
27 | uint32_t ** icache_dedicated_size_word , |
---|
28 | uint32_t ** icache_dedicated_associativity, |
---|
29 | uint32_t ** icache_dedicated_hit_latence , |
---|
30 | uint32_t ** icache_dedicated_miss_penality, |
---|
31 | uint32_t * dcache_dedicated_nb_level , |
---|
32 | uint32_t * dcache_dedicated_nb_port , |
---|
33 | uint32_t ** dcache_dedicated_nb_line , |
---|
34 | uint32_t ** dcache_dedicated_size_line , |
---|
35 | uint32_t ** dcache_dedicated_size_word , |
---|
36 | uint32_t ** dcache_dedicated_associativity, |
---|
37 | uint32_t ** dcache_dedicated_hit_latence , |
---|
38 | uint32_t ** dcache_dedicated_miss_penality, |
---|
39 | uint32_t cache_shared_nb_level , |
---|
40 | // uint32_t cache_shared_nb_port , |
---|
41 | uint32_t * cache_shared_nb_line , |
---|
42 | uint32_t * cache_shared_size_line , |
---|
43 | uint32_t * cache_shared_size_word , |
---|
44 | uint32_t * cache_shared_associativity , |
---|
45 | uint32_t * cache_shared_hit_latence , |
---|
46 | uint32_t * cache_shared_miss_penality ) |
---|
47 | { |
---|
48 | this->nb_cache_dedicated = nb_cache_dedicated; |
---|
49 | |
---|
50 | if (nb_cache_dedicated == 0) |
---|
51 | { |
---|
52 | std::cerr << "[ ERROR ] nb_cache_dedicated > 0" << std::endl; |
---|
53 | exit(0); |
---|
54 | } |
---|
55 | |
---|
56 | uint32_t cache_shared_nb_port = 0; |
---|
57 | nb_iport = 0; |
---|
58 | nb_dport = 0; |
---|
59 | |
---|
60 | for (uint32_t i=0; i<nb_cache_dedicated; i++) |
---|
61 | { |
---|
62 | nb_iport += icache_dedicated_nb_port [i]; |
---|
63 | nb_dport += dcache_dedicated_nb_port [i]; |
---|
64 | cache_shared_nb_port += icache_dedicated_nb_port [i]; |
---|
65 | cache_shared_nb_port += dcache_dedicated_nb_port [i]; |
---|
66 | } |
---|
67 | |
---|
68 | param_cache_shared = new cache_multilevel::Parameters |
---|
69 | (cache_shared_nb_level , |
---|
70 | cache_shared_nb_port , |
---|
71 | cache_shared_nb_line , |
---|
72 | cache_shared_size_line , |
---|
73 | cache_shared_size_word , |
---|
74 | cache_shared_associativity , |
---|
75 | cache_shared_hit_latence , |
---|
76 | cache_shared_miss_penality ); |
---|
77 | |
---|
78 | param_icache_dedicated = new cache_multilevel::Parameters * [nb_cache_dedicated]; |
---|
79 | param_dcache_dedicated = new cache_multilevel::Parameters * [nb_cache_dedicated]; |
---|
80 | |
---|
81 | for (uint32_t i=0; i<nb_cache_dedicated; i++) |
---|
82 | { |
---|
83 | param_icache_dedicated [i] = new cache_multilevel::Parameters |
---|
84 | (icache_dedicated_nb_level [i], |
---|
85 | icache_dedicated_nb_port [i], |
---|
86 | icache_dedicated_nb_line [i], |
---|
87 | icache_dedicated_size_line [i], |
---|
88 | icache_dedicated_size_word [i], |
---|
89 | icache_dedicated_associativity [i], |
---|
90 | icache_dedicated_hit_latence [i], |
---|
91 | icache_dedicated_miss_penality [i]); |
---|
92 | |
---|
93 | param_dcache_dedicated [i] = new cache_multilevel::Parameters |
---|
94 | (dcache_dedicated_nb_level [i], |
---|
95 | dcache_dedicated_nb_port [i], |
---|
96 | dcache_dedicated_nb_line [i], |
---|
97 | dcache_dedicated_size_line [i], |
---|
98 | dcache_dedicated_size_word [i], |
---|
99 | dcache_dedicated_associativity [i], |
---|
100 | dcache_dedicated_hit_latence [i], |
---|
101 | dcache_dedicated_miss_penality [i]); |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | public : ~Parameters (void) |
---|
106 | { |
---|
107 | for (uint32_t i=0; i<nb_cache_dedicated; i++) |
---|
108 | { |
---|
109 | delete param_icache_dedicated [i]; |
---|
110 | delete param_dcache_dedicated [i]; |
---|
111 | } |
---|
112 | delete [] param_icache_dedicated; |
---|
113 | delete [] param_dcache_dedicated; |
---|
114 | delete param_cache_shared; |
---|
115 | } |
---|
116 | |
---|
117 | public : std::string print (uint32_t depth) |
---|
118 | { |
---|
119 | std::string tab (depth,'\t'); |
---|
120 | std::stringstream str (""); |
---|
121 | |
---|
122 | str << tab << "* Nb Cache dedicated : " << nb_cache_dedicated << std::endl |
---|
123 | << tab << "* Nb iport : " << nb_iport << std::endl |
---|
124 | << tab << "* Nb dport : " << nb_dport << std::endl |
---|
125 | ; |
---|
126 | |
---|
127 | for (uint32_t i=0; i<nb_cache_dedicated; i++) |
---|
128 | str << tab << " * ICACHE DEDICATED " << i << std::endl |
---|
129 | << param_icache_dedicated [i]->print(depth+1) << std::endl; |
---|
130 | |
---|
131 | for (uint32_t i=0; i<nb_cache_dedicated; i++) |
---|
132 | str << tab << " * DCACHE DEDICATED " << i << std::endl |
---|
133 | << param_dcache_dedicated [i]->print(depth+1) << std::endl; |
---|
134 | |
---|
135 | str << tab << " * CACHE SHARED" << std::endl; |
---|
136 | str << param_cache_shared->print(depth+1) << std::endl; |
---|
137 | |
---|
138 | return str.str(); |
---|
139 | } |
---|
140 | |
---|
141 | friend std::ostream& operator<< (std::ostream& output, Parameters &x) |
---|
142 | { |
---|
143 | output << x.print(0); |
---|
144 | return output; |
---|
145 | } |
---|
146 | }; |
---|
147 | |
---|
148 | }; |
---|
149 | }; |
---|
150 | #endif |
---|