Project

General

Profile

MMU description » History » Version 82

Alexander Kamkin, 12/02/2014 06:28 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 82 Alexander Kamkin
The @width@ parameter specifies the address width. The parameter is obligatory, and 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 82 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 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 66 Alexander Kamkin
// The singleton.
79
address Void {
80
  width = 0;
81
}
82
</pre>
83
84
<pre>
85
// An unstructured 64-bit virtual addresses.
86
address VA {
87
  width = 64;
88
}
89
</pre>
90
91
<pre>
92
// A stuctured 40-bit physical addresses.
93
address PA {
94
  width = 40;
95
  format = (tag:24, l1Index:7, dwPosition:2, bytePosition:3);
96
}
97
</pre>
98
99
The code above defines three address spaces: (1) a singleton @Void@; (2) a space @VA@ consisting of 64-bit addresses (_virtual addresses_) and (3) a space @PA@ consisting of 40-bit addresses (_physical addresses_), each being divided into for fields: @tag@ (24 bits), @l1Index@ (7 bits), @dwPosition@ (2 bits) and @bytePosition@ (3 bits).
100 10 Alexander Kamkin
101 2 Taya Sergeeva
h2. Buffer Description
102 1 Taya Sergeeva
103 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.
104 1 Taya Sergeeva
105 75 Alexander Kamkin
h3. Grammar
106
107
<pre>
108
buffer
109
    : ''buffer'' ID ''{''
110
        (bufferParameter '';'')*
111
      ''}''
112
    ;
113
114
bufferParameter
115
    : ways
116
    | sets
117
    | format
118
    | index
119
    | match
120
    | policy
121
    ;
122
</pre>
123
124 78 Alexander Kamkin
h3. Buffer Associativity (ways)
125
126 82 Alexander Kamkin
The @ways@ parameter specifies the buffer associativity (the number of lines in a set). The parameter is obligatory, and its value should be positive.
127 80 Alexander Kamkin
128 78 Alexander Kamkin
h4. Grammar
129 1 Taya Sergeeva
130 80 Alexander Kamkin
<pre>
131
ways
132
    : ''ways'' ''='' expr
133
    ;
134
</pre>
135 1 Taya Sergeeva
136 80 Alexander Kamkin
h3. Buffer Length (sets)
137
138 82 Alexander Kamkin
The @sets@ parameter specifies the buffer length (the number of lines a cache). The parameter is obligatory, and its value should be positive.
139 80 Alexander Kamkin
140 78 Alexander Kamkin
h4. Grammar
141 1 Taya Sergeeva
142 80 Alexander Kamkin
<pre>
143
sets
144
    : ''sets'' ''='' expr
145
    ;
146 1 Taya Sergeeva
</pre>
147 80 Alexander Kamkin
148 1 Taya Sergeeva
h3. Buffer Line Format (format)
149
150 82 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).
151 1 Taya Sergeeva
152 82 Alexander Kamkin
A field has three attributes: name, width and, optionally, initial value.
153
154 1 Taya Sergeeva
h4. Grammar
155 82 Alexander Kamkin
156
<pre>
157
format
158
    : ''format'' ''='' ''(''
159
        field ('','' field)*
160
      '')''
161
    ;
162
163
field
164
    : ID '':'' expr (''='' expr)?
165
    ;
166
</pre>
167 78 Alexander Kamkin
168
h3. Buffer Index Function (index)
169 1 Taya Sergeeva
170 80 Alexander Kamkin
   _index_ is the function for index calculation;
171
   returns the initial and the final points of the field kept in bytes; they are marked in a three-cornered brackets, after _addr_; in our case index has 2 bits;
172
  _index_ depends on an _address_, which is ''physical'' (PA) in our case; the type of an address is set in the braces after _index_; 
173
174 78 Alexander Kamkin
h4. Grammar
175
176
h3. Buffer Match Predicate (match)
177 1 Taya Sergeeva
178 80 Alexander Kamkin
  _match_ is a predicate checking whether the line and the address match each other or not;
179
  it returns ''true'' or ''false'' depending on if the data required is in the given line or not; 
180
  it returns ''true'' if there is a ''hit'' in the line, and returns ''false'' otherwise; if the set contains a line with the tag equal to the 30 upper bits of the physical address, this is a ''hit''; if the set does not contain the line, this is a ''miss'' situation;
