2 * Copyright (c) 2010-2012 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 if (!params()->switched_out
&&
70 system
->getMemoryMode() != Enums::timing
) {
71 fatal("The timing CPU requires the memory system to be in "
75 // Initialise the ThreadContext's memory proxies
76 tcBase()->initMemProxies(tcBase());
78 if (FullSystem
&& !params()->switched_out
) {
79 for (int i
= 0; i
< threadContexts
.size(); ++i
) {
80 ThreadContext
*tc
= threadContexts
[i
];
81 // initialize CPU, including PC
82 TheISA::initCPU(tc
, _cpuId
);
88 TimingSimpleCPU::TimingCPUPort::TickEvent::schedule(PacketPtr _pkt
, Tick t
)
91 cpu
->schedule(this, t
);
94 TimingSimpleCPU::TimingSimpleCPU(TimingSimpleCPUParams
*p
)
95 : BaseSimpleCPU(p
), fetchTranslation(this), icachePort(this),
96 dcachePort(this), ifetch_pkt(NULL
), dcache_pkt(NULL
), previousCycle(0),
97 fetchEvent(this), drainManager(NULL
)
101 system
->totalNumInsts
= 0;
105 TimingSimpleCPU::~TimingSimpleCPU()
110 TimingSimpleCPU::drain(DrainManager
*drain_manager
)
112 if (_status
== Idle
||
113 (_status
== BaseSimpleCPU::Running
&& isDrained()) ||
114 _status
== SwitchedOut
) {
115 assert(!fetchEvent
.scheduled());
116 DPRINTF(Drain
, "No need to drain.\n");
119 drainManager
= drain_manager
;
120 DPRINTF(Drain
, "Requesting drain: %s\n", pcState());
122 // The fetch event can become descheduled if a drain didn't
123 // succeed on the first attempt. We need to reschedule it if
124 // the CPU is waiting for a microcode routine to complete.
125 if (_status
== BaseSimpleCPU::Running
&& !isDrained() &&
126 !fetchEvent
.scheduled()) {
127 schedule(fetchEvent
, nextCycle());
135 TimingSimpleCPU::drainResume()
137 assert(!fetchEvent
.scheduled());
139 DPRINTF(SimpleCPU
, "Resume\n");
140 if (_status
!= SwitchedOut
&& _status
!= Idle
) {
141 if (system
->getMemoryMode() != Enums::timing
) {
142 fatal("The timing CPU requires the memory system to be in "
146 schedule(fetchEvent
, nextCycle());
151 TimingSimpleCPU::tryCompleteDrain()
156 DPRINTF(Drain
, "tryCompleteDrain: %s\n", pcState());
160 DPRINTF(Drain
, "CPU done draining, processing drain event\n");
161 drainManager
->signalDrainDone();
168 TimingSimpleCPU::switchOut()
170 BaseSimpleCPU::switchOut();
172 assert(!fetchEvent
.scheduled());
173 assert(_status
== BaseSimpleCPU::Running
|| _status
== Idle
);
175 assert(microPC() == 0);
177 _status
= SwitchedOut
;
178 numCycles
+= curCycle() - previousCycle
;
183 TimingSimpleCPU::takeOverFrom(BaseCPU
*oldCPU
)
185 BaseSimpleCPU::takeOverFrom(oldCPU
);
187 // if any of this CPU's ThreadContexts are active, mark the CPU as
188 // running and schedule its tick event.
189 for (int i
= 0; i
< threadContexts
.size(); ++i
) {
190 ThreadContext
*tc
= threadContexts
[i
];
191 if (tc
->status() == ThreadContext::Active
&&
192 _status
!= BaseSimpleCPU::Running
) {
193 _status
= BaseSimpleCPU::Running
;
198 if (_status
!= BaseSimpleCPU::Running
) {
201 assert(threadContexts
.size() == 1);
202 previousCycle
= curCycle();
207 TimingSimpleCPU::activateContext(ThreadID thread_num
, Cycles delay
)
209 DPRINTF(SimpleCPU
, "ActivateContext %d (%d cycles)\n", thread_num
, delay
);
211 assert(thread_num
== 0);
214 assert(_status
== Idle
);
217 _status
= BaseSimpleCPU::Running
;
219 // kick things off by initiating the fetch of the next instruction
220 schedule(fetchEvent
, clockEdge(delay
));
225 TimingSimpleCPU::suspendContext(ThreadID thread_num
)
227 DPRINTF(SimpleCPU
, "SuspendContext %d\n", thread_num
);
229 assert(thread_num
== 0);
235 assert(_status
== BaseSimpleCPU::Running
);
237 // just change status to Idle... if status != Running,
238 // completeInst() will not initiate fetch of next instruction.
245 TimingSimpleCPU::handleReadPacket(PacketPtr pkt
)
247 RequestPtr req
= pkt
->req
;
248 if (req
->isMmappedIpr()) {
249 Cycles delay
= TheISA::handleIprRead(thread
->getTC(), pkt
);
250 new IprEvent(pkt
, this, clockEdge(delay
));
251 _status
= DcacheWaitResponse
;
253 } else if (!dcachePort
.sendTimingReq(pkt
)) {
254 _status
= DcacheRetry
;
257 _status
= DcacheWaitResponse
;
258 // memory system takes ownership of packet
261 return dcache_pkt
== NULL
;
265 TimingSimpleCPU::sendData(RequestPtr req
, uint8_t *data
, uint64_t *res
,
269 buildPacket(pkt
, req
, read
);
270 pkt
->dataDynamicArray
<uint8_t>(data
);
271 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
274 completeDataAccess(pkt
);
276 handleReadPacket(pkt
);
278 bool do_access
= true; // flag to suppress cache access
281 do_access
= TheISA::handleLockedWrite(thread
, req
);
282 } else if (req
->isCondSwap()) {
284 req
->setExtraData(*res
);
291 _status
= DcacheWaitResponse
;
292 completeDataAccess(pkt
);
298 TimingSimpleCPU::sendSplitData(RequestPtr req1
, RequestPtr req2
,
299 RequestPtr req
, uint8_t *data
, bool read
)
301 PacketPtr pkt1
, pkt2
;
302 buildSplitPacket(pkt1
, pkt2
, req1
, req2
, req
, data
, read
);
303 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
305 pkt1
->makeResponse();
306 completeDataAccess(pkt1
);
308 SplitFragmentSenderState
* send_state
=
309 dynamic_cast<SplitFragmentSenderState
*>(pkt1
->senderState
);
310 if (handleReadPacket(pkt1
)) {
311 send_state
->clearFromParent();
312 send_state
= dynamic_cast<SplitFragmentSenderState
*>(
314 if (handleReadPacket(pkt2
)) {
315 send_state
->clearFromParent();
320 SplitFragmentSenderState
* send_state
=
321 dynamic_cast<SplitFragmentSenderState
*>(pkt1
->senderState
);
322 if (handleWritePacket()) {
323 send_state
->clearFromParent();
325 send_state
= dynamic_cast<SplitFragmentSenderState
*>(
327 if (handleWritePacket()) {
328 send_state
->clearFromParent();
335 TimingSimpleCPU::translationFault(Fault fault
)
337 // fault may be NoFault in cases where a fault is suppressed,
338 // for instance prefetches.
339 numCycles
+= curCycle() - previousCycle
;
340 previousCycle
= curCycle();
343 // Since there was a fault, we shouldn't trace this instruction.
354 TimingSimpleCPU::buildPacket(PacketPtr
&pkt
, RequestPtr req
, bool read
)
358 cmd
= MemCmd::ReadReq
;
360 cmd
= MemCmd::LoadLockedReq
;
362 cmd
= MemCmd::WriteReq
;
364 cmd
= MemCmd::StoreCondReq
;
365 } else if (req
->isSwap()) {
366 cmd
= MemCmd::SwapReq
;
369 pkt
= new Packet(req
, cmd
);
373 TimingSimpleCPU::buildSplitPacket(PacketPtr
&pkt1
, PacketPtr
&pkt2
,
374 RequestPtr req1
, RequestPtr req2
, RequestPtr req
,
375 uint8_t *data
, bool read
)
379 assert(!req1
->isMmappedIpr() && !req2
->isMmappedIpr());
381 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
382 buildPacket(pkt1
, req
, read
);
386 buildPacket(pkt1
, req1
, read
);
387 buildPacket(pkt2
, req2
, read
);
389 req
->setPhys(req1
->getPaddr(), req
->getSize(), req1
->getFlags(), dataMasterId());
390 PacketPtr pkt
= new Packet(req
, pkt1
->cmd
.responseCommand());
392 pkt
->dataDynamicArray
<uint8_t>(data
);
393 pkt1
->dataStatic
<uint8_t>(data
);
394 pkt2
->dataStatic
<uint8_t>(data
+ req1
->getSize());
396 SplitMainSenderState
* main_send_state
= new SplitMainSenderState
;
397 pkt
->senderState
= main_send_state
;
398 main_send_state
->fragments
[0] = pkt1
;
399 main_send_state
->fragments
[1] = pkt2
;
400 main_send_state
->outstanding
= 2;
401 pkt1
->senderState
= new SplitFragmentSenderState(pkt
, 0);
402 pkt2
->senderState
= new SplitFragmentSenderState(pkt
, 1);
406 TimingSimpleCPU::readMem(Addr addr
, uint8_t *data
,
407 unsigned size
, unsigned flags
)
411 const ThreadID tid
= 0;
412 const Addr pc
= thread
->instAddr();
413 unsigned block_size
= dcachePort
.peerBlockSize();
414 BaseTLB::Mode mode
= BaseTLB::Read
;
417 traceData
->setAddr(addr
);
420 RequestPtr req
= new Request(asid
, addr
, size
,
421 flags
, dataMasterId(), pc
, _cpuId
, tid
);
423 Addr split_addr
= roundDown(addr
+ size
- 1, block_size
);
424 assert(split_addr
<= addr
|| split_addr
- addr
< block_size
);
426 _status
= DTBWaitResponse
;
427 if (split_addr
> addr
) {
428 RequestPtr req1
, req2
;
429 assert(!req
->isLLSC() && !req
->isSwap());
430 req
->splitOnVaddr(split_addr
, req1
, req2
);
432 WholeTranslationState
*state
=
433 new WholeTranslationState(req
, req1
, req2
, new uint8_t[size
],
435 DataTranslation
<TimingSimpleCPU
*> *trans1
=
436 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 0);
437 DataTranslation
<TimingSimpleCPU
*> *trans2
=
438 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 1);
440 thread
->dtb
->translateTiming(req1
, tc
, trans1
, mode
);
441 thread
->dtb
->translateTiming(req2
, tc
, trans2
, mode
);
443 WholeTranslationState
*state
=
444 new WholeTranslationState(req
, new uint8_t[size
], NULL
, mode
);
445 DataTranslation
<TimingSimpleCPU
*> *translation
446 = new DataTranslation
<TimingSimpleCPU
*>(this, state
);
447 thread
->dtb
->translateTiming(req
, tc
, translation
, mode
);
454 TimingSimpleCPU::handleWritePacket()
456 RequestPtr req
= dcache_pkt
->req
;
457 if (req
->isMmappedIpr()) {
458 Cycles delay
= TheISA::handleIprWrite(thread
->getTC(), dcache_pkt
);
459 new IprEvent(dcache_pkt
, this, clockEdge(delay
));
460 _status
= DcacheWaitResponse
;
462 } else if (!dcachePort
.sendTimingReq(dcache_pkt
)) {
463 _status
= DcacheRetry
;
465 _status
= DcacheWaitResponse
;
466 // memory system takes ownership of packet
469 return dcache_pkt
== NULL
;
473 TimingSimpleCPU::writeMem(uint8_t *data
, unsigned size
,
474 Addr addr
, unsigned flags
, uint64_t *res
)
476 uint8_t *newData
= new uint8_t[size
];
477 memcpy(newData
, data
, size
);
480 const ThreadID tid
= 0;
481 const Addr pc
= thread
->instAddr();
482 unsigned block_size
= dcachePort
.peerBlockSize();
483 BaseTLB::Mode mode
= BaseTLB::Write
;
486 traceData
->setAddr(addr
);
489 RequestPtr req
= new Request(asid
, addr
, size
,
490 flags
, dataMasterId(), pc
, _cpuId
, tid
);
492 Addr split_addr
= roundDown(addr
+ size
- 1, block_size
);
493 assert(split_addr
<= addr
|| split_addr
- addr
< block_size
);
495 _status
= DTBWaitResponse
;
496 if (split_addr
> addr
) {
497 RequestPtr req1
, req2
;
498 assert(!req
->isLLSC() && !req
->isSwap());
499 req
->splitOnVaddr(split_addr
, req1
, req2
);
501 WholeTranslationState
*state
=
502 new WholeTranslationState(req
, req1
, req2
, newData
, res
, mode
);
503 DataTranslation
<TimingSimpleCPU
*> *trans1
=
504 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 0);
505 DataTranslation
<TimingSimpleCPU
*> *trans2
=
506 new DataTranslation
<TimingSimpleCPU
*>(this, state
, 1);
508 thread
->dtb
->translateTiming(req1
, tc
, trans1
, mode
);
509 thread
->dtb
->translateTiming(req2
, tc
, trans2
, mode
);
511 WholeTranslationState
*state
=
512 new WholeTranslationState(req
, newData
, res
, mode
);
513 DataTranslation
<TimingSimpleCPU
*> *translation
=
514 new DataTranslation
<TimingSimpleCPU
*>(this, state
);
515 thread
->dtb
->translateTiming(req
, tc
, translation
, mode
);
518 // Translation faults will be returned via finishTranslation()
524 TimingSimpleCPU::finishTranslation(WholeTranslationState
*state
)
526 _status
= BaseSimpleCPU::Running
;
528 if (state
->getFault() != NoFault
) {
529 if (state
->isPrefetch()) {
532 delete [] state
->data
;
534 translationFault(state
->getFault());
536 if (!state
->isSplit
) {
537 sendData(state
->mainReq
, state
->data
, state
->res
,
538 state
->mode
== BaseTLB::Read
);
540 sendSplitData(state
->sreqLow
, state
->sreqHigh
, state
->mainReq
,
541 state
->data
, state
->mode
== BaseTLB::Read
);
550 TimingSimpleCPU::fetch()
552 DPRINTF(SimpleCPU
, "Fetch\n");
554 if (!curStaticInst
|| !curStaticInst
->isDelayedCommit())
555 checkForInterrupts();
559 // We must have just got suspended by a PC event
563 TheISA::PCState pcState
= thread
->pcState();
564 bool needToFetch
= !isRomMicroPC(pcState
.microPC()) && !curMacroStaticInst
;
567 _status
= BaseSimpleCPU::Running
;
568 Request
*ifetch_req
= new Request();
569 ifetch_req
->setThreadContext(_cpuId
, /* thread ID */ 0);
570 setupFetchRequest(ifetch_req
);
571 DPRINTF(SimpleCPU
, "Translating address %#x\n", ifetch_req
->getVaddr());
572 thread
->itb
->translateTiming(ifetch_req
, tc
, &fetchTranslation
,
575 _status
= IcacheWaitResponse
;
576 completeIfetch(NULL
);
578 numCycles
+= curCycle() - previousCycle
;
579 previousCycle
= curCycle();
585 TimingSimpleCPU::sendFetch(Fault fault
, RequestPtr req
, ThreadContext
*tc
)
587 if (fault
== NoFault
) {
588 DPRINTF(SimpleCPU
, "Sending fetch for addr %#x(pa: %#x)\n",
589 req
->getVaddr(), req
->getPaddr());
590 ifetch_pkt
= new Packet(req
, MemCmd::ReadReq
);
591 ifetch_pkt
->dataStatic(&inst
);
592 DPRINTF(SimpleCPU
, " -- pkt addr: %#x\n", ifetch_pkt
->getAddr());
594 if (!icachePort
.sendTimingReq(ifetch_pkt
)) {
595 // Need to wait for retry
596 _status
= IcacheRetry
;
598 // Need to wait for cache to respond
599 _status
= IcacheWaitResponse
;
600 // ownership of packet transferred to memory system
604 DPRINTF(SimpleCPU
, "Translation of addr %#x faulted\n", req
->getVaddr());
606 // fetch fault: advance directly to next instruction (fault handler)
607 _status
= BaseSimpleCPU::Running
;
611 numCycles
+= curCycle() - previousCycle
;
612 previousCycle
= curCycle();
617 TimingSimpleCPU::advanceInst(Fault fault
)
619 if (_status
== Faulting
)
622 if (fault
!= NoFault
) {
624 DPRINTF(SimpleCPU
, "Fault occured, scheduling fetch event\n");
625 reschedule(fetchEvent
, nextCycle(), true);
634 if (tryCompleteDrain())
637 if (_status
== BaseSimpleCPU::Running
) {
638 // kick off fetch of next instruction... callback from icache
639 // response will cause that instruction to be executed,
640 // keeping the CPU running.
647 TimingSimpleCPU::completeIfetch(PacketPtr pkt
)
649 DPRINTF(SimpleCPU
, "Complete ICache Fetch for addr %#x\n", pkt
?
652 // received a response from the icache: execute the received
655 assert(!pkt
|| !pkt
->isError());
656 assert(_status
== IcacheWaitResponse
);
658 _status
= BaseSimpleCPU::Running
;
660 numCycles
+= curCycle() - previousCycle
;
661 previousCycle
= curCycle();
664 if (curStaticInst
&& curStaticInst
->isMemRef()) {
665 // load or store: just send to dcache
666 Fault fault
= curStaticInst
->initiateAcc(this, traceData
);
668 // If we're not running now the instruction will complete in a dcache
669 // response callback or the instruction faulted and has started an
671 if (_status
== BaseSimpleCPU::Running
) {
672 if (fault
!= NoFault
&& traceData
) {
673 // If there was a fault, we shouldn't trace this instruction.
679 // @todo remove me after debugging with legion done
680 if (curStaticInst
&& (!curStaticInst
->isMicroop() ||
681 curStaticInst
->isFirstMicroop()))
685 } else if (curStaticInst
) {
686 // non-memory instruction: execute completely now
687 Fault fault
= curStaticInst
->execute(this, traceData
);
689 // keep an instruction count
690 if (fault
== NoFault
)
692 else if (traceData
&& !DTRACE(ExecFaulting
)) {
698 // @todo remove me after debugging with legion done
699 if (curStaticInst
&& (!curStaticInst
->isMicroop() ||
700 curStaticInst
->isFirstMicroop()))
704 advanceInst(NoFault
);
714 TimingSimpleCPU::IcachePort::ITickEvent::process()
716 cpu
->completeIfetch(pkt
);
720 TimingSimpleCPU::IcachePort::recvTimingResp(PacketPtr pkt
)
722 DPRINTF(SimpleCPU
, "Received timing response %#x\n", pkt
->getAddr());
723 // delay processing of returned data until next CPU clock edge
724 Tick next_tick
= cpu
->nextCycle();
726 if (next_tick
== curTick())
727 cpu
->completeIfetch(pkt
);
729 tickEvent
.schedule(pkt
, next_tick
);
735 TimingSimpleCPU::IcachePort::recvRetry()
737 // we shouldn't get a retry unless we have a packet that we're
738 // waiting to transmit
739 assert(cpu
->ifetch_pkt
!= NULL
);
740 assert(cpu
->_status
== IcacheRetry
);
741 PacketPtr tmp
= cpu
->ifetch_pkt
;
742 if (sendTimingReq(tmp
)) {
743 cpu
->_status
= IcacheWaitResponse
;
744 cpu
->ifetch_pkt
= NULL
;
749 TimingSimpleCPU::completeDataAccess(PacketPtr pkt
)
751 // received a response from the dcache: complete the load or store
753 assert(!pkt
->isError());
754 assert(_status
== DcacheWaitResponse
|| _status
== DTBWaitResponse
||
755 pkt
->req
->getFlags().isSet(Request::NO_ACCESS
));
757 numCycles
+= curCycle() - previousCycle
;
758 previousCycle
= curCycle();
760 if (pkt
->senderState
) {
761 SplitFragmentSenderState
* send_state
=
762 dynamic_cast<SplitFragmentSenderState
*>(pkt
->senderState
);
766 PacketPtr big_pkt
= send_state
->bigPkt
;
769 SplitMainSenderState
* main_send_state
=
770 dynamic_cast<SplitMainSenderState
*>(big_pkt
->senderState
);
771 assert(main_send_state
);
772 // Record the fact that this packet is no longer outstanding.
773 assert(main_send_state
->outstanding
!= 0);
774 main_send_state
->outstanding
--;
776 if (main_send_state
->outstanding
) {
779 delete main_send_state
;
780 big_pkt
->senderState
= NULL
;
785 _status
= BaseSimpleCPU::Running
;
787 Fault fault
= curStaticInst
->completeAcc(pkt
, this, traceData
);
789 // keep an instruction count
790 if (fault
== NoFault
)
792 else if (traceData
) {
793 // If there was a fault, we shouldn't trace this instruction.
798 // the locked flag may be cleared on the response packet, so check
799 // pkt->req and not pkt to see if it was a load-locked
800 if (pkt
->isRead() && pkt
->req
->isLLSC()) {
801 TheISA::handleLockedRead(thread
, pkt
->req
);
813 TimingSimpleCPU::DcachePort::recvTimingResp(PacketPtr pkt
)
815 // delay processing of returned data until next CPU clock edge
816 Tick next_tick
= cpu
->nextCycle();
818 if (next_tick
== curTick()) {
819 cpu
->completeDataAccess(pkt
);
821 if (!tickEvent
.scheduled()) {
822 tickEvent
.schedule(pkt
, next_tick
);
824 // In the case of a split transaction and a cache that is
825 // faster than a CPU we could get two responses before
827 if (!retryEvent
.scheduled())
828 cpu
->schedule(retryEvent
, next_tick
);
837 TimingSimpleCPU::DcachePort::DTickEvent::process()
839 cpu
->completeDataAccess(pkt
);
843 TimingSimpleCPU::DcachePort::recvRetry()
845 // we shouldn't get a retry unless we have a packet that we're
846 // waiting to transmit
847 assert(cpu
->dcache_pkt
!= NULL
);
848 assert(cpu
->_status
== DcacheRetry
);
849 PacketPtr tmp
= cpu
->dcache_pkt
;
850 if (tmp
->senderState
) {
851 // This is a packet from a split access.
852 SplitFragmentSenderState
* send_state
=
853 dynamic_cast<SplitFragmentSenderState
*>(tmp
->senderState
);
855 PacketPtr big_pkt
= send_state
->bigPkt
;
857 SplitMainSenderState
* main_send_state
=
858 dynamic_cast<SplitMainSenderState
*>(big_pkt
->senderState
);
859 assert(main_send_state
);
861 if (sendTimingReq(tmp
)) {
862 // If we were able to send without retrying, record that fact
863 // and try sending the other fragment.
864 send_state
->clearFromParent();
865 int other_index
= main_send_state
->getPendingFragment();
866 if (other_index
> 0) {
867 tmp
= main_send_state
->fragments
[other_index
];
868 cpu
->dcache_pkt
= tmp
;
869 if ((big_pkt
->isRead() && cpu
->handleReadPacket(tmp
)) ||
870 (big_pkt
->isWrite() && cpu
->handleWritePacket())) {
871 main_send_state
->fragments
[other_index
] = NULL
;
874 cpu
->_status
= DcacheWaitResponse
;
875 // memory system takes ownership of packet
876 cpu
->dcache_pkt
= NULL
;
879 } else if (sendTimingReq(tmp
)) {
880 cpu
->_status
= DcacheWaitResponse
;
881 // memory system takes ownership of packet
882 cpu
->dcache_pkt
= NULL
;
886 TimingSimpleCPU::IprEvent::IprEvent(Packet
*_pkt
, TimingSimpleCPU
*_cpu
,
888 : pkt(_pkt
), cpu(_cpu
)
890 cpu
->schedule(this, t
);
894 TimingSimpleCPU::IprEvent::process()
896 cpu
->completeDataAccess(pkt
);
900 TimingSimpleCPU::IprEvent::description() const
902 return "Timing Simple CPU Delay IPR event";
907 TimingSimpleCPU::printAddr(Addr a
)
909 dcachePort
.printAddr(a
);
913 ////////////////////////////////////////////////////////////////////////
915 // TimingSimpleCPU Simulation Object
918 TimingSimpleCPUParams::create()
921 if (!FullSystem
&& workload
.size() != 1)
922 panic("only one workload allowed");
923 return new TimingSimpleCPU(this);