MMU description » History » Version 113
Andrei Tatarnikov, 01/29/2015 02:13 PM
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 | 110 | Andrei Tatarnikov | An address space is described using a keyword @address@. The description includes the address type _identifier_ and the address _width_. The latter is specified in brackets. Its value should be non-negative (zero-length addresses are permitted). |
31 | 1 | Taya Sergeeva | |
32 | 75 | Alexander Kamkin | h3. Grammar |
33 | 69 | Alexander Kamkin | |
34 | <pre> |
||
35 | address |
||
36 | 104 | Andrei Tatarnikov | : ''address'' addressTypeID ''('' expr '')'' |
37 | 69 | Alexander Kamkin | ; |
38 | </pre> |
||
39 | |||
40 | 111 | Andrei Tatarnikov | h3. Examples |
41 | 106 | Andrei Tatarnikov | |
42 | <pre>// A 64-bit virtual address (VA). |
||
43 | address VA(64)</pre> |
||
44 | |||
45 | <pre>// A 36-bit physical address (PA). |
||
46 | address PA(36)</pre> |
||
47 | |||
48 | 112 | Andrei Tatarnikov | h2. Address Space Segment Description (segment) |
49 | 1 | Taya Sergeeva | |
50 | 112 | Andrei Tatarnikov | An address space segment is specified using the @segment@ keyword. A segment is associated with a specific address type. It is possible to specify any number (≥ 0) of segments (with different names) for one address type. Each segment is characterized by its _identifier_ and _address range_. Different segments should have different names, but address ranges are allowed to overlap, and moreover, to be the same. |
51 | 1 | Taya Sergeeva | |
52 | 112 | Andrei Tatarnikov | h3. Grammar |
53 | 69 | Alexander Kamkin | |
54 | <pre> |
||
55 | 112 | Andrei Tatarnikov | segment |
56 | : ''segment'' segmentID ''('' argumentID '':'' addressTypeID '')'' |
||
57 | ''range'' ''='' ''('' expr '','' expr '')'' |
||
58 | 99 | Alexander Kamkin | ; |
59 | 97 | Alexander Kamkin | </pre> |
60 | |||
61 | 112 | Andrei Tatarnikov | h3. Examples |
62 | 97 | Alexander Kamkin | |
63 | 1 | Taya Sergeeva | <pre> |
64 | 112 | Andrei Tatarnikov | segment USEG (va: VA) |
65 | range = (0x0000000000000000, 0x000000007fffffff) |
||
66 | 97 | Alexander Kamkin | </pre> |
67 | |||
68 | 72 | Alexander Kamkin | h2. Examples |
69 | 1 | Taya Sergeeva | |
70 | <pre> |
||
71 | 66 | Alexander Kamkin | // The singleton. |
72 | 90 | Alexander Kamkin | address Void |
73 | 1 | Taya Sergeeva | // The address width is zero (this is admissible for single-item buffers). |
74 | 90 | Alexander Kamkin | width = 0 |
75 | 66 | Alexander Kamkin | </pre> |
76 | 1 | Taya Sergeeva | |
77 | 88 | Alexander Kamkin | <pre> |
78 | 90 | Alexander Kamkin | // An unstructured 64-bit virtual addresses (VA). |
79 | 84 | Alexander Kamkin | address VA |
80 | 90 | Alexander Kamkin | // The address width. |
81 | 1 | Taya Sergeeva | width = 64 |
82 | </pre> |
||
83 | 66 | Alexander Kamkin | |
84 | <pre> |
||
85 | 90 | Alexander Kamkin | // A stuctured 40-bit physical addresses (PA). |
86 | 1 | Taya Sergeeva | address PA |
87 | 90 | Alexander Kamkin | // The address width. |
88 | 1 | Taya Sergeeva | width = 40 |
89 | 84 | Alexander Kamkin | // The address format: (<39..36>, TAG=<35..12>, INDEX=<11..5>, LOCAL=<4..0>). |
90 | 97 | Alexander Kamkin | format PA_L1 = ( |
91 | 84 | Alexander Kamkin | TAG : 24, // The tag (the <35..12> address bits). |
92 | 1 | Taya Sergeeva | INDEX : 7, // The set index (the <11..5> address bits). |
93 | LOCAL : 5, // The byte position (the <0..4> address bits). |
||
94 | 90 | Alexander Kamkin | ) |
95 | 84 | Alexander Kamkin | </pre> |
96 | 2 | Taya Sergeeva | |
97 | 91 | Alexander Kamkin | h2. Buffer Description (buffer) |
98 | 76 | Alexander Kamkin | |
99 | 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. |
100 | 75 | Alexander Kamkin | |
101 | h3. Grammar |
||
102 | 1 | Taya Sergeeva | |
103 | 75 | Alexander Kamkin | <pre> |
104 | 83 | Alexander Kamkin | buffer |
105 | 90 | Alexander Kamkin | : ''buffer'' bufferTypeID ''('' addressTypeID addressArgID '')'' |
106 | (bufferParameter)* |
||
107 | 75 | Alexander Kamkin | ; |
108 | |||
109 | bufferParameter |
||
110 | : ways |
||
111 | | sets |
||
112 | | format |
||
113 | | index |
||
114 | | match |
||
115 | | policy |
||
116 | ; |
||
117 | 1 | Taya Sergeeva | </pre> |
118 | |||
119 | 78 | Alexander Kamkin | h3. Buffer Associativity (ways) |
120 | |||
121 | 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. |
122 | 78 | Alexander Kamkin | |
123 | 1 | Taya Sergeeva | h4. Grammar |
124 | 80 | Alexander Kamkin | |
125 | <pre> |
||
126 | ways |
||
127 | : ''ways'' ''='' expr |
||
128 | 1 | Taya Sergeeva | ; |
129 | </pre> |
||
130 | |||
131 | 80 | Alexander Kamkin | h3. Buffer Length (sets) |
132 | 83 | Alexander Kamkin | |
133 | 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. |
134 | 78 | Alexander Kamkin | |
135 | 1 | Taya Sergeeva | h4. Grammar |
136 | 80 | Alexander Kamkin | |
137 | <pre> |
||
138 | 1 | Taya Sergeeva | sets |
139 | 80 | Alexander Kamkin | : ''sets'' ''='' expr |
140 | ; |
||
141 | 1 | Taya Sergeeva | </pre> |
142 | |||
143 | h3. Buffer Line Format (format) |
||
144 | 96 | Alexander Kamkin | |
145 | 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. |
146 | 83 | Alexander Kamkin | |
147 | 82 | Alexander Kamkin | A field has three attributes: a name, a width and, optionally, an initial value. |
148 | |||
149 | h4. Grammar |
||
150 | 1 | Taya Sergeeva | |
151 | 82 | Alexander Kamkin | <pre> |
152 | 83 | Alexander Kamkin | format |
153 | 101 | Alexander Kamkin | : ''format'' formatID ''='' ''('' field ('','' field)* '')'' |
154 | 82 | Alexander Kamkin | ; |
155 | 1 | Taya Sergeeva | |
156 | field |
||
157 | : fieldID '':'' expr (''='' expr)? |
||
158 | ; |
||
159 | </pre> |
||
160 | |||
161 | h3. Buffer Index Function (index) |
||
162 | 83 | Alexander Kamkin | |
163 | 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@. |
164 | 1 | Taya Sergeeva | |
165 | h4. Grammar |
||
166 | |||
167 | 83 | Alexander Kamkin | <pre> |
168 | 1 | Taya Sergeeva | index |
169 | 90 | Alexander Kamkin | : ''index'' ''='' expr |
170 | 83 | Alexander Kamkin | ; |
171 | </pre> |
||
172 | 1 | Taya Sergeeva | |
173 | h3. Buffer Match Predicate (match) |
||
174 | 83 | Alexander Kamkin | |
175 | 84 | Alexander Kamkin | The @match@ parameter specifies the _address-line match predicate_, which checks if an address matches a line. The parameter is obligatory. |
176 | 83 | Alexander Kamkin | |
177 | h4. Grammar |
||
178 | 1 | Taya Sergeeva | |
179 | 83 | Alexander Kamkin | <pre> |
180 | index |
||
181 | 90 | Alexander Kamkin | : ''match'' ''='' expr |
182 | 1 | Taya Sergeeva | ; |
183 | </pre> |
||
184 | 83 | Alexander Kamkin | |
185 | 1 | Taya Sergeeva | h3. Buffer Data Replacement Policy (policy) |
186 | |||
187 | 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@. |
188 | 84 | Alexander Kamkin | |
189 | 1 | Taya Sergeeva | h4. Grammar |
190 | |||
191 | <pre> |
||
192 | policy |
||
193 | : ''policy'' ''='' policyID |
||
194 | 54 | Taya Sergeeva | ; |
195 | </pre> |
||
196 | |||
197 | 1 | Taya Sergeeva | h3. Examples |
198 | |||
199 | 84 | Alexander Kamkin | <pre> |
200 | 90 | Alexander Kamkin | // A 4-way set associative cache (L1) addressed by physical addresses (PA). |
201 | buffer L1(PA addr) |
||
202 | 84 | Alexander Kamkin | // The cache associativity. |
203 | 1 | Taya Sergeeva | ways = 4 |
204 | 84 | Alexander Kamkin | // The number of sets. |
205 | 90 | Alexander Kamkin | sets = 128 |
206 | 1 | Taya Sergeeva | // The line format. |
207 | 101 | Alexander Kamkin | format LINE = ( |
208 | 85 | Alexander Kamkin | V : 1 = 0, // The validity flag (by default, the line is invalid). |
209 | TAG : 24, // The tag (the <35..12> address bits). |
||
210 | 1 | Taya Sergeeva | DATA : 256 // The data (4 double words). |
211 | 90 | Alexander Kamkin | ) |
212 | // The address-to-index function (example: using address fields). |
||
213 | index = addr.INDEX |
||
214 | // The address-line predicate (example: using address bits). |
||
215 | 101 | Alexander Kamkin | match = addr<35..12> == LINE.TAG |
216 | 1 | Taya Sergeeva | // The data replacement policy (example: using predefined policy LRU - Least Recently Used). |
217 | policy = LRU |
||
218 | 91 | Alexander Kamkin | </pre> |
219 | |||
220 | h2. Memory Description (memory) |
||
221 | |||
222 | 92 | Alexander Kamkin | A memory is described using a keyword @memory@. The description includes two obligatory parameters @read@ and @write@. |
223 | |||
224 | 91 | Alexander Kamkin | h3. Grammar |
225 | |||
226 | <pre> |
||
227 | 1 | Taya Sergeeva | memory |
228 | 92 | Alexander Kamkin | : ''memory'' memoryTypeID ''('' addressTypeID addressArgID '')'' |
229 | 91 | Alexander Kamkin | (memoryParameter)* |
230 | ; |
||
231 | |||
232 | memoryParameter |
||
233 | : read |
||
234 | | write |
||
235 | ; |
||
236 | 1 | Taya Sergeeva | </pre> |
237 | 91 | Alexander Kamkin | |
238 | 92 | Alexander Kamkin | h3. Memory Read Action (read) |
239 | 1 | Taya Sergeeva | |
240 | 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. |
241 | |||
242 | 91 | Alexander Kamkin | h4. Grammar |
243 | |||
244 | <pre> |
||
245 | read |
||
246 | : ''read'' ''='' ''{'' sequence ''}'' |
||
247 | 1 | Taya Sergeeva | ; |
248 | </pre> |
||
249 | |||
250 | 92 | Alexander Kamkin | h3. Memory Write Action (write) |
251 | |||
252 | 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. |
||
253 | 91 | Alexander Kamkin | |
254 | h4. Grammar |
||
255 | |||
256 | <pre> |
||
257 | write |
||
258 | : ''write'' ''='' ''{'' sequence ''}'' |
||
259 | ; |
||
260 | </pre> |
||
261 | |||
262 | h3. Examples |
||
263 | |||
264 | <pre> |
||
265 | 93 | Alexander Kamkin | // A memory unit addressed by virtual addresses (VA). |
266 | memory Memory(VA addr) |
||
267 | // The read action. |
||
268 | 1 | Taya Sergeeva | read = { |
269 | 93 | Alexander Kamkin | // Some statements. |
270 | ... |
||
271 | 1 | Taya Sergeeva | } |
272 | 93 | Alexander Kamkin | // The write action. |
273 | 1 | Taya Sergeeva | write = { |
274 | 93 | Alexander Kamkin | // Some statements. |
275 | ... |
||
276 | 91 | Alexander Kamkin | } |
277 | 1 | Taya Sergeeva | </pre> |