181
  _match_ description contains the the initial and the final points of the address field in the triangle brackets after _addr_; 
182
  as _index_ in the round braces _match_ also has the type of the address used; ''PA'' in our case;
183
184 78 Alexander Kamkin
h3. Buffer Data Replacement Policy (policy)
185 1 Taya Sergeeva
186 80 Alexander Kamkin
  _policy_ is the strategy of data displacement; 
187
  sets a policy which will be applied to our buffer, ''lru'' (Least Recently Used) in our example; 
188
  policy also can be ''plru'' (Pseudo LRU) and ''fifo'' (First Input First Out).
189
190 78 Alexander Kamkin
h4. Grammar
191
192
h3. Examples
193
194 56 Taya Sergeeva
Let as consider a simple buffer which has only 2 attributes, such as the associativity, *associativity*, i.e. the set''s size, and the number of sets in the buffer, *sets*. 
195
196
<pre>
197 75 Alexander Kamkin
buffer TLB { 
198
  ways = 8;
199
  sets = 64;
200 1 Taya Sergeeva
} 
201
</pre>
202 57 Taya Sergeeva
203 56 Taya Sergeeva
The example above describes translation lookaside buffer (_TLB_), which has an associativity being equal to 8, (i.e. the number of lines in one set in this TLB buffer is equal to 8), and has the number of lines being equal to 64.   
204 57 Taya Sergeeva
205 56 Taya Sergeeva
Each *line* of the buffer can be described optionally by _tag_ and _data_ parameters. 
206
For example, 
207 1 Taya Sergeeva
208 56 Taya Sergeeva
<pre>
209 1 Taya Sergeeva
line = (tag:22, data:1024);
210 56 Taya Sergeeva
</pre>
211 1 Taya Sergeeva
212 56 Taya Sergeeva
describes lines of the cache, each of them containing a 22-bit tag and 1024-bit data.
213 57 Taya Sergeeva
214 56 Taya Sergeeva
In a MMU buffer also can have the *index* computing function. When accessing data, the cache determines a set by calculating a x-bit index. For example,
215 1 Taya Sergeeva
216 57 Taya Sergeeva
<pre>
217 1 Taya Sergeeva
index(addr:PA) = addr<14..13>;
218
</pre>
219 57 Taya Sergeeva
220 1 Taya Sergeeva
The cache calculates a 2-bit index. _index_ returns the initial and the final points of the field kept in bytes.
221 57 Taya Sergeeva
222
Each device stores some data which can be accessed (read from or written into) by their address. If a device contains a line with a given address, this situation is called a ''hit''; the opposite situation referes to as a ''miss''. If a ''miss'' occurs, the device usually displaces one of the set''s line with the line associated with the address given. The predicate which determines if there is a ''miss'' or ''hit'' situation is called *match*. There is the example below:
223 56 Taya Sergeeva
224 57 Taya Sergeeva
<pre>
225
line = (tag:22, data:1024);
226 1 Taya Sergeeva
match(addr:VA) = line.tag == addr<14..1>;
227
</pre>
228
229 49 Taya Sergeeva
If the set contains a line with the tag equal to the 22 upper bits of the physical address, this is a ''hit''. _match_ returns ''true'' if there is a ''hit'' in the line, and returns ''false'' otherwise.
230 17 Taya Sergeeva
231 54 Taya Sergeeva
The strategy which will be used for the lines displacement is specified by *policy*. 
232
233
<pre>
234 1 Taya Sergeeva
policy = LRU;
235
</pre>
236 52 Taya Sergeeva
237 1 Taya Sergeeva
Example above sets the strategy of data replacement to be _Last_ _Recently_ _Used_ policy, i.e. if the ''miss'' occured, the cache displaces the least-recently-used line of the set.
238
239
There is the example below, describing a real ''lower-level'' cache L1: 
240 49 Taya Sergeeva
241 1 Taya Sergeeva
<pre>
242 54 Taya Sergeeva
buffer L1 
243 56 Taya Sergeeva
{
244 52 Taya Sergeeva
	associativity = 4;
245 1 Taya Sergeeva
	sets = 128;
246 25 Alexander Kamkin
	line = (tag:30, data:256);
247
	index(addr:PA) = addr<9..8>;
248
	match(addr:PA) = line.tag == addr<39..10>;
249
	policy = lru;
250
}
251
</pre>
252
253
_Description of each constructor_ in the buffer example is below: