2 * Copyright (c) 1999-2013 Mark D. Hill and David A. Wood
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $Id: MOESI_CMP_token-L1cache.sm 1.22 05/01/19 15:55:39-06:00 beckmann@s0-28.cs.wisc.edu $
34 machine(L1Cache, "Token protocol")
35 : Sequencer * sequencer;
36 CacheMemory * L1Icache;
37 CacheMemory * L1Dcache;
38 int l2_select_num_bits;
41 Cycles l1_request_latency := 2;
42 Cycles l1_response_latency := 2;
43 int retry_threshold := 1;
44 Cycles fixed_timeout_latency := 100;
45 Cycles reissue_wakeup_latency := 10;
46 Cycles use_timeout_latency := 50;
48 bool dynamic_timeout_enabled := "True";
49 bool no_mig_atomic := "True";
53 // From this node's L1 cache TO the network
55 // a local L1 -> this L2 bank
56 MessageBuffer * responseFromL1Cache, network="To", virtual_network="4",
57 ordered="false", vnet_type="response";
58 MessageBuffer * persistentFromL1Cache, network="To", virtual_network="3",
59 ordered="true", vnet_type="persistent";
60 // a local L1 -> this L2 bank, currently ordered with directory forwarded requests
61 MessageBuffer * requestFromL1Cache, network="To", virtual_network="1",
62 ordered="false", vnet_type="request";
65 // To this node's L1 cache FROM the network
67 // a L2 bank -> this L1
68 MessageBuffer * responseToL1Cache, network="From", virtual_network="4",
69 ordered="false", vnet_type="response";
70 MessageBuffer * persistentToL1Cache, network="From", virtual_network="3",
71 ordered="true", vnet_type="persistent";
72 // a L2 bank -> this L1
73 MessageBuffer * requestToL1Cache, network="From", virtual_network="1",
74 ordered="false", vnet_type="request";
78 state_declaration(State, desc="Cache states", default="L1Cache_State_I") {
80 NP, AccessPermission:Invalid, "NP", desc="Not Present";
81 I, AccessPermission:Invalid, "I", desc="Idle";
82 S, AccessPermission:Read_Only, "S", desc="Shared";
83 O, AccessPermission:Read_Only, "O", desc="Owned";
84 M, AccessPermission:Read_Only, "M", desc="Modified (dirty)";
85 MM, AccessPermission:Read_Write, "MM", desc="Modified (dirty and locally modified)";
86 M_W, AccessPermission:Read_Only, "M^W", desc="Modified (dirty), waiting";
87 MM_W, AccessPermission:Read_Write, "MM^W", desc="Modified (dirty and locally modified), waiting";
90 IM, AccessPermission:Busy, "IM", desc="Issued GetX";
91 SM, AccessPermission:Read_Only, "SM", desc="Issued GetX, we still have an old copy of the line";
92 OM, AccessPermission:Read_Only, "OM", desc="Issued GetX, received data";
93 IS, AccessPermission:Busy, "IS", desc="Issued GetS";
96 I_L, AccessPermission:Busy, "I^L", desc="Invalid, Locked";
97 S_L, AccessPermission:Busy, "S^L", desc="Shared, Locked";
98 IM_L, AccessPermission:Busy, "IM^L", desc="Invalid, Locked, trying to go to Modified";
99 SM_L, AccessPermission:Busy, "SM^L", desc="Shared, Locked, trying to go to Modified";
100 IS_L, AccessPermission:Busy, "IS^L", desc="Invalid, Locked, trying to go to Shared";
104 enumeration(Event, desc="Cache events") {
105 Load, desc="Load request from the processor";
106 Ifetch, desc="I-fetch request from the processor";
107 Store, desc="Store request from the processor";
108 Atomic, desc="Atomic request from the processor";
109 L1_Replacement, desc="L1 Replacement";
112 Data_Shared, desc="Received a data message, we are now a sharer";
113 Data_Owner, desc="Received a data message, we are now the owner";
114 Data_All_Tokens, desc="Received a data message, we are now the owner, we now have all the tokens";
115 Ack, desc="Received an ack message";
116 Ack_All_Tokens, desc="Received an ack message, we now have all the tokens";
119 Transient_GETX, desc="A GetX from another processor";
120 Transient_Local_GETX, desc="A GetX from another processor";
121 Transient_GETS, desc="A GetS from another processor";
122 Transient_Local_GETS, desc="A GetS from another processor";
123 Transient_GETS_Last_Token, desc="A GetS from another processor";
124 Transient_Local_GETS_Last_Token, desc="A GetS from another processor";
126 // Lock/Unlock for distributed
127 Persistent_GETX, desc="Another processor has priority to read/write";
128 Persistent_GETS, desc="Another processor has priority to read";
129 Persistent_GETS_Last_Token, desc="Another processor has priority to read, no more tokens";
130 Own_Lock_or_Unlock, desc="This processor now has priority";
133 Request_Timeout, desc="Timeout";
134 Use_TimeoutStarverX, desc="Timeout";
135 Use_TimeoutStarverS, desc="Timeout";
136 Use_TimeoutNoStarvers, desc="Timeout";
137 Use_TimeoutNoStarvers_NoMig, desc="Timeout Don't Migrate";
143 structure(Entry, desc="...", interface="AbstractCacheEntry") {
144 State CacheState, desc="cache state";
145 bool Dirty, desc="Is the data dirty (different than memory)?";
146 int Tokens, desc="The number of tokens we're holding for the line";
147 DataBlock DataBlk, desc="data for the block";
152 structure(TBE, desc="...") {
153 Address Addr, desc="Physical address for this TBE";
154 State TBEState, desc="Transient state";
155 int IssueCount, default="0", desc="The number of times we've issued a request for this line.";
156 Address PC, desc="Program counter of request";
158 bool WentPersistent, default="false", desc="Request went persistent";
159 bool ExternalResponse, default="false", desc="Response came from an external controller";
160 bool IsAtomic, default="false", desc="Request was an atomic request";
162 AccessType TypeOfAccess, desc="Type of request (used for profiling)";
163 Cycles IssueTime, desc="Time the request was issued";
164 RubyAccessMode AccessMode, desc="user/supervisor access type";
165 PrefetchBit Prefetch, desc="Is this a prefetch request";
168 structure(TBETable, external="yes") {
170 void allocate(Address);
171 void deallocate(Address);
172 bool isPresent(Address);
175 structure(PersistentTable, external="yes") {
176 void persistentRequestLock(Address, MachineID, AccessType);
177 void persistentRequestUnlock(Address, MachineID);
178 bool okToIssueStarving(Address, MachineID);
179 MachineID findSmallest(Address);
180 AccessType typeOfSmallest(Address);
181 void markEntries(Address);
182 bool isLocked(Address);
183 int countStarvingForAddress(Address);
184 int countReadStarvingForAddress(Address);
187 void set_cache_entry(AbstractCacheEntry b);
188 void unset_cache_entry();
191 void wakeUpAllBuffers();
192 void wakeUpBuffers(Address a);
195 TBETable L1_TBEs, template="<L1Cache_TBE>", constructor="m_number_of_TBEs";
197 MessageBuffer mandatoryQueue, ordered="false", abstract_chip_ptr="true";
199 bool starving, default="false";
200 int l2_select_low_bit, default="RubySystem::getBlockSizeBits()";
202 PersistentTable persistentTable;
203 TimerTable useTimerTable;
204 TimerTable reissueTimerTable;
206 int outstandingRequests, default="0";
207 int outstandingPersistentRequests, default="0";
209 // Constant that provides hysteresis for calculated the estimated average
210 int averageLatencyHysteresis, default="(8)";
211 Cycles averageLatencyCounter,
212 default="(Cycles(500) << (*m_averageLatencyHysteresis_ptr))";
214 Cycles averageLatencyEstimate() {
215 DPRINTF(RubySlicc, "%d\n",
216 (averageLatencyCounter >> averageLatencyHysteresis));
217 return averageLatencyCounter >> averageLatencyHysteresis;
220 void updateAverageLatencyEstimate(Cycles latency) {
221 DPRINTF(RubySlicc, "%d\n", latency);
223 // By subtracting the current average and then adding the most
224 // recent sample, we calculate an estimate of the recent average.
225 // If we simply used a running sum and divided by the total number
226 // of entries, the estimate of the average would adapt very slowly
227 // after the execution has run for a long time.
228 // averageLatencyCounter := averageLatencyCounter - averageLatencyEstimate() + latency;
230 averageLatencyCounter := averageLatencyCounter - averageLatencyEstimate() + latency;
233 Entry getCacheEntry(Address addr), return_by_pointer="yes" {
234 Entry L1Dcache_entry := static_cast(Entry, "pointer", L1Dcache.lookup(addr));
235 if(is_valid(L1Dcache_entry)) {
236 return L1Dcache_entry;
239 Entry L1Icache_entry := static_cast(Entry, "pointer", L1Icache.lookup(addr));
240 return L1Icache_entry;
243 DataBlock getDataBlock(Address addr), return_by_ref="yes" {
244 return getCacheEntry(addr).DataBlk;
247 Entry getL1DCacheEntry(Address addr), return_by_pointer="yes" {
248 Entry L1Dcache_entry := static_cast(Entry, "pointer", L1Dcache.lookup(addr));
249 return L1Dcache_entry;
252 Entry getL1ICacheEntry(Address addr), return_by_pointer="yes" {
253 Entry L1Icache_entry := static_cast(Entry, "pointer", L1Icache.lookup(addr));
254 return L1Icache_entry;
257 int getTokens(Entry cache_entry) {
258 if (is_valid(cache_entry)) {
259 return cache_entry.Tokens;
264 State getState(TBE tbe, Entry cache_entry, Address addr) {
268 } else if (is_valid(cache_entry)) {
269 return cache_entry.CacheState;
271 if (persistentTable.isLocked(addr) && (persistentTable.findSmallest(addr) != machineID)) {
272 // Not in cache, in persistent table, but this processor isn't highest priority
280 void setState(TBE tbe, Entry cache_entry, Address addr, State state) {
281 assert((L1Dcache.isTagPresent(addr) && L1Icache.isTagPresent(addr)) == false);
284 assert(state != State:I);
285 assert(state != State:S);
286 assert(state != State:O);
287 assert(state != State:MM);
288 assert(state != State:M);
289 tbe.TBEState := state;
292 if (is_valid(cache_entry)) {
293 // Make sure the token count is in range
294 assert(cache_entry.Tokens >= 0);
295 assert(cache_entry.Tokens <= max_tokens());
296 assert(cache_entry.Tokens != (max_tokens() / 2));
298 if ((state == State:I_L) ||
299 (state == State:IM_L) ||
300 (state == State:IS_L)) {
301 // Make sure we have no tokens in the "Invalid, locked" states
302 assert(cache_entry.Tokens == 0);
304 // Make sure the line is locked
305 // assert(persistentTable.isLocked(addr));
307 // But we shouldn't have highest priority for it
308 // assert(persistentTable.findSmallest(addr) != id);
310 } else if ((state == State:S_L) ||
311 (state == State:SM_L)) {
312 assert(cache_entry.Tokens >= 1);
313 assert(cache_entry.Tokens < (max_tokens() / 2));
315 // Make sure the line is locked...
316 // assert(persistentTable.isLocked(addr));
318 // ...But we shouldn't have highest priority for it...
319 // assert(persistentTable.findSmallest(addr) != id);
321 // ...And it must be a GETS request
322 // assert(persistentTable.typeOfSmallest(addr) == AccessType:Read);
326 // If there is an entry in the persistent table of this block,
327 // this processor needs to have an entry in the table for this
328 // block, and that entry better be the smallest (highest
329 // priority). Otherwise, the state should have been one of
332 //if (persistentTable.isLocked(addr)) {
333 // assert(persistentTable.findSmallest(addr) == id);
337 // in M and E you have all the tokens
338 if (state == State:MM || state == State:M || state == State:MM_W || state == State:M_W) {
339 assert(cache_entry.Tokens == max_tokens());
342 // in NP you have no tokens
343 if (state == State:NP) {
344 assert(cache_entry.Tokens == 0);
347 // You have at least one token in S-like states
348 if (state == State:S || state == State:SM) {
349 assert(cache_entry.Tokens > 0);
352 // You have at least half the token in O-like states
353 if (state == State:O && state == State:OM) {
354 assert(cache_entry.Tokens > (max_tokens() / 2));
357 cache_entry.CacheState := state;
361 AccessPermission getAccessPermission(Address addr) {
362 TBE tbe := L1_TBEs[addr];
364 return L1Cache_State_to_permission(tbe.TBEState);
367 Entry cache_entry := getCacheEntry(addr);
368 if(is_valid(cache_entry)) {
369 return L1Cache_State_to_permission(cache_entry.CacheState);
372 return AccessPermission:NotPresent;
375 void setAccessPermission(Entry cache_entry, Address addr, State state) {
376 if (is_valid(cache_entry)) {
377 cache_entry.changePermission(L1Cache_State_to_permission(state));
381 Event mandatory_request_type_to_event(RubyRequestType type) {
382 if (type == RubyRequestType:LD) {
384 } else if (type == RubyRequestType:IFETCH) {
386 } else if (type == RubyRequestType:ST) {
388 } else if (type == RubyRequestType:ATOMIC) {
395 error("Invalid RubyRequestType");
399 AccessType cache_request_type_to_access_type(RubyRequestType type) {
400 if ((type == RubyRequestType:LD) || (type == RubyRequestType:IFETCH)) {
401 return AccessType:Read;
402 } else if ((type == RubyRequestType:ST) || (type == RubyRequestType:ATOMIC)) {
403 return AccessType:Write;
405 error("Invalid RubyRequestType");
409 // NOTE: direct local hits should not call this function
410 bool isExternalHit(Address addr, MachineID sender) {
411 if (machineIDToMachineType(sender) == MachineType:L1Cache) {
413 } else if (machineIDToMachineType(sender) == MachineType:L2Cache) {
415 if (sender == mapAddressToRange(addr, MachineType:L2Cache,
416 l2_select_low_bit, l2_select_num_bits, intToID(0))) {
426 bool okToIssueStarving(Address addr, MachineID machineID) {
427 return persistentTable.okToIssueStarving(addr, machineID);
430 void markPersistentEntries(Address addr) {
431 persistentTable.markEntries(addr);
434 void setExternalResponse(TBE tbe) {
435 assert(is_valid(tbe));
436 tbe.ExternalResponse := true;
439 bool IsAtomic(TBE tbe) {
440 assert(is_valid(tbe));
445 out_port(persistentNetwork_out, PersistentMsg, persistentFromL1Cache);
446 out_port(requestNetwork_out, RequestMsg, requestFromL1Cache);
447 out_port(responseNetwork_out, ResponseMsg, responseFromL1Cache);
448 out_port(requestRecycle_out, RequestMsg, requestToL1Cache);
453 in_port(useTimerTable_in, Address, useTimerTable, rank=5) {
454 if (useTimerTable_in.isReady()) {
455 TBE tbe := L1_TBEs[useTimerTable.readyAddress()];
457 if (persistentTable.isLocked(useTimerTable.readyAddress()) &&
458 (persistentTable.findSmallest(useTimerTable.readyAddress()) != machineID)) {
459 if (persistentTable.typeOfSmallest(useTimerTable.readyAddress()) == AccessType:Write) {
460 trigger(Event:Use_TimeoutStarverX, useTimerTable.readyAddress(),
461 getCacheEntry(useTimerTable.readyAddress()), tbe);
463 trigger(Event:Use_TimeoutStarverS, useTimerTable.readyAddress(),
464 getCacheEntry(useTimerTable.readyAddress()), tbe);
467 if (no_mig_atomic && IsAtomic(tbe)) {
468 trigger(Event:Use_TimeoutNoStarvers_NoMig, useTimerTable.readyAddress(),
469 getCacheEntry(useTimerTable.readyAddress()), tbe);
471 trigger(Event:Use_TimeoutNoStarvers, useTimerTable.readyAddress(),
472 getCacheEntry(useTimerTable.readyAddress()), tbe);
479 in_port(reissueTimerTable_in, Address, reissueTimerTable, rank=4) {
480 if (reissueTimerTable_in.isReady()) {
481 trigger(Event:Request_Timeout, reissueTimerTable.readyAddress(),
482 getCacheEntry(reissueTimerTable.readyAddress()),
483 L1_TBEs[reissueTimerTable.readyAddress()]);
487 // Persistent Network
488 in_port(persistentNetwork_in, PersistentMsg, persistentToL1Cache, rank=3) {
489 if (persistentNetwork_in.isReady()) {
490 peek(persistentNetwork_in, PersistentMsg, block_on="Addr") {
491 assert(in_msg.Destination.isElement(machineID));
493 // Apply the lockdown or unlockdown message to the table
494 if (in_msg.Type == PersistentRequestType:GETX_PERSISTENT) {
495 persistentTable.persistentRequestLock(in_msg.Addr, in_msg.Requestor, AccessType:Write);
496 } else if (in_msg.Type == PersistentRequestType:GETS_PERSISTENT) {
497 persistentTable.persistentRequestLock(in_msg.Addr, in_msg.Requestor, AccessType:Read);
498 } else if (in_msg.Type == PersistentRequestType:DEACTIVATE_PERSISTENT) {
499 persistentTable.persistentRequestUnlock(in_msg.Addr, in_msg.Requestor);
501 error("Unexpected message");
504 // React to the message based on the current state of the table
505 Entry cache_entry := getCacheEntry(in_msg.Addr);
506 TBE tbe := L1_TBEs[in_msg.Addr];
508 if (persistentTable.isLocked(in_msg.Addr)) {
509 if (persistentTable.findSmallest(in_msg.Addr) == machineID) {
510 // Our Own Lock - this processor is highest priority
511 trigger(Event:Own_Lock_or_Unlock, in_msg.Addr,
514 if (persistentTable.typeOfSmallest(in_msg.Addr) == AccessType:Read) {
515 if (getTokens(cache_entry) == 1 ||
516 getTokens(cache_entry) == (max_tokens() / 2) + 1) {
517 trigger(Event:Persistent_GETS_Last_Token, in_msg.Addr,
520 trigger(Event:Persistent_GETS, in_msg.Addr,
524 trigger(Event:Persistent_GETX, in_msg.Addr,
529 // Unlock case - no entries in the table
530 trigger(Event:Own_Lock_or_Unlock, in_msg.Addr,
538 in_port(responseNetwork_in, ResponseMsg, responseToL1Cache, rank=2) {
539 if (responseNetwork_in.isReady()) {
540 peek(responseNetwork_in, ResponseMsg, block_on="Addr") {
541 assert(in_msg.Destination.isElement(machineID));
543 Entry cache_entry := getCacheEntry(in_msg.Addr);
544 TBE tbe := L1_TBEs[in_msg.Addr];
546 // Mark TBE flag if response received off-chip. Use this to update average latency estimate
547 if ( machineIDToMachineType(in_msg.Sender) == MachineType:L2Cache ) {
549 if (in_msg.Sender == mapAddressToRange(in_msg.Addr,
550 MachineType:L2Cache, l2_select_low_bit,
551 l2_select_num_bits, intToID(0))) {
553 // came from an off-chip L2 cache
555 // L1_TBEs[in_msg.Addr].ExternalResponse := true;
556 // profile_offchipL2_response(in_msg.Addr);
560 // profile_onchipL2_response(in_msg.Addr );
562 } else if ( machineIDToMachineType(in_msg.Sender) == MachineType:Directory ) {
564 setExternalResponse(tbe);
565 // profile_memory_response( in_msg.Addr);
567 } else if ( machineIDToMachineType(in_msg.Sender) == MachineType:L1Cache) {
568 //if (isLocalProcessor(machineID, in_msg.Sender) == false) {
569 //if (is_valid(tbe)) {
570 // tbe.ExternalResponse := true;
571 // profile_offchipL1_response(in_msg.Addr );
575 // profile_onchipL1_response(in_msg.Addr );
578 error("unexpected SenderMachine");
582 if (getTokens(cache_entry) + in_msg.Tokens != max_tokens()) {
583 if (in_msg.Type == CoherenceResponseType:ACK) {
584 assert(in_msg.Tokens < (max_tokens() / 2));
585 trigger(Event:Ack, in_msg.Addr, cache_entry, tbe);
586 } else if (in_msg.Type == CoherenceResponseType:DATA_OWNER) {
587 trigger(Event:Data_Owner, in_msg.Addr, cache_entry, tbe);
588 } else if (in_msg.Type == CoherenceResponseType:DATA_SHARED) {
589 assert(in_msg.Tokens < (max_tokens() / 2));
590 trigger(Event:Data_Shared, in_msg.Addr, cache_entry, tbe);
592 error("Unexpected message");
595 if (in_msg.Type == CoherenceResponseType:ACK) {
596 assert(in_msg.Tokens < (max_tokens() / 2));
597 trigger(Event:Ack_All_Tokens, in_msg.Addr, cache_entry, tbe);
598 } else if (in_msg.Type == CoherenceResponseType:DATA_OWNER || in_msg.Type == CoherenceResponseType:DATA_SHARED) {
599 trigger(Event:Data_All_Tokens, in_msg.Addr, cache_entry, tbe);
601 error("Unexpected message");
609 in_port(requestNetwork_in, RequestMsg, requestToL1Cache) {
610 if (requestNetwork_in.isReady()) {
611 peek(requestNetwork_in, RequestMsg, block_on="Addr") {
612 assert(in_msg.Destination.isElement(machineID));
614 Entry cache_entry := getCacheEntry(in_msg.Addr);
615 TBE tbe := L1_TBEs[in_msg.Addr];
617 if (in_msg.Type == CoherenceRequestType:GETX) {
618 if (in_msg.isLocal) {
619 trigger(Event:Transient_Local_GETX, in_msg.Addr,
623 trigger(Event:Transient_GETX, in_msg.Addr,
626 } else if (in_msg.Type == CoherenceRequestType:GETS) {
627 if (getTokens(cache_entry) == 1 ||
628 getTokens(cache_entry) == (max_tokens() / 2) + 1) {
629 if (in_msg.isLocal) {
630 trigger(Event:Transient_Local_GETS_Last_Token, in_msg.Addr,
634 trigger(Event:Transient_GETS_Last_Token, in_msg.Addr,
639 if (in_msg.isLocal) {
640 trigger(Event:Transient_Local_GETS, in_msg.Addr,
644 trigger(Event:Transient_GETS, in_msg.Addr,
649 error("Unexpected message");
656 in_port(mandatoryQueue_in, RubyRequest, mandatoryQueue, desc="...", rank=0) {
657 if (mandatoryQueue_in.isReady()) {
658 peek(mandatoryQueue_in, RubyRequest, block_on="LineAddress") {
659 // Check for data access to blocks in I-cache and ifetchs to blocks in D-cache
661 TBE tbe := L1_TBEs[in_msg.LineAddress];
663 if (in_msg.Type == RubyRequestType:IFETCH) {
664 // ** INSTRUCTION ACCESS ***
666 Entry L1Icache_entry := getL1ICacheEntry(in_msg.LineAddress);
667 if (is_valid(L1Icache_entry)) {
668 // The tag matches for the L1, so the L1 fetches the line.
669 // We know it can't be in the L2 due to exclusion.
670 trigger(mandatory_request_type_to_event(in_msg.Type),
671 in_msg.LineAddress, L1Icache_entry, tbe);
674 // Check to see if it is in the OTHER L1
675 Entry L1Dcache_entry := getL1DCacheEntry(in_msg.LineAddress);
676 if (is_valid(L1Dcache_entry)) {
677 // The block is in the wrong L1, try to write it to the L2
678 trigger(Event:L1_Replacement, in_msg.LineAddress,
679 L1Dcache_entry, tbe);
682 if (L1Icache.cacheAvail(in_msg.LineAddress)) {
683 // L1 does't have the line, but we have space for it in the L1
684 trigger(mandatory_request_type_to_event(in_msg.Type),
685 in_msg.LineAddress, L1Icache_entry, tbe);
687 // No room in the L1, so we need to make room
688 trigger(Event:L1_Replacement,
689 L1Icache.cacheProbe(in_msg.LineAddress),
690 getL1ICacheEntry(L1Icache.cacheProbe(in_msg.LineAddress)),
691 L1_TBEs[L1Icache.cacheProbe(in_msg.LineAddress)]);
695 // *** DATA ACCESS ***
697 Entry L1Dcache_entry := getL1DCacheEntry(in_msg.LineAddress);
698 if (is_valid(L1Dcache_entry)) {
699 // The tag matches for the L1, so the L1 fetches the line.
700 // We know it can't be in the L2 due to exclusion.
701 trigger(mandatory_request_type_to_event(in_msg.Type),
702 in_msg.LineAddress, L1Dcache_entry, tbe);
705 // Check to see if it is in the OTHER L1
706 Entry L1Icache_entry := getL1ICacheEntry(in_msg.LineAddress);
707 if (is_valid(L1Icache_entry)) {
708 // The block is in the wrong L1, try to write it to the L2
709 trigger(Event:L1_Replacement, in_msg.LineAddress,
710 L1Icache_entry, tbe);
713 if (L1Dcache.cacheAvail(in_msg.LineAddress)) {
714 // L1 does't have the line, but we have space for it in the L1
715 trigger(mandatory_request_type_to_event(in_msg.Type),
716 in_msg.LineAddress, L1Dcache_entry, tbe);
718 // No room in the L1, so we need to make room
719 trigger(Event:L1_Replacement,
720 L1Dcache.cacheProbe(in_msg.LineAddress),
721 getL1DCacheEntry(L1Dcache.cacheProbe(in_msg.LineAddress)),
722 L1_TBEs[L1Dcache.cacheProbe(in_msg.LineAddress)]);
732 action(a_issueReadRequest, "a", desc="Issue GETS") {
733 assert(is_valid(tbe));
734 if (tbe.IssueCount == 0) {
735 // Update outstanding requests
736 //profile_outstanding_request(outstandingRequests);
737 outstandingRequests := outstandingRequests + 1;
740 if (tbe.IssueCount >= retry_threshold) {
741 // Issue a persistent request if possible
742 if (okToIssueStarving(address, machineID) && (starving == false)) {
743 enqueue(persistentNetwork_out, PersistentMsg, l1_request_latency) {
744 out_msg.Addr := address;
745 out_msg.Type := PersistentRequestType:GETS_PERSISTENT;
746 out_msg.Requestor := machineID;
747 out_msg.Destination.broadcast(MachineType:L1Cache);
750 // Currently the configuration system limits the system to only one
751 // chip. Therefore, if we assume one shared L2 cache, then only one
752 // pertinent L2 cache exist.
754 //out_msg.Destination.addNetDest(getAllPertinentL2Banks(address));
756 out_msg.Destination.add(mapAddressToRange(address,
757 MachineType:L2Cache, l2_select_low_bit,
758 l2_select_num_bits, intToID(0)));
760 out_msg.Destination.add(map_Address_to_Directory(address));
761 out_msg.MessageSize := MessageSizeType:Persistent_Control;
762 out_msg.Prefetch := tbe.Prefetch;
763 out_msg.AccessMode := tbe.AccessMode;
765 markPersistentEntries(address);
768 if (tbe.IssueCount == 0) {
769 //profile_persistent_prediction(address, tbe.TypeOfAccess);
772 // Update outstanding requests
773 //profile_outstanding_persistent_request(outstandingPersistentRequests);
774 outstandingPersistentRequests := outstandingPersistentRequests + 1;
776 // Increment IssueCount
777 tbe.IssueCount := tbe.IssueCount + 1;
779 tbe.WentPersistent := true;
781 // Do not schedule a wakeup, a persistent requests will always complete
785 // We'd like to issue a persistent request, but are not allowed
786 // to issue a P.R. right now. This, we do not increment the
789 // Set a wakeup timer
790 reissueTimerTable.set(address, reissue_wakeup_latency);
794 // Make a normal request
795 enqueue(requestNetwork_out, RequestMsg, l1_request_latency) {
796 out_msg.Addr := address;
797 out_msg.Type := CoherenceRequestType:GETS;
798 out_msg.Requestor := machineID;
799 out_msg.Destination.add(mapAddressToRange(address,
800 MachineType:L2Cache, l2_select_low_bit,
801 l2_select_num_bits, intToID(0)));
803 out_msg.RetryNum := tbe.IssueCount;
804 if (tbe.IssueCount == 0) {
805 out_msg.MessageSize := MessageSizeType:Request_Control;
807 out_msg.MessageSize := MessageSizeType:Reissue_Control;
809 out_msg.Prefetch := tbe.Prefetch;
810 out_msg.AccessMode := tbe.AccessMode;
813 // send to other local L1s, with local bit set
814 enqueue(requestNetwork_out, RequestMsg, l1_request_latency) {
815 out_msg.Addr := address;
816 out_msg.Type := CoherenceRequestType:GETS;
817 out_msg.Requestor := machineID;
819 // Since only one chip, assuming all L1 caches are local
821 //out_msg.Destination := getOtherLocalL1IDs(machineID);
822 out_msg.Destination.broadcast(MachineType:L1Cache);
823 out_msg.Destination.remove(machineID);
825 out_msg.RetryNum := tbe.IssueCount;
826 out_msg.isLocal := true;
827 if (tbe.IssueCount == 0) {
828 out_msg.MessageSize := MessageSizeType:Broadcast_Control;
830 out_msg.MessageSize := MessageSizeType:Broadcast_Control;
832 out_msg.Prefetch := tbe.Prefetch;
833 out_msg.AccessMode := tbe.AccessMode;
836 // Increment IssueCount
837 tbe.IssueCount := tbe.IssueCount + 1;
839 // Set a wakeup timer
841 if (dynamic_timeout_enabled) {
842 reissueTimerTable.set(address, (5 * averageLatencyEstimate()) / 4);
844 reissueTimerTable.set(address, fixed_timeout_latency);
850 action(b_issueWriteRequest, "b", desc="Issue GETX") {
852 assert(is_valid(tbe));
853 if (tbe.IssueCount == 0) {
854 // Update outstanding requests
855 //profile_outstanding_request(outstandingRequests);
856 outstandingRequests := outstandingRequests + 1;
859 if (tbe.IssueCount >= retry_threshold) {
860 // Issue a persistent request if possible
861 if ( okToIssueStarving(address, machineID) && (starving == false)) {
862 enqueue(persistentNetwork_out, PersistentMsg, l1_request_latency) {
863 out_msg.Addr := address;
864 out_msg.Type := PersistentRequestType:GETX_PERSISTENT;
865 out_msg.Requestor := machineID;
866 out_msg.Destination.broadcast(MachineType:L1Cache);
869 // Currently the configuration system limits the system to only one
870 // chip. Therefore, if we assume one shared L2 cache, then only one
871 // pertinent L2 cache exist.
873 //out_msg.Destination.addNetDest(getAllPertinentL2Banks(address));
875 out_msg.Destination.add(mapAddressToRange(address,
876 MachineType:L2Cache, l2_select_low_bit,
877 l2_select_num_bits, intToID(0)));
879 out_msg.Destination.add(map_Address_to_Directory(address));
880 out_msg.MessageSize := MessageSizeType:Persistent_Control;
881 out_msg.Prefetch := tbe.Prefetch;
882 out_msg.AccessMode := tbe.AccessMode;
884 markPersistentEntries(address);
887 // Update outstanding requests
888 //profile_outstanding_persistent_request(outstandingPersistentRequests);
889 outstandingPersistentRequests := outstandingPersistentRequests + 1;
891 if (tbe.IssueCount == 0) {
892 //profile_persistent_prediction(address, tbe.TypeOfAccess);
895 // Increment IssueCount
896 tbe.IssueCount := tbe.IssueCount + 1;
898 tbe.WentPersistent := true;
900 // Do not schedule a wakeup, a persistent requests will always complete
904 // We'd like to issue a persistent request, but are not allowed
905 // to issue a P.R. right now. This, we do not increment the
908 // Set a wakeup timer
909 reissueTimerTable.set(address, reissue_wakeup_latency);
913 // Make a normal request
914 enqueue(requestNetwork_out, RequestMsg, l1_request_latency) {
915 out_msg.Addr := address;
916 out_msg.Type := CoherenceRequestType:GETX;
917 out_msg.Requestor := machineID;
919 out_msg.Destination.add(mapAddressToRange(address,
920 MachineType:L2Cache, l2_select_low_bit,
921 l2_select_num_bits, intToID(0)));
923 out_msg.RetryNum := tbe.IssueCount;
925 if (tbe.IssueCount == 0) {
926 out_msg.MessageSize := MessageSizeType:Request_Control;
928 out_msg.MessageSize := MessageSizeType:Reissue_Control;
930 out_msg.Prefetch := tbe.Prefetch;
931 out_msg.AccessMode := tbe.AccessMode;
934 // send to other local L1s too
935 enqueue(requestNetwork_out, RequestMsg, l1_request_latency) {
936 out_msg.Addr := address;
937 out_msg.Type := CoherenceRequestType:GETX;
938 out_msg.Requestor := machineID;
939 out_msg.isLocal := true;
942 // Since only one chip, assuming all L1 caches are local
944 //out_msg.Destination := getOtherLocalL1IDs(machineID);
945 out_msg.Destination.broadcast(MachineType:L1Cache);
946 out_msg.Destination.remove(machineID);
948 out_msg.RetryNum := tbe.IssueCount;
949 if (tbe.IssueCount == 0) {
950 out_msg.MessageSize := MessageSizeType:Broadcast_Control;
952 out_msg.MessageSize := MessageSizeType:Broadcast_Control;
954 out_msg.Prefetch := tbe.Prefetch;
955 out_msg.AccessMode := tbe.AccessMode;
958 // Increment IssueCount
959 tbe.IssueCount := tbe.IssueCount + 1;
961 DPRINTF(RubySlicc, "incremented issue count to %d\n",
964 // Set a wakeup timer
965 if (dynamic_timeout_enabled) {
966 reissueTimerTable.set(address, (5 * averageLatencyEstimate()) / 4);
968 reissueTimerTable.set(address, fixed_timeout_latency);
973 action(bb_bounceResponse, "\b", desc="Bounce tokens and data to memory") {
974 peek(responseNetwork_in, ResponseMsg) {
975 // FIXME, should use a 3rd vnet
976 enqueue(responseNetwork_out, ResponseMsg, 1) {
977 out_msg.Addr := address;
978 out_msg.Type := in_msg.Type;
979 out_msg.Sender := machineID;
980 out_msg.Destination.add(map_Address_to_Directory(address));
981 out_msg.Tokens := in_msg.Tokens;
982 out_msg.MessageSize := in_msg.MessageSize;
983 out_msg.DataBlk := in_msg.DataBlk;
984 out_msg.Dirty := in_msg.Dirty;
989 action(c_ownedReplacement, "c", desc="Issue writeback") {
990 assert(is_valid(cache_entry));
991 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
992 out_msg.Addr := address;
993 out_msg.Sender := machineID;
995 out_msg.Destination.add(mapAddressToRange(address,
996 MachineType:L2Cache, l2_select_low_bit,
997 l2_select_num_bits, intToID(0)));
999 out_msg.Tokens := cache_entry.Tokens;
1000 out_msg.DataBlk := cache_entry.DataBlk;
1001 out_msg.Dirty := cache_entry.Dirty;
1002 out_msg.Type := CoherenceResponseType:WB_OWNED;
1004 // always send the data?
1005 out_msg.MessageSize := MessageSizeType:Writeback_Data;
1007 cache_entry.Tokens := 0;
1010 action(cc_sharedReplacement, "\c", desc="Issue shared writeback") {
1012 // don't send writeback if replacing block with no tokens
1013 assert(is_valid(cache_entry));
1014 assert (cache_entry.Tokens > 0);
1015 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1016 out_msg.Addr := address;
1017 out_msg.Sender := machineID;
1019 out_msg.Destination.add(mapAddressToRange(address,
1020 MachineType:L2Cache, l2_select_low_bit,
1021 l2_select_num_bits, intToID(0)));
1023 out_msg.Tokens := cache_entry.Tokens;
1024 out_msg.DataBlk := cache_entry.DataBlk;
1025 // assert(cache_entry.Dirty == false);
1026 out_msg.Dirty := false;
1028 out_msg.MessageSize := MessageSizeType:Writeback_Data;
1029 out_msg.Type := CoherenceResponseType:WB_SHARED_DATA;
1031 cache_entry.Tokens := 0;
1034 action(tr_tokenReplacement, "tr", desc="Issue token writeback") {
1035 assert(is_valid(cache_entry));
1036 if (cache_entry.Tokens > 0) {
1037 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1038 out_msg.Addr := address;
1039 out_msg.Sender := machineID;
1041 out_msg.Destination.add(mapAddressToRange(address,
1042 MachineType:L2Cache, l2_select_low_bit,
1043 l2_select_num_bits, intToID(0)));
1045 out_msg.Tokens := cache_entry.Tokens;
1046 out_msg.DataBlk := cache_entry.DataBlk;
1047 // assert(cache_entry.Dirty == false);
1048 out_msg.Dirty := false;
1050 // always send the data?
1051 out_msg.MessageSize := MessageSizeType:Writeback_Control;
1052 out_msg.Type := CoherenceResponseType:WB_TOKENS;
1055 cache_entry.Tokens := 0;
1059 action(d_sendDataWithToken, "d", desc="Send data and a token from cache to requestor") {
1060 assert(is_valid(cache_entry));
1061 peek(requestNetwork_in, RequestMsg) {
1062 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1063 out_msg.Addr := address;
1064 out_msg.Type := CoherenceResponseType:DATA_SHARED;
1065 out_msg.Sender := machineID;
1066 out_msg.Destination.add(in_msg.Requestor);
1067 out_msg.Tokens := 1;
1068 out_msg.DataBlk := cache_entry.DataBlk;
1069 // out_msg.Dirty := cache_entry.Dirty;
1070 out_msg.Dirty := false;
1071 if (in_msg.isLocal) {
1072 out_msg.MessageSize := MessageSizeType:ResponseLocal_Data;
1074 out_msg.MessageSize := MessageSizeType:Response_Data;
1078 cache_entry.Tokens := cache_entry.Tokens - 1;
1079 assert(cache_entry.Tokens >= 1);
1082 action(d_sendDataWithNTokenIfAvail, "\dd", desc="Send data and a token from cache to requestor") {
1083 assert(is_valid(cache_entry));
1084 peek(requestNetwork_in, RequestMsg) {
1085 if (cache_entry.Tokens > (N_tokens + (max_tokens() / 2))) {
1086 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1087 out_msg.Addr := address;
1088 out_msg.Type := CoherenceResponseType:DATA_SHARED;
1089 out_msg.Sender := machineID;
1090 out_msg.Destination.add(in_msg.Requestor);
1091 out_msg.Tokens := N_tokens;
1092 out_msg.DataBlk := cache_entry.DataBlk;
1093 // out_msg.Dirty := cache_entry.Dirty;
1094 out_msg.Dirty := false;
1095 if (in_msg.isLocal) {
1096 out_msg.MessageSize := MessageSizeType:ResponseLocal_Data;
1098 out_msg.MessageSize := MessageSizeType:Response_Data;
1101 cache_entry.Tokens := cache_entry.Tokens - N_tokens;
1103 else if (cache_entry.Tokens > 1) {
1104 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1105 out_msg.Addr := address;
1106 out_msg.Type := CoherenceResponseType:DATA_SHARED;
1107 out_msg.Sender := machineID;
1108 out_msg.Destination.add(in_msg.Requestor);
1109 out_msg.Tokens := 1;
1110 out_msg.DataBlk := cache_entry.DataBlk;
1111 // out_msg.Dirty := cache_entry.Dirty;
1112 out_msg.Dirty := false;
1113 if (in_msg.isLocal) {
1114 out_msg.MessageSize := MessageSizeType:ResponseLocal_Data;
1116 out_msg.MessageSize := MessageSizeType:Response_Data;
1119 cache_entry.Tokens := cache_entry.Tokens - 1;
1122 // assert(cache_entry.Tokens >= 1);
1125 action(dd_sendDataWithAllTokens, "\d", desc="Send data and all tokens from cache to requestor") {
1126 peek(requestNetwork_in, RequestMsg) {
1127 assert(is_valid(cache_entry));
1128 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1129 out_msg.Addr := address;
1130 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1131 out_msg.Sender := machineID;
1132 out_msg.Destination.add(in_msg.Requestor);
1133 assert(cache_entry.Tokens > (max_tokens() / 2));
1134 out_msg.Tokens := cache_entry.Tokens;
1135 out_msg.DataBlk := cache_entry.DataBlk;
1136 out_msg.Dirty := cache_entry.Dirty;
1137 if (in_msg.isLocal) {
1138 out_msg.MessageSize := MessageSizeType:ResponseLocal_Data;
1140 out_msg.MessageSize := MessageSizeType:Response_Data;
1144 cache_entry.Tokens := 0;
1147 action(e_sendAckWithCollectedTokens, "e", desc="Send ack with the tokens we've collected thus far.") {
1148 // assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
1149 assert(is_valid(cache_entry));
1150 if (cache_entry.Tokens > 0) {
1151 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1152 out_msg.Addr := address;
1153 if (cache_entry.Tokens > (max_tokens() / 2)) {
1154 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1156 out_msg.Type := CoherenceResponseType:ACK;
1158 out_msg.Sender := machineID;
1159 out_msg.Destination.add(persistentTable.findSmallest(address));
1160 assert(cache_entry.Tokens >= 1);
1161 out_msg.Tokens := cache_entry.Tokens;
1162 out_msg.DataBlk := cache_entry.DataBlk;
1163 out_msg.MessageSize := MessageSizeType:Response_Control;
1166 cache_entry.Tokens := 0;
1169 action(ee_sendDataWithAllTokens, "\e", desc="Send data and all tokens from cache to starver") {
1170 //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
1171 assert(is_valid(cache_entry));
1172 assert(cache_entry.Tokens > 0);
1173 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1174 out_msg.Addr := address;
1175 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1176 out_msg.Sender := machineID;
1177 out_msg.Destination.add(persistentTable.findSmallest(address));
1178 assert(cache_entry.Tokens > (max_tokens() / 2));
1179 out_msg.Tokens := cache_entry.Tokens;
1180 out_msg.DataBlk := cache_entry.DataBlk;
1181 out_msg.Dirty := cache_entry.Dirty;
1182 out_msg.MessageSize := MessageSizeType:Response_Data;
1184 cache_entry.Tokens := 0;
1187 action(f_sendAckWithAllButNorOneTokens, "f", desc="Send ack with all our tokens but one to starver.") {
1188 //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
1189 assert(is_valid(cache_entry));
1190 assert(cache_entry.Tokens > 0);
1191 if (cache_entry.Tokens > 1) {
1192 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1193 out_msg.Addr := address;
1194 if (cache_entry.Tokens > (max_tokens() / 2)) {
1195 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1197 out_msg.Type := CoherenceResponseType:ACK;
1199 out_msg.Sender := machineID;
1200 out_msg.Destination.add(persistentTable.findSmallest(address));
1201 assert(cache_entry.Tokens >= 1);
1202 if (cache_entry.Tokens > N_tokens) {
1203 out_msg.Tokens := cache_entry.Tokens - N_tokens;
1205 out_msg.Tokens := cache_entry.Tokens - 1;
1207 out_msg.DataBlk := cache_entry.DataBlk;
1208 out_msg.MessageSize := MessageSizeType:Response_Control;
1211 if (cache_entry.Tokens > N_tokens) {
1212 cache_entry.Tokens := N_tokens;
1214 cache_entry.Tokens := 1;
1218 action(ff_sendDataWithAllButNorOneTokens, "\f", desc="Send data and out tokens but one to starver") {
1219 //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
1220 assert(is_valid(cache_entry));
1221 assert(cache_entry.Tokens > ((max_tokens() / 2) + 1));
1222 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1223 out_msg.Addr := address;
1224 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1225 out_msg.Sender := machineID;
1226 out_msg.Destination.add(persistentTable.findSmallest(address));
1227 if (cache_entry.Tokens > (N_tokens + (max_tokens() / 2))) {
1228 out_msg.Tokens := cache_entry.Tokens - N_tokens;
1230 out_msg.Tokens := cache_entry.Tokens - 1;
1232 assert(out_msg.Tokens > (max_tokens() / 2));
1233 out_msg.DataBlk := cache_entry.DataBlk;
1234 out_msg.Dirty := cache_entry.Dirty;
1235 out_msg.MessageSize := MessageSizeType:Response_Data;
1237 if (cache_entry.Tokens > (N_tokens + (max_tokens() / 2))) {
1238 cache_entry.Tokens := N_tokens;
1240 cache_entry.Tokens := 1;
1244 action(fo_sendDataWithOwnerToken, "fo", desc="Send data and owner tokens") {
1245 assert(is_valid(cache_entry));
1246 assert(cache_entry.Tokens == ((max_tokens() / 2) + 1));
1247 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1248 out_msg.Addr := address;
1249 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1250 out_msg.Sender := machineID;
1251 out_msg.Destination.add(persistentTable.findSmallest(address));
1252 out_msg.Tokens := cache_entry.Tokens;
1253 assert(out_msg.Tokens > (max_tokens() / 2));
1254 out_msg.DataBlk := cache_entry.DataBlk;
1255 out_msg.Dirty := cache_entry.Dirty;
1256 out_msg.MessageSize := MessageSizeType:Response_Data;
1258 cache_entry.Tokens := 0;
1261 action(g_bounceResponseToStarver, "g", desc="Redirect response to starving processor") {
1262 // assert(persistentTable.isLocked(address));
1264 peek(responseNetwork_in, ResponseMsg) {
1265 // assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
1266 // FIXME, should use a 3rd vnet in some cases
1267 enqueue(responseNetwork_out, ResponseMsg, 1) {
1268 out_msg.Addr := address;
1269 out_msg.Type := in_msg.Type;
1270 out_msg.Sender := machineID;
1271 out_msg.Destination.add(persistentTable.findSmallest(address));
1272 out_msg.Tokens := in_msg.Tokens;
1273 out_msg.DataBlk := in_msg.DataBlk;
1274 out_msg.Dirty := in_msg.Dirty;
1275 out_msg.MessageSize := in_msg.MessageSize;
1281 action(h_load_hit, "h", desc="Notify sequencer the load completed.") {
1282 assert(is_valid(cache_entry));
1283 DPRINTF(RubySlicc, "Address: %s, Data Block: %s\n",
1284 address, cache_entry.DataBlk);
1286 sequencer.readCallback(address, cache_entry.DataBlk, false,
1287 MachineType:L1Cache);
1290 action(x_external_load_hit, "x", desc="Notify sequencer the load completed.") {
1291 assert(is_valid(cache_entry));
1292 DPRINTF(RubySlicc, "Address: %s, Data Block: %s\n",
1293 address, cache_entry.DataBlk);
1294 peek(responseNetwork_in, ResponseMsg) {
1295 sequencer.readCallback(address, cache_entry.DataBlk,
1296 isExternalHit(address, in_msg.Sender),
1297 machineIDToMachineType(in_msg.Sender));
1301 action(hh_store_hit, "\h", desc="Notify sequencer that store completed.") {
1302 assert(is_valid(cache_entry));
1303 DPRINTF(RubySlicc, "Address: %s, Data Block: %s\n",
1304 address, cache_entry.DataBlk);
1306 sequencer.writeCallback(address, cache_entry.DataBlk, false,
1307 MachineType:L1Cache);
1308 cache_entry.Dirty := true;
1309 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
1312 action(xx_external_store_hit, "\x", desc="Notify sequencer that store completed.") {
1313 assert(is_valid(cache_entry));
1314 DPRINTF(RubySlicc, "Address: %s, Data Block: %s\n",
1315 address, cache_entry.DataBlk);
1316 peek(responseNetwork_in, ResponseMsg) {
1317 sequencer.writeCallback(address, cache_entry.DataBlk,
1318 isExternalHit(address, in_msg.Sender),
1319 machineIDToMachineType(in_msg.Sender));
1321 cache_entry.Dirty := true;
1322 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
1325 action(i_allocateTBE, "i", desc="Allocate TBE") {
1326 check_allocate(L1_TBEs);
1327 L1_TBEs.allocate(address);
1328 set_tbe(L1_TBEs[address]);
1329 tbe.IssueCount := 0;
1330 peek(mandatoryQueue_in, RubyRequest) {
1331 tbe.PC := in_msg.ProgramCounter;
1332 tbe.TypeOfAccess := cache_request_type_to_access_type(in_msg.Type);
1333 if (in_msg.Type == RubyRequestType:ATOMIC) {
1334 tbe.IsAtomic := true;
1336 tbe.Prefetch := in_msg.Prefetch;
1337 tbe.AccessMode := in_msg.AccessMode;
1339 tbe.IssueTime := curCycle();
1342 action(ta_traceStalledAddress, "ta", desc="Trace Stalled Address") {
1343 peek(mandatoryQueue_in, RubyRequest) {
1344 APPEND_TRANSITION_COMMENT(in_msg.LineAddress);
1348 action(j_unsetReissueTimer, "j", desc="Unset reissue timer.") {
1349 if (reissueTimerTable.isSet(address)) {
1350 reissueTimerTable.unset(address);
1354 action(jj_unsetUseTimer, "\j", desc="Unset use timer.") {
1355 useTimerTable.unset(address);
1358 action(k_popMandatoryQueue, "k", desc="Pop mandatory queue.") {
1359 mandatoryQueue_in.dequeue();
1362 action(l_popPersistentQueue, "l", desc="Pop persistent queue.") {
1363 persistentNetwork_in.dequeue();
1366 action(m_popRequestQueue, "m", desc="Pop request queue.") {
1367 requestNetwork_in.dequeue();
1370 action(n_popResponseQueue, "n", desc="Pop response queue") {
1371 responseNetwork_in.dequeue();
1374 action(o_scheduleUseTimeout, "o", desc="Schedule a use timeout.") {
1375 useTimerTable.set(address, use_timeout_latency);
1378 action(p_informL2AboutTokenLoss, "p", desc="Inform L2 about loss of all tokens") {
1379 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1380 out_msg.Addr := address;
1381 out_msg.Type := CoherenceResponseType:INV;
1382 out_msg.Tokens := 0;
1383 out_msg.Sender := machineID;
1385 out_msg.Destination.add(mapAddressToRange(address,
1386 MachineType:L2Cache, l2_select_low_bit,
1387 l2_select_num_bits, intToID(0)));
1388 out_msg.MessageSize := MessageSizeType:Response_Control;
1392 action(q_updateTokensFromResponse, "q", desc="Update the token count based on the incoming response message") {
1393 peek(responseNetwork_in, ResponseMsg) {
1394 assert(is_valid(cache_entry));
1395 assert(in_msg.Tokens != 0);
1396 DPRINTF(RubySlicc, "L1 received tokens for address: %s, tokens: %d\n",
1397 in_msg.Addr, in_msg.Tokens);
1398 cache_entry.Tokens := cache_entry.Tokens + in_msg.Tokens;
1399 DPRINTF(RubySlicc, "%d\n", cache_entry.Tokens);
1401 if (cache_entry.Dirty == false && in_msg.Dirty) {
1402 cache_entry.Dirty := true;
1407 action(s_deallocateTBE, "s", desc="Deallocate TBE") {
1409 assert(is_valid(tbe));
1410 if (tbe.WentPersistent) {
1411 // assert(starving);
1412 outstandingRequests := outstandingRequests - 1;
1413 enqueue(persistentNetwork_out, PersistentMsg, l1_request_latency) {
1414 out_msg.Addr := address;
1415 out_msg.Type := PersistentRequestType:DEACTIVATE_PERSISTENT;
1416 out_msg.Requestor := machineID;
1417 out_msg.Destination.broadcast(MachineType:L1Cache);
1420 // Currently the configuration system limits the system to only one
1421 // chip. Therefore, if we assume one shared L2 cache, then only one
1422 // pertinent L2 cache exist.
1424 //out_msg.Destination.addNetDest(getAllPertinentL2Banks(address));
1426 out_msg.Destination.add(mapAddressToRange(address,
1427 MachineType:L2Cache, l2_select_low_bit,
1428 l2_select_num_bits, intToID(0)));
1430 out_msg.Destination.add(map_Address_to_Directory(address));
1431 out_msg.MessageSize := MessageSizeType:Persistent_Control;
1436 // Update average latency
1437 if (tbe.IssueCount <= 1) {
1438 if (tbe.ExternalResponse) {
1439 updateAverageLatencyEstimate(curCycle() - tbe.IssueTime);
1444 //if (tbe.WentPersistent) {
1445 // profile_token_retry(address, tbe.TypeOfAccess, 2);
1448 // profile_token_retry(address, tbe.TypeOfAccess, 1);
1451 //profile_token_retry(address, tbe.TypeOfAccess, tbe.IssueCount);
1452 L1_TBEs.deallocate(address);
1456 action(t_sendAckWithCollectedTokens, "t", desc="Send ack with the tokens we've collected thus far.") {
1457 assert(is_valid(cache_entry));
1458 if (cache_entry.Tokens > 0) {
1459 peek(requestNetwork_in, RequestMsg) {
1460 enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) {
1461 out_msg.Addr := address;
1462 if (cache_entry.Tokens > (max_tokens() / 2)) {
1463 out_msg.Type := CoherenceResponseType:DATA_OWNER;
1465 out_msg.Type := CoherenceResponseType:ACK;
1467 out_msg.Sender := machineID;
1468 out_msg.Destination.add(in_msg.Requestor);
1469 assert(cache_entry.Tokens >= 1);
1470 out_msg.Tokens := cache_entry.Tokens;
1471 out_msg.DataBlk := cache_entry.DataBlk;
1472 out_msg.MessageSize := MessageSizeType:Response_Control;
1476 cache_entry.Tokens := 0;
1479 action(u_writeDataToCache, "u", desc="Write data to cache") {
1480 peek(responseNetwork_in, ResponseMsg) {
1481 assert(is_valid(cache_entry));
1482 cache_entry.DataBlk := in_msg.DataBlk;
1483 if (cache_entry.Dirty == false && in_msg.Dirty) {
1484 cache_entry.Dirty := in_msg.Dirty;
1490 action(gg_deallocateL1CacheBlock, "\g", desc="Deallocate cache block. Sets the cache to invalid, allowing a replacement in parallel with a fetch.") {
1491 assert(getTokens(cache_entry) == 0);
1492 if (L1Dcache.isTagPresent(address)) {
1493 L1Dcache.deallocate(address);
1495 L1Icache.deallocate(address);
1497 unset_cache_entry();
1500 action(ii_allocateL1DCacheBlock, "\i", desc="Set L1 D-cache tag equal to tag of block B.") {
1501 if (is_valid(cache_entry)) {
1503 set_cache_entry(L1Dcache.allocate(address, new Entry));
1507 action(pp_allocateL1ICacheBlock, "\p", desc="Set L1 I-cache tag equal to tag of block B.") {
1508 if (is_valid(cache_entry)) {
1510 set_cache_entry(L1Icache.allocate(address, new Entry));
1514 action(forward_eviction_to_cpu, "\cc", desc="sends eviction information to the processor") {
1515 if (send_evictions) {
1516 DPRINTF(RubySlicc, "Sending invalidation for %s to the CPU\n", address);
1517 sequencer.evictionCallback(address);
1521 action(uu_profileInstMiss, "\uim", desc="Profile the demand miss") {
1522 ++L1Icache.demand_misses;
1525 action(uu_profileInstHit, "\uih", desc="Profile the demand hit") {
1526 ++L1Icache.demand_hits;
1529 action(uu_profileDataMiss, "\udm", desc="Profile the demand miss") {
1530 ++L1Dcache.demand_misses;
1533 action(uu_profileDataHit, "\udh", desc="Profile the demand hit") {
1534 ++L1Dcache.demand_hits;
1537 action(w_assertIncomingDataAndCacheDataMatch, "w", desc="Assert that the incoming data and the data in the cache match") {
1538 peek(responseNetwork_in, ResponseMsg) {
1539 assert(is_valid(cache_entry));
1540 assert(cache_entry.DataBlk == in_msg.DataBlk);
1544 action(zz_stallAndWaitMandatoryQueue, "\z", desc="Send the head of the mandatory queue to the back of the queue.") {
1545 peek(mandatoryQueue_in, RubyRequest) {
1546 APPEND_TRANSITION_COMMENT(in_msg.LineAddress);
1548 stall_and_wait(mandatoryQueue_in, address);
1551 action(kd_wakeUpDependents, "kd", desc="wake-up dependents") {
1552 wakeUpBuffers(address);
1555 action(ka_wakeUpAllDependents, "ka", desc="wake-up all dependents") {
1559 //*****************************************************
1561 //*****************************************************
1563 // Transitions for Load/Store/L2_Replacement from transient states
1564 transition({IM, SM, OM, IS, IM_L, IS_L, I_L, S_L, SM_L, M_W, MM_W}, L1_Replacement) {
1565 ta_traceStalledAddress;
1566 zz_stallAndWaitMandatoryQueue;
1569 transition({IM, SM, OM, IS, IM_L, IS_L, SM_L}, {Store, Atomic}) {
1570 zz_stallAndWaitMandatoryQueue;
1573 transition({IM, IS, IM_L, IS_L}, {Load, Ifetch}) {
1574 zz_stallAndWaitMandatoryQueue;
1578 transition({NP, I, S, O, M, MM, M_W, MM_W, IM, SM, OM, IS}, Own_Lock_or_Unlock) {
1579 l_popPersistentQueue;
1582 // Transitions from NP
1583 transition(NP, Load, IS) {
1584 ii_allocateL1DCacheBlock;
1588 k_popMandatoryQueue;
1591 transition(NP, Ifetch, IS) {
1592 pp_allocateL1ICacheBlock;
1596 k_popMandatoryQueue;
1599 transition(NP, {Store, Atomic}, IM) {
1600 ii_allocateL1DCacheBlock;
1602 b_issueWriteRequest;
1604 k_popMandatoryQueue;
1607 transition(NP, {Ack, Data_Shared, Data_Owner, Data_All_Tokens}) {
1612 transition(NP, {Transient_GETX, Transient_Local_GETX, Transient_GETS, Transient_Local_GETS}) {
1616 transition(NP, {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token}, I_L) {
1617 l_popPersistentQueue;
1620 // Transitions from Idle
1621 transition(I, Load, IS) {
1625 k_popMandatoryQueue;
1628 transition(I, Ifetch, IS) {
1632 k_popMandatoryQueue;
1635 transition(I, {Store, Atomic}, IM) {
1637 b_issueWriteRequest;
1639 k_popMandatoryQueue;
1642 transition(I, L1_Replacement) {
1643 ta_traceStalledAddress;
1644 tr_tokenReplacement;
1645 gg_deallocateL1CacheBlock;
1646 ka_wakeUpAllDependents;
1649 transition(I, {Transient_GETX, Transient_Local_GETX}) {
1650 t_sendAckWithCollectedTokens;
1654 transition(I, {Transient_GETS, Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token, Transient_Local_GETS}) {
1658 transition(I, {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token}, I_L) {
1659 e_sendAckWithCollectedTokens;
1660 l_popPersistentQueue;
1663 transition(I_L, {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token}) {
1664 l_popPersistentQueue;
1667 transition(I, Ack) {
1668 q_updateTokensFromResponse;
1672 transition(I, Data_Shared, S) {
1674 q_updateTokensFromResponse;
1678 transition(I, Data_Owner, O) {
1680 q_updateTokensFromResponse;
1684 transition(I, Data_All_Tokens, M) {
1686 q_updateTokensFromResponse;
1690 // Transitions from Shared
1691 transition({S, SM, S_L, SM_L}, Load) {
1694 k_popMandatoryQueue;
1697 transition({S, SM, S_L, SM_L}, Ifetch) {
1700 k_popMandatoryQueue;
1703 transition(S, {Store, Atomic}, SM) {
1705 b_issueWriteRequest;
1707 k_popMandatoryQueue;
1710 transition(S, L1_Replacement, I) {
1711 ta_traceStalledAddress;
1712 cc_sharedReplacement; // Only needed in some cases
1713 forward_eviction_to_cpu;
1714 gg_deallocateL1CacheBlock;
1715 ka_wakeUpAllDependents;
1718 transition(S, {Transient_GETX, Transient_Local_GETX}, I) {
1719 t_sendAckWithCollectedTokens;
1720 p_informL2AboutTokenLoss;
1721 forward_eviction_to_cpu
1725 // only owner responds to non-local requests
1726 transition(S, Transient_GETS) {
1730 transition(S, Transient_Local_GETS) {
1731 d_sendDataWithToken;
1735 transition(S, {Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token}) {
1739 transition({S, S_L}, Persistent_GETX, I_L) {
1740 e_sendAckWithCollectedTokens;
1741 p_informL2AboutTokenLoss;
1742 forward_eviction_to_cpu
1743 l_popPersistentQueue;
1746 transition(S, {Persistent_GETS, Persistent_GETS_Last_Token}, S_L) {
1747 f_sendAckWithAllButNorOneTokens;
1748 l_popPersistentQueue;
1751 transition(S_L, {Persistent_GETS, Persistent_GETS_Last_Token}) {
1752 l_popPersistentQueue;
1755 transition(S, Ack) {
1756 q_updateTokensFromResponse;
1760 transition(S, Data_Shared) {
1761 w_assertIncomingDataAndCacheDataMatch;
1762 q_updateTokensFromResponse;
1766 transition(S, Data_Owner, O) {
1767 w_assertIncomingDataAndCacheDataMatch;
1768 q_updateTokensFromResponse;
1772 transition(S, Data_All_Tokens, M) {
1773 w_assertIncomingDataAndCacheDataMatch;
1774 q_updateTokensFromResponse;
1778 // Transitions from Owned
1779 transition({O, OM}, Ifetch) {
1782 k_popMandatoryQueue;
1785 transition({O, OM}, Load) {
1788 k_popMandatoryQueue;
1791 transition(O, {Store, Atomic}, OM) {
1793 b_issueWriteRequest;
1795 k_popMandatoryQueue;
1798 transition(O, L1_Replacement, I) {
1799 ta_traceStalledAddress;
1801 forward_eviction_to_cpu
1802 gg_deallocateL1CacheBlock;
1803 ka_wakeUpAllDependents;
1806 transition(O, {Transient_GETX, Transient_Local_GETX}, I) {
1807 dd_sendDataWithAllTokens;
1808 p_informL2AboutTokenLoss;
1809 forward_eviction_to_cpu
1813 transition(O, Persistent_GETX, I_L) {
1814 ee_sendDataWithAllTokens;
1815 p_informL2AboutTokenLoss;
1816 forward_eviction_to_cpu
1817 l_popPersistentQueue;
1820 transition(O, Persistent_GETS, S_L) {
1821 ff_sendDataWithAllButNorOneTokens;
1822 l_popPersistentQueue;
1825 transition(O, Persistent_GETS_Last_Token, I_L) {
1826 fo_sendDataWithOwnerToken;
1827 forward_eviction_to_cpu
1828 l_popPersistentQueue;
1831 transition(O, Transient_GETS) {
1832 d_sendDataWithToken;
1836 transition(O, Transient_Local_GETS) {
1837 d_sendDataWithToken;
1841 // ran out of tokens, wait for it to go persistent
1842 transition(O, {Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token}) {
1846 transition(O, Ack) {
1847 q_updateTokensFromResponse;
1851 transition(O, Ack_All_Tokens, M) {
1852 q_updateTokensFromResponse;
1856 transition(O, Data_Shared) {
1857 w_assertIncomingDataAndCacheDataMatch;
1858 q_updateTokensFromResponse;
1862 transition(O, Data_All_Tokens, M) {
1863 w_assertIncomingDataAndCacheDataMatch;
1864 q_updateTokensFromResponse;
1868 // Transitions from Modified
1869 transition({MM, MM_W}, Ifetch) {
1872 k_popMandatoryQueue;
1875 transition({MM, MM_W}, Load) {
1878 k_popMandatoryQueue;
1881 transition({MM_W}, {Store, Atomic}) {
1884 k_popMandatoryQueue;
1887 transition(MM, Store) {
1890 k_popMandatoryQueue;
1893 transition(MM, Atomic, M) {
1896 k_popMandatoryQueue;
1899 transition(MM, L1_Replacement, I) {
1900 ta_traceStalledAddress;
1902 forward_eviction_to_cpu
1903 gg_deallocateL1CacheBlock;
1904 ka_wakeUpAllDependents;
1907 transition(MM, {Transient_GETX, Transient_Local_GETX, Transient_GETS, Transient_Local_GETS}, I) {
1908 dd_sendDataWithAllTokens;
1909 p_informL2AboutTokenLoss;
1910 forward_eviction_to_cpu
1914 transition({MM_W}, {Transient_GETX, Transient_Local_GETX, Transient_GETS, Transient_Local_GETS}) { // Ignore the request
1918 // Implement the migratory sharing optimization, even for persistent requests
1919 transition(MM, {Persistent_GETX, Persistent_GETS}, I_L) {
1920 ee_sendDataWithAllTokens;
1921 p_informL2AboutTokenLoss;
1922 forward_eviction_to_cpu
1923 l_popPersistentQueue;
1926 // ignore persistent requests in lockout period
1927 transition(MM_W, {Persistent_GETX, Persistent_GETS}) {
1928 l_popPersistentQueue;
1931 transition(MM_W, Use_TimeoutNoStarvers, MM) {
1934 kd_wakeUpDependents;
1937 transition(MM_W, Use_TimeoutNoStarvers_NoMig, M) {
1940 kd_wakeUpDependents;
1943 // Transitions from Dirty Exclusive
1944 transition({M, M_W}, Ifetch) {
1947 k_popMandatoryQueue;
1950 transition({M, M_W}, Load) {
1953 k_popMandatoryQueue;
1956 transition(M, Store, MM) {
1959 k_popMandatoryQueue;
1962 transition(M, Atomic) {
1965 k_popMandatoryQueue;
1968 transition(M_W, Store, MM_W) {
1971 k_popMandatoryQueue;
1974 transition(M_W, Atomic) {
1977 k_popMandatoryQueue;
1980 transition(M, L1_Replacement, I) {
1981 ta_traceStalledAddress;
1983 forward_eviction_to_cpu
1984 gg_deallocateL1CacheBlock;
1985 ka_wakeUpAllDependents;
1988 transition(M, {Transient_GETX, Transient_Local_GETX}, I) {
1989 dd_sendDataWithAllTokens;
1990 p_informL2AboutTokenLoss;
1991 forward_eviction_to_cpu
1995 transition(M, Transient_Local_GETS, O) {
1996 d_sendDataWithToken;
2000 transition(M, Transient_GETS, O) {
2001 d_sendDataWithNTokenIfAvail;
2005 transition(M_W, {Transient_GETX, Transient_Local_GETX, Transient_GETS, Transient_Local_GETS}) { // Ignore the request
2009 transition(M, Persistent_GETX, I_L) {
2010 ee_sendDataWithAllTokens;
2011 p_informL2AboutTokenLoss;
2012 forward_eviction_to_cpu
2013 l_popPersistentQueue;
2016 transition(M, Persistent_GETS, S_L) {
2017 ff_sendDataWithAllButNorOneTokens;
2018 l_popPersistentQueue;
2021 // ignore persistent requests in lockout period
2022 transition(M_W, {Persistent_GETX, Persistent_GETS}) {
2023 l_popPersistentQueue;
2026 transition(M_W, Use_TimeoutStarverS, S_L) {
2028 ff_sendDataWithAllButNorOneTokens;
2032 // someone unlocked during timeout
2033 transition(M_W, {Use_TimeoutNoStarvers, Use_TimeoutNoStarvers_NoMig}, M) {
2036 kd_wakeUpDependents;
2039 transition(M_W, Use_TimeoutStarverX, I_L) {
2041 ee_sendDataWithAllTokens;
2042 forward_eviction_to_cpu;
2043 p_informL2AboutTokenLoss;
2048 transition(MM_W, {Use_TimeoutStarverX, Use_TimeoutStarverS}, I_L) {
2050 ee_sendDataWithAllTokens;
2051 forward_eviction_to_cpu;
2052 p_informL2AboutTokenLoss;
2057 // Transient_GETX and Transient_GETS in transient states
2058 transition(OM, {Transient_GETX, Transient_Local_GETX, Transient_GETS, Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token, Transient_Local_GETS}) {
2059 m_popRequestQueue; // Even if we have the data, we can pretend we don't have it yet.
2062 transition(IS, {Transient_GETX, Transient_Local_GETX}) {
2063 t_sendAckWithCollectedTokens;
2067 transition(IS, {Transient_GETS, Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token, Transient_Local_GETS}) {
2071 transition(IS, {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token}, IS_L) {
2072 e_sendAckWithCollectedTokens;
2073 l_popPersistentQueue;
2076 transition(IS_L, {Persistent_GETX, Persistent_GETS}) {
2077 l_popPersistentQueue;
2080 transition(IM, {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token}, IM_L) {
2081 e_sendAckWithCollectedTokens;
2082 l_popPersistentQueue;
2085 transition(IM_L, {Persistent_GETX, Persistent_GETS}) {
2086 l_popPersistentQueue;
2089 transition({SM, SM_L}, Persistent_GETX, IM_L) {
2090 e_sendAckWithCollectedTokens;
2091 forward_eviction_to_cpu
2092 l_popPersistentQueue;
2095 transition(SM, {Persistent_GETS, Persistent_GETS_Last_Token}, SM_L) {
2096 f_sendAckWithAllButNorOneTokens;
2097 l_popPersistentQueue;
2100 transition(SM_L, {Persistent_GETS, Persistent_GETS_Last_Token}) {
2101 l_popPersistentQueue;
2104 transition(OM, Persistent_GETX, IM_L) {
2105 ee_sendDataWithAllTokens;
2106 forward_eviction_to_cpu
2107 l_popPersistentQueue;
2110 transition(OM, Persistent_GETS, SM_L) {
2111 ff_sendDataWithAllButNorOneTokens;
2112 l_popPersistentQueue;
2115 transition(OM, Persistent_GETS_Last_Token, IM_L) {
2116 fo_sendDataWithOwnerToken;
2117 l_popPersistentQueue;
2120 // Transitions from IM/SM
2122 transition({IM, SM}, Ack) {
2123 q_updateTokensFromResponse;
2127 transition(IM, Data_Shared, SM) {
2129 q_updateTokensFromResponse;
2133 transition(IM, Data_Owner, OM) {
2135 q_updateTokensFromResponse;
2139 transition(IM, Data_All_Tokens, MM_W) {
2141 q_updateTokensFromResponse;
2142 xx_external_store_hit;
2143 o_scheduleUseTimeout;
2144 j_unsetReissueTimer;
2146 kd_wakeUpDependents;
2149 transition(SM, Data_Shared) {
2150 w_assertIncomingDataAndCacheDataMatch;
2151 q_updateTokensFromResponse;
2155 transition(SM, Data_Owner, OM) {
2156 w_assertIncomingDataAndCacheDataMatch;
2157 q_updateTokensFromResponse;
2161 transition(SM, Data_All_Tokens, MM_W) {
2162 w_assertIncomingDataAndCacheDataMatch;
2163 q_updateTokensFromResponse;
2164 xx_external_store_hit;
2165 o_scheduleUseTimeout;
2166 j_unsetReissueTimer;
2168 kd_wakeUpDependents;
2171 transition({IM, SM}, {Transient_GETX, Transient_Local_GETX}, IM) { // We don't have the data yet, but we might have collected some tokens. We give them up here to avoid livelock
2172 t_sendAckWithCollectedTokens;
2173 forward_eviction_to_cpu;
2177 transition({IM, SM}, {Transient_GETS, Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token, Transient_Local_GETS}) {
2181 transition({IM, SM}, Request_Timeout) {
2182 j_unsetReissueTimer;
2183 b_issueWriteRequest;
2186 // Transitions from OM
2188 transition(OM, Ack) {
2189 q_updateTokensFromResponse;
2193 transition(OM, Ack_All_Tokens, MM_W) {
2194 q_updateTokensFromResponse;
2195 xx_external_store_hit;
2196 o_scheduleUseTimeout;
2197 j_unsetReissueTimer;
2199 kd_wakeUpDependents;
2202 transition(OM, Data_Shared) {
2203 w_assertIncomingDataAndCacheDataMatch;
2204 q_updateTokensFromResponse;
2208 transition(OM, Data_All_Tokens, MM_W) {
2209 w_assertIncomingDataAndCacheDataMatch;
2210 q_updateTokensFromResponse;
2211 xx_external_store_hit;
2212 o_scheduleUseTimeout;
2213 j_unsetReissueTimer;
2215 kd_wakeUpDependents;
2218 transition(OM, Request_Timeout) {
2219 j_unsetReissueTimer;
2220 b_issueWriteRequest;
2223 // Transitions from IS
2225 transition(IS, Ack) {
2226 q_updateTokensFromResponse;
2230 transition(IS, Data_Shared, S) {
2232 q_updateTokensFromResponse;
2233 x_external_load_hit;
2235 j_unsetReissueTimer;
2237 kd_wakeUpDependents;
2240 transition(IS, Data_Owner, O) {
2242 q_updateTokensFromResponse;
2243 x_external_load_hit;
2245 j_unsetReissueTimer;
2247 kd_wakeUpDependents;
2250 transition(IS, Data_All_Tokens, M_W) {
2252 q_updateTokensFromResponse;
2253 x_external_load_hit;
2254 o_scheduleUseTimeout;
2255 j_unsetReissueTimer;
2257 kd_wakeUpDependents;
2260 transition(IS, Request_Timeout) {
2261 j_unsetReissueTimer;
2265 // Transitions from I_L
2267 transition(I_L, Load, IS_L) {
2268 ii_allocateL1DCacheBlock;
2272 k_popMandatoryQueue;
2275 transition(I_L, Ifetch, IS_L) {
2276 pp_allocateL1ICacheBlock;
2280 k_popMandatoryQueue;
2283 transition(I_L, {Store, Atomic}, IM_L) {
2284 ii_allocateL1DCacheBlock;
2286 b_issueWriteRequest;
2288 k_popMandatoryQueue;
2292 // Transitions from S_L
2294 transition(S_L, {Store, Atomic}, SM_L) {
2296 b_issueWriteRequest;
2298 k_popMandatoryQueue;
2301 // Other transitions from *_L states
2303 transition({I_L, IM_L, IS_L, S_L, SM_L}, {Transient_GETS, Transient_GETS_Last_Token, Transient_Local_GETS_Last_Token, Transient_Local_GETS, Transient_GETX, Transient_Local_GETX}) {
2307 transition({I_L, IM_L, IS_L, S_L, SM_L}, Ack) {
2308 g_bounceResponseToStarver;
2312 transition({I_L, IM_L, S_L, SM_L}, {Data_Shared, Data_Owner}) {
2313 g_bounceResponseToStarver;
2317 transition({I_L, S_L}, Data_All_Tokens) {
2318 g_bounceResponseToStarver;
2322 transition(IS_L, Request_Timeout) {
2323 j_unsetReissueTimer;
2327 transition({IM_L, SM_L}, Request_Timeout) {
2328 j_unsetReissueTimer;
2329 b_issueWriteRequest;
2332 // Opportunisticly Complete the memory operation in the following
2333 // cases. Note: these transitions could just use
2334 // g_bounceResponseToStarver, but if we have the data and tokens, we
2335 // might as well complete the memory request while we have the
2336 // chance (and then immediately forward on the data)
2338 transition(IM_L, Data_All_Tokens, MM_W) {
2340 q_updateTokensFromResponse;
2341 xx_external_store_hit;
2342 j_unsetReissueTimer;
2343 o_scheduleUseTimeout;
2345 kd_wakeUpDependents;
2348 transition(SM_L, Data_All_Tokens, S_L) {
2350 q_updateTokensFromResponse;
2351 xx_external_store_hit;
2352 ff_sendDataWithAllButNorOneTokens;
2354 j_unsetReissueTimer;
2358 transition(IS_L, Data_Shared, I_L) {
2360 q_updateTokensFromResponse;
2361 x_external_load_hit;
2363 e_sendAckWithCollectedTokens;
2364 p_informL2AboutTokenLoss;
2365 j_unsetReissueTimer;
2369 transition(IS_L, Data_Owner, I_L) {
2371 q_updateTokensFromResponse;
2372 x_external_load_hit;
2373 ee_sendDataWithAllTokens;
2375 p_informL2AboutTokenLoss;
2376 j_unsetReissueTimer;
2380 transition(IS_L, Data_All_Tokens, M_W) {
2382 q_updateTokensFromResponse;
2383 x_external_load_hit;
2384 j_unsetReissueTimer;
2385 o_scheduleUseTimeout;
2387 kd_wakeUpDependents;
2390 // Own_Lock_or_Unlock
2392 transition(I_L, Own_Lock_or_Unlock, I) {
2393 l_popPersistentQueue;
2394 kd_wakeUpDependents;
2397 transition(S_L, Own_Lock_or_Unlock, S) {
2398 l_popPersistentQueue;
2399 kd_wakeUpDependents;
2402 transition(IM_L, Own_Lock_or_Unlock, IM) {
2403 l_popPersistentQueue;
2404 kd_wakeUpDependents;
2407 transition(IS_L, Own_Lock_or_Unlock, IS) {
2408 l_popPersistentQueue;
2409 kd_wakeUpDependents;
2412 transition(SM_L, Own_Lock_or_Unlock, SM) {
2413 l_popPersistentQueue;
2414 kd_wakeUpDependents;