MMU description » History » Version 103
Andrei Tatarnikov, 01/29/2015 11:37 AM
1 | 24 | Alexander Kamkin | h1. MMU Description |
---|---|---|---|
2 | 1 | Taya Sergeeva | |
3 | 66 | Alexander Kamkin | _~By Alexander Kamkin and Taya Sergeeva~_ |
4 | 62 | Alexander Kamkin | |
5 | 63 | Alexander Kamkin | {{toc}} |
6 | |||
7 | 35 | Alexander Kamkin | A _memory management unit_ (_MMU_) is known to be one of the most complex and error-prone components of a modern microprocessor. MicroTESK has a special subsystem, called _MMU subsystem_, intended for (1) specifying memory devices and (2) deriving testing knowledge from such specifications. The subsystem provides unified facilities for describing memory buffers (like _L1_ and _L2 caches_, _translation look-aside buffers_ (_TLBs_), etc.) as well as a means for connecting several buffers into a memory hierarchy. |
8 | 1 | Taya Sergeeva | |
9 | 72 | Alexander Kamkin | h2. Grammar |
10 | 66 | Alexander Kamkin | |
11 | <pre> |
||
12 | 102 | Andrei Tatarnikov | startRule |
13 | : declaration* EOF! |
||
14 | 66 | Alexander Kamkin | ; |
15 | 1 | Taya Sergeeva | |
16 | 102 | Andrei Tatarnikov | declaration |
17 | 66 | Alexander Kamkin | : address |
18 | 102 | Andrei Tatarnikov | | segment |
19 | 66 | Alexander Kamkin | | buffer |
20 | 102 | Andrei Tatarnikov | | mmu |
21 | 66 | Alexander Kamkin | ; |
22 | </pre> |
||
23 | |||
24 | 103 | Andrei Tatarnikov | The expression syntax is derived from nML/Sim-nML (see [[Sim-nML Language Reference]]). |
25 | 89 | Alexander Kamkin | |
26 | 91 | Alexander Kamkin | h2. Address Description (address) |
27 | 56 | Taya Sergeeva | |
28 | 1 | Taya Sergeeva | A buffer is accessed by an _address_, which is typically a _bit vector_ of a fixed length (width). Different buffers are allowed to have a common address space (e.g., L1 and L2 are usually both addressed by physical addresses). However, in general case, each buffer has its own domain. |
29 | |||
30 | 76 | Alexander Kamkin | An address space is described using a keyword @address@. The description can specify two parameters: @width@ (obligatory) and @format@ (optional). |
31 | 1 | Taya Sergeeva | |
32 | 75 | Alexander Kamkin | h3. Grammar |
33 | 69 | Alexander Kamkin | |
34 | <pre> |
||
35 | address |
||
36 | 90 | Alexander Kamkin | : ''address'' ID |
37 | (addressParameter)* |
||
38 | 69 | Alexander Kamkin | ; |
39 | |||
40 | addressParameter |
||
41 | : width |
||
42 | 97 | Alexander Kamkin | | segment |
43 | 69 | Alexander Kamkin | | format |
44 | ; |
||
45 | </pre> |
||
46 | |||
47 | 79 | Alexander Kamkin | h3. Address Width (width) |
48 | 1 | Taya Sergeeva | |
49 | 84 | Alexander Kamkin | The @width@ parameter specifies the address _width_. The parameter is obligatory; its value should be non-negative (zero-length addresses are permitted). |
50 | 1 | Taya Sergeeva | |
51 | 69 | Alexander Kamkin | h4. Grammar |
52 | |||
53 | <pre> |
||
54 | width |
||
55 | : ''width'' ''='' expr |
||
56 | ; |
||
57 | </pre> |
||
58 | |||
59 | 97 | Alexander Kamkin | h3. Address Space Segment (segment) |
60 | |||
61 | 99 | Alexander Kamkin | The @segment@ parameter specifies the address space _segment_. Any number (≥ 0) of segments (with different names) can be specified for one address. Each segment is characterized by its _name_ and _address range_. Different segments should have different names, but address ranges are allowed to overlap, and moreover, to be the same. |
62 | 97 | Alexander Kamkin | |
63 | h4. Grammar |
||
64 | |||
65 | <pre> |
||
66 | 1 | Taya Sergeeva | segment |
67 | 101 | Alexander Kamkin | : ''segment'' segmentID ''='' ''('' expr '','' expr '')'' |
68 | 97 | Alexander Kamkin | ; |
69 | </pre> |
||
70 | |||
71 | 68 | Alexander Kamkin | h3. Address Format (format) |
72 | 95 | Alexander Kamkin | |
73 | 98 | Alexander Kamkin | The @format@ parameter specifies the address _format_ (a number of named fields). Any number (≥ 0) of formats (with different names) can be specified for one address. |
74 | 94 | Alexander Kamkin | |
75 | A field has three attributes: a _name_, a _width_ and, optionally, an _initial value_. |
||
76 | 69 | Alexander Kamkin | |
77 | h4. Grammar |
||
78 | |||
79 | 1 | Taya Sergeeva | <pre> |
80 | format |
||
81 | 101 | Alexander Kamkin | : ''format'' formatID ''='' ''('' |
82 | 69 | Alexander Kamkin | field ('','' field)* |
83 | '')'' |
||
84 | ; |
||
85 | |||
86 | field |
||
87 | : ID '':'' expr (''='' expr)? |
||
88 | ; |
||
89 | </pre> |
||
90 | |||
91 | 72 | Alexander Kamkin | h2. Examples |
92 | 1 | Taya Sergeeva | |
93 | <pre> |
||
94 | 66 | Alexander Kamkin | // The singleton. |
95 | 90 | Alexander Kamkin | address Void |
96 | 1 | Taya Sergeeva | // The address width is zero (this is admissible for single-item buffers). |
97 | 90 | Alexander Kamkin | width = 0 |
98 | 66 | Alexander Kamkin | </pre> |
99 | 1 | Taya Sergeeva | |
100 | 88 | Alexander Kamkin | <pre> |
101 | 90 | Alexander Kamkin | // An unstructured 64-bit virtual addresses (VA). |
102 | 84 | Alexander Kamkin | address VA |
103 | 90 | Alexander Kamkin | // The address width. |
104 | 1 | Taya Sergeeva | width = 64 |
105 | </pre> |
||
106 | 66 | Alexander Kamkin | |
107 | <pre> |
||
108 | 90 | Alexander Kamkin | // A stuctured 40-bit physical addresses (PA). |
109 | 1 | Taya Sergeeva | address PA |
110 | 90 | Alexander Kamkin | // The address width. |
111 | 1 | Taya Sergeeva | width = 40 |
112 | 84 | Alexander Kamkin | // The address format: (<39..36>, TAG=<35..12>, INDEX=<11..5>, LOCAL=<4..0>). |
113 | 97 | Alexander Kamkin | format PA_L1 = ( |
114 | 84 | Alexander Kamkin | TAG : 24, // The tag (the <35..12> address bits). |
115 | 1 | Taya Sergeeva | INDEX : 7, // The set index (the <11..5> address bits). |
116 | LOCAL : 5, // The byte position (the <0..4> address bits). |
||
117 | 90 | Alexander Kamkin | ) |
118 | 84 | Alexander Kamkin | </pre> |
119 | 2 | Taya Sergeeva | |
120 | 91 | Alexander Kamkin | h2. Buffer Description (buffer) |
121 | 76 | Alexander Kamkin | |
122 | 1 | Taya Sergeeva | A buffer is described using a keyword @buffer@. The description specifies a set of parameters, including @ways@, @sets@, @format@, @index@, @match@ and @policy@. All of the parameters except @index@ (if @sets = 1@) and @policy@ are obligatory. |
123 | 75 | Alexander Kamkin | |
124 | h3. Grammar |
||
125 | 1 | Taya Sergeeva | |
126 | 75 | Alexander Kamkin | <pre> |
127 | 83 | Alexander Kamkin | buffer |
128 | 90 | Alexander Kamkin | : ''buffer'' bufferTypeID ''('' addressTypeID addressArgID '')'' |
129 | (bufferParameter)* |
||
130 | 75 | Alexander Kamkin | ; |
131 | |||
132 | bufferParameter |
||
133 | : ways |
||
134 | | sets |
||
135 | | format |
||
136 | | index |
||
137 | | match |
||
138 | | policy |
||
139 | ; |
||
140 | 1 | Taya Sergeeva | </pre> |
141 | |||
142 | 78 | Alexander Kamkin | h3. Buffer Associativity (ways) |
143 | |||
144 | 84 | Alexander Kamkin | The @ways@ parameter specifies the buffer _associativity_ (the number of lines in a set). The parameter is obligatory; its value should be positive. |
145 | 78 | Alexander Kamkin | |
146 | 1 | Taya Sergeeva | h4. Grammar |
147 | 80 | Alexander Kamkin | |
148 | <pre> |
||
149 | ways |
||
150 | : ''ways'' ''='' expr |
||
151 | 1 | Taya Sergeeva | ; |
152 | </pre> |
||
153 | |||
154 | 80 | Alexander Kamkin | h3. Buffer Length (sets) |
155 | 83 | Alexander Kamkin | |
156 | 84 | Alexander Kamkin | The @sets@ parameter specifies the buffer _length_ (the number of sets a cache). The parameter is obligatory; its value should be positive. |
157 | 78 | Alexander Kamkin | |
158 | 1 | Taya Sergeeva | h4. Grammar |
159 | 80 | Alexander Kamkin | |
160 | <pre> |
||
161 | 1 | Taya Sergeeva | sets |
162 | 80 | Alexander Kamkin | : ''sets'' ''='' expr |
163 | ; |
||
164 | 1 | Taya Sergeeva | </pre> |
165 | |||
166 | h3. Buffer Line Format (format) |
||
167 | 96 | Alexander Kamkin | |
168 | 98 | Alexander Kamkin | The @format@ parameter specifies the buffer _line format_ (a number of named fields). Any number (≥ 0) of formats (with different names) can be specified for one buffer. |
169 | 83 | Alexander Kamkin | |
170 | 82 | Alexander Kamkin | A field has three attributes: a name, a width and, optionally, an initial value. |
171 | |||
172 | h4. Grammar |
||
173 | 1 | Taya Sergeeva | |
174 | 82 | Alexander Kamkin | <pre> |
175 | 83 | Alexander Kamkin | format |
176 | 101 | Alexander Kamkin | : ''format'' formatID ''='' ''('' field ('','' field)* '')'' |
177 | 82 | Alexander Kamkin | ; |
178 | 1 | Taya Sergeeva | |
179 | field |
||
180 | : fieldID '':'' expr (''='' expr)? |
||
181 | ; |
||
182 | </pre> |
||
183 | |||
184 | h3. Buffer Index Function (index) |
||
185 | 83 | Alexander Kamkin | |
186 | 84 | Alexander Kamkin | The @index@ parameter specifies the _address-to-index function_, which maps an address into the set index. The function may be omitted if the number of sets is @1@. |
187 | 1 | Taya Sergeeva | |
188 | h4. Grammar |
||
189 | |||
190 | 83 | Alexander Kamkin | <pre> |
191 | 1 | Taya Sergeeva | index |
192 | 90 | Alexander Kamkin | : ''index'' ''='' expr |
193 | 83 | Alexander Kamkin | ; |
194 | </pre> |
||
195 | 1 | Taya Sergeeva | |
196 | h3. Buffer Match Predicate (match) |
||
197 | 83 | Alexander Kamkin | |
198 | 84 | Alexander Kamkin | The @match@ parameter specifies the _address-line match predicate_, which checks if an address matches a line. The parameter is obligatory. |
199 | 83 | Alexander Kamkin | |
200 | h4. Grammar |
||
201 | 1 | Taya Sergeeva | |
202 | 83 | Alexander Kamkin | <pre> |
203 | index |
||
204 | 90 | Alexander Kamkin | : ''match'' ''='' expr |
205 | 1 | Taya Sergeeva | ; |
206 | </pre> |
||
207 | 83 | Alexander Kamkin | |
208 | 1 | Taya Sergeeva | h3. Buffer Data Replacement Policy (policy) |
209 | |||
210 | 57 | Taya Sergeeva | The @policy@ parameters specifies the _data replacement_ (_eviction_) _policy_. The parameter is optional. The list of supported policies includes: @RANDOM@, @FIFO@, @PLRU@ and @LRU@. |
211 | 84 | Alexander Kamkin | |
212 | 1 | Taya Sergeeva | h4. Grammar |
213 | |||
214 | <pre> |
||
215 | policy |
||
216 | : ''policy'' ''='' policyID |
||
217 | 54 | Taya Sergeeva | ; |
218 | </pre> |
||
219 | |||
220 | 1 | Taya Sergeeva | h3. Examples |
221 | |||
222 | 84 | Alexander Kamkin | <pre> |
223 | 90 | Alexander Kamkin | // A 4-way set associative cache (L1) addressed by physical addresses (PA). |
224 | buffer L1(PA addr) |
||
225 | 84 | Alexander Kamkin | // The cache associativity. |
226 | 1 | Taya Sergeeva | ways = 4 |
227 | 84 | Alexander Kamkin | // The number of sets. |
228 | 90 | Alexander Kamkin | sets = 128 |
229 | 1 | Taya Sergeeva | // The line format. |
230 | 101 | Alexander Kamkin | format LINE = ( |
231 | 85 | Alexander Kamkin | V : 1 = 0, // The validity flag (by default, the line is invalid). |
232 | TAG : 24, // The tag (the <35..12> address bits). |
||
233 | 1 | Taya Sergeeva | DATA : 256 // The data (4 double words). |
234 | 90 | Alexander Kamkin | ) |
235 | // The address-to-index function (example: using address fields). |
||
236 | index = addr.INDEX |
||
237 | // The address-line predicate (example: using address bits). |
||
238 | 101 | Alexander Kamkin | match = addr<35..12> == LINE.TAG |
239 | 1 | Taya Sergeeva | // The data replacement policy (example: using predefined policy LRU - Least Recently Used). |
240 | policy = LRU |
||
241 | 91 | Alexander Kamkin | </pre> |
242 | |||
243 | h2. Memory Description (memory) |
||
244 | |||
245 | 92 | Alexander Kamkin | A memory is described using a keyword @memory@. The description includes two obligatory parameters @read@ and @write@. |
246 | |||
247 | 91 | Alexander Kamkin | h3. Grammar |
248 | |||
249 | <pre> |
||
250 | 1 | Taya Sergeeva | memory |
251 | 92 | Alexander Kamkin | : ''memory'' memoryTypeID ''('' addressTypeID addressArgID '')'' |
252 | 91 | Alexander Kamkin | (memoryParameter)* |
253 | ; |
||
254 | |||
255 | memoryParameter |
||
256 | : read |
||
257 | | write |
||
258 | ; |
||
259 | 1 | Taya Sergeeva | </pre> |
260 | 91 | Alexander Kamkin | |
261 | 92 | Alexander Kamkin | h3. Memory Read Action (read) |
262 | 1 | Taya Sergeeva | |
263 | 92 | Alexander Kamkin | The @read@ parameter specifies the _read action_, which is a sequence of statements describing how the read operation is to be performed (by means of data transfers between buffers). The parameter is obligatory. |
264 | |||
265 | 91 | Alexander Kamkin | h4. Grammar |
266 | |||
267 | <pre> |
||
268 | read |
||
269 | : ''read'' ''='' ''{'' sequence ''}'' |
||
270 | 1 | Taya Sergeeva | ; |
271 | </pre> |
||
272 | |||
273 | 92 | Alexander Kamkin | h3. Memory Write Action (write) |
274 | |||
275 | The @write@ parameter specifies the _read action_, which is a sequence of statements describing how the write operation is to be performed (by means of data transfers between buffers). The parameter is obligatory. |
||
276 | 91 | Alexander Kamkin | |
277 | h4. Grammar |
||
278 | |||
279 | <pre> |
||
280 | write |
||
281 | : ''write'' ''='' ''{'' sequence ''}'' |
||
282 | ; |
||
283 | </pre> |
||
284 | |||
285 | h3. Examples |
||
286 | |||
287 | <pre> |
||
288 | 93 | Alexander Kamkin | // A memory unit addressed by virtual addresses (VA). |
289 | memory Memory(VA addr) |
||
290 | // The read action. |
||
291 | 1 | Taya Sergeeva | read = { |
292 | 93 | Alexander Kamkin | // Some statements. |
293 | ... |
||
294 | 1 | Taya Sergeeva | } |
295 | 93 | Alexander Kamkin | // The write action. |
296 | 1 | Taya Sergeeva | write = { |
297 | 93 | Alexander Kamkin | // Some statements. |
298 | ... |
||
299 | 91 | Alexander Kamkin | } |
300 | 1 | Taya Sergeeva | </pre> |