MMU description » History » Version 84
Alexander Kamkin, 12/02/2014 07:29 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 | 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). |
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 | 84 | 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 | 1 | Taya Sergeeva | // The singleton. |
81 | 66 | Alexander Kamkin | address Void { |
82 | 84 | Alexander Kamkin | // The address width is zero (this is admissible for single-item buffers). |
83 | 66 | Alexander Kamkin | width = 0; |
84 | } |
||
85 | </pre> |
||
86 | |||
87 | <pre> |
||
88 | 1 | Taya Sergeeva | // An unstructured 64-bit virtual addresses. |
89 | 66 | Alexander Kamkin | address VA { |
90 | 84 | Alexander Kamkin | // The address width. |
91 | 66 | Alexander Kamkin | width = 64; |
92 | } |
||
93 | </pre> |
||
94 | |||
95 | <pre> |
||
96 | 1 | Taya Sergeeva | // A stuctured 40-bit physical addresses. |
97 | address PA { |
||
98 | 84 | Alexander Kamkin | // The address width. |
99 | 1 | Taya Sergeeva | width = 40; |
100 | 84 | Alexander Kamkin | // The address format. |
101 | format = ( |
||
102 | TAG : 24, // The tag (the <35..12> address bits). |
||
103 | INDEX : 7, // The set index (the <11..5> address bits). |
||
104 | LOCAL : 5, // The byte position (the <0..4> address bits). |
||
105 | ); |
||
106 | 66 | Alexander Kamkin | } |
107 | </pre> |
||
108 | |||
109 | 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). |
||
110 | 10 | Alexander Kamkin | |
111 | 2 | Taya Sergeeva | h2. Buffer Description |
112 | 1 | Taya Sergeeva | |
113 | 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. |
114 | 1 | Taya Sergeeva | |
115 | 75 | Alexander Kamkin | h3. Grammar |
116 | |||
117 | 1 | Taya Sergeeva | <pre> |
118 | 75 | Alexander Kamkin | buffer |
119 | 83 | Alexander Kamkin | : ''buffer'' bufferTypeID ''{'' |
120 | 75 | Alexander Kamkin | (bufferParameter '';'')* |
121 | ''}'' |
||
122 | ; |
||
123 | |||
124 | bufferParameter |
||
125 | : ways |
||
126 | | sets |
||
127 | | format |
||
128 | | index |
||
129 | | match |
||
130 | | policy |
||
131 | ; |
||
132 | 1 | Taya Sergeeva | </pre> |
133 | |||
134 | 78 | Alexander Kamkin | h3. Buffer Associativity (ways) |
135 | |||
136 | 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. |
137 | 78 | Alexander Kamkin | |
138 | 1 | Taya Sergeeva | h4. Grammar |
139 | 80 | Alexander Kamkin | |
140 | <pre> |
||
141 | ways |
||
142 | : ''ways'' ''='' expr |
||
143 | 1 | Taya Sergeeva | ; |
144 | </pre> |
||
145 | |||
146 | 80 | Alexander Kamkin | h3. Buffer Length (sets) |
147 | 83 | Alexander Kamkin | |
148 | 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. |
149 | 78 | Alexander Kamkin | |
150 | 1 | Taya Sergeeva | h4. Grammar |
151 | 80 | Alexander Kamkin | |
152 | <pre> |
||
153 | sets |
||
154 | 1 | Taya Sergeeva | : ''sets'' ''='' expr |
155 | 80 | Alexander Kamkin | ; |
156 | </pre> |
||
157 | 1 | Taya Sergeeva | |
158 | h3. Buffer Line Format (format) |
||
159 | |||
160 | 84 | 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). |
161 | 82 | Alexander Kamkin | |
162 | 83 | Alexander Kamkin | A field has three attributes: a name, a width and, optionally, an initial value. |
163 | 82 | Alexander Kamkin | |
164 | h4. Grammar |
||
165 | |||
166 | <pre> |
||
167 | 83 | Alexander Kamkin | format |
168 | 82 | Alexander Kamkin | : ''format'' ''='' ''('' field ('','' field)* '')'' |
169 | 1 | Taya Sergeeva | ; |
170 | |||
171 | field |
||
172 | 83 | Alexander Kamkin | : fieldID '':'' expr (''='' expr)? |
173 | 1 | Taya Sergeeva | ; |
174 | </pre> |
||
175 | |||
176 | h3. Buffer Index Function (index) |
||
177 | 83 | Alexander Kamkin | |
178 | 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@. |
179 | 1 | Taya Sergeeva | |
180 | h4. Grammar |
||
181 | 83 | Alexander Kamkin | |
182 | 1 | Taya Sergeeva | <pre> |
183 | 83 | Alexander Kamkin | index |
184 | : ''index'' ''('' addressTypeID addressArgID '')'' ''='' expr |
||
185 | ; |
||
186 | </pre> |
||
187 | 1 | Taya Sergeeva | |
188 | h3. Buffer Match Predicate (match) |
||
189 | 83 | Alexander Kamkin | |
190 | 84 | Alexander Kamkin | The @match@ parameter specifies the _address-line match predicate_, which checks if an address matches a line. The parameter is obligatory. |
191 | 83 | Alexander Kamkin | |
192 | h4. Grammar |
||
193 | 1 | Taya Sergeeva | |
194 | 83 | Alexander Kamkin | <pre> |
195 | index |
||
196 | : ''match'' ''('' addressTypeID addressArgID '')'' ''='' expr |
||
197 | ; |
||
198 | 1 | Taya Sergeeva | </pre> |
199 | |||
200 | 57 | Taya Sergeeva | h3. Buffer Data Replacement Policy (policy) |
201 | |||
202 | 84 | 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@. |
203 | 57 | Taya Sergeeva | |
204 | h4. Grammar |
||
205 | 1 | Taya Sergeeva | |
206 | <pre> |
||
207 | policy |
||
208 | 49 | Taya Sergeeva | : ''policy'' ''='' policyID |
209 | 17 | Taya Sergeeva | ; |
210 | 54 | Taya Sergeeva | </pre> |
211 | |||
212 | h3. Examples |
||
213 | 1 | Taya Sergeeva | |
214 | <pre> |
||
215 | 84 | Alexander Kamkin | // A 4-way set associative cache (L1). |
216 | buffer L1 { |
||
217 | // The cache associativity. |
||
218 | ways = 4; |
||
219 | // The number of sets. |
||
220 | sets = 128; |
||
221 | // The line format. |
||
222 | format = ( |
||
223 | VAL : 1 = 0, // The validity flag (by default, the line is invalid). |
||
224 | TAG : 24, // The tag (the <35..12> address bits). |
||
225 | ROW : 256 // The data (4 double words). |
||
226 | ); |
||
227 | // The address-to-index function. |
||
228 | index(PA addr) = addr<11..5>; |
||
229 | // The address-line predicate. |
||
230 | match(PA addr) = addr<35..12> == TAG; |
||
231 | // The data replacement policy. |
||
232 | policy = LRU; |
||
233 | 1 | Taya Sergeeva | } |
234 | </pre> |