2 * Copyright (c) 2010-2013 ARM Limited
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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 * Authors: Steve Reinhardt
43 #include "arch/locked_mem.hh"
44 #include "arch/mmapped_ipr.hh"
45 #include "arch/utility.hh"
46 #include "base/bigint.hh"
47 #include "config/the_isa.hh"
48 #include "cpu/simple/timing.hh"
49 #include "cpu/exetrace.hh"
50 #include "debug/Config.hh"
51 #include "debug/Drain.hh"
52 #include "debug/ExecFaulting.hh"
53 #include "debug/SimpleCPU.hh"
54 #include "mem/packet.hh"
55 #include "mem/packet_access.hh"
56 #include "params/TimingSimpleCPU.hh"
57 #include "sim/faults.hh"
58 #include "sim/full_system.hh"
59 #include "sim/system.hh"
62 using namespace TheISA
;
65 TimingSimpleCPU::init()
69 // Initialise the ThreadContext's memory proxies
70 tcBase()->initMemProxies(tcBase());
72 if (FullSystem
&& !params()->switched_out
) {
73 for (int i
= 0; i
< threadContexts
.size(); ++i
) {
74 ThreadContext
*tc
= threadContexts
[i
];
75 // initialize CPU, including PC
76 TheISA::initCPU(tc
, _cpuId
);
82 TimingSimpleCPU::TimingCPUPort::TickEvent::schedule(PacketPtr _pkt
, Tick t
)
85 cpu
->schedule(this, t
);
88 TimingSimpleCPU::TimingSimpleCPU(TimingSimpleCPUParams
*p
)
89 : BaseSimpleCPU(p
), fetchTranslation(this), icachePort(this),
90 dcachePort(this), ifetch_pkt(NULL
), dcache_pkt(NULL
), previousCycle(0),
91 fetchEvent(this), drainManager(NULL
)
95 system
->totalNumInsts
= 0;
100 TimingSimpleCPU::~TimingSimpleCPU()
105 TimingSimpleCPU::drain(DrainManager
*drain_manager
)
107 assert(!drainManager
);
111 if (_status
== Idle
||
112 (_status
== BaseSimpleCPU::Running
&& isDrained())) {
113 DPRINTF(Drain
, "No need to drain.\n");
116 drainManager
= drain_manager
;
117 DPRINTF(Drain
, "Requesting drain: %s\n", pcState());
119 // The fetch event can become descheduled if a drain didn't
120 // succeed on the first attempt. We need to reschedule it if
121 // the CPU is waiting for a microcode routine to complete.
122 if (_status
== BaseSimpleCPU::Running
&& !fetchEvent
.scheduled())
123 schedule(fetchEvent
, clockEdge());
130 TimingSimpleCPU::drainResume()
132 assert(!fetchEvent
.scheduled());
133 assert(!drainManager
);
137 DPRINTF(SimpleCPU
, "Resume\n");
140 assert(!threadContexts
.empty());
141 if (threadContexts
.size() > 1)
142 fatal("The timing CPU only supports one thread.\n");
144 if (thread
->status() == ThreadContext::Active
) {
145 schedule(fetchEvent
, nextCycle());
146 _status
= BaseSimpleCPU::Running
;
149 _status
= BaseSimpleCPU::Idle
;
155 TimingSimpleCPU::tryCompleteDrain()
160 DPRINTF(Drain
, "tryCompleteDrain: %s\n", pcState());
164 DPRINTF(Drain
, "CPU done draining, processing drain event\n");
165 drainManager
->signalDrainDone();
172 TimingSimpleCPU::switchOut()
174 BaseSimpleCPU::switchOut();
176 assert(!fetchEvent
.scheduled());
177 assert(_status
== BaseSimpleCPU::Running
|| _status
== Idle
);
179 assert(microPC() == 0);
186 TimingSimpleCPU::takeOverFrom(BaseCPU
*oldCPU
)
188 BaseSimpleCPU::takeOverFrom(oldCPU
);
190 previousCycle
= curCycle();
194 TimingSimpleCPU::verifyMemoryMode() const
196 if (!system
->isTimingMode()) {
197 fatal("The timing CPU requires the memory system to be in "
203 TimingSimpleCPU::activateContext(ThreadID thread_num
)
205 DPRINTF(SimpleCPU
, "ActivateContext %d\n", thread_num
);
207 assert(thread_num
== 0);
210 assert(_status
== Idle
);
213 _status
= BaseSimpleCPU::Running
;
215 // kick things off by initiating the fetch of the next instruction
216 schedule(fetchEvent
, clockEdge(Cycles(0)));
221 TimingSimpleCPU::suspendContext(ThreadID thread_num
)
223 DPRINTF(SimpleCPU
, "SuspendContext %d\n", thread_num
);
225 assert(thread_num
== 0);
231 assert(_status
== BaseSimpleCPU::Running
);
233 // just change status to Idle... if status != Running,
234 // completeInst() will not initiate fetch of next instruction.
241 TimingSimpleCPU::handleReadPacket(PacketPtr pkt
)
243 RequestPtr req
= pkt
->req
;
244 if (req
->isMmappedIpr()) {
245 Cycles delay
= TheISA::handleIprRead(thread
->getTC(), pkt
);
246 new IprEvent(pkt
, this, clockEdge(delay
));
247 _status
= DcacheWaitResponse
;
249 } else if (!dcachePort
.sendTimingReq(pkt
)) {
250 _status
= DcacheRetry
;
253 _status
= DcacheWaitResponse
;
254 // memory system takes ownership of packet
257 return dcache_pkt
== NULL
;
261 TimingSimpleCPU::sendData(RequestPtr req
, uint8_t *data
, uint64_t *res
,
265 buildPacket(pkt
, req
, read
);
266 pkt
->dataDynamicArray
<uint8_t>(data
);
267 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
270 completeDataAccess(pkt
);
272 handleReadPacket(pkt
);
274 bool do_access
= true; // flag to suppress cache access
277 do_access
= TheISA::handleLockedWrite(thread
, req
, dcachePort
.cacheBlockMask
);
278 } else if (req
->isCondSwap()) {
280 req
->setExtraData(*res
);
287 _status
= DcacheWaitResponse
;
288 completeDataAccess(pkt
);
294 TimingSimpleCPU::sendSplitData(RequestPtr req1
, RequestPtr req2
,
295 RequestPtr req
, uint8_t *data
, bool read
)
297 PacketPtr pkt1
, pkt2
;
298 buildSplitPacket(pkt1
, pkt2
, req1
, req2
, req
, data
, read
);
299 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
301 pkt1
->makeResponse();
302 completeDataAccess(pkt1
);
304 SplitFragmentSenderState
* send_state
=
305 dynamic_cast<SplitFragmentSenderState
*>(pkt1
->senderState
);
306 if (handleReadPacket(pkt1
)) {
307 send_state
->clearFromParent();
308 send_state
= dynamic_cast<SplitFragmentSenderState
*>(
310 if (handleReadPacket(pkt2
)) {
311 send_state
->clearFromParent();
316 SplitFragmentSenderState
* send_state
=
317 dynamic_cast<SplitFragmentSenderState
*>(pkt1
->senderState
);
318 if (handleWritePacket()) {
319 send_state
->clearFromParent();
321 send_state
= dynamic_cast<SplitFragmentSenderState
*>(
323 if (handleWritePacket()) {
324 send_state
->clearFromParent();
331 TimingSimpleCPU::translationFault(const Fault
&fault
)
333 // fault may be NoFault in cases where a fault is suppressed,
334 // for instance prefetches.
338 // Since there was a fault, we shouldn't trace this instruction.
349 TimingSimpleCPU::buildPacket(PacketPtr
&pkt
, RequestPtr req
, bool read
)
351 pkt
= read
? Packet::createRead(req
) : Packet::createWrite(req
);
355 TimingSimpleCPU::buildSplitPacket(PacketPtr
&pkt1
, PacketPtr
&pkt2
,
356 RequestPtr req1
, RequestPtr req2
, RequestPtr req
,
357 uint8_t *data
, bool read
)
361 assert(!req1
->isMmappedIpr() && !req2
->isMmappedIpr());
363 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
364 buildPacket(pkt1
, req
, read
);
368 buildPacket(pkt1
, req1
, read
);
369 buildPacket(pkt2
, req2
, read
);
371 req
->setPhys(req1
->getPaddr(), req
->getSize(), req1
->getFlags(), dataMasterId());
372 PacketPtr pkt
= new Packet(req
, pkt1
->cmd
.responseCommand());
374 pkt
->dataDynamicArray
<uint8_t>(data
);
375 pkt1
->dataStatic
<uint8_t>(data
);
376 pkt2
->dataStatic
<uint8_t>(data
+ req1
->getSize());
378 SplitMainSenderState
* main_send_state
= new SplitMainSenderState
;
379 pkt
->senderState
= main_send_state
;
380 main_send_state
->fragments
[0] = pkt1
;
381 main_send_state
->fragments
[1] = pkt2
;
382 main_send_state
->outstanding
= 2;
383 pkt1
->senderState
= new SplitFragmentSenderState(pkt
, 0);
384 pkt2
->senderState
= new SplitFragmentSenderState(pkt
, 1);
388 TimingSimpleCPU::readMem(Addr addr
, uint8_t *data
,
389 unsigned size
, unsigned flags
)
393 const ThreadID tid
= 0;
394 const Addr pc
= thread
->instAddr();
395 unsigned block_size
= cacheLineSize();
396 BaseTLB::Mode mode
= BaseTLB::Read
;
399 traceData
->setAddr(addr
);
402 RequestPtr req
= new Request(asid
, addr
, size
,
403 flags
, dataMasterId(), pc
, _cpuId
, tid
);
405 req
->taskId(taskId());
407 Addr split_addr
= roundDown(addr
+ size
- 1, block_size
);
408 assert(split_addr
<= addr
|| split_addr
- addr
< block_size
);
410 _status
= DTBWaitResponse
;
411 if (split_addr
> addr
) {
412 RequestPtr req1
, req2
;
413 assert(!req
->isLLSC() && !req
->isSwap());
414 req
->splitOnVaddr(split_addr
, req1
, req2
);
416 WholeTranslationState
*state
=
417 new WholeTranslationState(req
, req1
, req2
, new uint8_t[size
],
419 DataTranslation
<TimingSimpleCPU
*> *trans1
=
420 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 0);
421 DataTranslation
<TimingSimpleCPU
*> *trans2
=
422 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 1);
424 thread
->dtb
->translateTiming(req1
, tc
, trans1
, mode
);
425 thread
->dtb
->translateTiming(req2
, tc
, trans2
, mode
);
427 WholeTranslationState
*state
=
428 new WholeTranslationState(req
, new uint8_t[size
], NULL
, mode
);
429 DataTranslation
<TimingSimpleCPU
*> *translation
430 = new DataTranslation
<TimingSimpleCPU
*>(this, state
);
431 thread
->dtb
->translateTiming(req
, tc
, translation
, mode
);
438 TimingSimpleCPU::handleWritePacket()
440 RequestPtr req
= dcache_pkt
->req
;
441 if (req
->isMmappedIpr()) {
442 Cycles delay
= TheISA::handleIprWrite(thread
->getTC(), dcache_pkt
);
443 new IprEvent(dcache_pkt
, this, clockEdge(delay
));
444 _status
= DcacheWaitResponse
;
446 } else if (!dcachePort
.sendTimingReq(dcache_pkt
)) {
447 _status
= DcacheRetry
;
449 _status
= DcacheWaitResponse
;
450 // memory system takes ownership of packet
453 return dcache_pkt
== NULL
;
457 TimingSimpleCPU::writeMem(uint8_t *data
, unsigned size
,
458 Addr addr
, unsigned flags
, uint64_t *res
)
460 uint8_t *newData
= new uint8_t[size
];
462 const ThreadID tid
= 0;
463 const Addr pc
= thread
->instAddr();
464 unsigned block_size
= cacheLineSize();
465 BaseTLB::Mode mode
= BaseTLB::Write
;
468 assert(flags
& Request::CACHE_BLOCK_ZERO
);
469 // This must be a cache block cleaning request
470 memset(newData
, 0, size
);
472 memcpy(newData
, data
, size
);
476 traceData
->setAddr(addr
);
479 RequestPtr req
= new Request(asid
, addr
, size
,
480 flags
, dataMasterId(), pc
, _cpuId
, tid
);
482 req
->taskId(taskId());
484 Addr split_addr
= roundDown(addr
+ size
- 1, block_size
);
485 assert(split_addr
<= addr
|| split_addr
- addr
< block_size
);
487 _status
= DTBWaitResponse
;
488 if (split_addr
> addr
) {
489 RequestPtr req1
, req2
;
490 assert(!req
->isLLSC() && !req
->isSwap());
491 req
->splitOnVaddr(split_addr
, req1
, req2
);
493 WholeTranslationState
*state
=
494 new WholeTranslationState(req
, req1
, req2
, newData
, res
, mode
);
495 DataTranslation
<TimingSimpleCPU
*> *trans1
=
496 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 0);
497 DataTranslation
<TimingSimpleCPU
*> *trans2
=
498 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 1);
500 thread
->dtb
->translateTiming(req1
, tc
, trans1
, mode
);
501 thread
->dtb
->translateTiming(req2
, tc
, trans2
, mode
);
503 WholeTranslationState
*state
=
504 new WholeTranslationState(req
, newData
, res
, mode
);
505 DataTranslation
<TimingSimpleCPU
*> *translation
=
506 new DataTranslation
<TimingSimpleCPU
*>(this, state
);
507 thread
->dtb
->translateTiming(req
, tc
, translation
, mode
);
510 // Translation faults will be returned via finishTranslation()
516 TimingSimpleCPU::finishTranslation(WholeTranslationState
*state
)
518 _status
= BaseSimpleCPU::Running
;
520 if (state
->getFault() != NoFault
) {
521 if (state
->isPrefetch()) {
524 delete [] state
->data
;
526 translationFault(state
->getFault());
528 if (!state
->isSplit
) {
529 sendData(state
->mainReq
, state
->data
, state
->res
,
530 state
->mode
== BaseTLB::Read
);
532 sendSplitData(state
->sreqLow
, state
->sreqHigh
, state
->mainReq
,
533 state
->data
, state
->mode
== BaseTLB::Read
);
542 TimingSimpleCPU::fetch()
544 DPRINTF(SimpleCPU
, "Fetch\n");
546 if (!curStaticInst
|| !curStaticInst
->isDelayedCommit())
547 checkForInterrupts();
551 // We must have just got suspended by a PC event
555 TheISA::PCState pcState
= thread
->pcState();
556 bool needToFetch
= !isRomMicroPC(pcState
.microPC()) && !curMacroStaticInst
;
559 _status
= BaseSimpleCPU::Running
;
560 Request
*ifetch_req
= new Request();
561 ifetch_req
->taskId(taskId());
562 ifetch_req
->setThreadContext(_cpuId
, /* thread ID */ 0);
563 setupFetchRequest(ifetch_req
);
564 DPRINTF(SimpleCPU
, "Translating address %#x\n", ifetch_req
->getVaddr());
565 thread
->itb
->translateTiming(ifetch_req
, tc
, &fetchTranslation
,
568 _status
= IcacheWaitResponse
;
569 completeIfetch(NULL
);
577 TimingSimpleCPU::sendFetch(const Fault
&fault
, RequestPtr req
,
580 if (fault
== NoFault
) {
581 DPRINTF(SimpleCPU
, "Sending fetch for addr %#x(pa: %#x)\n",
582 req
->getVaddr(), req
->getPaddr());
583 ifetch_pkt
= new Packet(req
, MemCmd::ReadReq
);
584 ifetch_pkt
->dataStatic(&inst
);
585 DPRINTF(SimpleCPU
, " -- pkt addr: %#x\n", ifetch_pkt
->getAddr());
587 if (!icachePort
.sendTimingReq(ifetch_pkt
)) {
588 // Need to wait for retry
589 _status
= IcacheRetry
;
591 // Need to wait for cache to respond
592 _status
= IcacheWaitResponse
;
593 // ownership of packet transferred to memory system
597 DPRINTF(SimpleCPU
, "Translation of addr %#x faulted\n", req
->getVaddr());
599 // fetch fault: advance directly to next instruction (fault handler)
600 _status
= BaseSimpleCPU::Running
;
609 TimingSimpleCPU::advanceInst(const Fault
&fault
)
611 if (_status
== Faulting
)
614 if (fault
!= NoFault
) {
616 DPRINTF(SimpleCPU
, "Fault occured, scheduling fetch event\n");
617 reschedule(fetchEvent
, clockEdge(), true);
626 if (tryCompleteDrain())
629 if (_status
== BaseSimpleCPU::Running
) {
630 // kick off fetch of next instruction... callback from icache
631 // response will cause that instruction to be executed,
632 // keeping the CPU running.
639 TimingSimpleCPU::completeIfetch(PacketPtr pkt
)
641 DPRINTF(SimpleCPU
, "Complete ICache Fetch for addr %#x\n", pkt
?
644 // received a response from the icache: execute the received
646 assert(!pkt
|| !pkt
->isError());
647 assert(_status
== IcacheWaitResponse
);
649 _status
= BaseSimpleCPU::Running
;
654 pkt
->req
->setAccessLatency();
658 if (curStaticInst
&& curStaticInst
->isMemRef()) {
659 // load or store: just send to dcache
660 Fault fault
= curStaticInst
->initiateAcc(this, traceData
);
662 // If we're not running now the instruction will complete in a dcache
663 // response callback or the instruction faulted and has started an
665 if (_status
== BaseSimpleCPU::Running
) {
666 if (fault
!= NoFault
&& traceData
) {
667 // If there was a fault, we shouldn't trace this instruction.
673 // @todo remove me after debugging with legion done
674 if (curStaticInst
&& (!curStaticInst
->isMicroop() ||
675 curStaticInst
->isFirstMicroop()))
679 } else if (curStaticInst
) {
680 // non-memory instruction: execute completely now
681 Fault fault
= curStaticInst
->execute(this, traceData
);
683 // keep an instruction count
684 if (fault
== NoFault
)
686 else if (traceData
&& !DTRACE(ExecFaulting
)) {
692 // @todo remove me after debugging with legion done
693 if (curStaticInst
&& (!curStaticInst
->isMicroop() ||
694 curStaticInst
->isFirstMicroop()))
698 advanceInst(NoFault
);
708 TimingSimpleCPU::IcachePort::ITickEvent::process()
710 cpu
->completeIfetch(pkt
);
714 TimingSimpleCPU::IcachePort::recvTimingResp(PacketPtr pkt
)
716 DPRINTF(SimpleCPU
, "Received timing response %#x\n", pkt
->getAddr());
717 // delay processing of returned data until next CPU clock edge
718 Tick next_tick
= cpu
->clockEdge();
720 if (next_tick
== curTick())
721 cpu
->completeIfetch(pkt
);
723 tickEvent
.schedule(pkt
, next_tick
);
729 TimingSimpleCPU::IcachePort::recvRetry()
731 // we shouldn't get a retry unless we have a packet that we're
732 // waiting to transmit
733 assert(cpu
->ifetch_pkt
!= NULL
);
734 assert(cpu
->_status
== IcacheRetry
);
735 PacketPtr tmp
= cpu
->ifetch_pkt
;
736 if (sendTimingReq(tmp
)) {
737 cpu
->_status
= IcacheWaitResponse
;
738 cpu
->ifetch_pkt
= NULL
;
743 TimingSimpleCPU::completeDataAccess(PacketPtr pkt
)
745 // received a response from the dcache: complete the load or store
747 assert(!pkt
->isError());
748 assert(_status
== DcacheWaitResponse
|| _status
== DTBWaitResponse
||
749 pkt
->req
->getFlags().isSet(Request::NO_ACCESS
));
751 pkt
->req
->setAccessLatency();
755 if (pkt
->senderState
) {
756 SplitFragmentSenderState
* send_state
=
757 dynamic_cast<SplitFragmentSenderState
*>(pkt
->senderState
);
761 PacketPtr big_pkt
= send_state
->bigPkt
;
764 SplitMainSenderState
* main_send_state
=
765 dynamic_cast<SplitMainSenderState
*>(big_pkt
->senderState
);
766 assert(main_send_state
);
767 // Record the fact that this packet is no longer outstanding.
768 assert(main_send_state
->outstanding
!= 0);
769 main_send_state
->outstanding
--;
771 if (main_send_state
->outstanding
) {
774 delete main_send_state
;
775 big_pkt
->senderState
= NULL
;
780 _status
= BaseSimpleCPU::Running
;
782 Fault fault
= curStaticInst
->completeAcc(pkt
, this, traceData
);
784 // keep an instruction count
785 if (fault
== NoFault
)
787 else if (traceData
) {
788 // If there was a fault, we shouldn't trace this instruction.
793 // the locked flag may be cleared on the response packet, so check
794 // pkt->req and not pkt to see if it was a load-locked
795 if (pkt
->isRead() && pkt
->req
->isLLSC()) {
796 TheISA::handleLockedRead(thread
, pkt
->req
);
808 TimingSimpleCPU::updateCycleCounts()
810 const Cycles
delta(curCycle() - previousCycle
);
813 ppCycles
->notify(delta
);
815 previousCycle
= curCycle();
819 TimingSimpleCPU::DcachePort::recvTimingSnoopReq(PacketPtr pkt
)
821 TheISA::handleLockedSnoop(cpu
->thread
, pkt
, cacheBlockMask
);
826 TimingSimpleCPU::DcachePort::recvTimingResp(PacketPtr pkt
)
828 // delay processing of returned data until next CPU clock edge
829 Tick next_tick
= cpu
->clockEdge();
831 if (next_tick
== curTick()) {
832 cpu
->completeDataAccess(pkt
);
834 if (!tickEvent
.scheduled()) {
835 tickEvent
.schedule(pkt
, next_tick
);
837 // In the case of a split transaction and a cache that is
838 // faster than a CPU we could get two responses before
840 if (!retryEvent
.scheduled())
841 cpu
->schedule(retryEvent
, next_tick
);
850 TimingSimpleCPU::DcachePort::DTickEvent::process()
852 cpu
->completeDataAccess(pkt
);
856 TimingSimpleCPU::DcachePort::recvRetry()
858 // we shouldn't get a retry unless we have a packet that we're
859 // waiting to transmit
860 assert(cpu
->dcache_pkt
!= NULL
);
861 assert(cpu
->_status
== DcacheRetry
);
862 PacketPtr tmp
= cpu
->dcache_pkt
;
863 if (tmp
->senderState
) {
864 // This is a packet from a split access.
865 SplitFragmentSenderState
* send_state
=
866 dynamic_cast<SplitFragmentSenderState
*>(tmp
->senderState
);
868 PacketPtr big_pkt
= send_state
->bigPkt
;
870 SplitMainSenderState
* main_send_state
=
871 dynamic_cast<SplitMainSenderState
*>(big_pkt
->senderState
);
872 assert(main_send_state
);
874 if (sendTimingReq(tmp
)) {
875 // If we were able to send without retrying, record that fact
876 // and try sending the other fragment.
877 send_state
->clearFromParent();
878 int other_index
= main_send_state
->getPendingFragment();
879 if (other_index
> 0) {
880 tmp
= main_send_state
->fragments
[other_index
];
881 cpu
->dcache_pkt
= tmp
;
882 if ((big_pkt
->isRead() && cpu
->handleReadPacket(tmp
)) ||
883 (big_pkt
->isWrite() && cpu
->handleWritePacket())) {
884 main_send_state
->fragments
[other_index
] = NULL
;
887 cpu
->_status
= DcacheWaitResponse
;
888 // memory system takes ownership of packet
889 cpu
->dcache_pkt
= NULL
;
892 } else if (sendTimingReq(tmp
)) {
893 cpu
->_status
= DcacheWaitResponse
;
894 // memory system takes ownership of packet
895 cpu
->dcache_pkt
= NULL
;
899 TimingSimpleCPU::IprEvent::IprEvent(Packet
*_pkt
, TimingSimpleCPU
*_cpu
,
901 : pkt(_pkt
), cpu(_cpu
)
903 cpu
->schedule(this, t
);
907 TimingSimpleCPU::IprEvent::process()
909 cpu
->completeDataAccess(pkt
);
913 TimingSimpleCPU::IprEvent::description() const
915 return "Timing Simple CPU Delay IPR event";
920 TimingSimpleCPU::printAddr(Addr a
)
922 dcachePort
.printAddr(a
);
926 ////////////////////////////////////////////////////////////////////////
928 // TimingSimpleCPU Simulation Object
931 TimingSimpleCPUParams::create()
934 if (!FullSystem
&& workload
.size() != 1)
935 panic("only one workload allowed");
936 return new TimingSimpleCPU(this);