2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 Advanced Micro Devices, Inc.
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.
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.
29 * AMD's contributions to the MOESI hammer protocol do not constitute an
30 * endorsement of its similarity to any AMD products.
32 * Authors: Milo Martin
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,
49 MessageBuffer requestFromCache, network="To", virtual_network="2", ordered="false", vnet_type="request";
50 MessageBuffer responseFromCache, network="To", virtual_network="4", ordered="false", vnet_type="response";
51 MessageBuffer unblockFromCache, network="To", virtual_network="5", ordered="false", vnet_type="unblock";
53 MessageBuffer forwardToCache, network="From", virtual_network="3", ordered="false", vnet_type="forward";
54 MessageBuffer responseToCache, network="From", virtual_network="4", ordered="false", vnet_type="response";
58 state_declaration(State, desc="Cache states", default="L1Cache_State_I") {
60 I, AccessPermission:Invalid, desc="Idle";
61 S, AccessPermission:Read_Only, desc="Shared";
62 O, AccessPermission:Read_Only, desc="Owned";
63 M, AccessPermission:Read_Only, desc="Modified (dirty)";
64 MM, AccessPermission:Read_Write, desc="Modified (dirty and locally modified)";
66 // Base states, locked and ready to service the mandatory queue
67 IR, AccessPermission:Invalid, desc="Idle";
68 SR, AccessPermission:Read_Only, desc="Shared";
69 OR, AccessPermission:Read_Only, desc="Owned";
70 MR, AccessPermission:Read_Only, desc="Modified (dirty)";
71 MMR, AccessPermission:Read_Write, desc="Modified (dirty and locally modified)";
74 IM, AccessPermission:Busy, "IM", desc="Issued GetX";
75 SM, AccessPermission:Read_Only, "SM", desc="Issued GetX, we still have a valid copy of the line";
76 OM, AccessPermission:Read_Only, "OM", desc="Issued GetX, received data";
77 ISM, AccessPermission:Read_Only, "ISM", desc="Issued GetX, received valid data, waiting for all acks";
78 M_W, AccessPermission:Read_Only, "M^W", desc="Issued GetS, received exclusive data";
79 MM_W, AccessPermission:Read_Write, "MM^W", desc="Issued GetX, received exclusive data";
80 IS, AccessPermission:Busy, "IS", desc="Issued GetS";
81 SS, AccessPermission:Read_Only, "SS", desc="Issued GetS, received data, waiting for all acks";
82 OI, AccessPermission:Busy, "OI", desc="Issued PutO, waiting for ack";
83 MI, AccessPermission:Busy, "MI", desc="Issued PutX, waiting for ack";
84 II, AccessPermission:Busy, "II", desc="Issued PutX/O, saw Other_GETS or Other_GETX, waiting for ack";
85 IT, AccessPermission:Busy, "IT", desc="Invalid block transferring to L1";
86 ST, AccessPermission:Busy, "ST", desc="S block transferring to L1";
87 OT, AccessPermission:Busy, "OT", desc="O block transferring to L1";
88 MT, AccessPermission:Busy, "MT", desc="M block transferring to L1";
89 MMT, AccessPermission:Busy, "MMT", desc="MM block transferring to L0";
91 //Transition States Related to Flushing
92 MI_F, AccessPermission:Busy, "MI_F", desc="Issued PutX due to a Flush, waiting for ack";
93 MM_F, AccessPermission:Busy, "MM_F", desc="Issued GETF due to a Flush, waiting for ack";
94 IM_F, AccessPermission:Busy, "IM_F", desc="Issued GetX due to a Flush";
95 ISM_F, AccessPermission:Read_Only, "ISM_F", desc="Issued GetX, received data, waiting for all acks";
96 SM_F, AccessPermission:Read_Only, "SM_F", desc="Issued GetX, we still have an old copy of the line";
97 OM_F, AccessPermission:Read_Only, "OM_F", desc="Issued GetX, received data";
98 MM_WF, AccessPermission:Busy, "MM_WF", desc="Issued GetX, received exclusive data";
102 enumeration(Event, desc="Cache events") {
103 Load, desc="Load request from the processor";
104 Ifetch, desc="I-fetch request from the processor";
105 Store, desc="Store request from the processor";
106 L2_Replacement, desc="L2 Replacement";
107 L1_to_L2, desc="L1 to L2 transfer";
108 Trigger_L2_to_L1D, desc="Trigger L2 to L1-Data transfer";
109 Trigger_L2_to_L1I, desc="Trigger L2 to L1-Instruction transfer";
110 Complete_L2_to_L1, desc="L2 to L1 transfer completed";
113 Other_GETX, desc="A GetX from another processor";
114 Other_GETS, desc="A GetS from another processor";
115 Merged_GETS, desc="A Merged GetS from another processor";
116 Other_GETS_No_Mig, desc="A GetS from another processor";
117 NC_DMA_GETS, desc="special GetS when only DMA exists";
118 Invalidate, desc="Invalidate block";
121 Ack, desc="Received an ack message";
122 Shared_Ack, desc="Received an ack message, responder has a shared copy";
123 Data, desc="Received a data message";
124 Shared_Data, desc="Received a data message, responder has a shared copy";
125 Exclusive_Data, desc="Received a data message, responder had an exclusive copy, they gave it to us";
127 Writeback_Ack, desc="Writeback O.K. from directory";
128 Writeback_Nack, desc="Writeback not O.K. from directory";
131 All_acks, desc="Received all required data and message acks";
132 All_acks_no_sharers, desc="Received all acks and no other processor has a shared copy";
135 Flush_line, desc="flush the cache line from all caches";
136 Block_Ack, desc="the directory is blocked and ready for the flush";
141 // STRUCTURE DEFINITIONS
143 MessageBuffer mandatoryQueue, ordered="false";
146 structure(Entry, desc="...", interface="AbstractCacheEntry") {
147 State CacheState, desc="cache state";
148 bool Dirty, desc="Is the data dirty (different than memory)?";
149 DataBlock DataBlk, desc="data for the block";
150 bool FromL2, default="false", desc="block just moved from L2";
151 bool AtomicAccessed, default="false", desc="block just moved from L2";
155 structure(TBE, desc="...") {
156 State TBEState, desc="Transient state";
157 DataBlock DataBlk, desc="data for the block, required for concurrent writebacks";
158 bool Dirty, desc="Is the data dirty (different than memory)?";
159 int NumPendingMsgs, desc="Number of acks/data messages that this processor is waiting for";
160 bool Sharers, desc="On a GetS, did we find any other sharers in the system";
161 bool AppliedSilentAcks, default="false", desc="for full-bit dir, does the pending msg count reflect the silent acks";
162 MachineID LastResponder, desc="last machine to send a response for this request";
163 MachineID CurOwner, desc="current owner of the block, used for UnblockS responses";
164 Time InitialRequestTime, default="0", desc="time the initial requests was sent from the L1Cache";
165 Time ForwardRequestTime, default="0", desc="time the dir forwarded the request";
166 Time FirstResponseTime, default="0", desc="the time the first response was received";
169 structure(TBETable, external="yes") {
171 void allocate(Address);
172 void deallocate(Address);
173 bool isPresent(Address);
176 TBETable TBEs, template="<L1Cache_TBE>";
178 void set_cache_entry(AbstractCacheEntry b);
179 void unset_cache_entry();
182 void wakeUpAllBuffers();
183 void wakeUpBuffers(Address a);
185 Entry getCacheEntry(Address address), return_by_pointer="yes" {
186 Entry L2cache_entry := static_cast(Entry, "pointer", L2cacheMemory.lookup(address));
187 if(is_valid(L2cache_entry)) {
188 return L2cache_entry;
191 Entry L1Dcache_entry := static_cast(Entry, "pointer", L1DcacheMemory.lookup(address));
192 if(is_valid(L1Dcache_entry)) {
193 return L1Dcache_entry;
196 Entry L1Icache_entry := static_cast(Entry, "pointer", L1IcacheMemory.lookup(address));
197 return L1Icache_entry;
200 DataBlock getDataBlock(Address addr), return_by_ref="yes" {
201 return getCacheEntry(addr).DataBlk;
204 Entry getL2CacheEntry(Address address), return_by_pointer="yes" {
205 Entry L2cache_entry := static_cast(Entry, "pointer", L2cacheMemory.lookup(address));
206 return L2cache_entry;
209 Entry getL1DCacheEntry(Address address), return_by_pointer="yes" {
210 Entry L1Dcache_entry := static_cast(Entry, "pointer", L1DcacheMemory.lookup(address));
211 return L1Dcache_entry;
214 Entry getL1ICacheEntry(Address address), return_by_pointer="yes" {
215 Entry L1Icache_entry := static_cast(Entry, "pointer", L1IcacheMemory.lookup(address));
216 return L1Icache_entry;
219 State getState(TBE tbe, Entry cache_entry, Address addr) {
222 } else if (is_valid(cache_entry)) {
223 return cache_entry.CacheState;
228 void setState(TBE tbe, Entry cache_entry, Address addr, State state) {
229 assert((L1DcacheMemory.isTagPresent(addr) && L1IcacheMemory.isTagPresent(addr)) == false);
230 assert((L1IcacheMemory.isTagPresent(addr) && L2cacheMemory.isTagPresent(addr)) == false);
231 assert((L1DcacheMemory.isTagPresent(addr) && L2cacheMemory.isTagPresent(addr)) == false);
234 tbe.TBEState := state;
237 if (is_valid(cache_entry)) {
238 cache_entry.CacheState := state;
242 AccessPermission getAccessPermission(Address addr) {
243 TBE tbe := TBEs[addr];
245 return L1Cache_State_to_permission(tbe.TBEState);
248 Entry cache_entry := getCacheEntry(addr);
249 if(is_valid(cache_entry)) {
250 return L1Cache_State_to_permission(cache_entry.CacheState);
253 return AccessPermission:NotPresent;
256 void setAccessPermission(Entry cache_entry, Address addr, State state) {
257 if (is_valid(cache_entry)) {
258 cache_entry.changePermission(L1Cache_State_to_permission(state));
262 Event mandatory_request_type_to_event(RubyRequestType type) {
263 if (type == RubyRequestType:LD) {
265 } else if (type == RubyRequestType:IFETCH) {
267 } else if ((type == RubyRequestType:ST) || (type == RubyRequestType:ATOMIC)) {
269 } else if ((type == RubyRequestType:FLUSH)) {
270 return Event:Flush_line;
272 error("Invalid RubyRequestType");
276 GenericMachineType getNondirectHitMachType(Address addr, MachineID sender) {
277 if (machineIDToMachineType(sender) == MachineType:L1Cache) {
279 // NOTE direct local hits should not call this
281 return GenericMachineType:L1Cache_wCC;
283 return ConvertMachToGenericMach(machineIDToMachineType(sender));
287 GenericMachineType testAndClearLocalHit(Entry cache_entry) {
288 if (is_valid(cache_entry) && cache_entry.FromL2) {
289 cache_entry.FromL2 := false;
290 return GenericMachineType:L2Cache;
292 return GenericMachineType:L1Cache;
296 bool IsAtomicAccessed(Entry cache_entry) {
297 assert(is_valid(cache_entry));
298 return cache_entry.AtomicAccessed;
301 MessageBuffer triggerQueue, ordered="false";
305 out_port(requestNetwork_out, RequestMsg, requestFromCache);
306 out_port(responseNetwork_out, ResponseMsg, responseFromCache);
307 out_port(unblockNetwork_out, ResponseMsg, unblockFromCache);
308 out_port(triggerQueue_out, TriggerMsg, triggerQueue);
313 in_port(triggerQueue_in, TriggerMsg, triggerQueue, rank=3) {
314 if (triggerQueue_in.isReady()) {
315 peek(triggerQueue_in, TriggerMsg) {
317 Entry cache_entry := getCacheEntry(in_msg.Address);
318 TBE tbe := TBEs[in_msg.Address];
320 if (in_msg.Type == TriggerType:L2_to_L1) {
321 trigger(Event:Complete_L2_to_L1, in_msg.Address, cache_entry, tbe);
322 } else if (in_msg.Type == TriggerType:ALL_ACKS) {
323 trigger(Event:All_acks, in_msg.Address, cache_entry, tbe);
324 } else if (in_msg.Type == TriggerType:ALL_ACKS_NO_SHARERS) {
325 trigger(Event:All_acks_no_sharers, in_msg.Address, cache_entry, tbe);
327 error("Unexpected message");
333 // Nothing from the unblock network
336 in_port(responseToCache_in, ResponseMsg, responseToCache, rank=2) {
337 if (responseToCache_in.isReady()) {
338 peek(responseToCache_in, ResponseMsg, block_on="Address") {
340 Entry cache_entry := getCacheEntry(in_msg.Address);
341 TBE tbe := TBEs[in_msg.Address];
343 if (in_msg.Type == CoherenceResponseType:ACK) {
344 trigger(Event:Ack, in_msg.Address, cache_entry, tbe);
345 } else if (in_msg.Type == CoherenceResponseType:ACK_SHARED) {
346 trigger(Event:Shared_Ack, in_msg.Address, cache_entry, tbe);
347 } else if (in_msg.Type == CoherenceResponseType:DATA) {
348 trigger(Event:Data, in_msg.Address, cache_entry, tbe);
349 } else if (in_msg.Type == CoherenceResponseType:DATA_SHARED) {
350 trigger(Event:Shared_Data, in_msg.Address, cache_entry, tbe);
351 } else if (in_msg.Type == CoherenceResponseType:DATA_EXCLUSIVE) {
352 trigger(Event:Exclusive_Data, in_msg.Address, cache_entry, tbe);
354 error("Unexpected message");
361 in_port(forwardToCache_in, RequestMsg, forwardToCache, rank=1) {
362 if (forwardToCache_in.isReady()) {
363 peek(forwardToCache_in, RequestMsg, block_on="Address") {
365 Entry cache_entry := getCacheEntry(in_msg.Address);
366 TBE tbe := TBEs[in_msg.Address];
368 if ((in_msg.Type == CoherenceRequestType:GETX) || (in_msg.Type == CoherenceRequestType:GETF)) {
369 trigger(Event:Other_GETX, in_msg.Address, cache_entry, tbe);
370 } else if (in_msg.Type == CoherenceRequestType:MERGED_GETS) {
371 trigger(Event:Merged_GETS, in_msg.Address, cache_entry, tbe);
372 } else if (in_msg.Type == CoherenceRequestType:GETS) {
373 if (machineCount(MachineType:L1Cache) > 1) {
374 if (is_valid(cache_entry)) {
375 if (IsAtomicAccessed(cache_entry) && no_mig_atomic) {
376 trigger(Event:Other_GETS_No_Mig, in_msg.Address, cache_entry, tbe);
378 trigger(Event:Other_GETS, in_msg.Address, cache_entry, tbe);
381 trigger(Event:Other_GETS, in_msg.Address, cache_entry, tbe);
384 trigger(Event:NC_DMA_GETS, in_msg.Address, cache_entry, tbe);
386 } else if (in_msg.Type == CoherenceRequestType:INV) {
387 trigger(Event:Invalidate, in_msg.Address, cache_entry, tbe);
388 } else if (in_msg.Type == CoherenceRequestType:WB_ACK) {
389 trigger(Event:Writeback_Ack, in_msg.Address, cache_entry, tbe);
390 } else if (in_msg.Type == CoherenceRequestType:WB_NACK) {
391 trigger(Event:Writeback_Nack, in_msg.Address, cache_entry, tbe);
392 } else if (in_msg.Type == CoherenceRequestType:BLOCK_ACK) {
393 trigger(Event:Block_Ack, in_msg.Address, cache_entry, tbe);
395 error("Unexpected message");
401 // Nothing from the request network
404 in_port(mandatoryQueue_in, RubyRequest, mandatoryQueue, desc="...", rank=0) {
405 if (mandatoryQueue_in.isReady()) {
406 peek(mandatoryQueue_in, RubyRequest, block_on="LineAddress") {
408 // Check for data access to blocks in I-cache and ifetchs to blocks in D-cache
409 TBE tbe := TBEs[in_msg.LineAddress];
411 if (in_msg.Type == RubyRequestType:IFETCH) {
412 // ** INSTRUCTION ACCESS ***
414 Entry L1Icache_entry := getL1ICacheEntry(in_msg.LineAddress);
415 if (is_valid(L1Icache_entry)) {
416 // The tag matches for the L1, so the L1 fetches the line. We know it can't be in the L2 due to exclusion
417 trigger(mandatory_request_type_to_event(in_msg.Type),
418 in_msg.LineAddress, L1Icache_entry, tbe);
420 // Check to see if it is in the OTHER L1
421 Entry L1Dcache_entry := getL1DCacheEntry(in_msg.LineAddress);
422 if (is_valid(L1Dcache_entry)) {
423 // The block is in the wrong L1, try to write it to the L2
424 if (L2cacheMemory.cacheAvail(in_msg.LineAddress)) {
425 trigger(Event:L1_to_L2, in_msg.LineAddress, L1Dcache_entry, tbe);
427 Address l2_victim_addr := L2cacheMemory.cacheProbe(in_msg.LineAddress);
428 trigger(Event:L2_Replacement,
430 getL2CacheEntry(l2_victim_addr),
431 TBEs[l2_victim_addr]);
435 if (L1IcacheMemory.cacheAvail(in_msg.LineAddress)) {
436 // L1 does't have the line, but we have space for it in the L1
438 Entry L2cache_entry := getL2CacheEntry(in_msg.LineAddress);
439 if (is_valid(L2cache_entry)) {
440 // L2 has it (maybe not with the right permissions)
441 trigger(Event:Trigger_L2_to_L1I, in_msg.LineAddress,
444 // We have room, the L2 doesn't have it, so the L1 fetches the line
445 trigger(mandatory_request_type_to_event(in_msg.Type),
446 in_msg.LineAddress, L1Icache_entry, tbe);
449 // No room in the L1, so we need to make room
450 Address l1i_victim_addr := L1IcacheMemory.cacheProbe(in_msg.LineAddress);
451 if (L2cacheMemory.cacheAvail(l1i_victim_addr)) {
452 // The L2 has room, so we move the line from the L1 to the L2
453 trigger(Event:L1_to_L2,
455 getL1ICacheEntry(l1i_victim_addr),
456 TBEs[l1i_victim_addr]);
458 Address l2_victim_addr := L2cacheMemory.cacheProbe(l1i_victim_addr);
459 // The L2 does not have room, so we replace a line from the L2
460 trigger(Event:L2_Replacement,
462 getL2CacheEntry(l2_victim_addr),
463 TBEs[l2_victim_addr]);
468 // *** DATA ACCESS ***
470 Entry L1Dcache_entry := getL1DCacheEntry(in_msg.LineAddress);
471 if (is_valid(L1Dcache_entry)) {
472 // The tag matches for the L1, so the L1 fetches the line. We know it can't be in the L2 due to exclusion
473 trigger(mandatory_request_type_to_event(in_msg.Type),
474 in_msg.LineAddress, L1Dcache_entry, tbe);
477 // Check to see if it is in the OTHER L1
478 Entry L1Icache_entry := getL1ICacheEntry(in_msg.LineAddress);
479 if (is_valid(L1Icache_entry)) {
480 // The block is in the wrong L1, try to write it to the L2
481 if (L2cacheMemory.cacheAvail(in_msg.LineAddress)) {
482 trigger(Event:L1_to_L2, in_msg.LineAddress, L1Icache_entry, tbe);
484 Address l2_victim_addr := L2cacheMemory.cacheProbe(in_msg.LineAddress);
485 trigger(Event:L2_Replacement,
487 getL2CacheEntry(l2_victim_addr),
488 TBEs[l2_victim_addr]);
492 if (L1DcacheMemory.cacheAvail(in_msg.LineAddress)) {
493 // L1 does't have the line, but we have space for it in the L1
494 Entry L2cache_entry := getL2CacheEntry(in_msg.LineAddress);
495 if (is_valid(L2cache_entry)) {
496 // L2 has it (maybe not with the right permissions)
497 trigger(Event:Trigger_L2_to_L1D, in_msg.LineAddress,
500 // We have room, the L2 doesn't have it, so the L1 fetches the line
501 trigger(mandatory_request_type_to_event(in_msg.Type),
502 in_msg.LineAddress, L1Dcache_entry, tbe);
505 // No room in the L1, so we need to make room
506 Address l1d_victim_addr := L1DcacheMemory.cacheProbe(in_msg.LineAddress);
507 if (L2cacheMemory.cacheAvail(l1d_victim_addr)) {
508 // The L2 has room, so we move the line from the L1 to the L2
509 trigger(Event:L1_to_L2,
511 getL1DCacheEntry(l1d_victim_addr),
512 TBEs[l1d_victim_addr]);
514 Address l2_victim_addr := L2cacheMemory.cacheProbe(l1d_victim_addr);
515 // The L2 does not have room, so we replace a line from the L2
516 trigger(Event:L2_Replacement,
518 getL2CacheEntry(l2_victim_addr),
519 TBEs[l2_victim_addr]);
530 action(a_issueGETS, "a", desc="Issue GETS") {
531 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
532 assert(is_valid(tbe));
533 out_msg.Address := address;
534 out_msg.Type := CoherenceRequestType:GETS;
535 out_msg.Requestor := machineID;
536 out_msg.Destination.add(map_Address_to_Directory(address));
537 out_msg.MessageSize := MessageSizeType:Request_Control;
538 out_msg.InitialRequestTime := get_time();
539 tbe.NumPendingMsgs := machineCount(MachineType:L1Cache); // One from each other cache (n-1) plus the memory (+1)
543 action(b_issueGETX, "b", desc="Issue GETX") {
544 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
545 assert(is_valid(tbe));
546 out_msg.Address := address;
547 out_msg.Type := CoherenceRequestType:GETX;
548 out_msg.Requestor := machineID;
549 out_msg.Destination.add(map_Address_to_Directory(address));
550 out_msg.MessageSize := MessageSizeType:Request_Control;
551 out_msg.InitialRequestTime := get_time();
552 tbe.NumPendingMsgs := machineCount(MachineType:L1Cache); // One from each other cache (n-1) plus the memory (+1)
556 action(b_issueGETXIfMoreThanOne, "bo", desc="Issue GETX") {
557 if (machineCount(MachineType:L1Cache) > 1) {
558 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
559 assert(is_valid(tbe));
560 out_msg.Address := address;
561 out_msg.Type := CoherenceRequestType:GETX;
562 out_msg.Requestor := machineID;
563 out_msg.Destination.add(map_Address_to_Directory(address));
564 out_msg.MessageSize := MessageSizeType:Request_Control;
565 out_msg.InitialRequestTime := get_time();
568 tbe.NumPendingMsgs := machineCount(MachineType:L1Cache); // One from each other cache (n-1) plus the memory (+1)
571 action(bf_issueGETF, "bf", desc="Issue GETF") {
572 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
573 assert(is_valid(tbe));
574 out_msg.Address := address;
575 out_msg.Type := CoherenceRequestType:GETF;
576 out_msg.Requestor := machineID;
577 out_msg.Destination.add(map_Address_to_Directory(address));
578 out_msg.MessageSize := MessageSizeType:Request_Control;
579 out_msg.InitialRequestTime := get_time();
580 tbe.NumPendingMsgs := machineCount(MachineType:L1Cache); // One from each other cache (n-1) plus the memory (+1)
584 action(c_sendExclusiveData, "c", desc="Send exclusive data from cache to requestor") {
585 peek(forwardToCache_in, RequestMsg) {
586 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
587 assert(is_valid(cache_entry));
588 out_msg.Address := address;
589 out_msg.Type := CoherenceResponseType:DATA_EXCLUSIVE;
590 out_msg.Sender := machineID;
591 out_msg.Destination.add(in_msg.Requestor);
592 out_msg.DataBlk := cache_entry.DataBlk;
593 out_msg.Dirty := cache_entry.Dirty;
594 if (in_msg.DirectedProbe) {
595 out_msg.Acks := machineCount(MachineType:L1Cache);
599 out_msg.SilentAcks := in_msg.SilentAcks;
600 out_msg.MessageSize := MessageSizeType:Response_Data;
601 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
602 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
607 action(ct_sendExclusiveDataFromTBE, "ct", desc="Send exclusive data from tbe to requestor") {
608 peek(forwardToCache_in, RequestMsg) {
609 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
610 assert(is_valid(tbe));
611 out_msg.Address := address;
612 out_msg.Type := CoherenceResponseType:DATA_EXCLUSIVE;
613 out_msg.Sender := machineID;
614 out_msg.Destination.add(in_msg.Requestor);
615 out_msg.DataBlk := tbe.DataBlk;
616 out_msg.Dirty := tbe.Dirty;
617 if (in_msg.DirectedProbe) {
618 out_msg.Acks := machineCount(MachineType:L1Cache);
622 out_msg.SilentAcks := in_msg.SilentAcks;
623 out_msg.MessageSize := MessageSizeType:Response_Data;
624 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
625 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
630 action(d_issuePUT, "d", desc="Issue PUT") {
631 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
632 out_msg.Address := address;
633 out_msg.Type := CoherenceRequestType:PUT;
634 out_msg.Requestor := machineID;
635 out_msg.Destination.add(map_Address_to_Directory(address));
636 out_msg.MessageSize := MessageSizeType:Writeback_Control;
640 action(df_issuePUTF, "df", desc="Issue PUTF") {
641 enqueue(requestNetwork_out, RequestMsg, latency=issue_latency) {
642 out_msg.Address := address;
643 out_msg.Type := CoherenceRequestType:PUTF;
644 out_msg.Requestor := machineID;
645 out_msg.Destination.add(map_Address_to_Directory(address));
646 out_msg.MessageSize := MessageSizeType:Writeback_Control;
650 action(e_sendData, "e", desc="Send data from cache to requestor") {
651 peek(forwardToCache_in, RequestMsg) {
652 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
653 assert(is_valid(cache_entry));
654 out_msg.Address := address;
655 out_msg.Type := CoherenceResponseType:DATA;
656 out_msg.Sender := machineID;
657 out_msg.Destination.add(in_msg.Requestor);
658 out_msg.DataBlk := cache_entry.DataBlk;
659 out_msg.Dirty := cache_entry.Dirty;
660 if (in_msg.DirectedProbe) {
661 out_msg.Acks := machineCount(MachineType:L1Cache);
665 out_msg.SilentAcks := in_msg.SilentAcks;
666 out_msg.MessageSize := MessageSizeType:Response_Data;
667 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
668 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
673 action(ee_sendDataShared, "\e", desc="Send data from cache to requestor, remaining the owner") {
674 peek(forwardToCache_in, RequestMsg) {
675 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
676 assert(is_valid(cache_entry));
677 out_msg.Address := address;
678 out_msg.Type := CoherenceResponseType:DATA_SHARED;
679 out_msg.Sender := machineID;
680 out_msg.Destination.add(in_msg.Requestor);
681 out_msg.DataBlk := cache_entry.DataBlk;
682 out_msg.Dirty := cache_entry.Dirty;
683 DPRINTF(RubySlicc, "%s\n", out_msg.DataBlk);
684 if (in_msg.DirectedProbe) {
685 out_msg.Acks := machineCount(MachineType:L1Cache);
689 out_msg.SilentAcks := in_msg.SilentAcks;
690 out_msg.MessageSize := MessageSizeType:Response_Data;
691 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
692 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
697 action(et_sendDataSharedFromTBE, "\et", desc="Send data from TBE to requestor, keep a shared copy") {
698 peek(forwardToCache_in, RequestMsg) {
699 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
700 assert(is_valid(tbe));
701 out_msg.Address := address;
702 out_msg.Type := CoherenceResponseType:DATA_SHARED;
703 out_msg.Sender := machineID;
704 out_msg.Destination.add(in_msg.Requestor);
705 out_msg.DataBlk := tbe.DataBlk;
706 out_msg.Dirty := tbe.Dirty;
707 DPRINTF(RubySlicc, "%s\n", out_msg.DataBlk);
708 if (in_msg.DirectedProbe) {
709 out_msg.Acks := machineCount(MachineType:L1Cache);
713 out_msg.SilentAcks := in_msg.SilentAcks;
714 out_msg.MessageSize := MessageSizeType:Response_Data;
715 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
716 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
721 action(em_sendDataSharedMultiple, "em", desc="Send data from cache to all requestors, still the owner") {
722 peek(forwardToCache_in, RequestMsg) {
723 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
724 assert(is_valid(cache_entry));
725 out_msg.Address := address;
726 out_msg.Type := CoherenceResponseType:DATA_SHARED;
727 out_msg.Sender := machineID;
728 out_msg.Destination := in_msg.MergedRequestors;
729 out_msg.DataBlk := cache_entry.DataBlk;
730 out_msg.Dirty := cache_entry.Dirty;
731 DPRINTF(RubySlicc, "%s\n", out_msg.DataBlk);
732 out_msg.Acks := machineCount(MachineType:L1Cache);
733 out_msg.SilentAcks := in_msg.SilentAcks;
734 out_msg.MessageSize := MessageSizeType:Response_Data;
735 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
736 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
741 action(emt_sendDataSharedMultipleFromTBE, "emt", desc="Send data from tbe to all requestors") {
742 peek(forwardToCache_in, RequestMsg) {
743 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
744 assert(is_valid(tbe));
745 out_msg.Address := address;
746 out_msg.Type := CoherenceResponseType:DATA_SHARED;
747 out_msg.Sender := machineID;
748 out_msg.Destination := in_msg.MergedRequestors;
749 out_msg.DataBlk := tbe.DataBlk;
750 out_msg.Dirty := tbe.Dirty;
751 DPRINTF(RubySlicc, "%s\n", out_msg.DataBlk);
752 out_msg.Acks := machineCount(MachineType:L1Cache);
753 out_msg.SilentAcks := in_msg.SilentAcks;
754 out_msg.MessageSize := MessageSizeType:Response_Data;
755 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
756 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
761 action(f_sendAck, "f", desc="Send ack from cache to requestor") {
762 peek(forwardToCache_in, RequestMsg) {
763 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
764 out_msg.Address := address;
765 out_msg.Type := CoherenceResponseType:ACK;
766 out_msg.Sender := machineID;
767 out_msg.Destination.add(in_msg.Requestor);
769 out_msg.SilentAcks := in_msg.SilentAcks;
770 assert(in_msg.DirectedProbe == false);
771 out_msg.MessageSize := MessageSizeType:Response_Control;
772 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
773 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
778 action(ff_sendAckShared, "\f", desc="Send shared ack from cache to requestor") {
779 peek(forwardToCache_in, RequestMsg) {
780 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
781 out_msg.Address := address;
782 out_msg.Type := CoherenceResponseType:ACK_SHARED;
783 out_msg.Sender := machineID;
784 out_msg.Destination.add(in_msg.Requestor);
786 out_msg.SilentAcks := in_msg.SilentAcks;
787 assert(in_msg.DirectedProbe == false);
788 out_msg.MessageSize := MessageSizeType:Response_Control;
789 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
790 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
795 action(g_sendUnblock, "g", desc="Send unblock to memory") {
796 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
797 out_msg.Address := address;
798 out_msg.Type := CoherenceResponseType:UNBLOCK;
799 out_msg.Sender := machineID;
800 out_msg.Destination.add(map_Address_to_Directory(address));
801 out_msg.MessageSize := MessageSizeType:Unblock_Control;
805 action(gm_sendUnblockM, "gm", desc="Send unblock to memory and indicate M/O/E state") {
806 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
807 out_msg.Address := address;
808 out_msg.Type := CoherenceResponseType:UNBLOCKM;
809 out_msg.Sender := machineID;
810 out_msg.Destination.add(map_Address_to_Directory(address));
811 out_msg.MessageSize := MessageSizeType:Unblock_Control;
815 action(gs_sendUnblockS, "gs", desc="Send unblock to memory and indicate S state") {
816 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
817 assert(is_valid(tbe));
818 out_msg.Address := address;
819 out_msg.Type := CoherenceResponseType:UNBLOCKS;
820 out_msg.Sender := machineID;
821 out_msg.CurOwner := tbe.CurOwner;
822 out_msg.Destination.add(map_Address_to_Directory(address));
823 out_msg.MessageSize := MessageSizeType:Unblock_Control;
827 action(h_load_hit, "h", desc="Notify sequencer the load completed.") {
828 assert(is_valid(cache_entry));
829 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
830 sequencer.readCallback(address, testAndClearLocalHit(cache_entry),
831 cache_entry.DataBlk);
834 action(hx_external_load_hit, "hx", desc="load required external msgs") {
835 assert(is_valid(cache_entry));
836 assert(is_valid(tbe));
837 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
838 peek(responseToCache_in, ResponseMsg) {
840 sequencer.readCallback(address,
841 getNondirectHitMachType(in_msg.Address, in_msg.Sender),
843 tbe.InitialRequestTime,
844 tbe.ForwardRequestTime,
845 tbe.FirstResponseTime);
849 action(hh_store_hit, "\h", desc="Notify sequencer that store completed.") {
850 assert(is_valid(cache_entry));
851 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
852 peek(mandatoryQueue_in, RubyRequest) {
853 sequencer.writeCallback(address, testAndClearLocalHit(cache_entry),
854 cache_entry.DataBlk);
856 cache_entry.Dirty := true;
857 if (in_msg.Type == RubyRequestType:ATOMIC) {
858 cache_entry.AtomicAccessed := true;
863 action(hh_flush_hit, "\hf", desc="Notify sequencer that flush completed.") {
864 assert(is_valid(tbe));
865 DPRINTF(RubySlicc, "%s\n", tbe.DataBlk);
866 sequencer.writeCallback(address, GenericMachineType:L1Cache,tbe.DataBlk);
869 action(sx_external_store_hit, "sx", desc="store required external msgs.") {
870 assert(is_valid(cache_entry));
871 assert(is_valid(tbe));
872 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
873 peek(responseToCache_in, ResponseMsg) {
875 sequencer.writeCallback(address,
876 getNondirectHitMachType(address, in_msg.Sender),
878 tbe.InitialRequestTime,
879 tbe.ForwardRequestTime,
880 tbe.FirstResponseTime);
882 cache_entry.Dirty := true;
885 action(sxt_trig_ext_store_hit, "sxt", desc="store required external msgs.") {
886 assert(is_valid(cache_entry));
887 assert(is_valid(tbe));
888 DPRINTF(RubySlicc, "%s\n", cache_entry.DataBlk);
890 sequencer.writeCallback(address,
891 getNondirectHitMachType(address, tbe.LastResponder),
893 tbe.InitialRequestTime,
894 tbe.ForwardRequestTime,
895 tbe.FirstResponseTime);
897 cache_entry.Dirty := true;
900 action(i_allocateTBE, "i", desc="Allocate TBE") {
901 check_allocate(TBEs);
902 assert(is_valid(cache_entry));
903 TBEs.allocate(address);
904 set_tbe(TBEs[address]);
905 tbe.DataBlk := cache_entry.DataBlk; // Data only used for writebacks
906 tbe.Dirty := cache_entry.Dirty;
907 tbe.Sharers := false;
910 action(it_allocateTBE, "it", desc="Allocate TBE") {
911 check_allocate(TBEs);
912 TBEs.allocate(address);
913 set_tbe(TBEs[address]);
915 tbe.Sharers := false;
918 action(j_popTriggerQueue, "j", desc="Pop trigger queue.") {
919 triggerQueue_in.dequeue();
922 action(k_popMandatoryQueue, "k", desc="Pop mandatory queue.") {
923 mandatoryQueue_in.dequeue();
926 action(l_popForwardQueue, "l", desc="Pop forwareded request queue.") {
927 forwardToCache_in.dequeue();
930 action(hp_copyFromTBEToL2, "li", desc="Copy data from TBE to L2 cache entry.") {
931 assert(is_valid(cache_entry));
932 assert(is_valid(tbe));
933 cache_entry.Dirty := tbe.Dirty;
934 cache_entry.DataBlk := tbe.DataBlk;
937 action(nb_copyFromTBEToL1, "fu", desc="Copy data from TBE to L1 cache entry.") {
938 assert(is_valid(cache_entry));
939 assert(is_valid(tbe));
940 cache_entry.Dirty := tbe.Dirty;
941 cache_entry.DataBlk := tbe.DataBlk;
942 cache_entry.FromL2 := true;
945 action(m_decrementNumberOfMessages, "m", desc="Decrement the number of messages for which we're waiting") {
946 peek(responseToCache_in, ResponseMsg) {
947 assert(in_msg.Acks >= 0);
948 assert(is_valid(tbe));
949 DPRINTF(RubySlicc, "Sender = %s\n", in_msg.Sender);
950 DPRINTF(RubySlicc, "SilentAcks = %d\n", in_msg.SilentAcks);
951 if (tbe.AppliedSilentAcks == false) {
952 tbe.NumPendingMsgs := tbe.NumPendingMsgs - in_msg.SilentAcks;
953 tbe.AppliedSilentAcks := true;
955 DPRINTF(RubySlicc, "%d\n", tbe.NumPendingMsgs);
956 tbe.NumPendingMsgs := tbe.NumPendingMsgs - in_msg.Acks;
957 DPRINTF(RubySlicc, "%d\n", tbe.NumPendingMsgs);
958 APPEND_TRANSITION_COMMENT(tbe.NumPendingMsgs);
959 APPEND_TRANSITION_COMMENT(in_msg.Sender);
960 tbe.LastResponder := in_msg.Sender;
961 if (tbe.InitialRequestTime != zero_time() && in_msg.InitialRequestTime != zero_time()) {
962 assert(tbe.InitialRequestTime == in_msg.InitialRequestTime);
964 if (in_msg.InitialRequestTime != zero_time()) {
965 tbe.InitialRequestTime := in_msg.InitialRequestTime;
967 if (tbe.ForwardRequestTime != zero_time() && in_msg.ForwardRequestTime != zero_time()) {
968 assert(tbe.ForwardRequestTime == in_msg.ForwardRequestTime);
970 if (in_msg.ForwardRequestTime != zero_time()) {
971 tbe.ForwardRequestTime := in_msg.ForwardRequestTime;
973 if (tbe.FirstResponseTime == zero_time()) {
974 tbe.FirstResponseTime := get_time();
978 action(uo_updateCurrentOwner, "uo", desc="When moving SS state, update current owner.") {
979 peek(responseToCache_in, ResponseMsg) {
980 assert(is_valid(tbe));
981 tbe.CurOwner := in_msg.Sender;
985 action(n_popResponseQueue, "n", desc="Pop response queue") {
986 responseToCache_in.dequeue();
989 action(ll_L2toL1Transfer, "ll", desc="") {
990 enqueue(triggerQueue_out, TriggerMsg, latency=l2_cache_hit_latency) {
991 out_msg.Address := address;
992 out_msg.Type := TriggerType:L2_to_L1;
996 action(o_checkForCompletion, "o", desc="Check if we have received all the messages required for completion") {
997 assert(is_valid(tbe));
998 if (tbe.NumPendingMsgs == 0) {
999 enqueue(triggerQueue_out, TriggerMsg) {
1000 out_msg.Address := address;
1002 out_msg.Type := TriggerType:ALL_ACKS;
1004 out_msg.Type := TriggerType:ALL_ACKS_NO_SHARERS;
1010 action(p_decrementNumberOfMessagesByOne, "p", desc="Decrement the number of messages for which we're waiting by one") {
1011 assert(is_valid(tbe));
1012 tbe.NumPendingMsgs := tbe.NumPendingMsgs - 1;
1015 action(pp_incrementNumberOfMessagesByOne, "\p", desc="Increment the number of messages for which we're waiting by one") {
1016 assert(is_valid(tbe));
1017 tbe.NumPendingMsgs := tbe.NumPendingMsgs + 1;
1020 action(q_sendDataFromTBEToCache, "q", desc="Send data from TBE to cache") {
1021 peek(forwardToCache_in, RequestMsg) {
1022 assert(in_msg.Requestor != machineID);
1023 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
1024 assert(is_valid(tbe));
1025 out_msg.Address := address;
1026 out_msg.Type := CoherenceResponseType:DATA;
1027 out_msg.Sender := machineID;
1028 out_msg.Destination.add(in_msg.Requestor);
1029 DPRINTF(RubySlicc, "%s\n", out_msg.Destination);
1030 out_msg.DataBlk := tbe.DataBlk;
1031 out_msg.Dirty := tbe.Dirty;
1032 if (in_msg.DirectedProbe) {
1033 out_msg.Acks := machineCount(MachineType:L1Cache);
1037 out_msg.SilentAcks := in_msg.SilentAcks;
1038 out_msg.MessageSize := MessageSizeType:Response_Data;
1039 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
1040 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
1045 action(sq_sendSharedDataFromTBEToCache, "sq", desc="Send shared data from TBE to cache, still the owner") {
1046 peek(forwardToCache_in, RequestMsg) {
1047 assert(in_msg.Requestor != machineID);
1048 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
1049 assert(is_valid(tbe));
1050 out_msg.Address := address;
1051 out_msg.Type := CoherenceResponseType:DATA_SHARED;
1052 out_msg.Sender := machineID;
1053 out_msg.Destination.add(in_msg.Requestor);
1054 DPRINTF(RubySlicc, "%s\n", out_msg.Destination);
1055 out_msg.DataBlk := tbe.DataBlk;
1056 out_msg.Dirty := tbe.Dirty;
1057 if (in_msg.DirectedProbe) {
1058 out_msg.Acks := machineCount(MachineType:L1Cache);
1062 out_msg.SilentAcks := in_msg.SilentAcks;
1063 out_msg.MessageSize := MessageSizeType:Response_Data;
1064 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
1065 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
1070 action(qm_sendDataFromTBEToCache, "qm", desc="Send data from TBE to cache, multiple sharers, still the owner") {
1071 peek(forwardToCache_in, RequestMsg) {
1072 enqueue(responseNetwork_out, ResponseMsg, latency=cache_response_latency) {
1073 assert(is_valid(tbe));
1074 out_msg.Address := address;
1075 out_msg.Type := CoherenceResponseType:DATA_SHARED;
1076 out_msg.Sender := machineID;
1077 out_msg.Destination := in_msg.MergedRequestors;
1078 DPRINTF(RubySlicc, "%s\n", out_msg.Destination);
1079 out_msg.DataBlk := tbe.DataBlk;
1080 out_msg.Dirty := tbe.Dirty;
1081 out_msg.Acks := machineCount(MachineType:L1Cache);
1082 out_msg.SilentAcks := in_msg.SilentAcks;
1083 out_msg.MessageSize := MessageSizeType:Response_Data;
1084 out_msg.InitialRequestTime := in_msg.InitialRequestTime;
1085 out_msg.ForwardRequestTime := in_msg.ForwardRequestTime;
1090 action(qq_sendDataFromTBEToMemory, "\q", desc="Send data from TBE to memory") {
1091 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
1092 assert(is_valid(tbe));
1093 out_msg.Address := address;
1094 out_msg.Sender := machineID;
1095 out_msg.Destination.add(map_Address_to_Directory(address));
1096 out_msg.Dirty := tbe.Dirty;
1098 out_msg.Type := CoherenceResponseType:WB_DIRTY;
1099 out_msg.DataBlk := tbe.DataBlk;
1100 out_msg.MessageSize := MessageSizeType:Writeback_Data;
1102 out_msg.Type := CoherenceResponseType:WB_CLEAN;
1103 // NOTE: in a real system this would not send data. We send
1104 // data here only so we can check it at the memory
1105 out_msg.DataBlk := tbe.DataBlk;
1106 out_msg.MessageSize := MessageSizeType:Writeback_Control;
1111 action(r_setSharerBit, "r", desc="We saw other sharers") {
1112 assert(is_valid(tbe));
1113 tbe.Sharers := true;
1116 action(s_deallocateTBE, "s", desc="Deallocate TBE") {
1117 TBEs.deallocate(address);
1121 action(t_sendExclusiveDataFromTBEToMemory, "t", desc="Send exclusive data from TBE to memory") {
1122 enqueue(unblockNetwork_out, ResponseMsg, latency=cache_response_latency) {
1123 assert(is_valid(tbe));
1124 out_msg.Address := address;
1125 out_msg.Sender := machineID;
1126 out_msg.Destination.add(map_Address_to_Directory(address));
1127 out_msg.DataBlk := tbe.DataBlk;
1128 out_msg.Dirty := tbe.Dirty;
1130 out_msg.Type := CoherenceResponseType:WB_EXCLUSIVE_DIRTY;
1131 out_msg.DataBlk := tbe.DataBlk;
1132 out_msg.MessageSize := MessageSizeType:Writeback_Data;
1134 out_msg.Type := CoherenceResponseType:WB_EXCLUSIVE_CLEAN;
1135 // NOTE: in a real system this would not send data. We send
1136 // data here only so we can check it at the memory
1137 out_msg.DataBlk := tbe.DataBlk;
1138 out_msg.MessageSize := MessageSizeType:Writeback_Control;
1143 action(u_writeDataToCache, "u", desc="Write data to cache") {
1144 peek(responseToCache_in, ResponseMsg) {
1145 assert(is_valid(cache_entry));
1146 cache_entry.DataBlk := in_msg.DataBlk;
1147 cache_entry.Dirty := in_msg.Dirty;
1151 action(uf_writeDataToCacheTBE, "uf", desc="Write data to TBE") {
1152 peek(responseToCache_in, ResponseMsg) {
1153 assert(is_valid(tbe));
1154 tbe.DataBlk := in_msg.DataBlk;
1155 tbe.Dirty := in_msg.Dirty;
1159 action(v_writeDataToCacheVerify, "v", desc="Write data to cache, assert it was same as before") {
1160 peek(responseToCache_in, ResponseMsg) {
1161 assert(is_valid(cache_entry));
1162 DPRINTF(RubySlicc, "Cached Data Block: %s, Msg Data Block: %s\n",
1163 cache_entry.DataBlk, in_msg.DataBlk);
1164 assert(cache_entry.DataBlk == in_msg.DataBlk);
1165 cache_entry.DataBlk := in_msg.DataBlk;
1166 cache_entry.Dirty := in_msg.Dirty || cache_entry.Dirty;
1170 action(vt_writeDataToTBEVerify, "vt", desc="Write data to TBE, assert it was same as before") {
1171 peek(responseToCache_in, ResponseMsg) {
1172 assert(is_valid(tbe));
1173 DPRINTF(RubySlicc, "Cached Data Block: %s, Msg Data Block: %s\n",
1174 tbe.DataBlk, in_msg.DataBlk);
1175 assert(tbe.DataBlk == in_msg.DataBlk);
1176 tbe.DataBlk := in_msg.DataBlk;
1177 tbe.Dirty := in_msg.Dirty || tbe.Dirty;
1181 action(gg_deallocateL1CacheBlock, "\g", desc="Deallocate cache block. Sets the cache to invalid, allowing a replacement in parallel with a fetch.") {
1182 if (L1DcacheMemory.isTagPresent(address)) {
1183 L1DcacheMemory.deallocate(address);
1185 L1IcacheMemory.deallocate(address);
1187 unset_cache_entry();
1190 action(ii_allocateL1DCacheBlock, "\i", desc="Set L1 D-cache tag equal to tag of block B.") {
1191 if (is_invalid(cache_entry)) {
1192 set_cache_entry(L1DcacheMemory.allocate(address, new Entry));
1196 action(jj_allocateL1ICacheBlock, "\j", desc="Set L1 I-cache tag equal to tag of block B.") {
1197 if (is_invalid(cache_entry)) {
1198 set_cache_entry(L1IcacheMemory.allocate(address, new Entry));
1202 action(vv_allocateL2CacheBlock, "\v", desc="Set L2 cache tag equal to tag of block B.") {
1203 set_cache_entry(L2cacheMemory.allocate(address, new Entry));
1206 action(rr_deallocateL2CacheBlock, "\r", desc="Deallocate L2 cache block. Sets the cache to not present, allowing a replacement in parallel with a fetch.") {
1207 L2cacheMemory.deallocate(address);
1208 unset_cache_entry();
1211 action(forward_eviction_to_cpu, "\cc", desc="sends eviction information to the processor") {
1212 if (send_evictions) {
1213 DPRINTF(RubySlicc, "Sending invalidation for %s to the CPU\n", address);
1214 sequencer.evictionCallback(address);
1218 action(uu_profileMiss, "\u", desc="Profile the demand miss") {
1219 peek(mandatoryQueue_in, RubyRequest) {
1220 if (L1IcacheMemory.isTagPresent(address)) {
1221 L1IcacheMemory.profileMiss(in_msg);
1222 } else if (L1DcacheMemory.isTagPresent(address)) {
1223 L1DcacheMemory.profileMiss(in_msg);
1225 if (L2cacheMemory.isTagPresent(address) == false) {
1226 L2cacheMemory.profileMiss(in_msg);
1231 action(zz_stallAndWaitMandatoryQueue, "\z", desc="Send the head of the mandatory queue to the back of the queue.") {
1232 stall_and_wait(mandatoryQueue_in, address);
1235 action(z_stall, "z", desc="stall") {
1236 // do nothing and the special z_stall action will return a protocol stall
1237 // so that the next port is checked
1240 action(kd_wakeUpDependents, "kd", desc="wake-up dependents") {
1241 wakeUpBuffers(address);
1244 action(ka_wakeUpAllDependents, "ka", desc="wake-up all dependents") {
1248 //*****************************************************
1250 //*****************************************************
1252 // Transitions for Load/Store/L2_Replacement from transient states
1253 transition({IM, IM_F, MM_WF, SM, SM_F, ISM, ISM_F, OM, OM_F, IS, SS, OI, MI, II, IT, ST, OT, MT, MMT}, {Store, L2_Replacement}) {
1254 zz_stallAndWaitMandatoryQueue;
1257 transition({IM, IM_F, MM_WF, SM, SM_F, ISM, ISM_F, OM, OM_F, IS, SS, OI, MI, II}, {Flush_line}) {
1258 zz_stallAndWaitMandatoryQueue;
1261 transition({M_W, MM_W}, {L2_Replacement, Flush_line}) {
1262 zz_stallAndWaitMandatoryQueue;
1265 transition({IM, IS, OI, MI, II, IT, ST, OT, MT, MMT, MI_F, MM_F, OM_F, IM_F, ISM_F, SM_F, MM_WF}, {Load, Ifetch}) {
1266 zz_stallAndWaitMandatoryQueue;
1269 transition({IM, SM, ISM, OM, IS, SS, MM_W, M_W, OI, MI, II, IT, ST, OT, MT, MMT, IM_F, SM_F, ISM_F, OM_F, MM_WF, MI_F, MM_F, IR, SR, OR, MR, MMR}, L1_to_L2) {
1270 zz_stallAndWaitMandatoryQueue;
1273 transition({MI_F, MM_F}, {Store}) {
1274 zz_stallAndWaitMandatoryQueue;
1277 transition({MM_F, MI_F}, {Flush_line}) {
1278 zz_stallAndWaitMandatoryQueue;
1281 transition({IT, ST, OT, MT, MMT}, {Other_GETX, NC_DMA_GETS, Other_GETS, Merged_GETS, Other_GETS_No_Mig, Invalidate, Flush_line}) {
1285 transition({IR, SR, OR, MR, MMR}, {Other_GETX, NC_DMA_GETS, Other_GETS, Merged_GETS, Other_GETS_No_Mig, Invalidate}) {
1289 // Transitions moving data between the L1 and L2 caches
1290 transition({I, S, O, M, MM}, L1_to_L2) {
1292 gg_deallocateL1CacheBlock;
1293 vv_allocateL2CacheBlock;
1298 transition(I, Trigger_L2_to_L1D, IT) {
1300 rr_deallocateL2CacheBlock;
1301 ii_allocateL1DCacheBlock;
1302 nb_copyFromTBEToL1; // Not really needed for state I
1305 zz_stallAndWaitMandatoryQueue;
1309 transition(S, Trigger_L2_to_L1D, ST) {
1311 rr_deallocateL2CacheBlock;
1312 ii_allocateL1DCacheBlock;
1316 zz_stallAndWaitMandatoryQueue;
1320 transition(O, Trigger_L2_to_L1D, OT) {
1322 rr_deallocateL2CacheBlock;
1323 ii_allocateL1DCacheBlock;
1327 zz_stallAndWaitMandatoryQueue;
1331 transition(M, Trigger_L2_to_L1D, MT) {
1333 rr_deallocateL2CacheBlock;
1334 ii_allocateL1DCacheBlock;
1338 zz_stallAndWaitMandatoryQueue;
1342 transition(MM, Trigger_L2_to_L1D, MMT) {
1344 rr_deallocateL2CacheBlock;
1345 ii_allocateL1DCacheBlock;
1349 zz_stallAndWaitMandatoryQueue;
1353 transition(I, Trigger_L2_to_L1I, IT) {
1355 rr_deallocateL2CacheBlock;
1356 jj_allocateL1ICacheBlock;
1360 zz_stallAndWaitMandatoryQueue;
1364 transition(S, Trigger_L2_to_L1I, ST) {
1366 rr_deallocateL2CacheBlock;
1367 jj_allocateL1ICacheBlock;
1371 zz_stallAndWaitMandatoryQueue;
1375 transition(O, Trigger_L2_to_L1I, OT) {
1377 rr_deallocateL2CacheBlock;
1378 jj_allocateL1ICacheBlock;
1382 zz_stallAndWaitMandatoryQueue;
1386 transition(M, Trigger_L2_to_L1I, MT) {
1388 rr_deallocateL2CacheBlock;
1389 jj_allocateL1ICacheBlock;
1393 zz_stallAndWaitMandatoryQueue;
1397 transition(MM, Trigger_L2_to_L1I, MMT) {
1399 rr_deallocateL2CacheBlock;
1400 jj_allocateL1ICacheBlock;
1404 zz_stallAndWaitMandatoryQueue;
1408 transition(IT, Complete_L2_to_L1, IR) {
1410 kd_wakeUpDependents;
1413 transition(ST, Complete_L2_to_L1, SR) {
1415 kd_wakeUpDependents;
1418 transition(OT, Complete_L2_to_L1, OR) {
1420 kd_wakeUpDependents;
1423 transition(MT, Complete_L2_to_L1, MR) {
1425 kd_wakeUpDependents;
1428 transition(MMT, Complete_L2_to_L1, MMR) {
1430 kd_wakeUpDependents;
1433 // Transitions from Idle
1434 transition({I, IR}, Load, IS) {
1435 ii_allocateL1DCacheBlock;
1439 k_popMandatoryQueue;
1442 transition({I, IR}, Ifetch, IS) {
1443 jj_allocateL1ICacheBlock;
1447 k_popMandatoryQueue;
1450 transition({I, IR}, Store, IM) {
1451 ii_allocateL1DCacheBlock;
1455 k_popMandatoryQueue;
1458 transition({I, IR}, Flush_line, IM_F) {
1462 k_popMandatoryQueue;
1465 transition(I, L2_Replacement) {
1466 rr_deallocateL2CacheBlock;
1467 ka_wakeUpAllDependents;
1470 transition(I, {Other_GETX, NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Invalidate}) {
1475 // Transitions from Shared
1476 transition({S, SM, ISM}, {Load, Ifetch}) {
1478 k_popMandatoryQueue;
1481 transition(SR, {Load, Ifetch}, S) {
1483 k_popMandatoryQueue;
1484 ka_wakeUpAllDependents;
1487 transition({S, SR}, Store, SM) {
1491 k_popMandatoryQueue;
1494 transition({S, SR}, Flush_line, SM_F) {
1498 forward_eviction_to_cpu;
1499 gg_deallocateL1CacheBlock;
1500 k_popMandatoryQueue;
1503 transition(S, L2_Replacement, I) {
1504 forward_eviction_to_cpu;
1505 rr_deallocateL2CacheBlock;
1506 ka_wakeUpAllDependents;
1509 transition(S, {Other_GETX, Invalidate}, I) {
1511 forward_eviction_to_cpu;
1515 transition(S, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1520 // Transitions from Owned
1521 transition({O, OM, SS, MM_W, M_W}, {Load, Ifetch}) {
1523 k_popMandatoryQueue;
1526 transition(OR, {Load, Ifetch}, O) {
1528 k_popMandatoryQueue;
1529 ka_wakeUpAllDependents;
1532 transition({O, OR}, Store, OM) {
1535 p_decrementNumberOfMessagesByOne;
1537 k_popMandatoryQueue;
1539 transition({O, OR}, Flush_line, OM_F) {
1542 p_decrementNumberOfMessagesByOne;
1544 forward_eviction_to_cpu;
1545 gg_deallocateL1CacheBlock;
1546 k_popMandatoryQueue;
1549 transition(O, L2_Replacement, OI) {
1552 forward_eviction_to_cpu;
1553 rr_deallocateL2CacheBlock;
1554 ka_wakeUpAllDependents;
1557 transition(O, {Other_GETX, Invalidate}, I) {
1559 forward_eviction_to_cpu;
1563 transition(O, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1568 transition(O, Merged_GETS) {
1569 em_sendDataSharedMultiple;
1573 // Transitions from Modified
1574 transition({MM, M}, {Load, Ifetch}) {
1576 k_popMandatoryQueue;
1579 transition(MM, Store) {
1581 k_popMandatoryQueue;
1584 transition(MMR, {Load, Ifetch}, MM) {
1586 k_popMandatoryQueue;
1587 ka_wakeUpAllDependents;
1590 transition(MMR, Store, MM) {
1592 k_popMandatoryQueue;
1593 ka_wakeUpAllDependents;
1596 transition({MM, M, MMR, MR}, Flush_line, MM_F) {
1599 p_decrementNumberOfMessagesByOne;
1600 forward_eviction_to_cpu;
1601 gg_deallocateL1CacheBlock;
1602 k_popMandatoryQueue;
1605 transition(MM_F, Block_Ack, MI_F) {
1608 kd_wakeUpDependents;
1611 transition(MM, L2_Replacement, MI) {
1614 forward_eviction_to_cpu;
1615 rr_deallocateL2CacheBlock;
1616 ka_wakeUpAllDependents;
1619 transition(MM, {Other_GETX, Invalidate}, I) {
1620 c_sendExclusiveData;
1621 forward_eviction_to_cpu;
1625 transition(MM, Other_GETS, I) {
1626 c_sendExclusiveData;
1627 forward_eviction_to_cpu;
1631 transition(MM, NC_DMA_GETS, O) {
1636 transition(MM, Other_GETS_No_Mig, O) {
1641 transition(MM, Merged_GETS, O) {
1642 em_sendDataSharedMultiple;
1646 // Transitions from Dirty Exclusive
1647 transition(M, Store, MM) {
1649 k_popMandatoryQueue;
1652 transition(MR, {Load, Ifetch}, M) {
1654 k_popMandatoryQueue;
1655 ka_wakeUpAllDependents;
1658 transition(MR, Store, MM) {
1660 k_popMandatoryQueue;
1661 ka_wakeUpAllDependents;
1664 transition(M, L2_Replacement, MI) {
1667 forward_eviction_to_cpu;
1668 rr_deallocateL2CacheBlock;
1669 ka_wakeUpAllDependents;
1672 transition(M, {Other_GETX, Invalidate}, I) {
1673 c_sendExclusiveData;
1674 forward_eviction_to_cpu;
1678 transition(M, {Other_GETS, Other_GETS_No_Mig}, O) {
1683 transition(M, NC_DMA_GETS, O) {
1688 transition(M, Merged_GETS, O) {
1689 em_sendDataSharedMultiple;
1693 // Transitions from IM
1695 transition({IM, IM_F}, {Other_GETX, NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Invalidate}) {
1700 transition({IM, IM_F, MM_F}, Ack) {
1701 m_decrementNumberOfMessages;
1702 o_checkForCompletion;
1706 transition(IM, Data, ISM) {
1708 m_decrementNumberOfMessages;
1709 o_checkForCompletion;
1713 transition(IM_F, Data, ISM_F) {
1714 uf_writeDataToCacheTBE;
1715 m_decrementNumberOfMessages;
1716 o_checkForCompletion;
1720 transition(IM, Exclusive_Data, MM_W) {
1722 m_decrementNumberOfMessages;
1723 o_checkForCompletion;
1724 sx_external_store_hit;
1726 kd_wakeUpDependents;
1729 transition(IM_F, Exclusive_Data, MM_WF) {
1730 uf_writeDataToCacheTBE;
1731 m_decrementNumberOfMessages;
1732 o_checkForCompletion;
1736 // Transitions from SM
1737 transition({SM, SM_F}, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1742 transition(SM, {Other_GETX, Invalidate}, IM) {
1744 forward_eviction_to_cpu;
1748 transition(SM_F, {Other_GETX, Invalidate}, IM_F) {
1750 forward_eviction_to_cpu;
1754 transition({SM, SM_F}, Ack) {
1755 m_decrementNumberOfMessages;
1756 o_checkForCompletion;
1760 transition(SM, {Data, Exclusive_Data}, ISM) {
1761 v_writeDataToCacheVerify;
1762 m_decrementNumberOfMessages;
1763 o_checkForCompletion;
1767 transition(SM_F, {Data, Exclusive_Data}, ISM_F) {
1768 vt_writeDataToTBEVerify;
1769 m_decrementNumberOfMessages;
1770 o_checkForCompletion;
1774 // Transitions from ISM
1775 transition({ISM, ISM_F}, Ack) {
1776 m_decrementNumberOfMessages;
1777 o_checkForCompletion;
1781 transition(ISM, All_acks_no_sharers, MM) {
1782 sxt_trig_ext_store_hit;
1786 kd_wakeUpDependents;
1789 transition(ISM_F, All_acks_no_sharers, MI_F) {
1792 kd_wakeUpDependents;
1795 // Transitions from OM
1797 transition(OM, {Other_GETX, Invalidate}, IM) {
1799 pp_incrementNumberOfMessagesByOne;
1800 forward_eviction_to_cpu;
1804 transition(OM_F, {Other_GETX, Invalidate}, IM_F) {
1805 q_sendDataFromTBEToCache;
1806 pp_incrementNumberOfMessagesByOne;
1807 forward_eviction_to_cpu;
1811 transition(OM, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1816 transition(OM, Merged_GETS) {
1817 em_sendDataSharedMultiple;
1821 transition(OM_F, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}) {
1822 et_sendDataSharedFromTBE;
1826 transition(OM_F, Merged_GETS) {
1827 emt_sendDataSharedMultipleFromTBE;
1831 transition({OM, OM_F}, Ack) {
1832 m_decrementNumberOfMessages;
1833 o_checkForCompletion;
1837 transition(OM, {All_acks, All_acks_no_sharers}, MM) {
1838 sxt_trig_ext_store_hit;
1842 kd_wakeUpDependents;
1845 transition({MM_F, OM_F}, {All_acks, All_acks_no_sharers}, MI_F) {
1848 kd_wakeUpDependents;
1850 // Transitions from IS
1852 transition(IS, {Other_GETX, NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Invalidate}) {
1857 transition(IS, Ack) {
1858 m_decrementNumberOfMessages;
1859 o_checkForCompletion;
1863 transition(IS, Shared_Ack) {
1864 m_decrementNumberOfMessages;
1866 o_checkForCompletion;
1870 transition(IS, Data, SS) {
1872 m_decrementNumberOfMessages;
1873 o_checkForCompletion;
1874 hx_external_load_hit;
1875 uo_updateCurrentOwner;
1877 kd_wakeUpDependents;
1880 transition(IS, Exclusive_Data, M_W) {
1882 m_decrementNumberOfMessages;
1883 o_checkForCompletion;
1884 hx_external_load_hit;
1886 kd_wakeUpDependents;
1889 transition(IS, Shared_Data, SS) {
1892 m_decrementNumberOfMessages;
1893 o_checkForCompletion;
1894 hx_external_load_hit;
1895 uo_updateCurrentOwner;
1897 kd_wakeUpDependents;
1900 // Transitions from SS
1902 transition(SS, Ack) {
1903 m_decrementNumberOfMessages;
1904 o_checkForCompletion;
1908 transition(SS, Shared_Ack) {
1909 m_decrementNumberOfMessages;
1911 o_checkForCompletion;
1915 transition(SS, All_acks, S) {
1919 kd_wakeUpDependents;
1922 transition(SS, All_acks_no_sharers, S) {
1923 // Note: The directory might still be the owner, so that is why we go to S
1927 kd_wakeUpDependents;
1930 // Transitions from MM_W
1932 transition(MM_W, Store) {
1934 k_popMandatoryQueue;
1937 transition({MM_W, MM_WF}, Ack) {
1938 m_decrementNumberOfMessages;
1939 o_checkForCompletion;
1943 transition(MM_W, All_acks_no_sharers, MM) {
1947 kd_wakeUpDependents;
1950 transition(MM_WF, All_acks_no_sharers, MI_F) {
1953 kd_wakeUpDependents;
1955 // Transitions from M_W
1957 transition(M_W, Store, MM_W) {
1959 k_popMandatoryQueue;
1962 transition(M_W, Ack) {
1963 m_decrementNumberOfMessages;
1964 o_checkForCompletion;
1968 transition(M_W, All_acks_no_sharers, M) {
1972 kd_wakeUpDependents;
1975 // Transitions from OI/MI
1977 transition({OI, MI}, {Other_GETX, Invalidate}, II) {
1978 q_sendDataFromTBEToCache;
1982 transition({OI, MI}, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig}, OI) {
1983 sq_sendSharedDataFromTBEToCache;
1987 transition({OI, MI}, Merged_GETS, OI) {
1988 qm_sendDataFromTBEToCache;
1992 transition(MI, Writeback_Ack, I) {
1993 t_sendExclusiveDataFromTBEToMemory;
1996 kd_wakeUpDependents;
1999 transition(MI_F, Writeback_Ack, I) {
2001 t_sendExclusiveDataFromTBEToMemory;
2004 kd_wakeUpDependents;
2007 transition(OI, Writeback_Ack, I) {
2008 qq_sendDataFromTBEToMemory;
2011 kd_wakeUpDependents;
2014 // Transitions from II
2015 transition(II, {NC_DMA_GETS, Other_GETS, Other_GETS_No_Mig, Other_GETX, Invalidate}, II) {
2020 transition(II, Writeback_Ack, I) {
2024 kd_wakeUpDependents;
2027 transition(II, Writeback_Nack, I) {
2030 kd_wakeUpDependents;
2033 transition(MM_F, {Other_GETX, Invalidate}, IM_F) {
2034 ct_sendExclusiveDataFromTBE;
2035 pp_incrementNumberOfMessagesByOne;
2039 transition(MM_F, Other_GETS, IM_F) {
2040 ct_sendExclusiveDataFromTBE;
2041 pp_incrementNumberOfMessagesByOne;
2045 transition(MM_F, NC_DMA_GETS, OM_F) {
2046 sq_sendSharedDataFromTBEToCache;
2050 transition(MM_F, Other_GETS_No_Mig, OM_F) {
2051 et_sendDataSharedFromTBE;
2055 transition(MM_F, Merged_GETS, OM_F) {
2056 emt_sendDataSharedMultipleFromTBE;