MMU description » History » Version 88
Alexander Kamkin, 12/02/2014 07:38 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 | startRule |
||
13 | : bufferOrAddress* |
||
14 | ; |
||
15 | |||
16 | bufferOrAddress |
||
17 | : address |
||
18 | | buffer |
||
19 | ; |
||
20 | </pre> |
||
21 | |||
22 | 1 | Taya Sergeeva | h2. Address Description |
23 | 56 | Taya Sergeeva | |
24 | 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. |
25 | |||
26 | 76 | Alexander Kamkin | An address space is described using a keyword @address@. The description can specify two parameters: @width@ (obligatory) and @format@ (optional). |
27 | 1 | Taya Sergeeva | |
28 | 75 | Alexander Kamkin | h3. Grammar |
29 | 69 | Alexander Kamkin | |
30 | <pre> |
||
31 | address |
||
32 | : ''address'' ID ''{'' |
||
33 | (addressParameter '';'')* |
||
34 | ''}'' |
||
35 | ; |
||
36 | |||
37 | addressParameter |
||
38 | : width |
||
39 | | format |
||
40 | ; |
||
41 | </pre> |
||
42 | |||
43 | 79 | Alexander Kamkin | h3. Address Width (width) |
44 | 1 | Taya Sergeeva | |
45 | 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). |
46 | 1 | Taya Sergeeva | |
47 | 69 | Alexander Kamkin | h4. Grammar |
48 | |||
49 | <pre> |
||
50 | width |
||
51 | : ''width'' ''='' expr |
||
52 | ; |
||
53 | </pre> |
||
54 | |||
55 | 79 | Alexander Kamkin | h3. Address Format (format) |
56 | 68 | Alexander Kamkin | |
57 | 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). |
58 | 1 | Taya Sergeeva | |
59 | 86 | Alexander Kamkin | A field has three attributes: a _name_, a _width_ and, optionally, an _initial value_. |
60 | 83 | Alexander Kamkin | |
61 | 69 | Alexander Kamkin | h4. Grammar |
62 | |||
63 | <pre> |
||
64 | format |
||
65 | : ''format'' ''='' ''('' |
||
66 | field ('','' field)* |
||
67 | '')'' |
||
68 | ; |
||
69 | |||
70 | field |
||
71 | : ID '':'' expr (''='' expr)? |
||
72 | ; |
||
73 | </pre> |
||
74 | |||
75 | 72 | Alexander Kamkin | h2. Examples |
76 | 69 | Alexander Kamkin | |
77 | 68 | Alexander Kamkin | <pre> |
78 | 1 | Taya Sergeeva | // The singleton. |
79 | 66 | Alexander Kamkin | address Void { |
80 | 84 | Alexander Kamkin | // The address width is zero (this is admissible for single-item buffers). |
81 | 66 | Alexander Kamkin | width = 0; |
82 | } |
||
83 | </pre> |
||
84 | 1 | Taya Sergeeva | |
85 | 66 | Alexander Kamkin | <pre> |
86 | 88 | Alexander Kamkin | // An unstructured 64-bit virtual addresses (VA). |
87 | 66 | Alexander Kamkin | address VA { |
88 | 84 | Alexander Kamkin | // The address width. |
89 | 66 | Alexander Kamkin | width = 64; |
90 | } |
||
91 | 1 | Taya Sergeeva | </pre> |
92 | 66 | Alexander Kamkin | |
93 | <pre> |
||
94 | 88 | Alexander Kamkin | // A stuctured 40-bit physical addresses (PA). |
95 | 1 | Taya Sergeeva | address PA { |
96 | 84 | Alexander Kamkin | // The address width. |
97 | 1 | Taya Sergeeva | width = 40; |
98 | 87 | Alexander Kamkin | // The address format: (<39..36>, TAG=<35..12>, INDEX=<11..5>, LOCAL=<4..0>). |
99 | 84 | Alexander Kamkin | format = ( |
100 | TAG : 24, // The tag (the <35..12> address bits). |
||
101 | INDEX : 7, // The set index (the <11..5> address bits). |
||
102 | LOCAL : 5, // The byte position (the <0..4> address bits). |
||
103 | ); |
||
104 | 66 | Alexander Kamkin | } |
105 | </pre> |
||
106 | |||
107 | 2 | Taya Sergeeva | h2. Buffer Description |
108 | 1 | Taya Sergeeva | |
109 | 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. |
110 | 1 | Taya Sergeeva | |
111 | 75 | Alexander Kamkin | h3. Grammar |
112 | |||
113 | 1 | Taya Sergeeva | <pre> |
114 | 75 | Alexander Kamkin | buffer |
115 | 83 | Alexander Kamkin | : ''buffer'' bufferTypeID ''{'' |
116 | 75 | Alexander Kamkin | (bufferParameter '';'')* |
117 | ''}'' |
||
118 | ; |
||
119 | |||
120 | bufferParameter |
||
121 | : ways |
||
122 | | sets |
||
123 | | format |
||
124 | | index |
||
125 | | match |
||
126 | | policy |
||
127 | ; |
||
128 | 1 | Taya Sergeeva | </pre> |
129 | |||
130 | 78 | Alexander Kamkin | h3. Buffer Associativity (ways) |
131 | |||
132 | 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. |
133 | 78 | Alexander Kamkin | |
134 | 1 | Taya Sergeeva | h4. Grammar |
135 | 80 | Alexander Kamkin | |
136 | <pre> |
||
137 | ways |
||
138 | : ''ways'' ''='' expr |
||
139 | 1 | Taya Sergeeva | ; |
140 | </pre> |
||
141 | |||
142 | 80 | Alexander Kamkin | h3. Buffer Length (sets) |
143 | 83 | Alexander Kamkin | |
144 | 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. |
145 | 78 | Alexander Kamkin | |
146 | 1 | Taya Sergeeva | h4. Grammar |
147 | 80 | Alexander Kamkin | |
148 | <pre> |
||
149 | sets |
||
150 | 1 | Taya Sergeeva | : ''sets'' ''='' expr |
151 | 80 | Alexander Kamkin | ; |
152 | </pre> |
||
153 | 1 | Taya Sergeeva | |
154 | h3. Buffer Line Format (format) |
||
155 | |||
156 | 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). |
157 | 82 | Alexander Kamkin | |
158 | 83 | Alexander Kamkin | A field has three attributes: a name, a width and, optionally, an initial value. |
159 | 82 | Alexander Kamkin | |
160 | h4. Grammar |
||
161 | |||
162 | <pre> |
||
163 | 83 | Alexander Kamkin | format |
164 | 82 | Alexander Kamkin | : ''format'' ''='' ''('' field ('','' field)* '')'' |
165 | 1 | Taya Sergeeva | ; |
166 | |||
167 | field |
||
168 | 83 | Alexander Kamkin | : fieldID '':'' expr (''='' expr)? |
169 | 1 | Taya Sergeeva | ; |
170 | </pre> |
||
171 | |||
172 | h3. Buffer Index Function (index) |
||
173 | 83 | Alexander Kamkin | |
174 | 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@. |
175 | 1 | Taya Sergeeva | |
176 | h4. Grammar |
||
177 | 83 | Alexander Kamkin | |
178 | 1 | Taya Sergeeva | <pre> |
179 | 83 | Alexander Kamkin | index |
180 | : ''index'' ''('' addressTypeID addressArgID '')'' ''='' expr |
||
181 | ; |
||
182 | </pre> |
||
183 | 1 | Taya Sergeeva | |
184 | h3. Buffer Match Predicate (match) |
||
185 | 83 | Alexander Kamkin | |
186 | 84 | Alexander Kamkin | The @match@ parameter specifies the _address-line match predicate_, which checks if an address matches a line. The parameter is obligatory. |
187 | 83 | Alexander Kamkin | |
188 | h4. Grammar |
||
189 | 1 | Taya Sergeeva | |
190 | 83 | Alexander Kamkin | <pre> |
191 | index |
||
192 | : ''match'' ''('' addressTypeID addressArgID '')'' ''='' expr |
||
193 | ; |
||
194 | 1 | Taya Sergeeva | </pre> |
195 | |||
196 | 57 | Taya Sergeeva | h3. Buffer Data Replacement Policy (policy) |
197 | |||
198 | 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@. |
199 | 57 | Taya Sergeeva | |
200 | h4. Grammar |
||
201 | 1 | Taya Sergeeva | |
202 | <pre> |
||
203 | policy |
||
204 | 49 | Taya Sergeeva | : ''policy'' ''='' policyID |
205 | 17 | Taya Sergeeva | ; |
206 | 54 | Taya Sergeeva | </pre> |
207 | |||
208 | h3. Examples |
||
209 | 1 | Taya Sergeeva | |
210 | <pre> |
||
211 | 84 | Alexander Kamkin | // A 4-way set associative cache (L1). |
212 | buffer L1 { |
||
213 | // The cache associativity. |
||
214 | ways = 4; |
||
215 | // The number of sets. |
||
216 | sets = 128; |
||
217 | 1 | Taya Sergeeva | // The line format. |
218 | format = ( |
||
219 | 85 | Alexander Kamkin | V : 1 = 0, // The validity flag (by default, the line is invalid). |
220 | TAG : 24, // The tag (the <35..12> address bits). |
||
221 | DATA : 256 // The data (4 double words). |
||
222 | 84 | Alexander Kamkin | ); |
223 | 1 | Taya Sergeeva | // The address-to-index function. |
224 | 84 | Alexander Kamkin | index(PA addr) = addr<11..5>; |
225 | // The address-line predicate. |
||
226 | match(PA addr) = addr<35..12> == TAG; |
||
227 | 88 | Alexander Kamkin | // The data replacement policy (LRU, Least Recently Used). |
228 | 84 | Alexander Kamkin | policy = LRU; |
229 | 1 | Taya Sergeeva | } |
230 | </pre> |