Project

General

Profile

MMU description » History » Version 111

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