Resource::Resource(string res_name, int res_id, int res_width,
int res_latency, InOrderCPU *_cpu)
: resName(res_name), id(res_id),
- width(res_width), latency(res_latency), cpu(_cpu)
+ width(res_width), latency(res_latency), cpu(_cpu),
+ resourceEvent(NULL)
{
reqs.resize(width);
// If the resource has a zero-cycle (no latency)
// function, then no reason to have events
// that will process them for the right tick
- if (latency > 0) {
- resourceEvent = new ResourceEvent[width];
- } else {
- resourceEvent = NULL;
- }
+ if (latency > 0)
+ resourceEvent = new ResourceEvent[width];
+
+
+ for (int i = 0; i < width; i++)
+ reqs[i] = new ResourceRequest(this);
- for (int i = 0; i < width; i++) {
- reqs[i] = new ResourceRequest(this);
- }
initSlots();
}
reqs[i] = new CacheRequest(this);
}
- // Currently Used to Model TLB Latency. Eventually
- // Switch to Timing TLB translations.
- resourceEvent = new CacheUnitEvent[width];
-
cacheBlkSize = this->cachePort->peerBlockSize();
cacheBlkMask = cacheBlkSize - 1;
ThreadContext *tc = cpu->thread[tid]->getTC();
PCState old_pc = tc->pcState();
tc->pcState() = inst->pcState();
+
inst->fault =
_tlb->translateAtomic(cache_req->memReq, tc, tlb_mode);
tc->pcState() = old_pc;
if (inst->fault != NoFault) {
DPRINTF(InOrderTLB, "[tid:%i]: %s encountered while translating "
- "addr:%08p for [sn:%i].\n", tid, inst->fault->name(),
+ "addr:%08p for [sn:%i].\n", tid, tlb_fault->name(),
cache_req->memReq->getVaddr(), inst->seqNum);
tlbBlocked[tid] = true;
tlbBlockSeqNum[tid] = inst->seqNum;
-#if !FULL_SYSTEM
- unsigned stage_num = cache_req->getStageNum();
-
- cpu->pipelineStage[stage_num]->setResStall(cache_req, tid);
- cache_req->tlbStall = true;
-
- // schedule a time to process the tlb miss.
- // latency hardcoded to 1 (for now), but will be updated
- // when timing translation gets added in
- unsigned slot_idx = cache_req->getSlot();
- scheduleEvent(slot_idx, 1);
-#endif
+ // Make sure nothing gets executed until after this faulting
+ // instruction gets handled.
+ inst->setSerializeAfter();
// Mark it as complete so it can pass through next stage.
// Fault Handling will happen at commit/graduation
cache_req->memReq->getVaddr(),
cache_req->memReq->getPaddr());
}
+}
+#if !FULL_SYSTEM
+void
+CacheUnit::trap(Fault fault, ThreadID tid, DynInstPtr inst)
+{
+ tlbBlocked[tid] = false;
}
+#endif
Fault
CacheUnit::read(DynInstPtr inst, Addr addr,
return;
}
+ if (inst->isSquashed()) {
+ DPRINTF(InOrderCachePort,
+ "[tid:%i]: [sn:%i]: Detected squashed instruction "
+ "next stage.\n", inst->readTid(), inst->seqNum);
+ finishCacheUnitReq(inst, cache_req);
+ return;
+ }
+
#if TRACING_ON
ThreadID tid = inst->readTid();
std::string acc_type = "write";
InstSeqNum seq_num = inst->seqNum;
int ud_idx = ud_req->useDefIdx;
- if (inst->fault != NoFault) {
- DPRINTF(InOrderUseDef,
- "[tid:%i]: [sn:%i]: Detected %s fault @ %x. Forwarding to "
- "next stage.\n", inst->readTid(), inst->seqNum, inst->fault->name(),
- inst->pcState());
- ud_req->done();
- return;
- }
-
if (serializeOnNextInst[tid] &&
seq_num > serializeAfterSeqNum[tid]) {
inst->setSerializeBefore();
serializeAfterSeqNum[tid] = seq_num;
}
+ if (inst->fault != NoFault) {
+ DPRINTF(InOrderUseDef,
+ "[tid:%i]: [sn:%i]: Detected %s fault @ %x. Forwarding to "
+ "next stage.\n", inst->readTid(), inst->seqNum, inst->fault->name(),
+ inst->pcState());
+ ud_req->done();
+ return;
+ }
+
// If there is a non-speculative instruction
// in the pipeline then stall instructions here
// ---