MMU description » History » Version 83
Alexander Kamkin, 12/02/2014 06:57 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 | 65 | Alexander Kamkin | *UNDER CONSTRUCTION* |
6 | |||
7 | 63 | Alexander Kamkin | {{toc}} |
8 | |||
9 | 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. |
10 | 1 | Taya Sergeeva | |
11 | 72 | Alexander Kamkin | h2. Grammar |
12 | 66 | Alexander Kamkin | |
13 | <pre> |
||
14 | startRule |
||
15 | : bufferOrAddress* |
||
16 | ; |
||
17 | |||
18 | bufferOrAddress |
||
19 | : address |
||
20 | | buffer |
||
21 | ; |
||
22 | </pre> |
||
23 | |||
24 | 1 | Taya Sergeeva | h2. Address Description |
25 | 56 | Taya Sergeeva | |
26 | 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. |
27 | |||
28 | 76 | Alexander Kamkin | An address space is described using a keyword @address@. The description can specify two parameters: @width@ (obligatory) and @format@ (optional). |
29 | 1 | Taya Sergeeva | |
30 | 75 | Alexander Kamkin | h3. Grammar |
31 | 69 | Alexander Kamkin | |
32 | <pre> |
||
33 | address |
||
34 | : ''address'' ID ''{'' |
||
35 | (addressParameter '';'')* |
||
36 | ''}'' |
||
37 | ; |
||
38 | |||
39 | addressParameter |
||
40 | : width |
||
41 | | format |
||
42 | ; |
||
43 | </pre> |
||
44 | |||
45 | 79 | Alexander Kamkin | h3. Address Width (width) |
46 | 1 | Taya Sergeeva | |
47 | 83 | Alexander Kamkin | The @width@ parameter specifies the address width. The parameter is obligatory; its value should be non-negative (zero-length addresses are permitted). |
48 | 1 | Taya Sergeeva | |
49 | 69 | Alexander Kamkin | h4. Grammar |
50 | |||
51 | <pre> |
||
52 | width |
||
53 | : ''width'' ''='' expr |
||
54 | ; |
||
55 | </pre> |
||
56 | |||
57 | 79 | Alexander Kamkin | h3. Address Format (format) |
58 | 68 | Alexander Kamkin | |
59 | 82 | Alexander Kamkin | The @format@ parameter specifies the address format (a number of named fields). The parameter is optional. By default, the address is unstructured (no fields are specified). |
60 | 1 | Taya Sergeeva | |
61 | 83 | Alexander Kamkin | A field has three attributes: a name, a width and, optionally, an initial value. |
62 | |||
63 | 69 | Alexander Kamkin | h4. Grammar |
64 | |||
65 | <pre> |
||
66 | format |
||
67 | : ''format'' ''='' ''('' |
||
68 | field ('','' field)* |
||
69 | '')'' |
||
70 | ; |
||
71 | |||
72 | field |
||
73 | : ID '':'' expr (''='' expr)? |
||
74 | ; |
||
75 | </pre> |
||
76 | |||
77 | 72 | Alexander Kamkin | h2. Examples |
78 | 69 | Alexander Kamkin | |
79 | 68 | Alexander Kamkin | <pre> |
80 | 66 | Alexander Kamkin | // The singleton. |
81 | address Void { |
||
82 | width = 0; |
||
83 | } |
||
84 | </pre> |
||
85 | |||
86 | <pre> |
||
87 | // An unstructured 64-bit virtual addresses. |
||
88 | address VA { |
||
89 | width = 64; |
||
90 | } |
||
91 | </pre> |
||
92 | |||
93 | <pre> |
||
94 | // A stuctured 40-bit physical addresses. |
||
95 | address PA { |
||
96 | width = 40; |
||
97 | format = (tag:24, l1Index:7, dwPosition:2, bytePosition:3); |
||
98 | } |
||
99 | </pre> |
||
100 | |||
101 | The code above defines three address spaces: (1) a singleton @Void@; (2) a space @VA@ consisting of 64-bit addresses (_virtual addresses_) and (3) a space @PA@ consisting of 40-bit addresses (_physical addresses_), each being divided into for fields: @tag@ (24 bits), @l1Index@ (7 bits), @dwPosition@ (2 bits) and @bytePosition@ (3 bits). |
||
102 | 10 | Alexander Kamkin | |
103 | 2 | Taya Sergeeva | h2. Buffer Description |
104 | 1 | Taya Sergeeva | |
105 | 76 | Alexander Kamkin | 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. |
106 | 1 | Taya Sergeeva | |
107 | 75 | Alexander Kamkin | h3. Grammar |
108 | |||
109 | 1 | Taya Sergeeva | <pre> |
110 | 75 | Alexander Kamkin | buffer |
111 | 83 | Alexander Kamkin | : ''buffer'' bufferTypeID ''{'' |
112 | 75 | Alexander Kamkin | (bufferParameter '';'')* |
113 | ''}'' |
||
114 | ; |
||
115 | |||
116 | bufferParameter |
||
117 | : ways |
||
118 | | sets |
||
119 | | format |
||
120 | | index |
||
121 | | match |
||
122 | | policy |
||
123 | ; |
||
124 | </pre> |
||
125 | 1 | Taya Sergeeva | |
126 | 78 | Alexander Kamkin | h3. Buffer Associativity (ways) |
127 | |||
128 | 83 | 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. |
129 | 80 | Alexander Kamkin | |
130 | 78 | Alexander Kamkin | h4. Grammar |
131 | 1 | Taya Sergeeva | |
132 | 80 | Alexander Kamkin | <pre> |
133 | ways |
||
134 | : ''ways'' ''='' expr |
||
135 | ; |
||
136 | 1 | Taya Sergeeva | </pre> |
137 | |||
138 | 80 | Alexander Kamkin | h3. Buffer Length (sets) |
139 | |||
140 | 83 | Alexander Kamkin | The @sets@ parameter specifies the buffer length (the number of sets a cache). The parameter is obligatory; its value should be positive. |
141 | 80 | Alexander Kamkin | |
142 | 78 | Alexander Kamkin | h4. Grammar |
143 | 1 | Taya Sergeeva | |
144 | 80 | Alexander Kamkin | <pre> |
145 | sets |
||
146 | : ''sets'' ''='' expr |
||
147 | ; |
||
148 | </pre> |
||
149 | 1 | Taya Sergeeva | |
150 | h3. Buffer Line Format (format) |
||
151 | |||
152 | 82 | Alexander Kamkin | The @format@ parameter specifies the buffer line format (a number of named fields). The parameter is optional. By default, the buffer line is unstructured (no fields are specified). |
153 | |||
154 | 83 | Alexander Kamkin | A field has three attributes: a name, a width and, optionally, an initial value. |
155 | 82 | Alexander Kamkin | |
156 | h4. Grammar |
||
157 | |||
158 | <pre> |
||
159 | format |
||
160 | 83 | Alexander Kamkin | : ''format'' ''='' ''('' field ('','' field)* '')'' |
161 | 82 | Alexander Kamkin | ; |
162 | 1 | Taya Sergeeva | |
163 | field |
||
164 | 83 | Alexander Kamkin | : fieldID '':'' expr (''='' expr)? |
165 | 1 | Taya Sergeeva | ; |
166 | </pre> |
||
167 | |||
168 | h3. Buffer Index Function (index) |
||
169 | |||
170 | 83 | Alexander Kamkin | The @index@ parameter specifies the index calculation function, which maps an address into the set index. The function may be omitted if the number of sets is @1@. |
171 | 1 | Taya Sergeeva | |
172 | h4. Grammar |
||
173 | |||
174 | 83 | Alexander Kamkin | <pre> |
175 | index |
||
176 | : ''index'' ''('' addressTypeID addressArgID '')'' ''='' expr |
||
177 | ; |
||
178 | </pre> |
||
179 | |||
180 | 1 | Taya Sergeeva | h3. Buffer Match Predicate (match) |
181 | |||
182 | 83 | Alexander Kamkin | The @match@ parameter specifies the line match predicate, which checks if an address matches a line. The parameter is obligatory. |
183 | 80 | Alexander Kamkin | |
184 | 83 | Alexander Kamkin | h4. Grammar |
185 | |||
186 | <pre> |
||
187 | index |
||
188 | : ''match'' ''('' addressTypeID addressArgID '')'' ''='' expr |
||
189 | ; |
||
190 | </pre> |
||
191 | |||
192 | 80 | Alexander Kamkin | h3. Buffer Data Replacement Policy (policy) |
193 | |||
194 | 83 | Alexander Kamkin | The @policy@ parameters specifies the data replacement (eviction) policy. The parameter is optional. The list of supported policies includes: @random@, @fifo@, @plru@ and @lru@. |
195 | 1 | Taya Sergeeva | |
196 | 80 | Alexander Kamkin | h4. Grammar |
197 | 83 | Alexander Kamkin | |
198 | <pre> |
||
199 | policy |
||
200 | : ''policy'' ''='' policyID |
||
201 | ; |
||
202 | </pre> |
||
203 | 78 | Alexander Kamkin | |
204 | 56 | Taya Sergeeva | h3. Examples |
205 | |||
206 | Let as consider a simple buffer which has only 2 attributes, such as the associativity, *associativity*, i.e. the set''s size, and the number of sets in the buffer, *sets*. |
||
207 | 75 | Alexander Kamkin | |
208 | <pre> |
||
209 | buffer TLB { |
||
210 | 1 | Taya Sergeeva | ways = 8; |
211 | sets = 64; |
||
212 | 57 | Taya Sergeeva | } |
213 | 56 | Taya Sergeeva | </pre> |
214 | 57 | Taya Sergeeva | |
215 | 56 | Taya Sergeeva | The example above describes translation lookaside buffer (_TLB_), which has an associativity being equal to 8, (i.e. the number of lines in one set in this TLB buffer is equal to 8), and has the number of lines being equal to 64. |
216 | |||
217 | 1 | Taya Sergeeva | Each *line* of the buffer can be described optionally by _tag_ and _data_ parameters. |
218 | 56 | Taya Sergeeva | For example, |
219 | 1 | Taya Sergeeva | |
220 | 56 | Taya Sergeeva | <pre> |
221 | 1 | Taya Sergeeva | line = (tag:22, data:1024); |
222 | 56 | Taya Sergeeva | </pre> |
223 | 57 | Taya Sergeeva | |
224 | 56 | Taya Sergeeva | describes lines of the cache, each of them containing a 22-bit tag and 1024-bit data. |
225 | 1 | Taya Sergeeva | |
226 | 57 | Taya Sergeeva | In a MMU buffer also can have the *index* computing function. When accessing data, the cache determines a set by calculating a x-bit index. For example, |
227 | 1 | Taya Sergeeva | |
228 | <pre> |
||
229 | 57 | Taya Sergeeva | index(addr:PA) = addr<14..13>; |
230 | 1 | Taya Sergeeva | </pre> |
231 | 57 | Taya Sergeeva | |
232 | The cache calculates a 2-bit index. _index_ returns the initial and the final points of the field kept in bytes. |
||
233 | 56 | Taya Sergeeva | |
234 | 57 | Taya Sergeeva | Each device stores some data which can be accessed (read from or written into) by their address. If a device contains a line with a given address, this situation is called a ''hit''; the opposite situation referes to as a ''miss''. If a ''miss'' occurs, the device usually displaces one of the set''s line with the line associated with the address given. The predicate which determines if there is a ''miss'' or ''hit'' situation is called *match*. There is the example below: |
235 | |||
236 | 1 | Taya Sergeeva | <pre> |
237 | line = (tag:22, data:1024); |
||
238 | match(addr:VA) = line.tag == addr<14..1>; |
||
239 | 49 | Taya Sergeeva | </pre> |
240 | 17 | Taya Sergeeva | |
241 | 54 | Taya Sergeeva | If the set contains a line with the tag equal to the 22 upper bits of the physical address, this is a ''hit''. _match_ returns ''true'' if there is a ''hit'' in the line, and returns ''false'' otherwise. |
242 | |||
243 | The strategy which will be used for the lines displacement is specified by *policy*. |
||
244 | 1 | Taya Sergeeva | |
245 | <pre> |
||
246 | 52 | Taya Sergeeva | policy = LRU; |
247 | 1 | Taya Sergeeva | </pre> |
248 | |||
249 | Example above sets the strategy of data replacement to be _Last_ _Recently_ _Used_ policy, i.e. if the ''miss'' occured, the cache displaces the least-recently-used line of the set. |
||
250 | 49 | Taya Sergeeva | |
251 | 1 | Taya Sergeeva | There is the example below, describing a real ''lower-level'' cache L1: |
252 | 54 | Taya Sergeeva | |
253 | 56 | Taya Sergeeva | <pre> |
254 | 52 | Taya Sergeeva | buffer L1 |
255 | 1 | Taya Sergeeva | { |
256 | 25 | Alexander Kamkin | associativity = 4; |
257 | sets = 128; |
||
258 | line = (tag:30, data:256); |
||
259 | index(addr:PA) = addr<9..8>; |
||
260 | match(addr:PA) = line.tag == addr<39..10>; |
||
261 | policy = lru; |
||
262 | } |
||
263 | </pre> |
||
264 | 1 | Taya Sergeeva | |
265 | _Description of each constructor_ in the buffer example is below: |