Project

General

Profile

MMU description » History » Version 109

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