2 * Copyright (c) 2007 MIPS Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Korey Sewell
35 #include "arch/isa_traits.hh"
36 #include "arch/locked_mem.hh"
37 #include "arch/utility.hh"
38 #include "arch/predecoder.hh"
39 #include "config/the_isa.hh"
40 #include "cpu/inorder/resources/cache_unit.hh"
41 #include "cpu/inorder/pipeline_traits.hh"
42 #include "cpu/inorder/cpu.hh"
43 #include "mem/request.hh"
46 using namespace TheISA
;
47 using namespace ThePipeline
;
50 CacheUnit::CachePort::recvAtomic(PacketPtr pkt
)
52 panic("DefaultFetch doesn't expect recvAtomic callback!");
57 CacheUnit::CachePort::recvFunctional(PacketPtr pkt
)
59 panic("DefaultFetch doesn't expect recvFunctional callback!");
63 CacheUnit::CachePort::recvStatusChange(Status status
)
65 if (status
== RangeChange
)
68 panic("DefaultFetch doesn't expect recvStatusChange callback!");
72 CacheUnit::CachePort::recvTiming(Packet
*pkt
)
74 cachePortUnit
->processCacheCompletion(pkt
);
79 CacheUnit::CachePort::recvRetry()
81 cachePortUnit
->recvRetry();
84 CacheUnit::CacheUnit(string res_name
, int res_id
, int res_width
,
85 int res_latency
, InOrderCPU
*_cpu
, ThePipeline::Params
*params
)
86 : Resource(res_name
, res_id
, res_width
, res_latency
, _cpu
),
87 retryPkt(NULL
), retrySlot(-1), cacheBlocked(false),
90 cachePort
= new CachePort(this);
92 // Hard-Code Selection For Now
93 if (res_name
== "icache_port")
95 else if (res_name
== "dcache_port")
98 fatal("Unrecognized TLB name passed by user");
100 for (int i
=0; i
< MaxThreads
; i
++) {
101 tlbBlocked
[i
] = false;
113 CacheUnit::getPort(const string
&if_name
, int idx
)
115 if (if_name
== resName
)
124 // Currently Used to Model TLB Latency. Eventually
125 // Switch to Timing TLB translations.
126 resourceEvent
= new CacheUnitEvent
[width
];
132 CacheUnit::getSlot(DynInstPtr inst
)
134 if (tlbBlocked
[inst
->threadNumber
]) {
138 if (!inst
->validMemAddr()) {
139 panic("Mem. Addr. must be set before requesting cache access\n");
142 Addr req_addr
= inst
->getMemAddr();
144 if (resName
== "icache_port" ||
145 find(addrList
.begin(), addrList
.end(), req_addr
) == addrList
.end()) {
147 int new_slot
= Resource::getSlot(inst
);
152 inst
->memTime
= curTick
;
153 addrList
.push_back(req_addr
);
154 addrMap
[req_addr
] = inst
->seqNum
;
155 DPRINTF(InOrderCachePort
,
156 "[tid:%i]: [sn:%i]: Address %08p added to dependency list\n",
157 inst
->readTid(), inst
->seqNum
, req_addr
);
160 DPRINTF(InOrderCachePort
,
161 "Denying request because there is an outstanding"
162 " request to/for addr. %08p. by [sn:%i] @ tick %i\n",
163 req_addr
, addrMap
[req_addr
], inst
->memTime
);
169 CacheUnit::freeSlot(int slot_num
)
171 vector
<Addr
>::iterator vect_it
= find(addrList
.begin(), addrList
.end(),
172 reqMap
[slot_num
]->inst
->getMemAddr());
173 assert(vect_it
!= addrList
.end());
175 DPRINTF(InOrderCachePort
,
176 "[tid:%i]: Address %08p removed from dependency list\n",
177 reqMap
[slot_num
]->inst
->readTid(), (*vect_it
));
179 addrList
.erase(vect_it
);
181 Resource::freeSlot(slot_num
);
185 CacheUnit::getRequest(DynInstPtr inst
, int stage_num
, int res_idx
,
186 int slot_num
, unsigned cmd
)
188 ScheduleEntry
* sched_entry
= inst
->resSched
.top();
190 if (!inst
->validMemAddr()) {
191 panic("Mem. Addr. must be set before requesting cache access\n");
194 MemCmd::Command pkt_cmd
;
196 switch (sched_entry
->cmd
)
198 case InitiateReadData
:
199 pkt_cmd
= MemCmd::ReadReq
;
201 DPRINTF(InOrderCachePort
,
202 "[tid:%i]: Read request from [sn:%i] for addr %08p\n",
203 inst
->readTid(), inst
->seqNum
, inst
->getMemAddr());
206 case InitiateWriteData
:
207 pkt_cmd
= MemCmd::WriteReq
;
209 DPRINTF(InOrderCachePort
,
210 "[tid:%i]: Write request from [sn:%i] for addr %08p\n",
211 inst
->readTid(), inst
->seqNum
, inst
->getMemAddr());
215 pkt_cmd
= MemCmd::ReadReq
;
217 DPRINTF(InOrderCachePort
,
218 "[tid:%i]: Fetch request from [sn:%i] for addr %08p\n",
219 inst
->readTid(), inst
->seqNum
, inst
->getMemAddr());
223 panic("%i: Unexpected request type (%i) to %s", curTick
,
224 sched_entry
->cmd
, name());
227 return new CacheRequest(this, inst
, stage_num
, id
, slot_num
,
228 sched_entry
->cmd
, 0, pkt_cmd
,
229 0/*flags*/, this->cpu
->readCpuId());
233 CacheUnit::requestAgain(DynInstPtr inst
, bool &service_request
)
235 CacheReqPtr cache_req
= dynamic_cast<CacheReqPtr
>(findRequest(inst
));
238 // Check to see if this instruction is requesting the same command
239 // or a different one
240 if (cache_req
->cmd
!= inst
->resSched
.top()->cmd
) {
241 // If different, then update command in the request
242 cache_req
->cmd
= inst
->resSched
.top()->cmd
;
243 DPRINTF(InOrderCachePort
,
244 "[tid:%i]: [sn:%i]: Updating the command for this instruction\n",
245 inst
->readTid(), inst
->seqNum
);
247 service_request
= true;
249 // If same command, just check to see if memory access was completed
250 // but dont try to re-execute
251 DPRINTF(InOrderCachePort
,
252 "[tid:%i]: [sn:%i]: requesting this resource again\n",
253 inst
->readTid(), inst
->seqNum
);
255 service_request
= true;
260 CacheUnit::doTLBAccess(DynInstPtr inst
, CacheReqPtr cache_req
, int acc_size
,
261 int flags
, TheISA::TLB::Mode tlb_mode
)
263 ThreadID tid
= inst
->readTid();
264 Addr aligned_addr
= inst
->getMemAddr();
265 unsigned stage_num
= cache_req
->getStageNum();
266 unsigned slot_idx
= cache_req
->getSlot();
268 if (tlb_mode
== TheISA::TLB::Execute
) {
269 inst
->fetchMemReq
= new Request(inst
->readTid(), aligned_addr
,
270 acc_size
, flags
, inst
->readPC(),
271 cpu
->readCpuId(), inst
->readTid());
272 cache_req
->memReq
= inst
->fetchMemReq
;
274 inst
->dataMemReq
= new Request(inst
->readTid(), aligned_addr
,
275 acc_size
, flags
, inst
->readPC(),
276 cpu
->readCpuId(), inst
->readTid());
277 cache_req
->memReq
= inst
->dataMemReq
;
282 _tlb
->translateAtomic(cache_req
->memReq
,
283 cpu
->thread
[tid
]->getTC(), tlb_mode
);
285 if (cache_req
->fault
!= NoFault
) {
286 DPRINTF(InOrderTLB
, "[tid:%i]: %s encountered while translating "
287 "addr:%08p for [sn:%i].\n", tid
, cache_req
->fault
->name(),
288 cache_req
->memReq
->getVaddr(), inst
->seqNum
);
290 cpu
->pipelineStage
[stage_num
]->setResStall(cache_req
, tid
);
292 tlbBlocked
[tid
] = true;
294 cache_req
->tlbStall
= true;
296 scheduleEvent(slot_idx
, 1);
298 cpu
->trap(cache_req
->fault
, tid
);
300 DPRINTF(InOrderTLB
, "[tid:%i]: [sn:%i] virt. addr %08p translated "
301 "to phys. addr:%08p.\n", tid
, inst
->seqNum
,
302 cache_req
->memReq
->getVaddr(),
303 cache_req
->memReq
->getPaddr());
306 return cache_req
->fault
;
311 CacheUnit::read(DynInstPtr inst
, Addr addr
, T
&data
, unsigned flags
)
313 CacheReqPtr cache_req
= dynamic_cast<CacheReqPtr
>(findRequest(inst
));
316 int acc_size
= sizeof(T
);
317 doTLBAccess(inst
, cache_req
, acc_size
, flags
, TheISA::TLB::Read
);
319 if (cache_req
->fault
== NoFault
) {
320 cache_req
->reqData
= new uint8_t[acc_size
];
321 doCacheAccess(inst
, NULL
);
324 return cache_req
->fault
;
329 CacheUnit::write(DynInstPtr inst
, T data
, Addr addr
, unsigned flags
,
332 CacheReqPtr cache_req
= dynamic_cast<CacheReqPtr
>(findRequest(inst
));
335 int acc_size
= sizeof(T
);
336 doTLBAccess(inst
, cache_req
, acc_size
, flags
, TheISA::TLB::Write
);
338 if (cache_req
->fault
== NoFault
) {
339 cache_req
->reqData
= new uint8_t[acc_size
];
340 doCacheAccess(inst
, write_res
);
343 return cache_req
->fault
;
348 CacheUnit::execute(int slot_num
)
351 DPRINTF(InOrderCachePort
, "Cache Blocked. Cannot Access\n");
355 CacheReqPtr cache_req
= dynamic_cast<CacheReqPtr
>(reqMap
[slot_num
]);
358 DynInstPtr inst
= cache_req
->inst
;
360 ThreadID tid
= inst
->readTid();
361 int seq_num
= inst
->seqNum
;
364 cache_req
->fault
= NoFault
;
366 switch (cache_req
->cmd
)
370 //@TODO: Switch to size of full cache block. Store in fetch buffer
371 int acc_size
= sizeof(TheISA::MachInst
);
373 doTLBAccess(inst
, cache_req
, acc_size
, 0, TheISA::TLB::Execute
);
375 // Only Do Access if no fault from TLB
376 if (cache_req
->fault
== NoFault
) {
378 DPRINTF(InOrderCachePort
,
379 "[tid:%u]: Initiating fetch access to %s for addr. %08p\n",
380 tid
, name(), cache_req
->inst
->getMemAddr());
382 cache_req
->reqData
= new uint8_t[acc_size
];
384 inst
->setCurResSlot(slot_num
);
392 case InitiateReadData
:
393 case InitiateWriteData
:
394 DPRINTF(InOrderCachePort
,
395 "[tid:%u]: Initiating data access to %s for addr. %08p\n",
396 tid
, name(), cache_req
->inst
->getMemAddr());
398 inst
->setCurResSlot(slot_num
);
400 if (inst
->isDataPrefetch() || inst
->isInstPrefetch()) {
409 if (cache_req
->isMemAccComplete()) {
410 DPRINTF(InOrderCachePort
,
411 "[tid:%i]: Completing Fetch Access for [sn:%i]\n",
415 DPRINTF(InOrderCachePort
, "[tid:%i]: Instruction [sn:%i] is: %s\n",
416 tid
, seq_num
, inst
->staticInst
->disassemble(inst
->PC
));
418 delete cache_req
->dataPkt
;
421 DPRINTF(InOrderCachePort
,
422 "[tid:%i]: [sn:%i]: Unable to Complete Fetch Access\n",
424 DPRINTF(InOrderStall
,
425 "STALL: [tid:%i]: Fetch miss from %08p\n",
426 tid
, cache_req
->inst
->readPC());
427 cache_req
->setCompleted(false);
431 case CompleteReadData
:
432 case CompleteWriteData
:
433 DPRINTF(InOrderCachePort
,
434 "[tid:%i]: [sn:%i]: Trying to Complete Data Access\n",
437 if (cache_req
->isMemAccComplete() ||
438 inst
->isDataPrefetch() ||
439 inst
->isInstPrefetch()) {
442 DPRINTF(InOrderStall
, "STALL: [tid:%i]: Data miss from %08p\n",
443 tid
, cache_req
->inst
->getMemAddr());
444 cache_req
->setCompleted(false);
449 fatal("Unrecognized command to %s", resName
);
454 CacheUnit::prefetch(DynInstPtr inst
)
456 warn_once("Prefetching currently unimplemented");
458 CacheReqPtr cache_req
459 = dynamic_cast<CacheReqPtr
>(reqMap
[inst
->getCurResSlot()]);
462 // Clean-Up cache resource request so
463 // other memory insts. can use them
464 cache_req
->setCompleted();
465 cacheStatus
= cacheAccessComplete
;
466 cacheBlocked
= false;
467 cache_req
->setMemAccPending(false);
468 cache_req
->setMemAccCompleted();
469 inst
->unsetMemAddr();
474 CacheUnit::writeHint(DynInstPtr inst
)
476 warn_once("Write Hints currently unimplemented");
478 CacheReqPtr cache_req
479 = dynamic_cast<CacheReqPtr
>(reqMap
[inst
->getCurResSlot()]);
482 // Clean-Up cache resource request so
483 // other memory insts. can use them
484 cache_req
->setCompleted();
485 cacheStatus
= cacheAccessComplete
;
486 cacheBlocked
= false;
487 cache_req
->setMemAccPending(false);
488 cache_req
->setMemAccCompleted();
489 inst
->unsetMemAddr();
492 // @TODO: Split into doCacheRead() and doCacheWrite()
494 CacheUnit::doCacheAccess(DynInstPtr inst
, uint64_t *write_res
)
496 Fault fault
= NoFault
;
498 ThreadID tid
= inst
->readTid();
501 CacheReqPtr cache_req
502 = dynamic_cast<CacheReqPtr
>(reqMap
[inst
->getCurResSlot()]);
505 // Check for LL/SC and if so change command
506 if (cache_req
->memReq
->isLLSC() && cache_req
->pktCmd
== MemCmd::ReadReq
) {
507 cache_req
->pktCmd
= MemCmd::LoadLockedReq
;
510 if (cache_req
->pktCmd
== MemCmd::WriteReq
) {
512 cache_req
->memReq
->isSwap() ? MemCmd::SwapReq
:
513 (cache_req
->memReq
->isLLSC() ? MemCmd::StoreCondReq
: MemCmd::WriteReq
);
516 cache_req
->dataPkt
= new CacheReqPacket(cache_req
, cache_req
->pktCmd
,
519 if (cache_req
->dataPkt
->isRead()) {
520 cache_req
->dataPkt
->dataStatic(cache_req
->reqData
);
521 } else if (cache_req
->dataPkt
->isWrite()) {
522 cache_req
->dataPkt
->dataStatic(&cache_req
->inst
->storeData
);
524 if (cache_req
->memReq
->isCondSwap()) {
526 cache_req
->memReq
->setExtraData(*write_res
);
530 cache_req
->dataPkt
->time
= curTick
;
532 bool do_access
= true; // flag to suppress cache access
534 Request
*memReq
= cache_req
->dataPkt
->req
;
536 if (cache_req
->dataPkt
->isWrite() && cache_req
->memReq
->isLLSC()) {
537 assert(cache_req
->inst
->isStoreConditional());
538 DPRINTF(InOrderCachePort
, "Evaluating Store Conditional access\n");
539 do_access
= TheISA::handleLockedWrite(cpu
, memReq
);
542 DPRINTF(InOrderCachePort
,
543 "[tid:%i] [sn:%i] attempting to access cache\n",
547 if (!cachePort
->sendTiming(cache_req
->dataPkt
)) {
548 DPRINTF(InOrderCachePort
,
549 "[tid:%i] [sn:%i] is waiting to retry request\n",
552 retrySlot
= cache_req
->getSlot();
553 retryReq
= cache_req
;
554 retryPkt
= cache_req
->dataPkt
;
556 cacheStatus
= cacheWaitRetry
;
558 //cacheBlocked = true;
560 DPRINTF(InOrderStall
, "STALL: \n");
562 cache_req
->setCompleted(false);
564 DPRINTF(InOrderCachePort
,
565 "[tid:%i] [sn:%i] is now waiting for cache response\n",
567 cache_req
->setCompleted();
568 cache_req
->setMemAccPending();
569 cacheStatus
= cacheWaitResponse
;
570 cacheBlocked
= false;
572 } else if (!do_access
&& memReq
->isLLSC()){
573 // Store-Conditional instructions complete even if they "failed"
574 assert(cache_req
->inst
->isStoreConditional());
575 cache_req
->setCompleted(true);
578 "[tid:%i]: T%i Ignoring Failed Store Conditional Access\n",
581 processCacheCompletion(cache_req
->dataPkt
);
583 // Make cache request again since access due to
584 // inability to access
585 DPRINTF(InOrderStall
, "STALL: \n");
586 cache_req
->setCompleted(false);
593 CacheUnit::processCacheCompletion(PacketPtr pkt
)
595 // Cast to correct packet type
596 CacheReqPacket
* cache_pkt
= dynamic_cast<CacheReqPacket
*>(pkt
);
599 if (cache_pkt
->cacheReq
->isSquashed()) {
600 DPRINTF(InOrderCachePort
,
601 "Ignoring completion of squashed access, [tid:%i] [sn:%i]\n",
602 cache_pkt
->cacheReq
->getInst()->readTid(),
603 cache_pkt
->cacheReq
->getInst()->seqNum
);
605 cache_pkt
->cacheReq
->done();
610 DPRINTF(InOrderCachePort
,
611 "[tid:%u]: [sn:%i]: Waking from cache access to addr. %08p\n",
612 cache_pkt
->cacheReq
->getInst()->readTid(),
613 cache_pkt
->cacheReq
->getInst()->seqNum
,
614 cache_pkt
->cacheReq
->getInst()->getMemAddr());
616 // Cast to correct request type
617 CacheRequest
*cache_req
= dynamic_cast<CacheReqPtr
>(
618 findRequest(cache_pkt
->cacheReq
->getInst()));
622 // Get resource request info
623 unsigned stage_num
= cache_req
->getStageNum();
624 DynInstPtr inst
= cache_req
->inst
;
625 ThreadID tid
= cache_req
->inst
->readTid();
627 if (!cache_req
->isSquashed()) {
628 if (inst
->resSched
.top()->cmd
== CompleteFetch
) {
629 DPRINTF(InOrderCachePort
,
630 "[tid:%u]: [sn:%i]: Processing fetch access\n",
633 // NOTE: This is only allowing a thread to fetch one line
634 // at a time. Re-examine when/if prefetching
636 //memcpy(fetchData[tid], cache_pkt->getPtr<uint8_t>(),
637 // cache_pkt->getSize());
639 // Get the instruction from the array of the cache line.
640 // @todo: update thsi
641 ExtMachInst ext_inst
;
642 StaticInstPtr staticInst
= NULL
;
643 Addr inst_pc
= inst
->readPC();
644 MachInst mach_inst
= TheISA::gtoh(*reinterpret_cast<TheISA::MachInst
*>
645 (cache_pkt
->getPtr
<uint8_t>()));
647 predecoder
.setTC(cpu
->thread
[tid
]->getTC());
648 predecoder
.moreBytes(inst_pc
, inst_pc
, mach_inst
);
649 ext_inst
= predecoder
.getExtMachInst();
651 inst
->setMachInst(ext_inst
);
653 // Set Up More TraceData info
654 if (inst
->traceData
) {
655 inst
->traceData
->setStaticInst(inst
->staticInst
);
656 inst
->traceData
->setPC(inst
->readPC());
659 } else if (inst
->staticInst
&& inst
->isMemRef()) {
660 DPRINTF(InOrderCachePort
,
661 "[tid:%u]: [sn:%i]: Processing cache access\n",
664 inst
->completeAcc(pkt
);
666 if (inst
->isLoad()) {
667 assert(cache_pkt
->isRead());
669 if (cache_pkt
->req
->isLLSC()) {
670 DPRINTF(InOrderCachePort
,
671 "[tid:%u]: Handling Load-Linked for [sn:%u]\n",
673 TheISA::handleLockedRead(cpu
, cache_pkt
->req
);
676 // @NOTE: Hardcoded to for load instructions. Assumes that
677 // the dest. idx 0 is always where the data is loaded to.
678 DPRINTF(InOrderCachePort
,
679 "[tid:%u]: [sn:%i]: Data loaded was: %08p\n",
680 tid
, inst
->seqNum
, inst
->readIntResult(0));
681 DPRINTF(InOrderCachePort
,
682 "[tid:%u]: [sn:%i]: FP Data loaded was: %08p\n",
683 tid
, inst
->seqNum
, inst
->readFloatResult(0));
684 } else if(inst
->isStore()) {
685 assert(cache_pkt
->isWrite());
687 DPRINTF(InOrderCachePort
,
688 "[tid:%u]: [sn:%i]: Data stored was: FIX ME\n",
690 getMemData(cache_pkt)*/);
696 cache_req
->setMemAccPending(false);
697 cache_req
->setMemAccCompleted();
699 // Wake up the CPU (if it went to sleep and was waiting on this
700 // completion event).
703 DPRINTF(Activity
, "[tid:%u] Activating %s due to cache completion\n",
704 tid
, cpu
->pipelineStage
[stage_num
]->name());
706 cpu
->switchToActive(stage_num
);
708 DPRINTF(InOrderCachePort
,
709 "[tid:%u] Miss on block @ %08p completed, but squashed\n",
710 tid
, cache_req
->inst
->readPC());
711 cache_req
->setMemAccCompleted();
714 inst
->unsetMemAddr();
718 CacheUnit::recvRetry()
720 DPRINTF(InOrderCachePort
, "Retrying Request for [tid:%i] [sn:%i]\n",
721 retryReq
->inst
->readTid(), retryReq
->inst
->seqNum
);
723 assert(retryPkt
!= NULL
);
724 assert(cacheBlocked
);
725 assert(cacheStatus
== cacheWaitRetry
);
727 if (cachePort
->sendTiming(retryPkt
)) {
728 cacheStatus
= cacheWaitResponse
;
730 cacheBlocked
= false;
732 DPRINTF(InOrderCachePort
,
733 "Retry Request for [tid:%i] [sn:%i] failed\n",
734 retryReq
->inst
->readTid(), retryReq
->inst
->seqNum
);
738 CacheUnitEvent::CacheUnitEvent()
743 CacheUnitEvent::process()
745 DynInstPtr inst
= resource
->reqMap
[slotIdx
]->inst
;
746 int stage_num
= resource
->reqMap
[slotIdx
]->getStageNum();
747 ThreadID tid
= inst
->threadNumber
;
748 CacheReqPtr req_ptr
= dynamic_cast<CacheReqPtr
>(resource
->reqMap
[slotIdx
]);
750 DPRINTF(InOrderTLB
, "Waking up from TLB Miss caused by [sn:%i].\n",
753 CacheUnit
* tlb_res
= dynamic_cast<CacheUnit
*>(resource
);
756 tlb_res
->tlbBlocked
[tid
] = false;
758 tlb_res
->cpu
->pipelineStage
[stage_num
]->unsetResStall(tlb_res
->reqMap
[slotIdx
], tid
);
760 req_ptr
->tlbStall
= false;
762 if (req_ptr
->isSquashed()) {
768 CacheUnit::squash(DynInstPtr inst
, int stage_num
,
769 InstSeqNum squash_seq_num
, ThreadID tid
)
771 vector
<int> slot_remove_list
;
773 map
<int, ResReqPtr
>::iterator map_it
= reqMap
.begin();
774 map
<int, ResReqPtr
>::iterator map_end
= reqMap
.end();
776 while (map_it
!= map_end
) {
777 ResReqPtr req_ptr
= (*map_it
).second
;
780 req_ptr
->getInst()->readTid() == tid
&&
781 req_ptr
->getInst()->seqNum
> squash_seq_num
) {
783 DPRINTF(InOrderCachePort
,
784 "[tid:%i] Squashing request from [sn:%i]\n",
785 req_ptr
->getInst()->readTid(), req_ptr
->getInst()->seqNum
);
787 req_ptr
->setSquashed();
789 req_ptr
->getInst()->setSquashed();
791 CacheReqPtr cache_req
= dynamic_cast<CacheReqPtr
>(req_ptr
);
794 int req_slot_num
= req_ptr
->getSlot();
796 if (cache_req
->tlbStall
) {
797 tlbBlocked
[tid
] = false;
799 int stall_stage
= reqMap
[req_slot_num
]->getStageNum();
801 cpu
->pipelineStage
[stall_stage
]->unsetResStall(reqMap
[req_slot_num
], tid
);
804 if (!cache_req
->tlbStall
&& !cache_req
->isMemAccPending()) {
805 // Mark request for later removal
806 cpu
->reqRemoveList
.push(req_ptr
);
808 // Mark slot for removal from resource
809 slot_remove_list
.push_back(req_ptr
->getSlot());
816 // Now Delete Slot Entry from Req. Map
817 for (int i
= 0; i
< slot_remove_list
.size(); i
++)
818 freeSlot(slot_remove_list
[i
]);
822 CacheUnit::getMemData(Packet
*packet
)
824 switch (packet
->getSize())
827 return packet
->get
<uint8_t>();
830 return packet
->get
<uint16_t>();
833 return packet
->get
<uint32_t>();
836 return packet
->get
<uint64_t>();
839 panic("bad store data size = %d\n", packet
->getSize());
843 // Extra Template Definitions
844 #ifndef DOXYGEN_SHOULD_SKIP_THIS
848 CacheUnit::read(DynInstPtr inst
, Addr addr
, Twin32_t
&data
, unsigned flags
);
852 CacheUnit::read(DynInstPtr inst
, Addr addr
, Twin64_t
&data
, unsigned flags
);
856 CacheUnit::read(DynInstPtr inst
, Addr addr
, uint64_t &data
, unsigned flags
);
860 CacheUnit::read(DynInstPtr inst
, Addr addr
, uint32_t &data
, unsigned flags
);
864 CacheUnit::read(DynInstPtr inst
, Addr addr
, uint16_t &data
, unsigned flags
);
868 CacheUnit::read(DynInstPtr inst
, Addr addr
, uint8_t &data
, unsigned flags
);
870 #endif //DOXYGEN_SHOULD_SKIP_THIS
874 CacheUnit::read(DynInstPtr inst
, Addr addr
, double &data
, unsigned flags
)
876 return read(inst
, addr
, *(uint64_t*)&data
, flags
);
881 CacheUnit::read(DynInstPtr inst
, Addr addr
, float &data
, unsigned flags
)
883 return read(inst
, addr
, *(uint32_t*)&data
, flags
);
889 CacheUnit::read(DynInstPtr inst
, Addr addr
, int32_t &data
, unsigned flags
)
891 return read(inst
, addr
, (uint32_t&)data
, flags
);
894 #ifndef DOXYGEN_SHOULD_SKIP_THIS
898 CacheUnit::write(DynInstPtr inst
, Twin32_t data
, Addr addr
,
899 unsigned flags
, uint64_t *res
);
903 CacheUnit::write(DynInstPtr inst
, Twin64_t data
, Addr addr
,
904 unsigned flags
, uint64_t *res
);
908 CacheUnit::write(DynInstPtr inst
, uint64_t data
, Addr addr
,
909 unsigned flags
, uint64_t *res
);
913 CacheUnit::write(DynInstPtr inst
, uint32_t data
, Addr addr
,
914 unsigned flags
, uint64_t *res
);
918 CacheUnit::write(DynInstPtr inst
, uint16_t data
, Addr addr
,
919 unsigned flags
, uint64_t *res
);
923 CacheUnit::write(DynInstPtr inst
, uint8_t data
, Addr addr
,
924 unsigned flags
, uint64_t *res
);
926 #endif //DOXYGEN_SHOULD_SKIP_THIS
930 CacheUnit::write(DynInstPtr inst
, double data
, Addr addr
, unsigned flags
, uint64_t *res
)
932 return write(inst
, *(uint64_t*)&data
, addr
, flags
, res
);
937 CacheUnit::write(DynInstPtr inst
, float data
, Addr addr
, unsigned flags
, uint64_t *res
)
939 return write(inst
, *(uint32_t*)&data
, addr
, flags
, res
);
945 CacheUnit::write(DynInstPtr inst
, int32_t data
, Addr addr
, unsigned flags
, uint64_t *res
)
947 return write(inst
, (uint32_t)data
, addr
, flags
, res
);