diff -r 629fe6e6c781 src/mem/cache/cache_impl.hh --- a/src/mem/cache/cache_impl.hh Thu Jun 25 11:58:28 2015 -0500 +++ b/src/mem/cache/cache_impl.hh Fri Oct 30 14:59:05 2015 +0530 @@ -72,13 +72,19 @@ doFastWrites(true), prefetchOnAccess(p->prefetch_on_access) { - tempBlock = new CacheBlk(); + receivedFromDRAMCache = 0; + tempBlock = new CacheBlk(); tempBlock->data = new uint8_t[blkSize]; cpuSidePort = new CpuSidePort(p->name + ".cpu_side", this, "CpuSidePort"); memSidePort = new MemSidePort(p->name + ".mem_side", this, "MemSidePort"); + if(this->isDRAMCache) { + std::cout<<"Instantiating a DRAM cache"<name + ".arr_side", this, + "ArraySidePort"); + } tags->setCache(this); if (prefetcher) @@ -92,12 +98,16 @@ delete cpuSidePort; delete memSidePort; + delete arraySidePort; } void Cache::regStats() { BaseCache::regStats(); + receivedFromDRAMCache + .name(name() + ".respDRAMCache") + .desc("receivedFromDRAMCache"); } void @@ -361,15 +371,26 @@ assert(!pkt->needsResponse()); std::memcpy(blk->data, pkt->getConstPtr(), blkSize); DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print()); - incHitCount(pkt); - return true; + incHitCount(pkt); + + if(isDRAMCache) { + std::cout<<"Got atleast one hit"<sendTimingReq(pkt); + } + return true; } else if ((blk != NULL) && (pkt->needsExclusive() ? blk->isWritable() : blk->isReadable())) { // OK to satisfy access incHitCount(pkt); - satisfyCpuSideRequest(pkt, blk); - return true; + + if(isDRAMCache) { + std::cout<<"Got atleast one hit"<sendTimingReq(pkt); + } + else + satisfyCpuSideRequest(pkt, blk); + return true; } // Can't satisfy access normally... either no block (blk == NULL) @@ -534,7 +555,6 @@ // Note that lat is passed by reference here. The function // access() calls accessBlock() which can modify lat value. satisfied = access(pkt, blk, lat, writebacks); - // copy writebacks to write buffer here to ensure they logically // proceed anything happening below while (!writebacks.empty()) { @@ -562,39 +582,43 @@ bool needsResponse = pkt->needsResponse(); if (satisfied) { - // should never be satisfying an uncacheable access as we - // flush and invalidate any existing block as part of the - // lookup - assert(!pkt->req->isUncacheable()); + if(!isDRAMCache) { + // should never be satisfying an uncacheable access as we + // flush and invalidate any existing block as part of the + // lookup + assert(!pkt->req->isUncacheable()); - // hit (for all other request types) + // hit (for all other request types) - if (prefetcher && (prefetchOnAccess || (blk && blk->wasPrefetched()))) { - if (blk) - blk->status &= ~BlkHWPrefetched; + if (prefetcher && (prefetchOnAccess || (blk && blk->wasPrefetched()))) { + if (blk) + blk->status &= ~BlkHWPrefetched; - // Don't notify on SWPrefetch - if (!pkt->cmd.isSWPrefetch()) - next_pf_time = prefetcher->notify(pkt); - } + // Don't notify on SWPrefetch + if (!pkt->cmd.isSWPrefetch()) + next_pf_time = prefetcher->notify(pkt); + } - if (needsResponse) { - pkt->makeTimingResponse(); - // @todo: Make someone pay for this - pkt->headerDelay = pkt->payloadDelay = 0; + if (needsResponse) { + pkt->makeTimingResponse(); + // @todo: Make someone pay for this + pkt->headerDelay = pkt->payloadDelay = 0; - // In this case we are considering request_time that takes - // into account the delay of the xbar, if any, and just - // lat, neglecting responseLatency, modelling hit latency - // just as lookupLatency or or the value of lat overriden - // by access(), that calls accessBlock() function. - cpuSidePort->schedTimingResp(pkt, request_time); - } else { - /// @todo nominally we should just delete the packet here, - /// however, until 4-phase stuff we can't because sending - /// cache is still relying on it - pendingDelete.push_back(pkt); - } + // In this case we are considering request_time that takes + // into account the delay of the xbar, if any, and just + // lat, neglecting responseLatency, modelling hit latency + // just as lookupLatency or or the value of lat overriden + // by access(), that calls accessBlock() function. + cpuSidePort->schedTimingResp(pkt, request_time); + } else { + /// @todo nominally we should just delete the packet here, + /// however, until 4-phase stuff we can't because sending + /// cache is still relying on it + pendingDelete.push_back(pkt); + } + } + else + std::cout<<"Request hit in DRAM cache"<needsExclusive()); bool is_forward = (bus_pkt == NULL); @@ -1129,6 +1153,12 @@ blk = handleFill(pkt, blk, writebacks); assert(blk != NULL); + if(isDRAMCache) { + if(pkt->isRead()) + arraySidePort->sendTimingReq(Packet::createRead(pkt->req)); + else + arraySidePort->sendTimingReq(Packet::createWrite(pkt->req)); + } } // First offset for critical word first calculations @@ -2268,4 +2298,70 @@ { } +BaseMasterPort & +Cache::getMasterPort(const std::string &if_name, PortID idx) +{ + if(if_name == "arr_side") { + std::cout<<"Getting the array port"<<(*arraySidePort).name()<cache = _cache; +} + +void +Cache::receiveDRAMCacheResponse(PacketPtr pkt) { + assert(pkt->isResponse()); + receivedFromDRAMCache++; + // should never be satisfying an uncacheable access as we + // flush and invalidate any existing block as part of the + // lookup + //assert(!pkt->req->isUncacheable()); + + // hit (for all other request types) + + /*if (prefetcher && (prefetchOnAccess || (blk && blk->wasPrefetched()))) { + if (blk) + blk->status &= ~BlkHWPrefetched; + + // Don't notify on SWPrefetch + if (!pkt->cmd.isSWPrefetch()) + next_pf_time = prefetcher->notify(pkt); + }*/ + bool needsResponse = pkt->needsResponse(); + if (needsResponse) { + pkt->makeTimingResponse(); + // @todo: Make someone pay for this + pkt->headerDelay = pkt->payloadDelay = 0; + + // In this case we are considering request_time that takes + // into account the delay of the xbar, if any, and just + // lat, neglecting responseLatency, modelling hit latency + // just as lookupLatency or or the value of lat overriden + // by access(), that calls accessBlock() function. + cpuSidePort->schedTimingResp(pkt, lookupLatency); + } else { + /// @todo nominally we should just delete the packet here, + /// however, until 4-phase stuff we can't because sending + /// cache is still relying on it + // pendingDelete.push_back(pkt); + } +} + +bool +Cache::ArraySidePort::recvTimingResp(PacketPtr pkt) { + cache->receiveDRAMCacheResponse(pkt); + return true; +} + #endif//__MEM_CACHE_CACHE_IMPL_HH__