MOESI_hammer: Added full-bit directory support
[gem5.git] / src / mem / protocol / MOESI_hammer-cache.sm
1 /*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * AMD's contributions to the MOESI hammer protocol do not constitute an
30 * endorsement of its similarity to any AMD products.
31 *
32 * Authors: Milo Martin
33 * Brad Beckmann
34 */
35
36 machine(L1Cache, "AMD Hammer-like protocol")
37 : Sequencer * sequencer,
38 CacheMemory * L1IcacheMemory,
39 CacheMemory * L1DcacheMemory,
40 CacheMemory * L2cacheMemory,
41 int cache_response_latency = 10,
42 int issue_latency = 2,
43 int l2_cache_hit_latency = 10,
44 bool no_mig_atomic = true
45 {
46
47 // NETWORK BUFFERS
48 MessageBuffer requestFromCache, network="To", virtual_network="2", ordered="false";
49 MessageBuffer responseFromCache, network="To", virtual_network="4", ordered="false";
50 MessageBuffer unblockFromCache, network="To", virtual_network="5", ordered="false";
51
52 MessageBuffer forwardToCache, network="From", virtual_network="3", ordered="false";
53 MessageBuffer responseToCache, network="From", virtual_network="4", ordered="false";
54
55
56 // STATES
57 enumeration(State, desc="Cache states", default="L1Cache_State_I") {
58 // Base states
59 I, desc="Idle";
60 S, desc="Shared";
61 O, desc="Owned";
62 M, desc="Modified (dirty)";
63 MM, desc="Modified (dirty and locally modified)";
64
65 // Transient States
66 IM, "IM", desc="Issued GetX";
67 SM, "SM", desc="Issued GetX, we still have an old copy of the line";
68 OM, "OM", desc="Issued GetX, received data";
69 ISM, "ISM", desc="Issued GetX, received data, waiting for all acks";
70 M_W, "M^W", desc="Issued GetS, received exclusive data";
71 MM_W, "MM^W", desc="Issued GetX, received exclusive data";
72 IS, "IS", desc="Issued GetS";
73 SS, "SS", desc="Issued GetS, received data, waiting for all acks";
74 OI, "OI", desc="Issued PutO, waiting for ack";
75 MI, "MI", desc="Issued PutX, waiting for ack";
76 II, "II", desc="Issued PutX/O, saw Other_GETS or Other_GETX, waiting for ack";
77 IT, "IT", desc="Invalid block transferring to L1";
78 ST, "ST", desc="S block transferring to L1";
79 OT, "OT", desc="O block transferring to L1";
80 MT, "MT", desc="M block transferring to L1";
81 MMT, "MMT", desc="MM block transferring to L1";
82 }
83
84 // EVENTS
85 enumeration(Event, desc="Cache events") {
86 Load, desc="Load request from the processor";
87 Ifetch, desc="I-fetch request from the processor";
88 Store, desc="Store request from the processor";
89 L2_Replacement, desc="L2 Replacement";
90 L1_to_L2, desc="L1 to L2 transfer";
91 Trigger_L2_to_L1D, desc="Trigger L2 to L1-Data transfer";
92 Trigger_L2_to_L1I, desc="Trigger L2 to L1-Instruction transfer";
93 Complete_L2_to_L1, desc="L2 to L1 transfer completed";
94
95 // Requests
96 Other_GETX, desc="A GetX from another processor";
97 Other_GETS, desc="A GetS from another processor";
98 Merged_GETS, desc="A Merged GetS from another processor";
99 Other_GETS_No_Mig, desc="A GetS from another processor";
100 NC_DMA_GETS, desc="special GetS when only DMA exists";
101 Invalidate, desc="Invalidate block";
102
103 // Responses
104 Ack, desc="Received an ack message";
105 Shared_Ack, desc="Received an ack message, responder has a shared copy";
106 Data, desc="Received a data message";
107 Shared_Data, desc="Received a data message, responder has a shared copy";
108 Exclusive_Data, desc="Received a data message, responder had an exclusive copy, they gave it to us";
109
110 Writeback_Ack, desc="Writeback O.K. from directory";
111 Writeback_Nack, desc="Writeback not O.K. from directory";
112
113 // Triggers
114 All_acks, desc="Received all required data and message acks";
115 All_acks_no_sharers, desc="Received all acks and no other processor has a shared copy";
116 }
117
118 // TYPES
119
120 // STRUCTURE DEFINITIONS
121
122 MessageBuffer mandatoryQueue, ordered="false";
123
124 // CacheEntry
125 structure(Entry, desc="...", interface="AbstractCacheEntry") {
126 State CacheState, desc="cache state";
127 bool Dirty, desc="Is the data dirty (different than memory)?";
128 DataBlock DataBlk, desc="data for the block";
129 bool FromL2, default="false", desc="block just moved from L2";
130 bool AtomicAccessed, default="false", desc="block just moved from L2";
131 }
132
133 // TBE fields
134 structure(TBE, desc="...") {
135 State TBEState, desc="Transient state";
136 DataBlock DataBlk, desc="data for the block, required for concurrent writebacks";
137 bool Dirty, desc="Is the data dirty (different than memory)?";
138 int NumPendingMsgs, desc="Number of acks/data messages that this processor is waiting for";
139 bool Sharers, desc="On a GetS, did we find any other sharers in the system";
140 bool AppliedSilentAcks, default="false", desc="for full-bit dir, does the pending msg count reflect the silent acks";
141 MachineID LastResponder, desc="last machine to send a response for this request";
142 MachineID CurOwner, desc="current owner of the block, used for UnblockS responses";
143 Time InitialRequestTime, default="0", desc="time the initial requests was sent from the L1Cache";
144 Time ForwardRequestTime, default="0", desc="time the dir forwarded the request";
145 Time FirstResponseTime, default="0", desc="the time the first response was received";
146 }
147
148 external_type(TBETable) {
149 TBE lookup(Address);
150 void allocate(Address);
151 void deallocate(Address);
152 bool isPresent(Address);
153 }
154
155 TBETable TBEs, template_hack="<L1Cache_TBE>";
156
157 void set_cache_entry(AbstractCacheEntry b);
158 void unset_cache_entry();
159 void set_tbe(TBE b);
160 void unset_tbe();
161
162 Entry getCacheEntry(Address address), return_by_pointer="yes" {
163 Entry L2cache_entry := static_cast(Entry, "pointer", L2cacheMemory.lookup(address));
164 if(is_valid(L2cache_entry)) {
165 return L2cache_entry;
166 }
167
168 Entry L1Dcache_entry := static_cast(Entry, "pointer", L1DcacheMemory.lookup(address));
169 if(is_valid(L1Dcache_entry)) {
170 return L1Dcache_entry;
171 }
172
173 Entry L1Icache_entry := static_cast(Entry, "pointer", L1IcacheMemory.lookup(address));
174 return L1Icache_entry;
175 }
176
177 Entry getL2CacheEntry(Address address), return_by_pointer="yes" {
178 Entry L2cache_entry := static_cast(Entry, "pointer", L2cacheMemory.lookup(address));
179 return L2cache_entry;
180 }
181
182 Entry getL1DCacheEntry(Address address), return_by_pointer="yes" {
183 Entry L1Dcache_entry := static_cast(Entry, "pointer", L1DcacheMemory.lookup(address));
184 return L1Dcache_entry;
185 }
186
187 Entry getL1ICacheEntry(Address address), return_by_pointer="yes" {
188 Entry L1Icache_entry := static_cast(Entry, "pointer", L1IcacheMemory.lookup(address));
189 return L1Icache_entry;
190 }
191
192 State getState(TBE tbe, Entry cache_entry, Address addr) {
193 if(is_valid(tbe)) {
194 return tbe.TBEState;
195 } else if (is_valid(cache_entry)) {
196 return cache_entry.CacheState;
197 }
198 return State:I;
199 }
200
201 void setState(TBE tbe, Entry cache_entry, Address addr, State state) {
202 assert((L1DcacheMemory.isTagPresent(addr) && L1IcacheMemory.isTagPresent(addr)) == false);
203 assert((L1IcacheMemory.isTagPresent(addr) && L2cacheMemory.isTagPresent(addr)) == false);
204 assert((L1DcacheMemory.isTagPresent(addr) && L2cacheMemory.isTagPresent(addr)) == false);
205
206 if (is_valid(tbe)) {
207 tbe.TBEState := state;
208 }
209
210 if (is_valid(cache_entry)) {
211 cache_entry.CacheState := state;
212
213 // Set permission
214 if ((state == State:MM) ||
215 (state == State:MM_W)) {
216 cache_entry.changePermission(AccessPermission:Read_Write);
217 } else if (state == State:S ||
218 state == State:O ||
219 state == State:M ||
220 state == State:M_W ||
221 state == State:SM ||
222 state == State:ISM ||
223 state == State:OM ||
224 state == State:SS) {
225 cache_entry.changePermission(AccessPermission:Read_Only);
226 } else {
227 cache_entry.changePermission(AccessPermission:Invalid);
228 }
229 }
230 }
231
232 Event mandatory_request_type_to_event(CacheRequestType type) {
233 if (type == CacheRequestType:LD) {
234 return Event:Load;
235 } else if (type == CacheRequestType:IFETCH) {
236 return Event:Ifetch;
237 } else if ((type == CacheRequestType:ST) || (type == CacheRequestType:ATOMIC)) {
238 return Event:Store;
239 } else {
240 error("Invalid CacheRequestType");
241 }
242 }
243
244 GenericMachineType getNondirectHitMachType(Address addr, MachineID sender) {
245 if (machineIDToMachineType(sender) == MachineType:L1Cache) {
246 //
247 // NOTE direct local hits should not call this
248 //
249 return GenericMachineType:L1Cache_wCC;
250 } else {
251 return ConvertMachToGenericMach(machineIDToMachineType(sender));
252 }
253 }
254
255 GenericMachineType testAndClearLocalHit(Entry cache_entry) {
256 if (is_valid(cache_entry) && cache_entry.FromL2) {
257 cache_entry.FromL2 := false;
258 return GenericMachineType:L2Cache;
259 } else {
260 return GenericMachineType:L1Cache;
261 }
262 }
263
264 bool IsAtomicAccessed(Entry cache_entry) {
265 assert(is_valid(cache_entry));
266 return cache_entry.AtomicAccessed;
267 }
268
269 MessageBuffer triggerQueue, ordered="false";
270
271 // ** OUT_PORTS **
272
273 out_port(requestNetwork_out, RequestMsg, requestFromCache);
274 out_port(responseNetwork_out, ResponseMsg, responseFromCache);
275 out_port(unblockNetwork_out, ResponseMsg, unblockFromCache);
276 out_port(triggerQueue_out, TriggerMsg, triggerQueue);
277
278 // ** IN_PORTS **
279
280 // Trigger Queue
281 in_port(triggerQueue_in, TriggerMsg, triggerQueue) {
282 if (triggerQueue_in.isReady()) {
283 peek(triggerQueue_in, TriggerMsg) {
284
285 Entry cache_entry := getCacheEntry(in_msg.Address);
286 TBE tbe := TBEs[in_msg.Address];
287
288 if (in_msg.Type == TriggerType:L2_to_L1) {
289 trigger(Event:Complete_L2_to_L1, in_msg.Address, cache_entry, tbe);
290 } else if (in_msg.Type == TriggerType:ALL_ACKS) {
291 trigger(Event:All_acks, in_msg.Address, cache_entry, tbe);
292 } else if (in_msg.Type == TriggerType:ALL_ACKS_NO_SHARERS) {
293 trigger(Event:All_acks_no_sharers, in_msg.Address, cache_entry, tbe);
294 } else {
295 error("Unexpected message");
296 }
297 }
298 }
299 }
300
301 // Nothing from the request network
302
303 // Forward Network
304 in_port(forwardToCache_in, RequestMsg, forwardToCache) {
305 if (forwardToCache_in.isReady()) {
306 peek(forwardToCache_in, RequestMsg, block_on="Address") {
307
308 Entry cache_entry := getCacheEntry(in_msg.Address);
309 TBE tbe := TBEs[in_msg.Address];
310
311 if (in_msg.Type == CoherenceRequestType:GETX) {
312 trigger(Event:Other_GETX, in_msg.Address, cache_entry, tbe);
313 } else if (in_msg.Type == CoherenceRequestType:MERGED_GETS) {
314 trigger(Event:Merged_GETS, in_msg.Address, cache_entry, tbe);
315 } else if (in_msg.Type == CoherenceRequestType:GETS) {
316 if (machineCount(MachineType:L1Cache) > 1) {
317 if (is_valid(cache_entry)) {
318 if (IsAtomicAccessed(cache_entry) && no_mig_atomic) {
319 trigger(Event:Other_GETS_No_Mig, in_msg.Address, cache_entry, tbe);
320 } else {
321 trigger(Event:Other_GETS, in_msg.Address, cache_entry, tbe);
322 }
323 } else {
324 trigger(Event:Other_GETS, in_msg.Address, cache_entry, tbe);
325 }
326 } else {
327 trigger(Event:NC_DMA_GETS, in_msg.Address, cache_entry, tbe);
328 }
329 } else if (in_msg.Type == CoherenceRequestType:INV) {
330 trigger(Event:Invalidate, in_msg.Address, cache_entry, tbe);
331 } else if (in_msg.Type == CoherenceRequestType:WB_ACK) {
332 trigger(Event:Writeback_Ack, in_msg.Address, cache_entry, tbe);
333 } else if (in_msg.Type == CoherenceRequestType:WB_NACK) {
334 trigger(Event:Writeback_Nack, in_msg.Address, cache_entry, tbe);
335 } else {
336 error("Unexpected message");
337 }
338 }
339 }
340 }
341
342 // Response Network
343 in_port(responseToCache_in, ResponseMsg, responseToCache) {
344 if (responseToCache_in.isReady()) {
345 peek(responseToCache_in, ResponseMsg, block_on="Address") {
346
347 Entry cache_entry := getCacheEntry(in_msg.Address);
348 TBE tbe := TBEs[in_msg.Address];
349
350 if (in_msg.Type == CoherenceResponseType:ACK) {
351 trigger(Event:Ack, in_msg.Address, cache_entry, tbe);
352 } else if (in_msg.Type == CoherenceResponseType:ACK_SHARED) {
353 trigger(Event:Shared_Ack, in_msg.Address, cache_entry, tbe);
354 } else if (in_msg.Type == CoherenceResponseType:DATA) {
355 trigger(Event:Data, in_msg.Address, cache_entry, tbe);
356 } else if (in_msg.Type == CoherenceResponseType:DATA_SHARED) {
357 trigger(Event:Shared_Data, in_msg.Address, cache_entry, tbe);
358 } else if (in_msg.Type == CoherenceResponseType:DATA_EXCLUSIVE) {
359 trigger(Event:Exclusive_Data, in_msg.Address, cache_entry, tbe);
360 } else {
361 error("Unexpected message");
362 }
363 }
364 }
365 }
366
367 // Nothing from the unblock network
368
369 // Mandatory Queue
370 in_port(mandatoryQueue_in, CacheMsg, mandatoryQueue, desc="...") {
371 if (mandatoryQueue_in.isReady()) {
372 peek(mandatoryQueue_in, CacheMsg, block_on="LineAddress") {
373
374 // Check for data access to blocks in I-cache and ifetchs to blocks in D-cache
375 TBE tbe := TBEs[in_msg.LineAddress];
376
377 if (in_msg.Type == CacheRequestType:IFETCH) {
378 // ** INSTRUCTION ACCESS ***
379
380 // Check to see if it is in the OTHER L1
381 Entry L1Dcache_entry := getL1DCacheEntry(in_msg.LineAddress);
382 if (is_valid(L1Dcache_entry)) {
383 // The block is in the wrong L1, try to write it to the L2
384 if (L2cacheMemory.cacheAvail(in_msg.LineAddress)) {
385 trigger(Event:L1_to_L2, in_msg.LineAddress, L1Dcache_entry, tbe);
386 } else {
387 trigger(Event:L2_Replacement,
388 L2cacheMemory.cacheProbe(in_msg.LineAddress),
389 getL2CacheEntry(L2cacheMemory.cacheProbe(in_msg.LineAddress)),
390 TBEs[L2cacheMemory.cacheProbe(in_msg.LineAddress)]);
391 }
392 }
393
394 Entry L1Icache_entry := getL1ICacheEntry(in_msg.LineAddress);
395 if (is_valid(L1Icache_entry)) {
396 // The tag matches for the L1, so the L1 fetches the line. We know it can't be in the L2 due to exclusion
397 trigger(mandatory_request_type_to_event(in_msg.Type),
398 in_msg.LineAddress, L1Icache_entry, tbe);
399 } else {
400 if (L1IcacheMemory.cacheAvail(in_msg.LineAddress)) {
401 // L1 does't have the line, but we have space for it in the L1
402
403 Entry L2cache_entry := getL2CacheEntry(in_msg.LineAddress);
404 if (is_valid(L2cache_entry)) {
405 // L2 has it (maybe not with the right permissions)
406 trigger(Event:Trigger_L2_to_L1I, in_msg.LineAddress,
407 L2cache_entry, tbe);
408 } else {
409 // We have room, the L2 doesn't have it, so the L1 fetches the line
410 trigger(mandatory_request_type_to_event(in_msg.Type),
411 in_msg.LineAddress, L1Icache_entry, tbe);
412 }
413 } else {
414 // No room in the L1, so we need to make room
415 if (L2cacheMemory.cacheAvail(L1IcacheMemory.cacheProbe(in_msg.LineAddress))) {
416 // The L2 has room, so we move the line from the L1 to the L2
417 trigger(Event:L1_to_L2,
418 L1IcacheMemory.cacheProbe(in_msg.LineAddress),
419 getL1ICacheEntry(L1IcacheMemory.cacheProbe(in_msg.LineAddress)),
420 TBEs[L1IcacheMemory.cacheProbe(in_msg.LineAddress)]);
421 } else {
422 // The L2 does not have room, so we replace a line from the L2
423 trigger(Event:L2_Replacement,
424 L2cacheMemory.cacheProbe(L1IcacheMemory.cacheProbe(in_msg.LineAddress)),
425 getL2CacheEntry(L2cacheMemory.cacheProbe(L1IcacheMemory.cacheProbe(in_msg.LineAddress))),
426 TBEs[L2cacheMemory.cacheProbe(L1IcacheMemory.cacheProbe(in_msg.LineAddress))]);
427 }
428 }
429 }
430 } else {
431 // *** DATA ACCESS ***
432
433 // Check to see if it is in the OTHER L1
434 Entry L1Icache_entry := getL1ICacheEntry(in_msg.LineAddress);
435 if (is_valid(L1Icache_entry)) {
436 // The block is in the wrong L1, try to write it to the L2
437 if (L2cacheMemory.cacheAvail(in_msg.LineAddress)) {
438 trigger(Event:L1_to_L2, in_msg.LineAddress, L1Icache_entry, tbe);
439 } else {
440 trigger(Event:L2_Replacement,
441 L2cacheMemory.cacheProbe(in_msg.LineAddress),
442 getL2CacheEntry(L2cacheMemory.cacheProbe(in_msg.LineAddress)),
443 TBEs[L2cacheMemory.cacheProbe(in_msg.LineAddress)]);
444 }
445 }
446
447 Entry L1Dcache_entry := getL1DCacheEntry(in_msg.LineAddress);
448 if (is_valid(L1Dcache_entry)) {
449 // The tag matches for the L1, so the L1 fetches the line. We know it can't be in the L2 due to exclusion
450 trigger(mandatory_request_type_to_event(in_msg.Type),
451 in_msg.LineAddress, L1Dcache_entry, tbe);
452 } else {
453 if (L1DcacheMemory.cacheAvail(in_msg.LineAddress)) {
454 // L1 does't have the line, but we have space for it in the L1
455 Entry L2cache_entry := getL2CacheEntry(in_msg.LineAddress);
456 if (is_valid(L2cache_entry)) {
457 // L2 has it (maybe not with the right permissions)
458 trigger(Event:Trigger_L2_to_L1D, in_msg.LineAddress,
459 L2cache_entry, tbe);
460 } else {
461 // We have room, the L2 doesn't have it, so the L1 fetches the line
462 trigger(mandatory_request_type_to_event(in_msg.Type),
463 in_msg.LineAddress, L1Dcache_entry, tbe);
464 }
465 } else {
466 // No room in the L1, so we need to make room
467 if (L2cacheMemory.cacheAvail(L1DcacheMemory.cacheProbe(in_msg.LineAddress))) {
468 // The L2 has room, so we move the line from the L1 to the L2
469 trigger(Event:L1_to_L2,
470 L1DcacheMemory.cacheProbe(in_msg.LineAddress),
471 getL1DCacheEntry(L1DcacheMemory.cacheProbe(in_msg.LineAddress)),
472 TBEs[L1DcacheMemory.cacheProbe(in_msg.LineAddress)]);
473 } else {
474 // The L2 does not have room, so we replace a line from the L2
475 trigger(Event:L2_Replacement,
476 L2cacheMemory.cacheProbe(L1DcacheMemory.cacheProbe(in_msg.LineAddress)),
477 getL2CacheEntry(L2cacheMemory.cacheProbe(L1DcacheMemory.cacheProbe(in_msg.LineAddress))),
478 TBEs[L2cacheMemory.cacheProbe(L1DcacheMemory.cacheProbe(in_msg.LineAddress))]);
479 }
480 }
481 }
482 }
483 }
484 }
485 }
486
487 // ACTIONS
488
489 action(a_issueGETS, "a", desc="Issue GETS") {
490 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
491 assert(is_valid(tbe));
492 out_msg.Address := address;
493 out_msg.Type := CoherenceRequestType:GETS;
494 out_msg.Requestor := machineID;
495 out_msg.Destination.add(map_Address_to_Directory(address));
496 out_msg.MessageSize := MessageSizeType:Request_Control;
497 out_msg.InitialRequestTime := get_time();
498 tbe.NumPendingMsgs := machineCount(MachineType:L1Cache); // One from each other cache (n-1) plus the memory (+1)
499 }
500 }
501
502 action(b_issueGETX, "b", desc="Issue GETX") {
503 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
504 assert(is_valid(tbe));
505 out_msg.Address := address;
506 out_msg.Type := CoherenceRequestType:GETX;
507 out_msg.Requestor := machineID;
508 out_msg.Destination.add(map_Address_to_Directory(address));
509 out_msg.MessageSize := MessageSizeType:Request_Control;
510 out_msg.InitialRequestTime := get_time();
511 tbe.NumPendingMsgs := machineCount(MachineType:L1Cache); // One from each other cache (n-1) plus the memory (+1)
512 }
513 }
514
515 action(c_sendExclusiveData, "c", desc="Send exclusive data from cache to requestor") {
516 peek(forwardToCache_in, RequestMsg) {
517 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
518 assert(is_valid(cache_entry));
519 out_msg.Address := address;
520 out_msg.Type := CoherenceResponseType:DATA_EXCLUSIVE;
521 out_msg.Sender := machineID;
522 out_msg.Destination.add(in_msg.Requestor);
523 out_msg.DataBlk := cache_entry.DataBlk;
524 out_msg.Dirty := cache_entry.Dirty;
525 if (in_msg.DirectedProbe) {
526 out_msg.Acks := machineCount(MachineType:L1Cache);
527 } else {
528 out_msg.Acks := 2;
529 }
530 out_msg.SilentAcks := in_msg.SilentAcks;
531 out_msg.MessageSize := MessageSizeType:Response_Data;
532 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
533 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
534 }
535 }
536 }
537
538 action(d_issuePUT, "d", desc="Issue PUT") {
539 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
540 out_msg.Address := address;
541 out_msg.Type := CoherenceRequestType:PUT;
542 out_msg.Requestor := machineID;
543 out_msg.Destination.add(map_Address_to_Directory(address));
544 out_msg.MessageSize := MessageSizeType:Writeback_Control;
545 }
546 }
547
548 action(e_sendData, "e", desc="Send data from cache to requestor") {
549 peek(forwardToCache_in, RequestMsg) {
550 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
551 assert(is_valid(cache_entry));
552 out_msg.Address := address;
553 out_msg.Type := CoherenceResponseType:DATA;
554 out_msg.Sender := machineID;
555 out_msg.Destination.add(in_msg.Requestor);
556 out_msg.DataBlk := cache_entry.DataBlk;
557 out_msg.Dirty := cache_entry.Dirty;
558 if (in_msg.DirectedProbe) {
559 out_msg.Acks := machineCount(MachineType:L1Cache);
560 } else {
561 out_msg.Acks := 2;
562 }
563 out_msg.SilentAcks := in_msg.SilentAcks;
564 out_msg.MessageSize := MessageSizeType:Response_Data;
565 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
566 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
567 }
568 }
569 }
570
571 action(ee_sendDataShared, "\e", desc="Send data from cache to requestor, keep a shared copy") {
572 peek(forwardToCache_in, RequestMsg) {
573 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
574 assert(is_valid(cache_entry));
575 out_msg.Address := address;
576 out_msg.Type := CoherenceResponseType:DATA_SHARED;
577 out_msg.Sender := machineID;
578 out_msg.Destination.add(in_msg.Requestor);
579 out_msg.DataBlk := cache_entry.DataBlk;
580 out_msg.Dirty := cache_entry.Dirty;
581 DPRINTF(RubySlicc, "%s\n", out_msg.DataBlk);
582 if (in_msg.DirectedProbe) {
583 out_msg.Acks := machineCount(MachineType:L1Cache);
584 } else {
585 out_msg.Acks := 2;
586 }
587 out_msg.SilentAcks := in_msg.SilentAcks;
588 out_msg.MessageSize := MessageSizeType:Response_Data;
589 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
590 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
591 }
592 }
593 }
594
595 action(em_sendDataSharedMultiple, "em", desc="Send data from cache to all requestors") {
596 peek(forwardToCache_in, RequestMsg) {
597 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
598 assert(is_valid(cache_entry));
599 out_msg.Address := address;
600 out_msg.Type := CoherenceResponseType:DATA_SHARED;
601 out_msg.Sender := machineID;
602 out_msg.Destination := in_msg.MergedRequestors;
603 out_msg.DataBlk := cache_entry.DataBlk;
604 out_msg.Dirty := cache_entry.Dirty;
605 DPRINTF(RubySlicc, "%s\n", out_msg.DataBlk);
606 out_msg.Acks := machineCount(MachineType:L1Cache);
607 out_msg.SilentAcks := in_msg.SilentAcks;
608 out_msg.MessageSize := MessageSizeType:Response_Data;
609 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
610 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
611 }
612 }
613 }
614
615 action(f_sendAck, "f", desc="Send ack from cache to requestor") {
616 peek(forwardToCache_in, RequestMsg) {
617 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
618 out_msg.Address := address;
619 out_msg.Type := CoherenceResponseType:ACK;
620 out_msg.Sender := machineID;
621 out_msg.Destination.add(in_msg.Requestor);
622 out_msg.Acks := 1;
623 out_msg.SilentAcks := in_msg.SilentAcks;
624 assert(in_msg.DirectedProbe == false);
625 out_msg.MessageSize := MessageSizeType:Response_Control;
626 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
627 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
628 }
629 }
630 }
631
632 action(ff_sendAckShared, "\f", desc="Send shared ack from cache to requestor") {
633 peek(forwardToCache_in, RequestMsg) {
634 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
635 out_msg.Address := address;
636 out_msg.Type := CoherenceResponseType:ACK_SHARED;
637 out_msg.Sender := machineID;
638 out_msg.Destination.add(in_msg.Requestor);
639 out_msg.Acks := 1;
640 out_msg.SilentAcks := in_msg.SilentAcks;
641 assert(in_msg.DirectedProbe == false);
642 out_msg.MessageSize := MessageSizeType:Response_Control;
643 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
644 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
645 }
646 }
647 }
648
649 action(g_sendUnblock, "g", desc="Send unblock to memory") {
650 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
651 out_msg.Address := address;
652 out_msg.Type := CoherenceResponseType:UNBLOCK;
653 out_msg.Sender := machineID;
654 out_msg.Destination.add(map_Address_to_Directory(address));
655 out_msg.MessageSize := MessageSizeType:Unblock_Control;
656 }
657 }
658
659 action(gm_sendUnblockM, "gm", desc="Send unblock to memory and indicate M/O/E state") {
660 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
661 out_msg.Address := address;
662 out_msg.Type := CoherenceResponseType:UNBLOCKM;
663 out_msg.Sender := machineID;
664 out_msg.Destination.add(map_Address_to_Directory(address));
665 out_msg.MessageSize := MessageSizeType:Unblock_Control;
666 }
667 }
668
669 action(gs_sendUnblockS, "gs", desc="Send unblock to memory and indicate S state") {
670 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
671 assert(is_valid(tbe));
672 out_msg.Address := address;
673 out_msg.Type := CoherenceResponseType:UNBLOCKS;
674 out_msg.Sender := machineID;
675 out_msg.CurOwner := tbe.CurOwner;
676 out_msg.Destination.add(map_Address_to_Directory(address));
677 out_msg.MessageSize := MessageSizeType:Unblock_Control;
678 }
679 }
680
681 action(h_load_hit, "h", desc="Notify sequencer the load completed.") {
682 assert(is_valid(cache_entry));
683 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
684 sequencer.readCallback(address, testAndClearLocalHit(cache_entry),
685 cache_entry.DataBlk);
686 }
687
688 action(hx_external_load_hit, "hx", desc="load required external msgs") {
689 assert(is_valid(cache_entry));
690 assert(is_valid(tbe));
691 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
692 peek(responseToCache_in, ResponseMsg) {
693
694 sequencer.readCallback(address,
695 getNondirectHitMachType(in_msg.Address, in_msg.Sender),
696 cache_entry.DataBlk,
697 tbe.InitialRequestTime,
698 tbe.ForwardRequestTime,
699 tbe.FirstResponseTime);
700 }
701 }
702
703 action(hh_store_hit, "\h", desc="Notify sequencer that store completed.") {
704 assert(is_valid(cache_entry));
705 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
706 peek(mandatoryQueue_in, CacheMsg) {
707 sequencer.writeCallback(address, testAndClearLocalHit(cache_entry),
708 cache_entry.DataBlk);
709
710 cache_entry.Dirty := true;
711 if (in_msg.Type == CacheRequestType:ATOMIC) {
712 cache_entry.AtomicAccessed := true;
713 }
714 }
715 }
716
717 action(sx_external_store_hit, "sx", desc="store required external msgs.") {
718 assert(is_valid(cache_entry));
719 assert(is_valid(tbe));
720 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
721 peek(responseToCache_in, ResponseMsg) {
722
723 sequencer.writeCallback(address,
724 getNondirectHitMachType(address, in_msg.Sender),
725 cache_entry.DataBlk,
726 tbe.InitialRequestTime,
727 tbe.ForwardRequestTime,
728 tbe.FirstResponseTime);
729 }
730 cache_entry.Dirty := true;
731 }
732
733 action(sxt_trig_ext_store_hit, "sxt", desc="store required external msgs.") {
734 assert(is_valid(cache_entry));
735 assert(is_valid(tbe));
736 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
737
738 sequencer.writeCallback(address,
739 getNondirectHitMachType(address, tbe.LastResponder),
740 cache_entry.DataBlk,
741 tbe.InitialRequestTime,
742 tbe.ForwardRequestTime,
743 tbe.FirstResponseTime);
744
745 cache_entry.Dirty := true;
746 }
747
748 action(i_allocateTBE, "i", desc="Allocate TBE") {
749 check_allocate(TBEs);
750 assert(is_valid(cache_entry));
751 TBEs.allocate(address);
752 set_tbe(TBEs[address]);
753 tbe.DataBlk := cache_entry.DataBlk; // Data only used for writebacks
754 tbe.Dirty := cache_entry.Dirty;
755 tbe.Sharers := false;
756 }
757
758 action(j_popTriggerQueue, "j", desc="Pop trigger queue.") {
759 triggerQueue_in.dequeue();
760 }
761
762 action(k_popMandatoryQueue, "k", desc="Pop mandatory queue.") {
763 mandatoryQueue_in.dequeue();
764 }
765
766 action(l_popForwardQueue, "l", desc="Pop forwareded request queue.") {
767 forwardToCache_in.dequeue();
768 }
769
770 action(hp_copyFromTBEToL2, "li", desc="Copy data from TBE to L2 cache entry.") {
771 assert(is_valid(cache_entry));
772 assert(is_valid(tbe));
773 cache_entry.Dirty := tbe.Dirty;
774 cache_entry.DataBlk := tbe.DataBlk;
775 }
776
777 action(nb_copyFromTBEToL1, "fu", desc="Copy data from TBE to L1 cache entry.") {
778 assert(is_valid(cache_entry));
779 assert(is_valid(tbe));
780 cache_entry.Dirty := tbe.Dirty;
781 cache_entry.DataBlk := tbe.DataBlk;
782 cache_entry.FromL2 := true;
783 }
784
785 action(m_decrementNumberOfMessages, "m", desc="Decrement the number of messages for which we're waiting") {
786 peek(responseToCache_in, ResponseMsg) {
787 assert(in_msg.Acks > 0);
788 assert(is_valid(tbe));
789 DPRINTF(RubySlicc, "Sender = %s\n", in_msg.Sender);
790 DPRINTF(RubySlicc, "SilentAcks = %d\n", in_msg.SilentAcks);
791 if (tbe.AppliedSilentAcks == false) {
792 tbe.NumPendingMsgs := tbe.NumPendingMsgs - in_msg.SilentAcks;
793 tbe.AppliedSilentAcks := true;
794 }
795 DPRINTF(RubySlicc, "%d\n", tbe.NumPendingMsgs);
796 tbe.NumPendingMsgs := tbe.NumPendingMsgs - in_msg.Acks;
797 DPRINTF(RubySlicc, "%d\n", tbe.NumPendingMsgs);
798 APPEND_TRANSITION_COMMENT(tbe.NumPendingMsgs);
799 APPEND_TRANSITION_COMMENT(in_msg.Sender);
800 tbe.LastResponder := in_msg.Sender;
801 if (tbe.InitialRequestTime != zero_time() && in_msg.InitialRequestTime != zero_time()) {
802 assert(tbe.InitialRequestTime == in_msg.InitialRequestTime);
803 }
804 if (in_msg.InitialRequestTime != zero_time()) {
805 tbe.InitialRequestTime := in_msg.InitialRequestTime;
806 }
807 if (tbe.ForwardRequestTime != zero_time() && in_msg.ForwardRequestTime != zero_time()) {
808 assert(tbe.ForwardRequestTime == in_msg.ForwardRequestTime);
809 }
810 if (in_msg.ForwardRequestTime != zero_time()) {
811 tbe.ForwardRequestTime := in_msg.ForwardRequestTime;
812 }
813 if (tbe.FirstResponseTime == zero_time()) {
814 tbe.FirstResponseTime := get_time();
815 }
816 }
817 }
818 action(uo_updateCurrentOwner, "uo", desc="When moving SS state, update current owner.") {
819 peek(responseToCache_in, ResponseMsg) {
820 assert(is_valid(tbe));
821 tbe.CurOwner := in_msg.Sender;
822 }
823 }
824
825 action(n_popResponseQueue, "n", desc="Pop response queue") {
826 responseToCache_in.dequeue();
827 }
828
829 action(ll_L2toL1Transfer, "ll", desc="") {
830 enqueue(triggerQueue_out, TriggerMsg, latency=l2_cache_hit_latency) {
831 out_msg.Address := address;
832 out_msg.Type := TriggerType:L2_to_L1;
833 }
834 }
835
836 action(o_checkForCompletion, "o", desc="Check if we have received all the messages required for completion") {
837 assert(is_valid(tbe));
838 if (tbe.NumPendingMsgs == 0) {
839 enqueue(triggerQueue_out, TriggerMsg) {
840 out_msg.Address := address;
841 if (tbe.Sharers) {
842 out_msg.Type := TriggerType:ALL_ACKS;
843 } else {
844 out_msg.Type := TriggerType:ALL_ACKS_NO_SHARERS;
845 }
846 }
847 }
848 }
849
850 action(p_decrementNumberOfMessagesByOne, "p", desc="Decrement the number of messages for which we're waiting by one") {
851 assert(is_valid(tbe));
852 tbe.NumPendingMsgs := tbe.NumPendingMsgs - 1;
853 }
854
855 action(pp_incrementNumberOfMessagesByOne, "\p", desc="Increment the number of messages for which we're waiting by one") {
856 assert(is_valid(tbe));
857 tbe.NumPendingMsgs := tbe.NumPendingMsgs + 1;
858 }
859
860 action(q_sendDataFromTBEToCache, "q", desc="Send data from TBE to cache") {
861 peek(forwardToCache_in, RequestMsg) {
862 assert(in_msg.Requestor != machineID);
863 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
864 assert(is_valid(tbe));
865 out_msg.Address := address;
866 out_msg.Type := CoherenceResponseType:DATA;
867 out_msg.Sender := machineID;
868 out_msg.Destination.add(in_msg.Requestor);
869 DPRINTF(RubySlicc, "%s\n", out_msg.Destination);
870 out_msg.DataBlk := tbe.DataBlk;
871 out_msg.Dirty := tbe.Dirty;
872 if (in_msg.DirectedProbe) {
873 out_msg.Acks := machineCount(MachineType:L1Cache);
874 } else {
875 out_msg.Acks := 2;
876 }
877 out_msg.SilentAcks := in_msg.SilentAcks;
878 out_msg.MessageSize := MessageSizeType:Response_Data;
879 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
880 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
881 }
882 }
883 }
884
885 action(qm_sendDataFromTBEToCache, "qm", desc="Send data from TBE to cache, multiple sharers") {
886 peek(forwardToCache_in, RequestMsg) {
887 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
888 assert(is_valid(tbe));
889 out_msg.Address := address;
890 out_msg.Type := CoherenceResponseType:DATA;
891 out_msg.Sender := machineID;
892 out_msg.Destination := in_msg.MergedRequestors;
893 DPRINTF(RubySlicc, "%s\n", out_msg.Destination);
894 out_msg.DataBlk := tbe.DataBlk;
895 out_msg.Dirty := tbe.Dirty;
896 out_msg.Acks := machineCount(MachineType:L1Cache);
897 out_msg.SilentAcks := in_msg.SilentAcks;
898 out_msg.MessageSize := MessageSizeType:Response_Data;
899 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
900 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
901 }
902 }
903 }
904
905 action(qq_sendDataFromTBEToMemory, "\q", desc="Send data from TBE to memory") {
906 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
907 assert(is_valid(tbe));
908 out_msg.Address := address;
909 out_msg.Sender := machineID;
910 out_msg.Destination.add(map_Address_to_Directory(address));
911 out_msg.Dirty := tbe.Dirty;
912 if (tbe.Dirty) {
913 out_msg.Type := CoherenceResponseType:WB_DIRTY;
914 out_msg.DataBlk := tbe.DataBlk;
915 out_msg.MessageSize := MessageSizeType:Writeback_Data;
916 } else {
917 out_msg.Type := CoherenceResponseType:WB_CLEAN;
918 // NOTE: in a real system this would not send data. We send
919 // data here only so we can check it at the memory
920 out_msg.DataBlk := tbe.DataBlk;
921 out_msg.MessageSize := MessageSizeType:Writeback_Control;
922 }
923 }
924 }
925
926 action(r_setSharerBit, "r", desc="We saw other sharers") {
927 assert(is_valid(tbe));
928 tbe.Sharers := true;
929 }
930
931 action(s_deallocateTBE, "s", desc="Deallocate TBE") {
932 TBEs.deallocate(address);
933 unset_tbe();
934 }
935
936 action(t_sendExclusiveDataFromTBEToMemory, "t", desc="Send exclusive data from TBE to memory") {
937 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
938 assert(is_valid(tbe));
939 out_msg.Address := address;
940 out_msg.Sender := machineID;
941 out_msg.Destination.add(map_Address_to_Directory(address));
942 out_msg.DataBlk := tbe.DataBlk;
943 out_msg.Dirty := tbe.Dirty;
944 if (tbe.Dirty) {
945 out_msg.Type := CoherenceResponseType:WB_EXCLUSIVE_DIRTY;
946 out_msg.DataBlk := tbe.DataBlk;
947 out_msg.MessageSize := MessageSizeType:Writeback_Data;
948 } else {
949 out_msg.Type := CoherenceResponseType:WB_EXCLUSIVE_CLEAN;
950 // NOTE: in a real system this would not send data. We send
951 // data here only so we can check it at the memory
952 out_msg.DataBlk := tbe.DataBlk;
953 out_msg.MessageSize := MessageSizeType:Writeback_Control;
954 }
955 }
956 }
957
958 action(u_writeDataToCache, "u", desc="Write data to cache") {
959 peek(responseToCache_in, ResponseMsg) {
960 assert(is_valid(cache_entry));
961 cache_entry.DataBlk := in_msg.DataBlk;
962 cache_entry.Dirty := in_msg.Dirty;
963 }
964 }
965
966 action(v_writeDataToCacheVerify, "v", desc="Write data to cache, assert it was same as before") {
967 peek(responseToCache_in, ResponseMsg) {
968 assert(is_valid(cache_entry));
969 DPRINTF(RubySlicc, "Cached Data Block: %s, Msg Data Block: %s\n",
970 cache_entry.DataBlk, in_msg.DataBlk);
971 assert(cache_entry.DataBlk == in_msg.DataBlk);
972 cache_entry.DataBlk := in_msg.DataBlk;
973 cache_entry.Dirty := in_msg.Dirty || cache_entry.Dirty;
974 }
975 }
976
977 action(gg_deallocateL1CacheBlock, "\g", desc="Deallocate cache block. Sets the cache to invalid, allowing a replacement in parallel with a fetch.") {
978 if (L1DcacheMemory.isTagPresent(address)) {
979 L1DcacheMemory.deallocate(address);
980 } else {
981 L1IcacheMemory.deallocate(address);
982 }
983 unset_cache_entry();
984 }
985
986 action(ii_allocateL1DCacheBlock, "\i", desc="Set L1 D-cache tag equal to tag of block B.") {
987 if (is_invalid(cache_entry)) {
988 set_cache_entry(L1DcacheMemory.allocate(address, new Entry));
989 }
990 }
991
992 action(jj_allocateL1ICacheBlock, "\j", desc="Set L1 I-cache tag equal to tag of block B.") {
993 if (is_invalid(cache_entry)) {
994 set_cache_entry(L1IcacheMemory.allocate(address, new Entry));
995 }
996 }
997
998 action(vv_allocateL2CacheBlock, "\v", desc="Set L2 cache tag equal to tag of block B.") {
999 set_cache_entry(L2cacheMemory.allocate(address, new Entry));
1000 }
1001
1002 action(rr_deallocateL2CacheBlock, "\r", desc="Deallocate L2 cache block. Sets the cache to not present, allowing a replacement in parallel with a fetch.") {
1003 L2cacheMemory.deallocate(address);
1004 unset_cache_entry();
1005 }
1006
1007 action(uu_profileMiss, "\u", desc="Profile the demand miss") {
1008 peek(mandatoryQueue_in, CacheMsg) {
1009 if (L1IcacheMemory.isTagPresent(address)) {
1010 L1IcacheMemory.profileMiss(in_msg);
1011 } else if (L1DcacheMemory.isTagPresent(address)) {
1012 L1DcacheMemory.profileMiss(in_msg);
1013 }
1014 if (L2cacheMemory.isTagPresent(address) == false) {
1015 L2cacheMemory.profileMiss(in_msg);
1016 }
1017 }
1018 }
1019
1020 action(zz_recycleMandatoryQueue, "\z", desc="Send the head of the mandatory queue to the back of the queue.") {
1021 mandatoryQueue_in.recycle();
1022 }
1023
1024 //*****************************************************
1025 // TRANSITIONS
1026 //*****************************************************
1027
1028 // Transitions for Load/Store/L2_Replacement from transient states
1029 transition({IM, SM, ISM, OM, IS, SS, OI, MI, II, IT, ST, OT, MT, MMT}, {Store, L2_Replacement}) {
1030 zz_recycleMandatoryQueue;
1031 }
1032
1033 transition({M_W, MM_W}, {L2_Replacement}) {
1034 zz_recycleMandatoryQueue;
1035 }
1036
1037 transition({IM, IS, OI, MI, II, IT, ST, OT, MT, MMT}, {Load, Ifetch}) {
1038 zz_recycleMandatoryQueue;
1039 }
1040
1041 transition({IM, SM, ISM, OM, IS, SS, MM_W, M_W, OI, MI, II, IT, ST, OT, MT, MMT}, L1_to_L2) {
1042 zz_recycleMandatoryQueue;
1043 }
1044
1045 transition({IT, ST, OT, MT, MMT}, {Other_GETX, NC_DMA_GETS, Other_GETS, Merged_GETS, Other_GETS_No_Mig, Invalidate}) {
1046 // stall
1047 }
1048
1049 // Transitions moving data between the L1 and L2 caches
1050 transition({I, S, O, M, MM}, L1_to_L2) {
1051 i_allocateTBE;
1052 gg_deallocateL1CacheBlock;
1053 vv_allocateL2CacheBlock;
1054 hp_copyFromTBEToL2;
1055 s_deallocateTBE;
1056 }
1057
1058 transition(I, Trigger_L2_to_L1D, IT) {
1059 i_allocateTBE;
1060 rr_deallocateL2CacheBlock;
1061 ii_allocateL1DCacheBlock;
1062 nb_copyFromTBEToL1; // Not really needed for state I
1063 s_deallocateTBE;
1064 uu_profileMiss;
1065 zz_recycleMandatoryQueue;
1066 ll_L2toL1Transfer;
1067 }
1068
1069 transition(S, Trigger_L2_to_L1D, ST) {
1070 i_allocateTBE;
1071 rr_deallocateL2CacheBlock;
1072 ii_allocateL1DCacheBlock;
1073 nb_copyFromTBEToL1;
1074 s_deallocateTBE;
1075 uu_profileMiss;
1076 zz_recycleMandatoryQueue;
1077 ll_L2toL1Transfer;
1078 }
1079
1080 transition(O, Trigger_L2_to_L1D, OT) {
1081 i_allocateTBE;
1082 rr_deallocateL2CacheBlock;
1083 ii_allocateL1DCacheBlock;
1084 nb_copyFromTBEToL1;
1085 s_deallocateTBE;
1086 uu_profileMiss;
1087 zz_recycleMandatoryQueue;
1088 ll_L2toL1Transfer;
1089 }
1090
1091 transition(M, Trigger_L2_to_L1D, MT) {
1092 i_allocateTBE;
1093 rr_deallocateL2CacheBlock;
1094 ii_allocateL1DCacheBlock;
1095 nb_copyFromTBEToL1;
1096 s_deallocateTBE;
1097 uu_profileMiss;
1098 zz_recycleMandatoryQueue;
1099 ll_L2toL1Transfer;
1100 }
1101
1102 transition(MM, Trigger_L2_to_L1D, MMT) {
1103 i_allocateTBE;
1104 rr_deallocateL2CacheBlock;
1105 ii_allocateL1DCacheBlock;
1106 nb_copyFromTBEToL1;
1107 s_deallocateTBE;
1108 uu_profileMiss;
1109 zz_recycleMandatoryQueue;
1110 ll_L2toL1Transfer;
1111 }
1112
1113 transition(I, Trigger_L2_to_L1I, IT) {
1114 i_allocateTBE;
1115 rr_deallocateL2CacheBlock;
1116 jj_allocateL1ICacheBlock;
1117 nb_copyFromTBEToL1;
1118 s_deallocateTBE;
1119 uu_profileMiss;
1120 zz_recycleMandatoryQueue;
1121 ll_L2toL1Transfer;
1122 }
1123
1124 transition(S, Trigger_L2_to_L1I, ST) {
1125 i_allocateTBE;
1126 rr_deallocateL2CacheBlock;
1127 jj_allocateL1ICacheBlock;
1128 nb_copyFromTBEToL1;
1129 s_deallocateTBE;
1130 uu_profileMiss;
1131 zz_recycleMandatoryQueue;
1132 ll_L2toL1Transfer;
1133 }
1134
1135 transition(O, Trigger_L2_to_L1I, OT) {
1136 i_allocateTBE;
1137 rr_deallocateL2CacheBlock;
1138 jj_allocateL1ICacheBlock;
1139 nb_copyFromTBEToL1;
1140 s_deallocateTBE;
1141 uu_profileMiss;
1142 zz_recycleMandatoryQueue;
1143 ll_L2toL1Transfer;
1144 }
1145
1146 transition(M, Trigger_L2_to_L1I, MT) {
1147 i_allocateTBE;
1148 rr_deallocateL2CacheBlock;
1149 jj_allocateL1ICacheBlock;
1150 nb_copyFromTBEToL1;
1151 s_deallocateTBE;
1152 uu_profileMiss;
1153 zz_recycleMandatoryQueue;
1154 ll_L2toL1Transfer;
1155 }
1156
1157 transition(MM, Trigger_L2_to_L1I, MMT) {
1158 i_allocateTBE;
1159 rr_deallocateL2CacheBlock;
1160 jj_allocateL1ICacheBlock;
1161 nb_copyFromTBEToL1;
1162 s_deallocateTBE;
1163 uu_profileMiss;
1164 zz_recycleMandatoryQueue;
1165 ll_L2toL1Transfer;
1166 }
1167
1168 transition(IT, Complete_L2_to_L1, I) {
1169 j_popTriggerQueue;
1170 }
1171
1172 transition(ST, Complete_L2_to_L1, S) {
1173 j_popTriggerQueue;
1174 }
1175
1176 transition(OT, Complete_L2_to_L1, O) {
1177 j_popTriggerQueue;
1178 }
1179
1180 transition(MT, Complete_L2_to_L1, M) {
1181 j_popTriggerQueue;
1182 }
1183
1184 transition(MMT, Complete_L2_to_L1, MM) {
1185 j_popTriggerQueue;
1186 }
1187
1188 // Transitions from Idle
1189 transition(I, Load, IS) {
1190 ii_allocateL1DCacheBlock;
1191 i_allocateTBE;
1192 a_issueGETS;
1193 uu_profileMiss;
1194 k_popMandatoryQueue;
1195 }
1196
1197 transition(I, Ifetch, IS) {
1198 jj_allocateL1ICacheBlock;
1199 i_allocateTBE;
1200 a_issueGETS;
1201 uu_profileMiss;
1202 k_popMandatoryQueue;
1203 }
1204
1205 transition(I, Store, IM) {
1206 ii_allocateL1DCacheBlock;
1207 i_allocateTBE;
1208 b_issueGETX;
1209 uu_profileMiss;
1210 k_popMandatoryQueue;
1211 }
1212
1213 transition(I, L2_Replacement) {
1214 rr_deallocateL2CacheBlock;
1215 }
1216
1217 transition(I, {Other_GETX, NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Invalidate}) {
1218 f_sendAck;
1219 l_popForwardQueue;
1220 }
1221
1222 // Transitions from Shared
1223 transition({S, SM, ISM}, {Load, Ifetch}) {
1224 h_load_hit;
1225 k_popMandatoryQueue;
1226 }
1227
1228 transition(S, Store, SM) {
1229 i_allocateTBE;
1230 b_issueGETX;
1231 uu_profileMiss;
1232 k_popMandatoryQueue;
1233 }
1234
1235 transition(S, L2_Replacement, I) {
1236 rr_deallocateL2CacheBlock;
1237 }
1238
1239 transition(S, {Other_GETX, Invalidate}, I) {
1240 f_sendAck;
1241 l_popForwardQueue;
1242 }
1243
1244 transition(S, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1245 ff_sendAckShared;
1246 l_popForwardQueue;
1247 }
1248
1249 // Transitions from Owned
1250 transition({O, OM, SS, MM_W, M_W}, {Load, Ifetch}) {
1251 h_load_hit;
1252 k_popMandatoryQueue;
1253 }
1254
1255 transition(O, Store, OM) {
1256 i_allocateTBE;
1257 b_issueGETX;
1258 p_decrementNumberOfMessagesByOne;
1259 uu_profileMiss;
1260 k_popMandatoryQueue;
1261 }
1262
1263 transition(O, L2_Replacement, OI) {
1264 i_allocateTBE;
1265 d_issuePUT;
1266 rr_deallocateL2CacheBlock;
1267 }
1268
1269 transition(O, {Other_GETX, Invalidate}, I) {
1270 e_sendData;
1271 l_popForwardQueue;
1272 }
1273
1274 transition(O, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1275 ee_sendDataShared;
1276 l_popForwardQueue;
1277 }
1278
1279 transition(O, Merged_GETS) {
1280 em_sendDataSharedMultiple;
1281 l_popForwardQueue;
1282 }
1283
1284 // Transitions from Modified
1285 transition(MM, {Load, Ifetch}) {
1286 h_load_hit;
1287 k_popMandatoryQueue;
1288 }
1289
1290 transition(MM, Store) {
1291 hh_store_hit;
1292 k_popMandatoryQueue;
1293 }
1294
1295 transition(MM, L2_Replacement, MI) {
1296 i_allocateTBE;
1297 d_issuePUT;
1298 rr_deallocateL2CacheBlock;
1299 }
1300
1301 transition(MM, {Other_GETX, Invalidate}, I) {
1302 c_sendExclusiveData;
1303 l_popForwardQueue;
1304 }
1305
1306 transition(MM, Other_GETS, I) {
1307 c_sendExclusiveData;
1308 l_popForwardQueue;
1309 }
1310
1311 transition(MM, NC_DMA_GETS) {
1312 c_sendExclusiveData;
1313 l_popForwardQueue;
1314 }
1315
1316 transition(MM, Other_GETS_No_Mig, O) {
1317 ee_sendDataShared;
1318 l_popForwardQueue;
1319 }
1320
1321 transition(MM, Merged_GETS, O) {
1322 em_sendDataSharedMultiple;
1323 l_popForwardQueue;
1324 }
1325
1326 // Transitions from Dirty Exclusive
1327 transition(M, {Load, Ifetch}) {
1328 h_load_hit;
1329 k_popMandatoryQueue;
1330 }
1331
1332 transition(M, Store, MM) {
1333 hh_store_hit;
1334 k_popMandatoryQueue;
1335 }
1336
1337 transition(M, L2_Replacement, MI) {
1338 i_allocateTBE;
1339 d_issuePUT;
1340 rr_deallocateL2CacheBlock;
1341 }
1342
1343 transition(M, {Other_GETX, Invalidate}, I) {
1344 c_sendExclusiveData;
1345 l_popForwardQueue;
1346 }
1347
1348 transition(M, {Other_GETS, Other_GETS_No_Mig}, O) {
1349 ee_sendDataShared;
1350 l_popForwardQueue;
1351 }
1352
1353 transition(M, NC_DMA_GETS) {
1354 ee_sendDataShared;
1355 l_popForwardQueue;
1356 }
1357
1358 transition(M, Merged_GETS, O) {
1359 em_sendDataSharedMultiple;
1360 l_popForwardQueue;
1361 }
1362
1363 // Transitions from IM
1364
1365 transition(IM, {Other_GETX, NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Invalidate}) {
1366 f_sendAck;
1367 l_popForwardQueue;
1368 }
1369
1370 transition(IM, Ack) {
1371 m_decrementNumberOfMessages;
1372 o_checkForCompletion;
1373 n_popResponseQueue;
1374 }
1375
1376 transition(IM, Data, ISM) {
1377 u_writeDataToCache;
1378 m_decrementNumberOfMessages;
1379 o_checkForCompletion;
1380 n_popResponseQueue;
1381 }
1382
1383 transition(IM, Exclusive_Data, MM_W) {
1384 u_writeDataToCache;
1385 m_decrementNumberOfMessages;
1386 o_checkForCompletion;
1387 sx_external_store_hit;
1388 n_popResponseQueue;
1389 }
1390
1391 // Transitions from SM
1392 transition(SM, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1393 ff_sendAckShared;
1394 l_popForwardQueue;
1395 }
1396
1397 transition(SM, {Other_GETX, Invalidate}, IM) {
1398 f_sendAck;
1399 l_popForwardQueue;
1400 }
1401
1402 transition(SM, Ack) {
1403 m_decrementNumberOfMessages;
1404 o_checkForCompletion;
1405 n_popResponseQueue;
1406 }
1407
1408 transition(SM, {Data, Exclusive_Data}, ISM) {
1409 v_writeDataToCacheVerify;
1410 m_decrementNumberOfMessages;
1411 o_checkForCompletion;
1412 n_popResponseQueue;
1413 }
1414
1415 // Transitions from ISM
1416 transition(ISM, Ack) {
1417 m_decrementNumberOfMessages;
1418 o_checkForCompletion;
1419 n_popResponseQueue;
1420 }
1421
1422 transition(ISM, All_acks_no_sharers, MM) {
1423 sxt_trig_ext_store_hit;
1424 gm_sendUnblockM;
1425 s_deallocateTBE;
1426 j_popTriggerQueue;
1427 }
1428
1429 // Transitions from OM
1430
1431 transition(OM, {Other_GETX, Invalidate}, IM) {
1432 e_sendData;
1433 pp_incrementNumberOfMessagesByOne;
1434 l_popForwardQueue;
1435 }
1436
1437 transition(OM, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1438 ee_sendDataShared;
1439 l_popForwardQueue;
1440 }
1441
1442 transition(OM, Merged_GETS) {
1443 em_sendDataSharedMultiple;
1444 l_popForwardQueue;
1445 }
1446
1447 transition(OM, Ack) {
1448 m_decrementNumberOfMessages;
1449 o_checkForCompletion;
1450 n_popResponseQueue;
1451 }
1452
1453 transition(OM, {All_acks, All_acks_no_sharers}, MM) {
1454 sxt_trig_ext_store_hit;
1455 gm_sendUnblockM;
1456 s_deallocateTBE;
1457 j_popTriggerQueue;
1458 }
1459
1460 // Transitions from IS
1461
1462 transition(IS, {Other_GETX, NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Invalidate}) {
1463 f_sendAck;
1464 l_popForwardQueue;
1465 }
1466
1467 transition(IS, Ack) {
1468 m_decrementNumberOfMessages;
1469 o_checkForCompletion;
1470 n_popResponseQueue;
1471 }
1472
1473 transition(IS, Shared_Ack) {
1474 m_decrementNumberOfMessages;
1475 r_setSharerBit;
1476 o_checkForCompletion;
1477 n_popResponseQueue;
1478 }
1479
1480 transition(IS, Data, SS) {
1481 u_writeDataToCache;
1482 m_decrementNumberOfMessages;
1483 o_checkForCompletion;
1484 hx_external_load_hit;
1485 uo_updateCurrentOwner;
1486 n_popResponseQueue;
1487 }
1488
1489 transition(IS, Exclusive_Data, M_W) {
1490 u_writeDataToCache;
1491 m_decrementNumberOfMessages;
1492 o_checkForCompletion;
1493 hx_external_load_hit;
1494 n_popResponseQueue;
1495 }
1496
1497 transition(IS, Shared_Data, SS) {
1498 u_writeDataToCache;
1499 r_setSharerBit;
1500 m_decrementNumberOfMessages;
1501 o_checkForCompletion;
1502 hx_external_load_hit;
1503 uo_updateCurrentOwner;
1504 n_popResponseQueue;
1505 }
1506
1507 // Transitions from SS
1508
1509 transition(SS, Ack) {
1510 m_decrementNumberOfMessages;
1511 o_checkForCompletion;
1512 n_popResponseQueue;
1513 }
1514
1515 transition(SS, Shared_Ack) {
1516 m_decrementNumberOfMessages;
1517 r_setSharerBit;
1518 o_checkForCompletion;
1519 n_popResponseQueue;
1520 }
1521
1522 transition(SS, All_acks, S) {
1523 gs_sendUnblockS;
1524 s_deallocateTBE;
1525 j_popTriggerQueue;
1526 }
1527
1528 transition(SS, All_acks_no_sharers, S) {
1529 // Note: The directory might still be the owner, so that is why we go to S
1530 gs_sendUnblockS;
1531 s_deallocateTBE;
1532 j_popTriggerQueue;
1533 }
1534
1535 // Transitions from MM_W
1536
1537 transition(MM_W, Store) {
1538 hh_store_hit;
1539 k_popMandatoryQueue;
1540 }
1541
1542 transition(MM_W, Ack) {
1543 m_decrementNumberOfMessages;
1544 o_checkForCompletion;
1545 n_popResponseQueue;
1546 }
1547
1548 transition(MM_W, All_acks_no_sharers, MM) {
1549 gm_sendUnblockM;
1550 s_deallocateTBE;
1551 j_popTriggerQueue;
1552 }
1553
1554 // Transitions from M_W
1555
1556 transition(M_W, Store, MM_W) {
1557 hh_store_hit;
1558 k_popMandatoryQueue;
1559 }
1560
1561 transition(M_W, Ack) {
1562 m_decrementNumberOfMessages;
1563 o_checkForCompletion;
1564 n_popResponseQueue;
1565 }
1566
1567 transition(M_W, All_acks_no_sharers, M) {
1568 gm_sendUnblockM;
1569 s_deallocateTBE;
1570 j_popTriggerQueue;
1571 }
1572
1573 // Transitions from OI/MI
1574
1575 transition({OI, MI}, {Other_GETX, Invalidate}, II) {
1576 q_sendDataFromTBEToCache;
1577 l_popForwardQueue;
1578 }
1579
1580 transition({OI, MI}, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}, OI) {
1581 q_sendDataFromTBEToCache;
1582 l_popForwardQueue;
1583 }
1584
1585 transition({OI, MI}, Merged_GETS, OI) {
1586 qm_sendDataFromTBEToCache;
1587 l_popForwardQueue;
1588 }
1589
1590 transition(MI, Writeback_Ack, I) {
1591 t_sendExclusiveDataFromTBEToMemory;
1592 s_deallocateTBE;
1593 l_popForwardQueue;
1594 }
1595
1596 transition(OI, Writeback_Ack, I) {
1597 qq_sendDataFromTBEToMemory;
1598 s_deallocateTBE;
1599 l_popForwardQueue;
1600 }
1601
1602 // Transitions from II
1603 transition(II, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Other_GETX, Invalidate}, II) {
1604 f_sendAck;
1605 l_popForwardQueue;
1606 }
1607
1608 transition(II, Writeback_Ack, I) {
1609 g_sendUnblock;
1610 s_deallocateTBE;
1611 l_popForwardQueue;
1612 }
1613
1614 transition(II, Writeback_Nack, I) {
1615 s_deallocateTBE;
1616 l_popForwardQueue;
1617 }
1618 }