Deleted Added
sdiff udiff text old ( 13941:2c19da00ef9c ) new ( 13945:a573bed35a8b )
full compact
1/*
2 * Copyright (c) 2012-2013, 2018-2019 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

--- 40 unchanged lines hidden (view full) ---

49#include "mem/cache/base.hh"
50
51#include "base/compiler.hh"
52#include "base/logging.hh"
53#include "debug/Cache.hh"
54#include "debug/CachePort.hh"
55#include "debug/CacheRepl.hh"
56#include "debug/CacheVerbose.hh"
57#include "mem/cache/mshr.hh"
58#include "mem/cache/prefetch/base.hh"
59#include "mem/cache/queue_entry.hh"
60#include "params/BaseCache.hh"
61#include "params/WriteAllocator.hh"
62#include "sim/core.hh"
63
64class BaseMasterPort;

--- 13 unchanged lines hidden (view full) ---

78
79BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size)
80 : ClockedObject(p),
81 cpuSidePort (p->name + ".cpu_side", this, "CpuSidePort"),
82 memSidePort(p->name + ".mem_side", this, "MemSidePort"),
83 mshrQueue("MSHRs", p->mshrs, 0, p->demand_mshr_reserve), // see below
84 writeBuffer("write buffer", p->write_buffers, p->mshrs), // see below
85 tags(p->tags),
86 prefetcher(p->prefetcher),
87 writeAllocator(p->write_allocator),
88 writebackClean(p->writeback_clean),
89 tempBlockWriteback(nullptr),
90 writebackTempBlockAtomicEvent([this]{ writebackTempBlockAtomic(); },
91 name(), false,
92 EventBase::Delayed_Writeback_Pri),
93 blkSize(blk_size),

--- 935 unchanged lines hidden (view full) ---

1029 // A writeback searches for the block, then writes the data.
1030 // As the block could not be found, it was a tag-only access.
1031 lat = calculateTagOnlyLatency(pkt->headerDelay, tag_latency);
1032
1033 return false;
1034 }
1035
1036 blk->status |= BlkReadable;
1037 }
1038 // only mark the block dirty if we got a writeback command,
1039 // and leave it as is for a clean writeback
1040 if (pkt->cmd == MemCmd::WritebackDirty) {
1041 // TODO: the coherent cache can assert(!blk->isDirty());
1042 blk->status |= BlkDirty;
1043 }
1044 // if the packet does not have sharers, it is passing
1045 // writable, and we got the writeback in Modified or Exclusive

--- 63 unchanged lines hidden (view full) ---

1109 lat = calculateTagOnlyLatency(pkt->headerDelay,
1110 tag_latency);
1111
1112 return false;
1113 }
1114
1115 blk->status |= BlkReadable;
1116 }
1117 }
1118
1119 // at this point either this is a writeback or a write-through
1120 // write clean operation and the block is already in this
1121 // cache, we need to update the data and the block flags
1122 assert(blk);
1123 // TODO: the coherent cache can assert(!blk->isDirty());
1124 if (!pkt->writeThrough()) {

--- 21 unchanged lines hidden (view full) ---

1146 } else if (blk && (pkt->needsWritable() ? blk->isWritable() :
1147 blk->isReadable())) {
1148 // OK to satisfy access
1149 incHitCount(pkt);
1150
1151 // Calculate access latency based on the need to access the data array
1152 if (pkt->isRead() || pkt->isWrite()) {
1153 lat = calculateAccessLatency(blk, pkt->headerDelay, tag_latency);
1154 } else {
1155 lat = calculateTagOnlyLatency(pkt->headerDelay, tag_latency);
1156 }
1157
1158 satisfyRequest(pkt, blk);
1159 maintainClusivity(pkt->fromCache(), blk);
1160
1161 return true;

--- 152 unchanged lines hidden (view full) ---

1314BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
1315{
1316 // Get address
1317 const Addr addr = pkt->getAddr();
1318
1319 // Get secure bit
1320 const bool is_secure = pkt->isSecure();
1321
1322 // @todo Compress and get compression related data
1323 std::size_t blk_size_bits = blkSize*8;
1324
1325 // Find replacement victim
1326 std::vector<CacheBlk*> evict_blks;
1327 CacheBlk *victim = tags->findVictim(addr, is_secure, blk_size_bits,
1328 evict_blks);
1329
1330 // It is valid to return nullptr if there is no victim
1331 if (!victim)
1332 return nullptr;

--- 39 unchanged lines hidden (view full) ---

1372
1373 evictBlock(blk, writebacks);
1374 }
1375 }
1376
1377 replacements++;
1378 }
1379
1380 // Insert new block at victimized entry
1381 tags->insertBlock(pkt, victim);
1382
1383 return victim;
1384}
1385
1386void
1387BaseCache::invalidateBlock(CacheBlk *blk)

--- 50 unchanged lines hidden (view full) ---

1438 }
1439
1440 // make sure the block is not marked dirty
1441 blk->status &= ~BlkDirty;
1442
1443 pkt->allocate();
1444 pkt->setDataFromBlock(blk->data, blkSize);
1445
1446 return pkt;
1447}
1448
1449PacketPtr
1450BaseCache::writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id)
1451{
1452 RequestPtr req = std::make_shared<Request>(
1453 regenerateBlkAddr(blk), blkSize, 0, Request::wbMasterId);

--- 23 unchanged lines hidden (view full) ---

1477 }
1478
1479 // make sure the block is not marked dirty
1480 blk->status &= ~BlkDirty;
1481
1482 pkt->allocate();
1483 pkt->setDataFromBlock(blk->data, blkSize);
1484
1485 return pkt;
1486}
1487
1488
1489void
1490BaseCache::memWriteback()
1491{
1492 tags->forEachBlk([this](CacheBlk &blk) { writebackVisitor(blk); });

--- 1050 unchanged lines hidden ---