Project

General

Profile

MMU description » History » Version 104

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