2006-04-23 00:26:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-07 22:02:55 +02:00
|
|
|
*
|
|
|
|
* Authors: Kevin Lim
|
|
|
|
* Korey Sewell
|
2006-04-23 00:26:48 +02:00
|
|
|
*/
|
|
|
|
|
2006-06-16 23:08:47 +02:00
|
|
|
#include "config/use_checker.hh"
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
#include "cpu/o3/lsq.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
#include "cpu/o3/lsq_unit.hh"
|
|
|
|
#include "base/str.hh"
|
2006-06-13 17:38:16 +02:00
|
|
|
#include "mem/packet.hh"
|
2006-06-03 00:15:20 +02:00
|
|
|
#include "mem/request.hh"
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-23 00:09:31 +02:00
|
|
|
#if USE_CHECKER
|
|
|
|
#include "cpu/checker/cpu.hh"
|
|
|
|
#endif
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
template<class Impl>
|
2006-06-06 00:14:39 +02:00
|
|
|
LSQUnit<Impl>::WritebackEvent::WritebackEvent(DynInstPtr &_inst, PacketPtr _pkt,
|
|
|
|
LSQUnit *lsq_ptr)
|
|
|
|
: Event(&mainEventQueue), inst(_inst), pkt(_pkt), lsqPtr(lsq_ptr)
|
2006-06-03 00:15:20 +02:00
|
|
|
{
|
2006-06-06 00:14:39 +02:00
|
|
|
this->setFlags(Event::AutoDelete);
|
|
|
|
}
|
2006-06-03 00:15:20 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::WritebackEvent::process()
|
|
|
|
{
|
|
|
|
if (!lsqPtr->isSwitchedOut()) {
|
|
|
|
lsqPtr->writeback(inst, pkt);
|
2006-06-03 00:15:20 +02:00
|
|
|
}
|
2006-06-06 00:14:39 +02:00
|
|
|
delete pkt;
|
|
|
|
}
|
2006-06-03 00:15:20 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
template<class Impl>
|
|
|
|
const char *
|
|
|
|
LSQUnit<Impl>::WritebackEvent::description()
|
|
|
|
{
|
|
|
|
return "Store writeback event";
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
template<class Impl>
|
2006-04-23 00:26:48 +02:00
|
|
|
void
|
2006-06-06 00:14:39 +02:00
|
|
|
LSQUnit<Impl>::completeDataAccess(PacketPtr pkt)
|
2006-04-23 00:26:48 +02:00
|
|
|
{
|
2006-06-06 00:14:39 +02:00
|
|
|
LSQSenderState *state = dynamic_cast<LSQSenderState *>(pkt->senderState);
|
|
|
|
DynInstPtr inst = state->inst;
|
|
|
|
DPRINTF(IEW, "Writeback event [sn:%lli]\n", inst->seqNum);
|
2006-06-09 22:28:17 +02:00
|
|
|
DPRINTF(Activity, "Activity: Writeback event [sn:%lli]\n", inst->seqNum);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
//iewStage->ldstQueue.removeMSHR(inst->threadNumber,inst->seqNum);
|
2006-05-25 20:41:36 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
if (isSwitchedOut() || inst->isSquashed()) {
|
2006-07-05 21:51:36 +02:00
|
|
|
iewStage->decrWb(inst->seqNum);
|
2006-06-06 00:14:39 +02:00
|
|
|
delete state;
|
|
|
|
delete pkt;
|
2006-05-04 17:36:20 +02:00
|
|
|
return;
|
2006-06-06 00:14:39 +02:00
|
|
|
} else {
|
|
|
|
if (!state->noWB) {
|
|
|
|
writeback(inst, pkt);
|
|
|
|
}
|
2006-05-04 17:36:20 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
if (inst->isStore()) {
|
|
|
|
completeStore(state->idx);
|
|
|
|
}
|
|
|
|
}
|
2006-06-03 00:15:20 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
delete state;
|
|
|
|
delete pkt;
|
2006-06-03 00:15:20 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
LSQUnit<Impl>::LSQUnit()
|
2006-06-06 00:14:39 +02:00
|
|
|
: loads(0), stores(0), storesToWB(0), stalled(false),
|
|
|
|
isStoreBlocked(false), isLoadBlocked(false),
|
2006-04-23 00:26:48 +02:00
|
|
|
loadBlockedHandled(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Impl>
|
|
|
|
void
|
2006-07-13 19:12:51 +02:00
|
|
|
LSQUnit<Impl>::init(Params *params, LSQ *lsq_ptr, unsigned maxLQEntries,
|
2006-04-23 00:26:48 +02:00
|
|
|
unsigned maxSQEntries, unsigned id)
|
|
|
|
{
|
|
|
|
DPRINTF(LSQUnit, "Creating LSQUnit%i object.\n",id);
|
|
|
|
|
2006-05-04 17:36:20 +02:00
|
|
|
switchedOut = false;
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
lsq = lsq_ptr;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
lsqID = id;
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
// Add 1 for the sentinel entry (they are circular queues).
|
|
|
|
LQEntries = maxLQEntries + 1;
|
|
|
|
SQEntries = maxSQEntries + 1;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
loadQueue.resize(LQEntries);
|
|
|
|
storeQueue.resize(SQEntries);
|
|
|
|
|
|
|
|
loadHead = loadTail = 0;
|
|
|
|
|
|
|
|
storeHead = storeWBIdx = storeTail = 0;
|
|
|
|
|
|
|
|
usedPorts = 0;
|
|
|
|
cachePorts = params->cachePorts;
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
memDepViolator = NULL;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
blockedLoadSeqNum = 0;
|
|
|
|
}
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
template<class Impl>
|
|
|
|
void
|
2006-06-16 23:08:47 +02:00
|
|
|
LSQUnit<Impl>::setCPU(O3CPU *cpu_ptr)
|
2006-06-03 00:15:20 +02:00
|
|
|
{
|
|
|
|
cpu = cpu_ptr;
|
2006-06-06 00:14:39 +02:00
|
|
|
|
2006-06-16 23:08:47 +02:00
|
|
|
#if USE_CHECKER
|
2006-06-06 20:06:30 +02:00
|
|
|
if (cpu->checker) {
|
|
|
|
cpu->checker->setDcachePort(dcachePort);
|
|
|
|
}
|
2006-06-16 23:08:47 +02:00
|
|
|
#endif
|
2006-06-03 00:15:20 +02:00
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template<class Impl>
|
|
|
|
std::string
|
|
|
|
LSQUnit<Impl>::name() const
|
|
|
|
{
|
|
|
|
if (Impl::MaxThreads == 1) {
|
|
|
|
return iewStage->name() + ".lsq";
|
|
|
|
} else {
|
|
|
|
return iewStage->name() + ".lsq.thread." + to_string(lsqID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::regStats()
|
|
|
|
{
|
|
|
|
lsqForwLoads
|
|
|
|
.name(name() + ".forwLoads")
|
|
|
|
.desc("Number of loads that had data forwarded from stores");
|
|
|
|
|
|
|
|
invAddrLoads
|
|
|
|
.name(name() + ".invAddrLoads")
|
|
|
|
.desc("Number of loads ignored due to an invalid address");
|
|
|
|
|
|
|
|
lsqSquashedLoads
|
|
|
|
.name(name() + ".squashedLoads")
|
|
|
|
.desc("Number of loads squashed");
|
|
|
|
|
|
|
|
lsqIgnoredResponses
|
|
|
|
.name(name() + ".ignoredResponses")
|
|
|
|
.desc("Number of memory responses ignored because the instruction is squashed");
|
|
|
|
|
2006-08-24 23:29:34 +02:00
|
|
|
lsqMemOrderViolation
|
|
|
|
.name(name() + ".memOrderViolation")
|
|
|
|
.desc("Number of memory ordering violations");
|
|
|
|
|
2006-06-14 04:35:05 +02:00
|
|
|
lsqSquashedStores
|
|
|
|
.name(name() + ".squashedStores")
|
|
|
|
.desc("Number of stores squashed");
|
|
|
|
|
|
|
|
invAddrSwpfs
|
|
|
|
.name(name() + ".invAddrSwpfs")
|
|
|
|
.desc("Number of software prefetches ignored due to an invalid address");
|
|
|
|
|
|
|
|
lsqBlockedLoads
|
|
|
|
.name(name() + ".blockedLoads")
|
|
|
|
.desc("Number of blocked loads due to partial load-store forwarding");
|
|
|
|
|
|
|
|
lsqRescheduledLoads
|
|
|
|
.name(name() + ".rescheduledLoads")
|
|
|
|
.desc("Number of loads that were rescheduled");
|
|
|
|
|
|
|
|
lsqCacheBlocked
|
|
|
|
.name(name() + ".cacheBlocked")
|
|
|
|
.desc("Number of times an access to memory failed due to the cache being blocked");
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::clearLQ()
|
|
|
|
{
|
|
|
|
loadQueue.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::clearSQ()
|
|
|
|
{
|
|
|
|
storeQueue.clear();
|
|
|
|
}
|
|
|
|
|
2006-05-04 17:36:20 +02:00
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::switchOut()
|
|
|
|
{
|
|
|
|
switchedOut = true;
|
2006-09-28 06:09:27 +02:00
|
|
|
for (int i = 0; i < loadQueue.size(); ++i) {
|
|
|
|
assert(!loadQueue[i]);
|
2006-05-04 17:36:20 +02:00
|
|
|
loadQueue[i] = NULL;
|
2006-09-28 06:09:27 +02:00
|
|
|
}
|
2006-05-04 17:36:20 +02:00
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
assert(storesToWB == 0);
|
2006-05-04 17:36:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::takeOverFrom()
|
|
|
|
{
|
|
|
|
switchedOut = false;
|
|
|
|
loads = stores = storesToWB = 0;
|
|
|
|
|
|
|
|
loadHead = loadTail = 0;
|
|
|
|
|
|
|
|
storeHead = storeWBIdx = storeTail = 0;
|
|
|
|
|
|
|
|
usedPorts = 0;
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
memDepViolator = NULL;
|
2006-05-04 17:36:20 +02:00
|
|
|
|
|
|
|
blockedLoadSeqNum = 0;
|
|
|
|
|
|
|
|
stalled = false;
|
|
|
|
isLoadBlocked = false;
|
|
|
|
loadBlockedHandled = false;
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::resizeLQ(unsigned size)
|
|
|
|
{
|
2006-05-19 21:53:17 +02:00
|
|
|
unsigned size_plus_sentinel = size + 1;
|
|
|
|
assert(size_plus_sentinel >= LQEntries);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
if (size_plus_sentinel > LQEntries) {
|
|
|
|
while (size_plus_sentinel > loadQueue.size()) {
|
2006-04-23 00:26:48 +02:00
|
|
|
DynInstPtr dummy;
|
|
|
|
loadQueue.push_back(dummy);
|
|
|
|
LQEntries++;
|
|
|
|
}
|
|
|
|
} else {
|
2006-05-19 21:53:17 +02:00
|
|
|
LQEntries = size_plus_sentinel;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::resizeSQ(unsigned size)
|
|
|
|
{
|
2006-05-19 21:53:17 +02:00
|
|
|
unsigned size_plus_sentinel = size + 1;
|
|
|
|
if (size_plus_sentinel > SQEntries) {
|
|
|
|
while (size_plus_sentinel > storeQueue.size()) {
|
2006-04-23 00:26:48 +02:00
|
|
|
SQEntry dummy;
|
|
|
|
storeQueue.push_back(dummy);
|
|
|
|
SQEntries++;
|
|
|
|
}
|
|
|
|
} else {
|
2006-05-19 21:53:17 +02:00
|
|
|
SQEntries = size_plus_sentinel;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::insert(DynInstPtr &inst)
|
|
|
|
{
|
|
|
|
assert(inst->isMemRef());
|
|
|
|
|
|
|
|
assert(inst->isLoad() || inst->isStore());
|
|
|
|
|
|
|
|
if (inst->isLoad()) {
|
|
|
|
insertLoad(inst);
|
|
|
|
} else {
|
|
|
|
insertStore(inst);
|
|
|
|
}
|
|
|
|
|
|
|
|
inst->setInLSQ();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::insertLoad(DynInstPtr &load_inst)
|
|
|
|
{
|
2006-05-19 21:53:17 +02:00
|
|
|
assert((loadTail + 1) % LQEntries != loadHead);
|
|
|
|
assert(loads < LQEntries);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Inserting load PC %#x, idx:%i [sn:%lli]\n",
|
|
|
|
load_inst->readPC(), loadTail, load_inst->seqNum);
|
|
|
|
|
|
|
|
load_inst->lqIdx = loadTail;
|
|
|
|
|
|
|
|
if (stores == 0) {
|
|
|
|
load_inst->sqIdx = -1;
|
|
|
|
} else {
|
|
|
|
load_inst->sqIdx = storeTail;
|
|
|
|
}
|
|
|
|
|
|
|
|
loadQueue[loadTail] = load_inst;
|
|
|
|
|
|
|
|
incrLdIdx(loadTail);
|
|
|
|
|
|
|
|
++loads;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::insertStore(DynInstPtr &store_inst)
|
|
|
|
{
|
|
|
|
// Make sure it is not full before inserting an instruction.
|
|
|
|
assert((storeTail + 1) % SQEntries != storeHead);
|
|
|
|
assert(stores < SQEntries);
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Inserting store PC %#x, idx:%i [sn:%lli]\n",
|
|
|
|
store_inst->readPC(), storeTail, store_inst->seqNum);
|
|
|
|
|
|
|
|
store_inst->sqIdx = storeTail;
|
|
|
|
store_inst->lqIdx = loadTail;
|
|
|
|
|
|
|
|
storeQueue[storeTail] = SQEntry(store_inst);
|
|
|
|
|
|
|
|
incrStIdx(storeTail);
|
|
|
|
|
|
|
|
++stores;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
typename Impl::DynInstPtr
|
|
|
|
LSQUnit<Impl>::getMemDepViolator()
|
|
|
|
{
|
|
|
|
DynInstPtr temp = memDepViolator;
|
|
|
|
|
|
|
|
memDepViolator = NULL;
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
unsigned
|
|
|
|
LSQUnit<Impl>::numFreeEntries()
|
|
|
|
{
|
|
|
|
unsigned free_lq_entries = LQEntries - loads;
|
|
|
|
unsigned free_sq_entries = SQEntries - stores;
|
|
|
|
|
|
|
|
// Both the LQ and SQ entries have an extra dummy entry to differentiate
|
|
|
|
// empty/full conditions. Subtract 1 from the free entries.
|
|
|
|
if (free_lq_entries < free_sq_entries) {
|
|
|
|
return free_lq_entries - 1;
|
|
|
|
} else {
|
|
|
|
return free_sq_entries - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
int
|
|
|
|
LSQUnit<Impl>::numLoadsReady()
|
|
|
|
{
|
|
|
|
int load_idx = loadHead;
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
while (load_idx != loadTail) {
|
|
|
|
assert(loadQueue[load_idx]);
|
|
|
|
|
|
|
|
if (loadQueue[load_idx]->readyToIssue()) {
|
|
|
|
++retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
Fault
|
|
|
|
LSQUnit<Impl>::executeLoad(DynInstPtr &inst)
|
|
|
|
{
|
|
|
|
// Execute a specific load.
|
|
|
|
Fault load_fault = NoFault;
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Executing load PC %#x, [sn:%lli]\n",
|
|
|
|
inst->readPC(),inst->seqNum);
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
load_fault = inst->initiateAcc();
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
// If the instruction faulted, then we need to send it along to commit
|
|
|
|
// without the instruction completing.
|
|
|
|
if (load_fault != NoFault) {
|
2006-05-19 21:53:17 +02:00
|
|
|
// Send this instruction to commit, also make sure iew stage
|
|
|
|
// realizes there is activity.
|
2006-09-28 06:09:27 +02:00
|
|
|
// Mark it as executed unless it is an uncached load that
|
|
|
|
// needs to hit the head of commit.
|
2006-10-08 23:48:24 +02:00
|
|
|
if (!(inst->req->isUncacheable()) || inst->isAtCommit()) {
|
2006-09-28 06:09:27 +02:00
|
|
|
inst->setExecuted();
|
|
|
|
}
|
2006-04-23 00:26:48 +02:00
|
|
|
iewStage->instToCommit(inst);
|
|
|
|
iewStage->activityThisCycle();
|
|
|
|
}
|
|
|
|
|
|
|
|
return load_fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
Fault
|
|
|
|
LSQUnit<Impl>::executeStore(DynInstPtr &store_inst)
|
|
|
|
{
|
|
|
|
using namespace TheISA;
|
|
|
|
// Make sure that a store exists.
|
|
|
|
assert(stores != 0);
|
|
|
|
|
|
|
|
int store_idx = store_inst->sqIdx;
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Executing store PC %#x [sn:%lli]\n",
|
|
|
|
store_inst->readPC(), store_inst->seqNum);
|
|
|
|
|
|
|
|
// Check the recently completed loads to see if any match this store's
|
|
|
|
// address. If so, then we have a memory ordering violation.
|
|
|
|
int load_idx = store_inst->lqIdx;
|
|
|
|
|
|
|
|
Fault store_fault = store_inst->initiateAcc();
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
if (storeQueue[store_idx].size == 0) {
|
2006-04-23 00:26:48 +02:00
|
|
|
DPRINTF(LSQUnit,"Fault on Store PC %#x, [sn:%lli],Size = 0\n",
|
|
|
|
store_inst->readPC(),store_inst->seqNum);
|
|
|
|
|
|
|
|
return store_fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(store_fault == NoFault);
|
|
|
|
|
2006-05-23 20:38:16 +02:00
|
|
|
if (store_inst->isStoreConditional()) {
|
|
|
|
// Store conditionals need to set themselves as able to
|
|
|
|
// writeback if we haven't had a fault by here.
|
2006-05-19 21:53:17 +02:00
|
|
|
storeQueue[store_idx].canWB = true;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
++storesToWB;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!memDepViolator) {
|
|
|
|
while (load_idx != loadTail) {
|
2006-05-19 21:53:17 +02:00
|
|
|
// Really only need to check loads that have actually executed
|
|
|
|
// It's safe to check all loads because effAddr is set to
|
|
|
|
// InvalAddr when the dyn inst is created.
|
|
|
|
|
|
|
|
// @todo: For now this is extra conservative, detecting a
|
|
|
|
// violation if the addresses match assuming all accesses
|
|
|
|
// are quad word accesses.
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
// @todo: Fix this, magic number being used here
|
|
|
|
if ((loadQueue[load_idx]->effAddr >> 8) ==
|
|
|
|
(store_inst->effAddr >> 8)) {
|
|
|
|
// A load incorrectly passed this store. Squash and refetch.
|
|
|
|
// For now return a fault to show that it was unsuccessful.
|
|
|
|
memDepViolator = loadQueue[load_idx];
|
2006-08-24 23:29:34 +02:00
|
|
|
++lsqMemOrderViolation;
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
return genMachineCheckFault();
|
|
|
|
}
|
|
|
|
|
|
|
|
incrLdIdx(load_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we've reached this point, there was no violation.
|
|
|
|
memDepViolator = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return store_fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::commitLoad()
|
|
|
|
{
|
|
|
|
assert(loadQueue[loadHead]);
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit, "Committing head load instruction, PC %#x\n",
|
|
|
|
loadQueue[loadHead]->readPC());
|
|
|
|
|
|
|
|
loadQueue[loadHead] = NULL;
|
|
|
|
|
|
|
|
incrLdIdx(loadHead);
|
|
|
|
|
|
|
|
--loads;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::commitLoads(InstSeqNum &youngest_inst)
|
|
|
|
{
|
|
|
|
assert(loads == 0 || loadQueue[loadHead]);
|
|
|
|
|
|
|
|
while (loads != 0 && loadQueue[loadHead]->seqNum <= youngest_inst) {
|
|
|
|
commitLoad();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::commitStores(InstSeqNum &youngest_inst)
|
|
|
|
{
|
|
|
|
assert(stores == 0 || storeQueue[storeHead].inst);
|
|
|
|
|
|
|
|
int store_idx = storeHead;
|
|
|
|
|
|
|
|
while (store_idx != storeTail) {
|
|
|
|
assert(storeQueue[store_idx].inst);
|
2006-05-19 21:53:17 +02:00
|
|
|
// Mark any stores that are now committed and have not yet
|
|
|
|
// been marked as able to write back.
|
2006-04-23 00:26:48 +02:00
|
|
|
if (!storeQueue[store_idx].canWB) {
|
|
|
|
if (storeQueue[store_idx].inst->seqNum > youngest_inst) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DPRINTF(LSQUnit, "Marking store as able to write back, PC "
|
|
|
|
"%#x [sn:%lli]\n",
|
|
|
|
storeQueue[store_idx].inst->readPC(),
|
|
|
|
storeQueue[store_idx].inst->seqNum);
|
|
|
|
|
|
|
|
storeQueue[store_idx].canWB = true;
|
|
|
|
|
|
|
|
++storesToWB;
|
|
|
|
}
|
|
|
|
|
|
|
|
incrStIdx(store_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::writebackStores()
|
|
|
|
{
|
|
|
|
while (storesToWB > 0 &&
|
|
|
|
storeWBIdx != storeTail &&
|
|
|
|
storeQueue[storeWBIdx].inst &&
|
|
|
|
storeQueue[storeWBIdx].canWB &&
|
|
|
|
usedPorts < cachePorts) {
|
|
|
|
|
2006-07-13 19:12:51 +02:00
|
|
|
if (isStoreBlocked || lsq->cacheBlocked()) {
|
2006-06-06 00:14:39 +02:00
|
|
|
DPRINTF(LSQUnit, "Unable to write back any more stores, cache"
|
|
|
|
" is blocked!\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
// Store didn't write any data so no need to write it back to
|
|
|
|
// memory.
|
2006-04-23 00:26:48 +02:00
|
|
|
if (storeQueue[storeWBIdx].size == 0) {
|
|
|
|
completeStore(storeWBIdx);
|
|
|
|
|
|
|
|
incrStIdx(storeWBIdx);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2006-06-06 00:14:39 +02:00
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
++usedPorts;
|
|
|
|
|
|
|
|
if (storeQueue[storeWBIdx].inst->isDataPrefetch()) {
|
|
|
|
incrStIdx(storeWBIdx);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(storeQueue[storeWBIdx].req);
|
|
|
|
assert(!storeQueue[storeWBIdx].committed);
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
DynInstPtr inst = storeQueue[storeWBIdx].inst;
|
|
|
|
|
|
|
|
Request *req = storeQueue[storeWBIdx].req;
|
2006-04-23 00:26:48 +02:00
|
|
|
storeQueue[storeWBIdx].committed = true;
|
|
|
|
|
2006-06-03 00:15:20 +02:00
|
|
|
assert(!inst->memData);
|
|
|
|
inst->memData = new uint8_t[64];
|
2006-06-06 00:14:39 +02:00
|
|
|
memcpy(inst->memData, (uint8_t *)&storeQueue[storeWBIdx].data,
|
|
|
|
req->getSize());
|
2006-06-03 00:15:20 +02:00
|
|
|
|
|
|
|
PacketPtr data_pkt = new Packet(req, Packet::WriteReq, Packet::Broadcast);
|
|
|
|
data_pkt->dataStatic(inst->memData);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
LSQSenderState *state = new LSQSenderState;
|
|
|
|
state->isLoad = false;
|
|
|
|
state->idx = storeWBIdx;
|
|
|
|
state->inst = inst;
|
|
|
|
data_pkt->senderState = state;
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
DPRINTF(LSQUnit, "D-Cache: Writing back store idx:%i PC:%#x "
|
|
|
|
"to Addr:%#x, data:%#x [sn:%lli]\n",
|
2006-10-08 06:53:41 +02:00
|
|
|
storeWBIdx, inst->readPC(),
|
2006-06-03 00:15:20 +02:00
|
|
|
req->getPaddr(), *(inst->memData),
|
2006-10-08 06:53:41 +02:00
|
|
|
inst->seqNum);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
2006-06-09 17:46:35 +02:00
|
|
|
// @todo: Remove this SC hack once the memory system handles it.
|
2006-10-08 23:48:24 +02:00
|
|
|
if (req->isLocked()) {
|
|
|
|
if (req->isUncacheable()) {
|
2006-06-09 17:46:35 +02:00
|
|
|
req->setScResult(2);
|
|
|
|
} else {
|
|
|
|
if (cpu->lockFlag) {
|
|
|
|
req->setScResult(1);
|
2006-10-08 06:53:41 +02:00
|
|
|
DPRINTF(LSQUnit, "Store conditional [sn:%lli] succeeded.",
|
|
|
|
inst->seqNum);
|
2006-06-09 17:46:35 +02:00
|
|
|
} else {
|
|
|
|
req->setScResult(0);
|
|
|
|
// Hack: Instantly complete this store.
|
2006-10-08 06:53:41 +02:00
|
|
|
// completeDataAccess(data_pkt);
|
|
|
|
DPRINTF(LSQUnit, "Store conditional [sn:%lli] failed. "
|
|
|
|
"Instantly completing it.\n",
|
|
|
|
inst->seqNum);
|
|
|
|
WritebackEvent *wb = new WritebackEvent(inst, data_pkt, this);
|
|
|
|
wb->schedule(curTick + 1);
|
|
|
|
delete state;
|
|
|
|
completeStore(storeWBIdx);
|
2006-06-09 17:46:35 +02:00
|
|
|
incrStIdx(storeWBIdx);
|
|
|
|
continue;
|
2006-06-08 23:04:41 +02:00
|
|
|
}
|
2006-05-19 21:53:17 +02:00
|
|
|
}
|
2006-06-09 17:46:35 +02:00
|
|
|
} else {
|
|
|
|
// Non-store conditionals do not need a writeback.
|
|
|
|
state->noWB = true;
|
|
|
|
}
|
2006-06-06 00:14:39 +02:00
|
|
|
|
2006-06-09 17:46:35 +02:00
|
|
|
if (!dcachePort->sendTiming(data_pkt)) {
|
2006-10-08 06:53:41 +02:00
|
|
|
if (data_pkt->result == Packet::BadAddress) {
|
|
|
|
panic("LSQ sent out a bad address for a completed store!");
|
|
|
|
}
|
2006-06-09 17:46:35 +02:00
|
|
|
// Need to handle becoming blocked on a store.
|
2006-10-08 06:53:41 +02:00
|
|
|
DPRINTF(IEW, "D-Cache became blcoked when writing [sn:%lli], will"
|
|
|
|
"retry later\n",
|
|
|
|
inst->seqNum);
|
2006-06-09 17:46:35 +02:00
|
|
|
isStoreBlocked = true;
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqCacheBlocked;
|
2006-06-09 22:28:17 +02:00
|
|
|
assert(retryPkt == NULL);
|
|
|
|
retryPkt = data_pkt;
|
2006-08-16 21:56:22 +02:00
|
|
|
lsq->setRetryTid(lsqID);
|
2006-06-09 17:46:35 +02:00
|
|
|
} else {
|
|
|
|
storePostSend(data_pkt);
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not sure this should set it to 0.
|
|
|
|
usedPorts = 0;
|
|
|
|
|
|
|
|
assert(stores >= 0 && storesToWB >= 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::removeMSHR(InstSeqNum seqNum)
|
|
|
|
{
|
|
|
|
list<InstSeqNum>::iterator mshr_it = find(mshrSeqNums.begin(),
|
|
|
|
mshrSeqNums.end(),
|
|
|
|
seqNum);
|
|
|
|
|
|
|
|
if (mshr_it != mshrSeqNums.end()) {
|
|
|
|
mshrSeqNums.erase(mshr_it);
|
|
|
|
DPRINTF(LSQUnit, "Removing MSHR. count = %i\n",mshrSeqNums.size());
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::squash(const InstSeqNum &squashed_num)
|
|
|
|
{
|
|
|
|
DPRINTF(LSQUnit, "Squashing until [sn:%lli]!"
|
2006-05-19 21:53:17 +02:00
|
|
|
"(Loads:%i Stores:%i)\n", squashed_num, loads, stores);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
int load_idx = loadTail;
|
|
|
|
decrLdIdx(load_idx);
|
|
|
|
|
|
|
|
while (loads != 0 && loadQueue[load_idx]->seqNum > squashed_num) {
|
|
|
|
DPRINTF(LSQUnit,"Load Instruction PC %#x squashed, "
|
|
|
|
"[sn:%lli]\n",
|
|
|
|
loadQueue[load_idx]->readPC(),
|
|
|
|
loadQueue[load_idx]->seqNum);
|
|
|
|
|
|
|
|
if (isStalled() && load_idx == stallingLoadIdx) {
|
|
|
|
stalled = false;
|
|
|
|
stallingStoreIsn = 0;
|
|
|
|
stallingLoadIdx = 0;
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
// Clear the smart pointer to make sure it is decremented.
|
2006-06-14 19:12:41 +02:00
|
|
|
loadQueue[load_idx]->setSquashed();
|
2006-04-23 00:26:48 +02:00
|
|
|
loadQueue[load_idx] = NULL;
|
|
|
|
--loads;
|
|
|
|
|
|
|
|
// Inefficient!
|
|
|
|
loadTail = load_idx;
|
|
|
|
|
|
|
|
decrLdIdx(load_idx);
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqSquashedLoads;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isLoadBlocked) {
|
|
|
|
if (squashed_num < blockedLoadSeqNum) {
|
|
|
|
isLoadBlocked = false;
|
|
|
|
loadBlockedHandled = false;
|
|
|
|
blockedLoadSeqNum = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int store_idx = storeTail;
|
|
|
|
decrStIdx(store_idx);
|
|
|
|
|
|
|
|
while (stores != 0 &&
|
|
|
|
storeQueue[store_idx].inst->seqNum > squashed_num) {
|
2006-05-19 21:53:17 +02:00
|
|
|
// Instructions marked as can WB are already committed.
|
2006-04-23 00:26:48 +02:00
|
|
|
if (storeQueue[store_idx].canWB) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(LSQUnit,"Store Instruction PC %#x squashed, "
|
|
|
|
"idx:%i [sn:%lli]\n",
|
|
|
|
storeQueue[store_idx].inst->readPC(),
|
|
|
|
store_idx, storeQueue[store_idx].inst->seqNum);
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
// I don't think this can happen. It should have been cleared
|
|
|
|
// by the stalling load.
|
2006-04-23 00:26:48 +02:00
|
|
|
if (isStalled() &&
|
|
|
|
storeQueue[store_idx].inst->seqNum == stallingStoreIsn) {
|
|
|
|
panic("Is stalled should have been cleared by stalling load!\n");
|
|
|
|
stalled = false;
|
|
|
|
stallingStoreIsn = 0;
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
// Clear the smart pointer to make sure it is decremented.
|
2006-06-14 19:12:41 +02:00
|
|
|
storeQueue[store_idx].inst->setSquashed();
|
2006-04-23 00:26:48 +02:00
|
|
|
storeQueue[store_idx].inst = NULL;
|
|
|
|
storeQueue[store_idx].canWB = 0;
|
|
|
|
|
|
|
|
storeQueue[store_idx].req = NULL;
|
|
|
|
--stores;
|
|
|
|
|
|
|
|
// Inefficient!
|
|
|
|
storeTail = store_idx;
|
|
|
|
|
|
|
|
decrStIdx(store_idx);
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqSquashedStores;
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 17:46:35 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::storePostSend(Packet *pkt)
|
|
|
|
{
|
|
|
|
if (isStalled() &&
|
|
|
|
storeQueue[storeWBIdx].inst->seqNum == stallingStoreIsn) {
|
|
|
|
DPRINTF(LSQUnit, "Unstalling, stalling store [sn:%lli] "
|
|
|
|
"load idx:%i\n",
|
|
|
|
stallingStoreIsn, stallingLoadIdx);
|
|
|
|
stalled = false;
|
|
|
|
stallingStoreIsn = 0;
|
|
|
|
iewStage->replayMemInst(loadQueue[stallingLoadIdx]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!storeQueue[storeWBIdx].inst->isStoreConditional()) {
|
|
|
|
// The store is basically completed at this time. This
|
|
|
|
// only works so long as the checker doesn't try to
|
|
|
|
// verify the value in memory for stores.
|
|
|
|
storeQueue[storeWBIdx].inst->setCompleted();
|
2006-06-16 23:08:47 +02:00
|
|
|
#if USE_CHECKER
|
2006-06-09 17:46:35 +02:00
|
|
|
if (cpu->checker) {
|
2006-06-16 19:10:47 +02:00
|
|
|
cpu->checker->verify(storeQueue[storeWBIdx].inst);
|
2006-06-09 17:46:35 +02:00
|
|
|
}
|
2006-06-16 23:08:47 +02:00
|
|
|
#endif
|
2006-06-09 17:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pkt->result != Packet::Success) {
|
|
|
|
DPRINTF(LSQUnit,"D-Cache Write Miss on idx:%i!\n",
|
|
|
|
storeWBIdx);
|
|
|
|
|
|
|
|
DPRINTF(Activity, "Active st accessing mem miss [sn:%lli]\n",
|
|
|
|
storeQueue[storeWBIdx].inst->seqNum);
|
|
|
|
|
|
|
|
//mshrSeqNums.push_back(storeQueue[storeWBIdx].inst->seqNum);
|
|
|
|
|
|
|
|
//DPRINTF(LSQUnit, "Added MSHR. count = %i\n",mshrSeqNums.size());
|
|
|
|
|
|
|
|
// @todo: Increment stat here.
|
|
|
|
} else {
|
|
|
|
DPRINTF(LSQUnit,"D-Cache: Write Hit on idx:%i !\n",
|
|
|
|
storeWBIdx);
|
|
|
|
|
|
|
|
DPRINTF(Activity, "Active st accessing mem hit [sn:%lli]\n",
|
|
|
|
storeQueue[storeWBIdx].inst->seqNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
incrStIdx(storeWBIdx);
|
|
|
|
}
|
|
|
|
|
2006-06-06 00:14:39 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::writeback(DynInstPtr &inst, PacketPtr pkt)
|
|
|
|
{
|
|
|
|
iewStage->wakeCPU();
|
|
|
|
|
|
|
|
// Squashed instructions do not need to complete their access.
|
|
|
|
if (inst->isSquashed()) {
|
2006-07-19 21:28:02 +02:00
|
|
|
iewStage->decrWb(inst->seqNum);
|
2006-06-06 00:14:39 +02:00
|
|
|
assert(!inst->isStore());
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqIgnoredResponses;
|
2006-06-06 00:14:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!inst->isExecuted()) {
|
|
|
|
inst->setExecuted();
|
|
|
|
|
|
|
|
// Complete access to copy data to proper place.
|
|
|
|
inst->completeAcc(pkt);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to insert instruction into queue to commit
|
|
|
|
iewStage->instToCommit(inst);
|
|
|
|
|
|
|
|
iewStage->activityThisCycle();
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::completeStore(int store_idx)
|
|
|
|
{
|
|
|
|
assert(storeQueue[store_idx].inst);
|
|
|
|
storeQueue[store_idx].completed = true;
|
|
|
|
--storesToWB;
|
|
|
|
// A bit conservative because a store completion may not free up entries,
|
|
|
|
// but hopefully avoids two store completions in one cycle from making
|
|
|
|
// the CPU tick twice.
|
2006-10-02 17:58:09 +02:00
|
|
|
cpu->wakeCPU();
|
2006-04-23 00:26:48 +02:00
|
|
|
cpu->activityThisCycle();
|
|
|
|
|
|
|
|
if (store_idx == storeHead) {
|
|
|
|
do {
|
|
|
|
incrStIdx(storeHead);
|
|
|
|
|
|
|
|
--stores;
|
|
|
|
} while (storeQueue[storeHead].completed &&
|
|
|
|
storeHead != storeTail);
|
|
|
|
|
|
|
|
iewStage->updateLSQNextCycle = true;
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:53:17 +02:00
|
|
|
DPRINTF(LSQUnit, "Completing store [sn:%lli], idx:%i, store head "
|
|
|
|
"idx:%i\n",
|
|
|
|
storeQueue[store_idx].inst->seqNum, store_idx, storeHead);
|
2006-04-23 00:26:48 +02:00
|
|
|
|
|
|
|
if (isStalled() &&
|
|
|
|
storeQueue[store_idx].inst->seqNum == stallingStoreIsn) {
|
|
|
|
DPRINTF(LSQUnit, "Unstalling, stalling store [sn:%lli] "
|
|
|
|
"load idx:%i\n",
|
|
|
|
stallingStoreIsn, stallingLoadIdx);
|
|
|
|
stalled = false;
|
|
|
|
stallingStoreIsn = 0;
|
|
|
|
iewStage->replayMemInst(loadQueue[stallingLoadIdx]);
|
|
|
|
}
|
2006-05-16 20:06:35 +02:00
|
|
|
|
|
|
|
storeQueue[store_idx].inst->setCompleted();
|
2006-05-19 21:53:17 +02:00
|
|
|
|
|
|
|
// Tell the checker we've completed this instruction. Some stores
|
|
|
|
// may get reported twice to the checker, but the checker can
|
|
|
|
// handle that case.
|
2006-06-16 23:08:47 +02:00
|
|
|
#if USE_CHECKER
|
2006-05-16 20:06:35 +02:00
|
|
|
if (cpu->checker) {
|
2006-06-16 19:10:47 +02:00
|
|
|
cpu->checker->verify(storeQueue[store_idx].inst);
|
2006-05-16 20:06:35 +02:00
|
|
|
}
|
2006-06-16 23:08:47 +02:00
|
|
|
#endif
|
2006-04-23 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 17:46:35 +02:00
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::recvRetry()
|
|
|
|
{
|
|
|
|
if (isStoreBlocked) {
|
2006-06-09 22:28:17 +02:00
|
|
|
assert(retryPkt != NULL);
|
|
|
|
|
|
|
|
if (dcachePort->sendTiming(retryPkt)) {
|
2006-10-08 06:53:41 +02:00
|
|
|
if (retryPkt->result == Packet::BadAddress) {
|
|
|
|
panic("LSQ sent out a bad address for a completed store!");
|
|
|
|
}
|
2006-06-09 22:28:17 +02:00
|
|
|
storePostSend(retryPkt);
|
2006-06-09 23:21:37 +02:00
|
|
|
retryPkt = NULL;
|
2006-06-09 17:46:35 +02:00
|
|
|
isStoreBlocked = false;
|
2006-08-16 21:56:22 +02:00
|
|
|
lsq->setRetryTid(-1);
|
2006-06-09 17:46:35 +02:00
|
|
|
} else {
|
|
|
|
// Still blocked!
|
2006-06-14 04:35:05 +02:00
|
|
|
++lsqCacheBlocked;
|
2006-07-13 19:12:51 +02:00
|
|
|
lsq->setRetryTid(lsqID);
|
2006-06-09 17:46:35 +02:00
|
|
|
}
|
|
|
|
} else if (isLoadBlocked) {
|
|
|
|
DPRINTF(LSQUnit, "Loads squash themselves and all younger insts, "
|
|
|
|
"no need to resend packet.\n");
|
|
|
|
} else {
|
|
|
|
DPRINTF(LSQUnit, "Retry received but LSQ is no longer blocked.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-23 00:26:48 +02:00
|
|
|
template <class Impl>
|
|
|
|
inline void
|
|
|
|
LSQUnit<Impl>::incrStIdx(int &store_idx)
|
|
|
|
{
|
|
|
|
if (++store_idx >= SQEntries)
|
|
|
|
store_idx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
inline void
|
|
|
|
LSQUnit<Impl>::decrStIdx(int &store_idx)
|
|
|
|
{
|
|
|
|
if (--store_idx < 0)
|
|
|
|
store_idx += SQEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
inline void
|
|
|
|
LSQUnit<Impl>::incrLdIdx(int &load_idx)
|
|
|
|
{
|
|
|
|
if (++load_idx >= LQEntries)
|
|
|
|
load_idx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
inline void
|
|
|
|
LSQUnit<Impl>::decrLdIdx(int &load_idx)
|
|
|
|
{
|
|
|
|
if (--load_idx < 0)
|
|
|
|
load_idx += LQEntries;
|
|
|
|
}
|
2006-05-19 21:53:17 +02:00
|
|
|
|
|
|
|
template <class Impl>
|
|
|
|
void
|
|
|
|
LSQUnit<Impl>::dumpInsts()
|
|
|
|
{
|
|
|
|
cprintf("Load store queue: Dumping instructions.\n");
|
|
|
|
cprintf("Load queue size: %i\n", loads);
|
|
|
|
cprintf("Load queue: ");
|
|
|
|
|
|
|
|
int load_idx = loadHead;
|
|
|
|
|
|
|
|
while (load_idx != loadTail && loadQueue[load_idx]) {
|
|
|
|
cprintf("%#x ", loadQueue[load_idx]->readPC());
|
|
|
|
|
|
|
|
incrLdIdx(load_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
cprintf("Store queue size: %i\n", stores);
|
|
|
|
cprintf("Store queue: ");
|
|
|
|
|
|
|
|
int store_idx = storeHead;
|
|
|
|
|
|
|
|
while (store_idx != storeTail && storeQueue[store_idx].inst) {
|
|
|
|
cprintf("%#x ", storeQueue[store_idx].inst->readPC());
|
|
|
|
|
|
|
|
incrStIdx(store_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
cprintf("\n");
|
|
|
|
}
|