Project

General

Profile

MMU description » History » Version 87

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