base.cc (12749:223c83ed9979) | base.cc (12754:15c1d281ce1a) |
---|---|
1/* 2 * Copyright (c) 2012-2013, 2018 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 956 unchanged lines hidden (view full) --- 965 mshrQueue.findMatch(pkt->getAddr(), pkt->isSecure())) { 966 DPRINTF(Cache, "Clean writeback %#llx to block with MSHR, " 967 "dropping\n", pkt->getAddr()); 968 return true; 969 } 970 971 if (!blk) { 972 // need to do a replacement | 1/* 2 * Copyright (c) 2012-2013, 2018 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 956 unchanged lines hidden (view full) --- 965 mshrQueue.findMatch(pkt->getAddr(), pkt->isSecure())) { 966 DPRINTF(Cache, "Clean writeback %#llx to block with MSHR, " 967 "dropping\n", pkt->getAddr()); 968 return true; 969 } 970 971 if (!blk) { 972 // need to do a replacement |
973 blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), writebacks); | 973 blk = allocateBlock(pkt, writebacks); |
974 if (!blk) { 975 // no replaceable block available: give up, fwd to next level. 976 incMissCount(pkt); 977 return false; 978 } | 974 if (!blk) { 975 // no replaceable block available: give up, fwd to next level. 976 incMissCount(pkt); 977 return false; 978 } |
979 tags->insertBlock(pkt, blk); | |
980 981 blk->status |= (BlkValid | BlkReadable); 982 } 983 // only mark the block dirty if we got a writeback command, 984 // and leave it as is for a clean writeback 985 if (pkt->cmd == MemCmd::WritebackDirty) { 986 // TODO: the coherent cache can assert(!blk->isDirty()); 987 blk->status |= BlkDirty; --- 35 unchanged lines hidden (view full) --- 1023 1024 if (!blk) { 1025 if (pkt->writeThrough()) { 1026 // if this is a write through packet, we don't try to 1027 // allocate if the block is not present 1028 return false; 1029 } else { 1030 // a writeback that misses needs to allocate a new block | 979 980 blk->status |= (BlkValid | BlkReadable); 981 } 982 // only mark the block dirty if we got a writeback command, 983 // and leave it as is for a clean writeback 984 if (pkt->cmd == MemCmd::WritebackDirty) { 985 // TODO: the coherent cache can assert(!blk->isDirty()); 986 blk->status |= BlkDirty; --- 35 unchanged lines hidden (view full) --- 1022 1023 if (!blk) { 1024 if (pkt->writeThrough()) { 1025 // if this is a write through packet, we don't try to 1026 // allocate if the block is not present 1027 return false; 1028 } else { 1029 // a writeback that misses needs to allocate a new block |
1031 blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), 1032 writebacks); | 1030 blk = allocateBlock(pkt, writebacks); |
1033 if (!blk) { 1034 // no replaceable block available: give up, fwd to 1035 // next level. 1036 incMissCount(pkt); 1037 return false; 1038 } | 1031 if (!blk) { 1032 // no replaceable block available: give up, fwd to 1033 // next level. 1034 incMissCount(pkt); 1035 return false; 1036 } |
1039 tags->insertBlock(pkt, blk); | |
1040 1041 blk->status |= (BlkValid | BlkReadable); 1042 } 1043 } 1044 1045 // at this point either this is a writeback or a write-through 1046 // write clean operation and the block is already in this 1047 // cache, we need to update the data and the block flags --- 71 unchanged lines hidden (view full) --- 1119 1120 // only read responses and write-line requests have data; 1121 // note that we don't write the data here for write-line - that 1122 // happens in the subsequent call to satisfyRequest 1123 assert(pkt->isRead() || pkt->cmd == MemCmd::WriteLineReq); 1124 1125 // need to do a replacement if allocating, otherwise we stick 1126 // with the temporary storage | 1037 1038 blk->status |= (BlkValid | BlkReadable); 1039 } 1040 } 1041 1042 // at this point either this is a writeback or a write-through 1043 // write clean operation and the block is already in this 1044 // cache, we need to update the data and the block flags --- 71 unchanged lines hidden (view full) --- 1116 1117 // only read responses and write-line requests have data; 1118 // note that we don't write the data here for write-line - that 1119 // happens in the subsequent call to satisfyRequest 1120 assert(pkt->isRead() || pkt->cmd == MemCmd::WriteLineReq); 1121 1122 // need to do a replacement if allocating, otherwise we stick 1123 // with the temporary storage |
1127 blk = allocate ? allocateBlock(addr, is_secure, writebacks) : nullptr; | 1124 blk = allocate ? allocateBlock(pkt, writebacks) : nullptr; |
1128 1129 if (!blk) { 1130 // No replaceable block or a mostly exclusive 1131 // cache... just use temporary storage to complete the 1132 // current request and then get rid of it 1133 assert(!tempBlock->isValid()); 1134 blk = tempBlock; 1135 tempBlock->insert(addr, is_secure); 1136 DPRINTF(Cache, "using temp block for %#llx (%s)\n", addr, 1137 is_secure ? "s" : "ns"); | 1125 1126 if (!blk) { 1127 // No replaceable block or a mostly exclusive 1128 // cache... just use temporary storage to complete the 1129 // current request and then get rid of it 1130 assert(!tempBlock->isValid()); 1131 blk = tempBlock; 1132 tempBlock->insert(addr, is_secure); 1133 DPRINTF(Cache, "using temp block for %#llx (%s)\n", addr, 1134 is_secure ? "s" : "ns"); |
1138 } else { 1139 tags->insertBlock(pkt, blk); | |
1140 } 1141 1142 // we should never be overwriting a valid block 1143 assert(!blk->isValid()); 1144 } else { 1145 // existing block... probably an upgrade 1146 assert(regenerateBlkAddr(blk) == addr); 1147 assert(blk->isSecure() == is_secure); --- 52 unchanged lines hidden (view full) --- 1200 // We pay for fillLatency here. 1201 blk->whenReady = clockEdge() + fillLatency * clockPeriod() + 1202 pkt->payloadDelay; 1203 1204 return blk; 1205} 1206 1207CacheBlk* | 1135 } 1136 1137 // we should never be overwriting a valid block 1138 assert(!blk->isValid()); 1139 } else { 1140 // existing block... probably an upgrade 1141 assert(regenerateBlkAddr(blk) == addr); 1142 assert(blk->isSecure() == is_secure); --- 52 unchanged lines hidden (view full) --- 1195 // We pay for fillLatency here. 1196 blk->whenReady = clockEdge() + fillLatency * clockPeriod() + 1197 pkt->payloadDelay; 1198 1199 return blk; 1200} 1201 1202CacheBlk* |
1208BaseCache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks) | 1203BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks) |
1209{ | 1204{ |
1205 // Get address 1206 const Addr addr = pkt->getAddr(); 1207 1208 // Get secure bit 1209 const bool is_secure = pkt->isSecure(); 1210 |
|
1210 // Find replacement victim 1211 std::vector<CacheBlk*> evict_blks; 1212 CacheBlk *victim = tags->findVictim(addr, is_secure, evict_blks); 1213 1214 // It is valid to return nullptr if there is no victim 1215 if (!victim) 1216 return nullptr; 1217 --- 34 unchanged lines hidden (view full) --- 1252 if (blk->wasPrefetched()) { 1253 unusedPrefetches++; 1254 } 1255 1256 evictBlock(blk, writebacks); 1257 } 1258 } 1259 | 1211 // Find replacement victim 1212 std::vector<CacheBlk*> evict_blks; 1213 CacheBlk *victim = tags->findVictim(addr, is_secure, evict_blks); 1214 1215 // It is valid to return nullptr if there is no victim 1216 if (!victim) 1217 return nullptr; 1218 --- 34 unchanged lines hidden (view full) --- 1253 if (blk->wasPrefetched()) { 1254 unusedPrefetches++; 1255 } 1256 1257 evictBlock(blk, writebacks); 1258 } 1259 } 1260 |
1261 // Insert new block at victimized entry 1262 tags->insertBlock(pkt, victim); 1263 |
|
1260 return victim; 1261} 1262 1263void 1264BaseCache::invalidateBlock(CacheBlk *blk) 1265{ 1266 if (blk != tempBlock) 1267 tags->invalidate(blk); --- 1061 unchanged lines hidden --- | 1264 return victim; 1265} 1266 1267void 1268BaseCache::invalidateBlock(CacheBlk *blk) 1269{ 1270 if (blk != tempBlock) 1271 tags->invalidate(blk); --- 1061 unchanged lines hidden --- |