2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
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: Steve Reinhardt
31 #include "arch/locked_mem.hh"
32 #include "arch/mmaped_ipr.hh"
33 #include "arch/utility.hh"
34 #include "base/bigint.hh"
35 #include "cpu/exetrace.hh"
36 #include "cpu/simple/timing.hh"
37 #include "mem/packet.hh"
38 #include "mem/packet_access.hh"
39 #include "params/TimingSimpleCPU.hh"
40 #include "sim/system.hh"
43 using namespace TheISA
;
46 TimingSimpleCPU::getPort(const std::string
&if_name
, int idx
)
48 if (if_name
== "dcache_port")
50 else if (if_name
== "icache_port")
53 panic("No Such Port\n");
57 TimingSimpleCPU::init()
61 for (int i
= 0; i
< threadContexts
.size(); ++i
) {
62 ThreadContext
*tc
= threadContexts
[i
];
64 // initialize CPU, including PC
65 TheISA::initCPU(tc
, _cpuId
);
71 TimingSimpleCPU::CpuPort::recvAtomic(PacketPtr pkt
)
73 panic("TimingSimpleCPU doesn't expect recvAtomic callback!");
78 TimingSimpleCPU::CpuPort::recvFunctional(PacketPtr pkt
)
80 //No internal storage to update, jusst return
85 TimingSimpleCPU::CpuPort::recvStatusChange(Status status
)
87 if (status
== RangeChange
) {
88 if (!snoopRangeSent
) {
89 snoopRangeSent
= true;
90 sendStatusChange(Port::RangeChange
);
95 panic("TimingSimpleCPU doesn't expect recvStatusChange callback!");
100 TimingSimpleCPU::CpuPort::TickEvent::schedule(PacketPtr _pkt
, Tick t
)
103 cpu
->schedule(this, t
);
106 TimingSimpleCPU::TimingSimpleCPU(TimingSimpleCPUParams
*p
)
107 : BaseSimpleCPU(p
), icachePort(this, p
->clock
), dcachePort(this, p
->clock
), fetchEvent(this)
111 icachePort
.snoopRangeSent
= false;
112 dcachePort
.snoopRangeSent
= false;
114 ifetch_pkt
= dcache_pkt
= NULL
;
117 changeState(SimObject::Running
);
121 TimingSimpleCPU::~TimingSimpleCPU()
126 TimingSimpleCPU::serialize(ostream
&os
)
128 SimObject::State so_state
= SimObject::getState();
129 SERIALIZE_ENUM(so_state
);
130 BaseSimpleCPU::serialize(os
);
134 TimingSimpleCPU::unserialize(Checkpoint
*cp
, const string
§ion
)
136 SimObject::State so_state
;
137 UNSERIALIZE_ENUM(so_state
);
138 BaseSimpleCPU::unserialize(cp
, section
);
142 TimingSimpleCPU::drain(Event
*drain_event
)
144 // TimingSimpleCPU is ready to drain if it's not waiting for
145 // an access to complete.
146 if (_status
== Idle
|| _status
== Running
|| _status
== SwitchedOut
) {
147 changeState(SimObject::Drained
);
150 changeState(SimObject::Draining
);
151 drainEvent
= drain_event
;
157 TimingSimpleCPU::resume()
159 DPRINTF(SimpleCPU
, "Resume\n");
160 if (_status
!= SwitchedOut
&& _status
!= Idle
) {
161 assert(system
->getMemoryMode() == Enums::timing
);
163 if (fetchEvent
.scheduled())
164 deschedule(fetchEvent
);
166 schedule(fetchEvent
, nextCycle());
169 changeState(SimObject::Running
);
173 TimingSimpleCPU::switchOut()
175 assert(_status
== Running
|| _status
== Idle
);
176 _status
= SwitchedOut
;
177 numCycles
+= tickToCycles(curTick
- previousTick
);
179 // If we've been scheduled to resume but are then told to switch out,
180 // we'll need to cancel it.
181 if (fetchEvent
.scheduled())
182 deschedule(fetchEvent
);
187 TimingSimpleCPU::takeOverFrom(BaseCPU
*oldCPU
)
189 BaseCPU::takeOverFrom(oldCPU
, &icachePort
, &dcachePort
);
191 // if any of this CPU's ThreadContexts are active, mark the CPU as
192 // running and schedule its tick event.
193 for (int i
= 0; i
< threadContexts
.size(); ++i
) {
194 ThreadContext
*tc
= threadContexts
[i
];
195 if (tc
->status() == ThreadContext::Active
&& _status
!= Running
) {
201 if (_status
!= Running
) {
204 assert(threadContexts
.size() == 1);
205 previousTick
= curTick
;
210 TimingSimpleCPU::activateContext(int thread_num
, int delay
)
212 DPRINTF(SimpleCPU
, "ActivateContext %d (%d cycles)\n", thread_num
, delay
);
214 assert(thread_num
== 0);
217 assert(_status
== Idle
);
222 // kick things off by initiating the fetch of the next instruction
223 schedule(fetchEvent
, nextCycle(curTick
+ ticks(delay
)));
228 TimingSimpleCPU::suspendContext(int thread_num
)
230 DPRINTF(SimpleCPU
, "SuspendContext %d\n", thread_num
);
232 assert(thread_num
== 0);
235 assert(_status
== 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
->isMmapedIpr()) {
250 delay
= TheISA::handleIprRead(thread
->getTC(), pkt
);
251 new IprEvent(pkt
, this, nextCycle(curTick
+ delay
));
252 _status
= DcacheWaitResponse
;
254 } else if (!dcachePort
.sendTiming(pkt
)) {
255 _status
= DcacheRetry
;
258 _status
= DcacheWaitResponse
;
259 // memory system takes ownership of packet
262 return dcache_pkt
== NULL
;
266 TimingSimpleCPU::buildSplitPacket(PacketPtr
&pkt1
, PacketPtr
&pkt2
,
267 RequestPtr
&req
, Addr split_addr
, uint8_t *data
, bool read
)
270 RequestPtr req1
, req2
;
271 assert(!req
->isLocked() && !req
->isSwap());
272 req
->splitOnVaddr(split_addr
, req1
, req2
);
275 if ((fault
= buildPacket(pkt1
, req1
, read
)) != NoFault
||
276 (fault
= buildPacket(pkt2
, req2
, read
)) != NoFault
) {
285 assert(!req1
->isMmapedIpr() && !req2
->isMmapedIpr());
287 req
->setPhys(req1
->getPaddr(), req
->getSize(), req1
->getFlags());
288 PacketPtr pkt
= new Packet(req
, pkt1
->cmd
.responseCommand(),
290 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
300 pkt
->dataDynamic
<uint8_t>(data
);
301 pkt1
->dataStatic
<uint8_t>(data
);
302 pkt2
->dataStatic
<uint8_t>(data
+ req1
->getSize());
304 SplitMainSenderState
* main_send_state
= new SplitMainSenderState
;
305 pkt
->senderState
= main_send_state
;
306 main_send_state
->fragments
[0] = pkt1
;
307 main_send_state
->fragments
[1] = pkt2
;
308 main_send_state
->outstanding
= 2;
309 pkt1
->senderState
= new SplitFragmentSenderState(pkt
, 0);
310 pkt2
->senderState
= new SplitFragmentSenderState(pkt
, 1);
315 TimingSimpleCPU::buildPacket(PacketPtr
&pkt
, RequestPtr
&req
, bool read
)
317 Fault fault
= thread
->dtb
->translateAtomic(req
, tc
, !read
);
319 if (fault
!= NoFault
) {
325 cmd
= MemCmd::ReadReq
;
327 cmd
= MemCmd::LoadLockedReq
;
329 cmd
= MemCmd::WriteReq
;
330 if (req
->isLocked()) {
331 cmd
= MemCmd::StoreCondReq
;
332 } else if (req
->isSwap()) {
333 cmd
= MemCmd::SwapReq
;
336 pkt
= new Packet(req
, cmd
, Packet::Broadcast
);
342 TimingSimpleCPU::read(Addr addr
, T
&data
, unsigned flags
)
346 const int thread_id
= 0;
347 const Addr pc
= thread
->readPC();
348 int block_size
= dcachePort
.peerBlockSize();
349 int data_size
= sizeof(T
);
352 RequestPtr req
= new Request(asid
, addr
, data_size
,
353 flags
, pc
, _cpuId
, thread_id
);
355 Addr split_addr
= roundDown(addr
+ data_size
- 1, block_size
);
356 assert(split_addr
<= addr
|| split_addr
- addr
< block_size
);
358 if (split_addr
> addr
) {
359 PacketPtr pkt1
, pkt2
;
360 Fault fault
= this->buildSplitPacket(pkt1
, pkt2
, req
,
361 split_addr
, (uint8_t *)(new T
), true);
362 if (fault
!= NoFault
)
364 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
366 } else if (handleReadPacket(pkt1
)) {
367 SplitFragmentSenderState
* send_state
=
368 dynamic_cast<SplitFragmentSenderState
*>(pkt1
->senderState
);
369 send_state
->clearFromParent();
370 if (handleReadPacket(pkt2
)) {
372 dynamic_cast<SplitFragmentSenderState
*>(pkt1
->senderState
);
373 send_state
->clearFromParent();
377 Fault fault
= buildPacket(pkt
, req
, true);
378 if (fault
!= NoFault
) {
381 if (req
->getFlags().isSet(Request::NO_ACCESS
)) {
384 pkt
->dataDynamic
<T
>(new T
);
385 handleReadPacket(pkt
);
390 traceData
->setData(data
);
391 traceData
->setAddr(addr
);
394 // This will need a new way to tell if it has a dcache attached.
395 if (req
->isUncacheable())
396 recordEvent("Uncached Read");
401 #ifndef DOXYGEN_SHOULD_SKIP_THIS
405 TimingSimpleCPU::read(Addr addr
, Twin64_t
&data
, unsigned flags
);
409 TimingSimpleCPU::read(Addr addr
, Twin32_t
&data
, unsigned flags
);
413 TimingSimpleCPU::read(Addr addr
, uint64_t &data
, unsigned flags
);
417 TimingSimpleCPU::read(Addr addr
, uint32_t &data
, unsigned flags
);
421 TimingSimpleCPU::read(Addr addr
, uint16_t &data
, unsigned flags
);
425 TimingSimpleCPU::read(Addr addr
, uint8_t &data
, unsigned flags
);
427 #endif //DOXYGEN_SHOULD_SKIP_THIS
431 TimingSimpleCPU::read(Addr addr
, double &data
, unsigned flags
)
433 return read(addr
, *(uint64_t*)&data
, flags
);
438 TimingSimpleCPU::read(Addr addr
, float &data
, unsigned flags
)
440 return read(addr
, *(uint32_t*)&data
, flags
);
446 TimingSimpleCPU::read(Addr addr
, int32_t &data
, unsigned flags
)
448 return read(addr
, (uint32_t&)data
, flags
);
452 TimingSimpleCPU::handleWritePacket()
454 RequestPtr req
= dcache_pkt
->req
;
455 if (req
->isMmapedIpr()) {
457 delay
= TheISA::handleIprWrite(thread
->getTC(), dcache_pkt
);
458 new IprEvent(dcache_pkt
, this, nextCycle(curTick
+ delay
));
459 _status
= DcacheWaitResponse
;
461 } else if (!dcachePort
.sendTiming(dcache_pkt
)) {
462 _status
= DcacheRetry
;
464 _status
= DcacheWaitResponse
;
465 // memory system takes ownership of packet
468 return dcache_pkt
== NULL
;
473 TimingSimpleCPU::write(T data
, Addr addr
, unsigned flags
, uint64_t *res
)
476 const int thread_id
= 0;
477 const Addr pc
= thread
->readPC();
478 int block_size
= dcachePort
.peerBlockSize();
479 int data_size
= sizeof(T
);
481 RequestPtr req
= new Request(asid
, addr
, data_size
,
482 flags
, pc
, _cpuId
, thread_id
);
484 Addr split_addr
= roundDown(addr
+ data_size
- 1, block_size
);
485 assert(split_addr
<= addr
|| split_addr
- addr
< block_size
);
487 if (split_addr
> addr
) {
488 PacketPtr pkt1
, pkt2
;
491 Fault fault
= this->buildSplitPacket(pkt1
, pkt2
, req
, split_addr
,
492 (uint8_t *)dataP
, false);
493 if (fault
!= NoFault
)
496 if (!req
->getFlags().isSet(Request::NO_ACCESS
)) {
497 if (handleWritePacket()) {
498 SplitFragmentSenderState
* send_state
=
499 dynamic_cast<SplitFragmentSenderState
*>(
501 send_state
->clearFromParent();
503 if (handleReadPacket(pkt2
)) {
505 dynamic_cast<SplitFragmentSenderState
*>(
507 send_state
->clearFromParent();
512 bool do_access
= true; // flag to suppress cache access
514 Fault fault
= buildPacket(dcache_pkt
, req
, false);
515 if (fault
!= NoFault
)
518 if (!req
->getFlags().isSet(Request::NO_ACCESS
)) {
519 if (req
->isLocked()) {
520 do_access
= TheISA::handleLockedWrite(thread
, req
);
521 } else if (req
->isCondSwap()) {
523 req
->setExtraData(*res
);
526 dcache_pkt
->allocate();
527 if (req
->isMmapedIpr())
528 dcache_pkt
->set(htog(data
));
530 dcache_pkt
->set(data
);
538 traceData
->setAddr(req
->getVaddr());
539 traceData
->setData(data
);
542 // This will need a new way to tell if it's hooked up to a cache or not.
543 if (req
->isUncacheable())
544 recordEvent("Uncached Write");
546 // If the write needs to have a fault on the access, consider calling
547 // changeStatus() and changing it to "bad addr write" or something.
552 #ifndef DOXYGEN_SHOULD_SKIP_THIS
555 TimingSimpleCPU::write(Twin32_t data
, Addr addr
,
556 unsigned flags
, uint64_t *res
);
560 TimingSimpleCPU::write(Twin64_t data
, Addr addr
,
561 unsigned flags
, uint64_t *res
);
565 TimingSimpleCPU::write(uint64_t data
, Addr addr
,
566 unsigned flags
, uint64_t *res
);
570 TimingSimpleCPU::write(uint32_t data
, Addr addr
,
571 unsigned flags
, uint64_t *res
);
575 TimingSimpleCPU::write(uint16_t data
, Addr addr
,
576 unsigned flags
, uint64_t *res
);
580 TimingSimpleCPU::write(uint8_t data
, Addr addr
,
581 unsigned flags
, uint64_t *res
);
583 #endif //DOXYGEN_SHOULD_SKIP_THIS
587 TimingSimpleCPU::write(double data
, Addr addr
, unsigned flags
, uint64_t *res
)
589 return write(*(uint64_t*)&data
, addr
, flags
, res
);
594 TimingSimpleCPU::write(float data
, Addr addr
, unsigned flags
, uint64_t *res
)
596 return write(*(uint32_t*)&data
, addr
, flags
, res
);
602 TimingSimpleCPU::write(int32_t data
, Addr addr
, unsigned flags
, uint64_t *res
)
604 return write((uint32_t)data
, addr
, flags
, res
);
609 TimingSimpleCPU::fetch()
611 DPRINTF(SimpleCPU
, "Fetch\n");
613 if (!curStaticInst
|| !curStaticInst
->isDelayedCommit())
614 checkForInterrupts();
618 bool fromRom
= isRomMicroPC(thread
->readMicroPC());
621 Request
*ifetch_req
= new Request();
622 ifetch_req
->setThreadContext(_cpuId
, /* thread ID */ 0);
623 Fault fault
= setupFetchRequest(ifetch_req
);
625 ifetch_pkt
= new Packet(ifetch_req
, MemCmd::ReadReq
, Packet::Broadcast
);
626 ifetch_pkt
->dataStatic(&inst
);
628 if (fault
== NoFault
) {
629 if (!icachePort
.sendTiming(ifetch_pkt
)) {
630 // Need to wait for retry
631 _status
= IcacheRetry
;
633 // Need to wait for cache to respond
634 _status
= IcacheWaitResponse
;
635 // ownership of packet transferred to memory system
641 // fetch fault: advance directly to next instruction (fault handler)
645 _status
= IcacheWaitResponse
;
646 completeIfetch(NULL
);
649 numCycles
+= tickToCycles(curTick
- previousTick
);
650 previousTick
= curTick
;
655 TimingSimpleCPU::advanceInst(Fault fault
)
657 if (fault
!= NoFault
|| !stayAtPC
)
660 if (_status
== Running
) {
661 // kick off fetch of next instruction... callback from icache
662 // response will cause that instruction to be executed,
663 // keeping the CPU running.
670 TimingSimpleCPU::completeIfetch(PacketPtr pkt
)
672 DPRINTF(SimpleCPU
, "Complete ICache Fetch\n");
674 // received a response from the icache: execute the received
677 assert(!pkt
|| !pkt
->isError());
678 assert(_status
== IcacheWaitResponse
);
682 numCycles
+= tickToCycles(curTick
- previousTick
);
683 previousTick
= curTick
;
685 if (getState() == SimObject::Draining
) {
697 curStaticInst
->isMemRef() && !curStaticInst
->isDataPrefetch()) {
698 // load or store: just send to dcache
699 Fault fault
= curStaticInst
->initiateAcc(this, traceData
);
700 if (_status
!= Running
) {
701 // instruction will complete in dcache response callback
702 assert(_status
== DcacheWaitResponse
|| _status
== DcacheRetry
);
703 assert(fault
== NoFault
);
705 if (fault
== NoFault
) {
706 // Note that ARM can have NULL packets if the instruction gets
707 // squashed due to predication
708 // early fail on store conditional: complete now
709 assert(dcache_pkt
!= NULL
|| THE_ISA
== ARM_ISA
);
711 fault
= curStaticInst
->completeAcc(dcache_pkt
, this,
713 if (dcache_pkt
!= NULL
)
715 delete dcache_pkt
->req
;
720 // keep an instruction count
721 if (fault
== NoFault
)
723 } else if (traceData
) {
724 // If there was a fault, we shouldn't trace this instruction.
730 // @todo remove me after debugging with legion done
731 if (curStaticInst
&& (!curStaticInst
->isMicroop() ||
732 curStaticInst
->isFirstMicroop()))
736 } else if (curStaticInst
) {
737 // non-memory instruction: execute completely now
738 Fault fault
= curStaticInst
->execute(this, traceData
);
740 // keep an instruction count
741 if (fault
== NoFault
)
743 else if (traceData
) {
744 // If there was a fault, we shouldn't trace this instruction.
750 // @todo remove me after debugging with legion done
751 if (curStaticInst
&& (!curStaticInst
->isMicroop() ||
752 curStaticInst
->isFirstMicroop()))
756 advanceInst(NoFault
);
766 TimingSimpleCPU::IcachePort::ITickEvent::process()
768 cpu
->completeIfetch(pkt
);
772 TimingSimpleCPU::IcachePort::recvTiming(PacketPtr pkt
)
774 if (pkt
->isResponse() && !pkt
->wasNacked()) {
775 // delay processing of returned data until next CPU clock edge
776 Tick next_tick
= cpu
->nextCycle(curTick
);
778 if (next_tick
== curTick
)
779 cpu
->completeIfetch(pkt
);
781 tickEvent
.schedule(pkt
, next_tick
);
785 else if (pkt
->wasNacked()) {
786 assert(cpu
->_status
== IcacheWaitResponse
);
788 if (!sendTiming(pkt
)) {
789 cpu
->_status
= IcacheRetry
;
790 cpu
->ifetch_pkt
= pkt
;
793 //Snooping a Coherence Request, do nothing
798 TimingSimpleCPU::IcachePort::recvRetry()
800 // we shouldn't get a retry unless we have a packet that we're
801 // waiting to transmit
802 assert(cpu
->ifetch_pkt
!= NULL
);
803 assert(cpu
->_status
== IcacheRetry
);
804 PacketPtr tmp
= cpu
->ifetch_pkt
;
805 if (sendTiming(tmp
)) {
806 cpu
->_status
= IcacheWaitResponse
;
807 cpu
->ifetch_pkt
= NULL
;
812 TimingSimpleCPU::completeDataAccess(PacketPtr pkt
)
814 // received a response from the dcache: complete the load or store
816 assert(!pkt
->isError());
818 numCycles
+= tickToCycles(curTick
- previousTick
);
819 previousTick
= curTick
;
821 if (pkt
->senderState
) {
822 SplitFragmentSenderState
* send_state
=
823 dynamic_cast<SplitFragmentSenderState
*>(pkt
->senderState
);
827 PacketPtr big_pkt
= send_state
->bigPkt
;
830 SplitMainSenderState
* main_send_state
=
831 dynamic_cast<SplitMainSenderState
*>(big_pkt
->senderState
);
832 assert(main_send_state
);
833 // Record the fact that this packet is no longer outstanding.
834 assert(main_send_state
->outstanding
!= 0);
835 main_send_state
->outstanding
--;
837 if (main_send_state
->outstanding
) {
840 delete main_send_state
;
841 big_pkt
->senderState
= NULL
;
846 assert(_status
== DcacheWaitResponse
);
849 Fault fault
= curStaticInst
->completeAcc(pkt
, this, traceData
);
851 // keep an instruction count
852 if (fault
== NoFault
)
854 else if (traceData
) {
855 // If there was a fault, we shouldn't trace this instruction.
860 // the locked flag may be cleared on the response packet, so check
861 // pkt->req and not pkt to see if it was a load-locked
862 if (pkt
->isRead() && pkt
->req
->isLocked()) {
863 TheISA::handleLockedRead(thread
, pkt
->req
);
871 if (getState() == SimObject::Draining
) {
883 TimingSimpleCPU::completeDrain()
885 DPRINTF(Config
, "Done draining\n");
886 changeState(SimObject::Drained
);
887 drainEvent
->process();
891 TimingSimpleCPU::DcachePort::setPeer(Port
*port
)
896 // Update the ThreadContext's memory ports (Functional/Virtual
898 cpu
->tcBase()->connectMemPorts(cpu
->tcBase());
903 TimingSimpleCPU::DcachePort::recvTiming(PacketPtr pkt
)
905 if (pkt
->isResponse() && !pkt
->wasNacked()) {
906 // delay processing of returned data until next CPU clock edge
907 Tick next_tick
= cpu
->nextCycle(curTick
);
909 if (next_tick
== curTick
) {
910 cpu
->completeDataAccess(pkt
);
912 tickEvent
.schedule(pkt
, next_tick
);
917 else if (pkt
->wasNacked()) {
918 assert(cpu
->_status
== DcacheWaitResponse
);
920 if (!sendTiming(pkt
)) {
921 cpu
->_status
= DcacheRetry
;
922 cpu
->dcache_pkt
= pkt
;
925 //Snooping a Coherence Request, do nothing
930 TimingSimpleCPU::DcachePort::DTickEvent::process()
932 cpu
->completeDataAccess(pkt
);
936 TimingSimpleCPU::DcachePort::recvRetry()
938 // we shouldn't get a retry unless we have a packet that we're
939 // waiting to transmit
940 assert(cpu
->dcache_pkt
!= NULL
);
941 assert(cpu
->_status
== DcacheRetry
);
942 PacketPtr tmp
= cpu
->dcache_pkt
;
943 if (tmp
->senderState
) {
944 // This is a packet from a split access.
945 SplitFragmentSenderState
* send_state
=
946 dynamic_cast<SplitFragmentSenderState
*>(tmp
->senderState
);
948 PacketPtr big_pkt
= send_state
->bigPkt
;
950 SplitMainSenderState
* main_send_state
=
951 dynamic_cast<SplitMainSenderState
*>(big_pkt
->senderState
);
952 assert(main_send_state
);
954 if (sendTiming(tmp
)) {
955 // If we were able to send without retrying, record that fact
956 // and try sending the other fragment.
957 send_state
->clearFromParent();
958 int other_index
= main_send_state
->getPendingFragment();
959 if (other_index
> 0) {
960 tmp
= main_send_state
->fragments
[other_index
];
961 cpu
->dcache_pkt
= tmp
;
962 if ((big_pkt
->isRead() && cpu
->handleReadPacket(tmp
)) ||
963 (big_pkt
->isWrite() && cpu
->handleWritePacket())) {
964 main_send_state
->fragments
[other_index
] = NULL
;
967 cpu
->_status
= DcacheWaitResponse
;
968 // memory system takes ownership of packet
969 cpu
->dcache_pkt
= NULL
;
972 } else if (sendTiming(tmp
)) {
973 cpu
->_status
= DcacheWaitResponse
;
974 // memory system takes ownership of packet
975 cpu
->dcache_pkt
= NULL
;
979 TimingSimpleCPU::IprEvent::IprEvent(Packet
*_pkt
, TimingSimpleCPU
*_cpu
,
981 : pkt(_pkt
), cpu(_cpu
)
983 cpu
->schedule(this, t
);
987 TimingSimpleCPU::IprEvent::process()
989 cpu
->completeDataAccess(pkt
);
993 TimingSimpleCPU::IprEvent::description() const
995 return "Timing Simple CPU Delay IPR event";
1000 TimingSimpleCPU::printAddr(Addr a
)
1002 dcachePort
.printAddr(a
);
1006 ////////////////////////////////////////////////////////////////////////
1008 // TimingSimpleCPU Simulation Object
1011 TimingSimpleCPUParams::create()
1015 if (workload
.size() != 1)
1016 panic("only one workload allowed");
1018 return new TimingSimpleCPU(this);