1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 *
28 * Authors: Steve Reinhardt
29 */
30
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/atomic.hh"
37#include "mem/packet.hh"
38#include "mem/packet_access.hh"
39#include "params/AtomicSimpleCPU.hh"
40#include "sim/system.hh"
41
42using namespace std;
43using namespace TheISA;
44
45AtomicSimpleCPU::TickEvent::TickEvent(AtomicSimpleCPU *c)
46 : Event(CPU_Tick_Pri), cpu(c)
47{
48}
49
50
51void
52AtomicSimpleCPU::TickEvent::process()
53{
54 cpu->tick();
55}
56
57const char *
58AtomicSimpleCPU::TickEvent::description() const
59{
60 return "AtomicSimpleCPU tick";
61}
62
63Port *
64AtomicSimpleCPU::getPort(const std::string &if_name, int idx)
65{
66 if (if_name == "dcache_port")
67 return &dcachePort;
68 else if (if_name == "icache_port")
69 return &icachePort;
70 else if (if_name == "physmem_port") {
71 hasPhysMemPort = true;
72 return &physmemPort;
73 }
74 else
75 panic("No Such Port\n");
76}
77
78void
79AtomicSimpleCPU::init()
80{
81 BaseCPU::init();
82 cpuId = tc->readCpuId();
82#if FULL_SYSTEM
83 for (int i = 0; i < threadContexts.size(); ++i) {
84 ThreadContext *tc = threadContexts[i];
85
86 // initialize CPU, including PC
88 TheISA::initCPU(tc, cpuId);
87 TheISA::initCPU(tc, _cpuId);
88 }
89#endif
90 if (hasPhysMemPort) {
91 bool snoop = false;
92 AddrRangeList pmAddrList;
93 physmemPort.getPeerAddressRanges(pmAddrList, snoop);
94 physMemAddr = *pmAddrList.begin();
95 }
97 ifetch_req.setThreadContext(cpuId, 0); // Add thread ID if we add MT
98 data_read_req.setThreadContext(cpuId, 0); // Add thread ID here too
99 data_write_req.setThreadContext(cpuId, 0); // Add thread ID here too
96 ifetch_req.setThreadContext(_cpuId, 0); // Add thread ID if we add MT
97 data_read_req.setThreadContext(_cpuId, 0); // Add thread ID here too
98 data_write_req.setThreadContext(_cpuId, 0); // Add thread ID here too
99}
100
101bool
102AtomicSimpleCPU::CpuPort::recvTiming(PacketPtr pkt)
103{
104 panic("AtomicSimpleCPU doesn't expect recvTiming callback!");
105 return true;
106}
107
108Tick
109AtomicSimpleCPU::CpuPort::recvAtomic(PacketPtr pkt)
110{
111 //Snooping a coherence request, just return
112 return 0;
113}
114
115void
116AtomicSimpleCPU::CpuPort::recvFunctional(PacketPtr pkt)
117{
118 //No internal storage to update, just return
119 return;
120}
121
122void
123AtomicSimpleCPU::CpuPort::recvStatusChange(Status status)
124{
125 if (status == RangeChange) {
126 if (!snoopRangeSent) {
127 snoopRangeSent = true;
128 sendStatusChange(Port::RangeChange);
129 }
130 return;
131 }
132
133 panic("AtomicSimpleCPU doesn't expect recvStatusChange callback!");
134}
135
136void
137AtomicSimpleCPU::CpuPort::recvRetry()
138{
139 panic("AtomicSimpleCPU doesn't expect recvRetry callback!");
140}
141
142void
143AtomicSimpleCPU::DcachePort::setPeer(Port *port)
144{
145 Port::setPeer(port);
146
147#if FULL_SYSTEM
148 // Update the ThreadContext's memory ports (Functional/Virtual
149 // Ports)
150 cpu->tcBase()->connectMemPorts(cpu->tcBase());
151#endif
152}
153
154AtomicSimpleCPU::AtomicSimpleCPU(AtomicSimpleCPUParams *p)
155 : BaseSimpleCPU(p), tickEvent(this), width(p->width),
156 simulate_data_stalls(p->simulate_data_stalls),
157 simulate_inst_stalls(p->simulate_inst_stalls),
158 icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this),
159 physmemPort(name() + "-iport", this), hasPhysMemPort(false)
160{
161 _status = Idle;
162
163 icachePort.snoopRangeSent = false;
164 dcachePort.snoopRangeSent = false;
165
166}
167
168
169AtomicSimpleCPU::~AtomicSimpleCPU()
170{
171}
172
173void
174AtomicSimpleCPU::serialize(ostream &os)
175{
176 SimObject::State so_state = SimObject::getState();
177 SERIALIZE_ENUM(so_state);
178 BaseSimpleCPU::serialize(os);
179 nameOut(os, csprintf("%s.tickEvent", name()));
180 tickEvent.serialize(os);
181}
182
183void
184AtomicSimpleCPU::unserialize(Checkpoint *cp, const string &section)
185{
186 SimObject::State so_state;
187 UNSERIALIZE_ENUM(so_state);
188 BaseSimpleCPU::unserialize(cp, section);
189 tickEvent.unserialize(cp, csprintf("%s.tickEvent", section));
190}
191
192void
193AtomicSimpleCPU::resume()
194{
195 if (_status == Idle || _status == SwitchedOut)
196 return;
197
198 DPRINTF(SimpleCPU, "Resume\n");
199 assert(system->getMemoryMode() == Enums::atomic);
200
201 changeState(SimObject::Running);
202 if (thread->status() == ThreadContext::Active) {
203 if (!tickEvent.scheduled())
204 schedule(tickEvent, nextCycle());
205 }
206}
207
208void
209AtomicSimpleCPU::switchOut()
210{
211 assert(_status == Running || _status == Idle);
212 _status = SwitchedOut;
213
214 tickEvent.squash();
215}
216
217
218void
219AtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
220{
221 BaseCPU::takeOverFrom(oldCPU, &icachePort, &dcachePort);
222
223 assert(!tickEvent.scheduled());
224
225 // if any of this CPU's ThreadContexts are active, mark the CPU as
226 // running and schedule its tick event.
227 for (int i = 0; i < threadContexts.size(); ++i) {
228 ThreadContext *tc = threadContexts[i];
229 if (tc->status() == ThreadContext::Active && _status != Running) {
230 _status = Running;
231 schedule(tickEvent, nextCycle());
232 break;
233 }
234 }
235 if (_status != Running) {
236 _status = Idle;
237 }
238 assert(threadContexts.size() == 1);
240 cpuId = tc->readCpuId();
241 ifetch_req.setThreadContext(cpuId, 0); // Add thread ID if we add MT
242 data_read_req.setThreadContext(cpuId, 0); // Add thread ID here too
243 data_write_req.setThreadContext(cpuId, 0); // Add thread ID here too
239 ifetch_req.setThreadContext(_cpuId, 0); // Add thread ID if we add MT
240 data_read_req.setThreadContext(_cpuId, 0); // Add thread ID here too
241 data_write_req.setThreadContext(_cpuId, 0); // Add thread ID here too
242}
243
244
245void
246AtomicSimpleCPU::activateContext(int thread_num, int delay)
247{
248 DPRINTF(SimpleCPU, "ActivateContext %d (%d cycles)\n", thread_num, delay);
249
250 assert(thread_num == 0);
251 assert(thread);
252
253 assert(_status == Idle);
254 assert(!tickEvent.scheduled());
255
256 notIdleFraction++;
257 numCycles += tickToCycles(thread->lastActivate - thread->lastSuspend);
258
259 //Make sure ticks are still on multiples of cycles
260 schedule(tickEvent, nextCycle(curTick + ticks(delay)));
261 _status = Running;
262}
263
264
265void
266AtomicSimpleCPU::suspendContext(int thread_num)
267{
268 DPRINTF(SimpleCPU, "SuspendContext %d\n", thread_num);
269
270 assert(thread_num == 0);
271 assert(thread);
272
273 assert(_status == Running);
274
275 // tick event may not be scheduled if this gets called from inside
276 // an instruction's execution, e.g. "quiesce"
277 if (tickEvent.scheduled())
278 deschedule(tickEvent);
279
280 notIdleFraction--;
281 _status = Idle;
282}
283
284
285template <class T>
286Fault
287AtomicSimpleCPU::read(Addr addr, T &data, unsigned flags)
288{
289 // use the CPU's statically allocated read request and packet objects
290 Request *req = &data_read_req;
291
292 if (traceData) {
293 traceData->setAddr(addr);
294 }
295
296 //The block size of our peer.
297 int blockSize = dcachePort.peerBlockSize();
298 //The size of the data we're trying to read.
299 int dataSize = sizeof(T);
300
301 uint8_t * dataPtr = (uint8_t *)&data;
302
303 //The address of the second part of this access if it needs to be split
304 //across a cache line boundary.
305 Addr secondAddr = roundDown(addr + dataSize - 1, blockSize);
306
307 if(secondAddr > addr)
308 dataSize = secondAddr - addr;
309
310 dcache_latency = 0;
311
312 while(1) {
313 req->setVirt(0, addr, dataSize, flags, thread->readPC());
314
315 // translate to physical address
316 Fault fault = thread->translateDataReadReq(req);
317
318 // Now do the access.
319 if (fault == NoFault) {
320 Packet pkt = Packet(req,
321 req->isLocked() ? MemCmd::LoadLockedReq : MemCmd::ReadReq,
322 Packet::Broadcast);
323 pkt.dataStatic(dataPtr);
324
325 if (req->isMmapedIpr())
326 dcache_latency += TheISA::handleIprRead(thread->getTC(), &pkt);
327 else {
328 if (hasPhysMemPort && pkt.getAddr() == physMemAddr)
329 dcache_latency += physmemPort.sendAtomic(&pkt);
330 else
331 dcache_latency += dcachePort.sendAtomic(&pkt);
332 }
333 dcache_access = true;
334
335 assert(!pkt.isError());
336
337 if (req->isLocked()) {
338 TheISA::handleLockedRead(thread, req);
339 }
340 }
341
342 // This will need a new way to tell if it has a dcache attached.
343 if (req->isUncacheable())
344 recordEvent("Uncached Read");
345
346 //If there's a fault, return it
347 if (fault != NoFault)
348 return fault;
349 //If we don't need to access a second cache line, stop now.
350 if (secondAddr <= addr)
351 {
352 data = gtoh(data);
353 if (traceData) {
354 traceData->setData(data);
355 }
356 return fault;
357 }
358
359 /*
360 * Set up for accessing the second cache line.
361 */
362
363 //Move the pointer we're reading into to the correct location.
364 dataPtr += dataSize;
365 //Adjust the size to get the remaining bytes.
366 dataSize = addr + sizeof(T) - secondAddr;
367 //And access the right address.
368 addr = secondAddr;
369 }
370}
371
372Fault
373AtomicSimpleCPU::translateDataReadAddr(Addr vaddr, Addr & paddr,
374 int size, unsigned flags)
375{
376 // use the CPU's statically allocated read request and packet objects
377 Request *req = &data_read_req;
378
379 if (traceData) {
380 traceData->setAddr(vaddr);
381 }
382
383 //The block size of our peer.
384 int blockSize = dcachePort.peerBlockSize();
385 //The size of the data we're trying to read.
386 int dataSize = size;
387
388 bool firstTimeThrough = true;
389
390 //The address of the second part of this access if it needs to be split
391 //across a cache line boundary.
392 Addr secondAddr = roundDown(vaddr + dataSize - 1, blockSize);
393
394 if(secondAddr > vaddr)
395 dataSize = secondAddr - vaddr;
396
397 while(1) {
398 req->setVirt(0, vaddr, dataSize, flags, thread->readPC());
399
400 // translate to physical address
401 Fault fault = thread->translateDataReadReq(req);
402
403 //If there's a fault, return it
404 if (fault != NoFault)
405 return fault;
406
407 if (firstTimeThrough) {
408 paddr = req->getPaddr();
409 firstTimeThrough = false;
410 }
411
412 //If we don't need to access a second cache line, stop now.
413 if (secondAddr <= vaddr)
414 return fault;
415
416 /*
417 * Set up for accessing the second cache line.
418 */
419
420 //Adjust the size to get the remaining bytes.
421 dataSize = vaddr + size - secondAddr;
422 //And access the right address.
423 vaddr = secondAddr;
424 }
425}
426
427#ifndef DOXYGEN_SHOULD_SKIP_THIS
428
429template
430Fault
431AtomicSimpleCPU::read(Addr addr, Twin32_t &data, unsigned flags);
432
433template
434Fault
435AtomicSimpleCPU::read(Addr addr, Twin64_t &data, unsigned flags);
436
437template
438Fault
439AtomicSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags);
440
441template
442Fault
443AtomicSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags);
444
445template
446Fault
447AtomicSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags);
448
449template
450Fault
451AtomicSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags);
452
453#endif //DOXYGEN_SHOULD_SKIP_THIS
454
455template<>
456Fault
457AtomicSimpleCPU::read(Addr addr, double &data, unsigned flags)
458{
459 return read(addr, *(uint64_t*)&data, flags);
460}
461
462template<>
463Fault
464AtomicSimpleCPU::read(Addr addr, float &data, unsigned flags)
465{
466 return read(addr, *(uint32_t*)&data, flags);
467}
468
469
470template<>
471Fault
472AtomicSimpleCPU::read(Addr addr, int32_t &data, unsigned flags)
473{
474 return read(addr, (uint32_t&)data, flags);
475}
476
477
478template <class T>
479Fault
480AtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
481{
482 // use the CPU's statically allocated write request and packet objects
483 Request *req = &data_write_req;
484
485 if (traceData) {
486 traceData->setAddr(addr);
487 }
488
489 //The block size of our peer.
490 int blockSize = dcachePort.peerBlockSize();
491 //The size of the data we're trying to read.
492 int dataSize = sizeof(T);
493
494 uint8_t * dataPtr = (uint8_t *)&data;
495
496 //The address of the second part of this access if it needs to be split
497 //across a cache line boundary.
498 Addr secondAddr = roundDown(addr + dataSize - 1, blockSize);
499
500 if(secondAddr > addr)
501 dataSize = secondAddr - addr;
502
503 dcache_latency = 0;
504
505 while(1) {
506 req->setVirt(0, addr, dataSize, flags, thread->readPC());
507
508 // translate to physical address
509 Fault fault = thread->translateDataWriteReq(req);
510
511 // Now do the access.
512 if (fault == NoFault) {
513 MemCmd cmd = MemCmd::WriteReq; // default
514 bool do_access = true; // flag to suppress cache access
515
516 if (req->isLocked()) {
517 cmd = MemCmd::StoreCondReq;
518 do_access = TheISA::handleLockedWrite(thread, req);
519 } else if (req->isSwap()) {
520 cmd = MemCmd::SwapReq;
521 if (req->isCondSwap()) {
522 assert(res);
523 req->setExtraData(*res);
524 }
525 }
526
527 if (do_access) {
528 Packet pkt = Packet(req, cmd, Packet::Broadcast);
529 pkt.dataStatic(dataPtr);
530
531 if (req->isMmapedIpr()) {
532 dcache_latency +=
533 TheISA::handleIprWrite(thread->getTC(), &pkt);
534 } else {
535 //XXX This needs to be outside of the loop in order to
536 //work properly for cache line boundary crossing
537 //accesses in transendian simulations.
538 data = htog(data);
539 if (hasPhysMemPort && pkt.getAddr() == physMemAddr)
540 dcache_latency += physmemPort.sendAtomic(&pkt);
541 else
542 dcache_latency += dcachePort.sendAtomic(&pkt);
543 }
544 dcache_access = true;
545 assert(!pkt.isError());
546
547 if (req->isSwap()) {
548 assert(res);
549 *res = pkt.get<T>();
550 }
551 }
552
553 if (res && !req->isSwap()) {
554 *res = req->getExtraData();
555 }
556 }
557
558 // This will need a new way to tell if it's hooked up to a cache or not.
559 if (req->isUncacheable())
560 recordEvent("Uncached Write");
561
562 //If there's a fault or we don't need to access a second cache line,
563 //stop now.
564 if (fault != NoFault || secondAddr <= addr)
565 {
566 // If the write needs to have a fault on the access, consider
567 // calling changeStatus() and changing it to "bad addr write"
568 // or something.
569 if (traceData) {
570 traceData->setData(data);
571 }
572 return fault;
573 }
574
575 /*
576 * Set up for accessing the second cache line.
577 */
578
579 //Move the pointer we're reading into to the correct location.
580 dataPtr += dataSize;
581 //Adjust the size to get the remaining bytes.
582 dataSize = addr + sizeof(T) - secondAddr;
583 //And access the right address.
584 addr = secondAddr;
585 }
586}
587
588Fault
589AtomicSimpleCPU::translateDataWriteAddr(Addr vaddr, Addr &paddr,
590 int size, unsigned flags)
591{
592 // use the CPU's statically allocated write request and packet objects
593 Request *req = &data_write_req;
594
595 if (traceData) {
596 traceData->setAddr(vaddr);
597 }
598
599 //The block size of our peer.
600 int blockSize = dcachePort.peerBlockSize();
601
602 //The address of the second part of this access if it needs to be split
603 //across a cache line boundary.
604 Addr secondAddr = roundDown(vaddr + size - 1, blockSize);
605
606 //The size of the data we're trying to read.
607 int dataSize = size;
608
609 bool firstTimeThrough = true;
610
611 if(secondAddr > vaddr)
612 dataSize = secondAddr - vaddr;
613
614 dcache_latency = 0;
615
616 while(1) {
617 req->setVirt(0, vaddr, dataSize, flags, thread->readPC());
618
619 // translate to physical address
620 Fault fault = thread->translateDataWriteReq(req);
621
622 //If there's a fault or we don't need to access a second cache line,
623 //stop now.
624 if (fault != NoFault)
625 return fault;
626
627 if (firstTimeThrough) {
628 paddr = req->getPaddr();
629 firstTimeThrough = false;
630 }
631
632 if (secondAddr <= vaddr)
633 return fault;
634
635 /*
636 * Set up for accessing the second cache line.
637 */
638
639 //Adjust the size to get the remaining bytes.
640 dataSize = vaddr + size - secondAddr;
641 //And access the right address.
642 vaddr = secondAddr;
643 }
644}
645
646
647#ifndef DOXYGEN_SHOULD_SKIP_THIS
648
649template
650Fault
651AtomicSimpleCPU::write(Twin32_t data, Addr addr,
652 unsigned flags, uint64_t *res);
653
654template
655Fault
656AtomicSimpleCPU::write(Twin64_t data, Addr addr,
657 unsigned flags, uint64_t *res);
658
659template
660Fault
661AtomicSimpleCPU::write(uint64_t data, Addr addr,
662 unsigned flags, uint64_t *res);
663
664template
665Fault
666AtomicSimpleCPU::write(uint32_t data, Addr addr,
667 unsigned flags, uint64_t *res);
668
669template
670Fault
671AtomicSimpleCPU::write(uint16_t data, Addr addr,
672 unsigned flags, uint64_t *res);
673
674template
675Fault
676AtomicSimpleCPU::write(uint8_t data, Addr addr,
677 unsigned flags, uint64_t *res);
678
679#endif //DOXYGEN_SHOULD_SKIP_THIS
680
681template<>
682Fault
683AtomicSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res)
684{
685 return write(*(uint64_t*)&data, addr, flags, res);
686}
687
688template<>
689Fault
690AtomicSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res)
691{
692 return write(*(uint32_t*)&data, addr, flags, res);
693}
694
695
696template<>
697Fault
698AtomicSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res)
699{
700 return write((uint32_t)data, addr, flags, res);
701}
702
703
704void
705AtomicSimpleCPU::tick()
706{
707 DPRINTF(SimpleCPU, "Tick\n");
708
709 Tick latency = 0;
710
711 for (int i = 0; i < width; ++i) {
712 numCycles++;
713
714 if (!curStaticInst || !curStaticInst->isDelayedCommit())
715 checkForInterrupts();
716
717 checkPcEventQueue();
718
719 Fault fault = NoFault;
720
721 bool fromRom = isRomMicroPC(thread->readMicroPC());
722 if (!fromRom)
723 fault = setupFetchRequest(&ifetch_req);
724
725 if (fault == NoFault) {
726 Tick icache_latency = 0;
727 bool icache_access = false;
728 dcache_access = false; // assume no dcache access
729
730 if (!fromRom) {
731 // This is commented out because the predecoder would act like
732 // a tiny cache otherwise. It wouldn't be flushed when needed
733 // like the I cache. It should be flushed, and when that works
734 // this code should be uncommented.
735 //Fetch more instruction memory if necessary
736 //if(predecoder.needMoreBytes())
737 //{
738 icache_access = true;
739 Packet ifetch_pkt = Packet(&ifetch_req, MemCmd::ReadReq,
740 Packet::Broadcast);
741 ifetch_pkt.dataStatic(&inst);
742
743 if (hasPhysMemPort && ifetch_pkt.getAddr() == physMemAddr)
744 icache_latency = physmemPort.sendAtomic(&ifetch_pkt);
745 else
746 icache_latency = icachePort.sendAtomic(&ifetch_pkt);
747
748 assert(!ifetch_pkt.isError());
749
750 // ifetch_req is initialized to read the instruction directly
751 // into the CPU object's inst field.
752 //}
753 }
754
755 preExecute();
756
757 if (curStaticInst) {
758 fault = curStaticInst->execute(this, traceData);
759
760 // keep an instruction count
761 if (fault == NoFault)
762 countInst();
763 else if (traceData) {
764 // If there was a fault, we should trace this instruction.
765 delete traceData;
766 traceData = NULL;
767 }
768
769 postExecute();
770 }
771
772 // @todo remove me after debugging with legion done
773 if (curStaticInst && (!curStaticInst->isMicroop() ||
774 curStaticInst->isFirstMicroop()))
775 instCnt++;
776
777 Tick stall_ticks = 0;
778 if (simulate_inst_stalls && icache_access)
779 stall_ticks += icache_latency;
780
781 if (simulate_data_stalls && dcache_access)
782 stall_ticks += dcache_latency;
783
784 if (stall_ticks) {
785 Tick stall_cycles = stall_ticks / ticks(1);
786 Tick aligned_stall_ticks = ticks(stall_cycles);
787
788 if (aligned_stall_ticks < stall_ticks)
789 aligned_stall_ticks += 1;
790
791 latency += aligned_stall_ticks;
792 }
793
794 }
795 if(fault != NoFault || !stayAtPC)
796 advancePC(fault);
797 }
798
799 // instruction takes at least one cycle
800 if (latency < ticks(1))
801 latency = ticks(1);
802
803 if (_status != Idle)
804 schedule(tickEvent, curTick + latency);
805}
806
807
808void
809AtomicSimpleCPU::printAddr(Addr a)
810{
811 dcachePort.printAddr(a);
812}
813
814
815////////////////////////////////////////////////////////////////////////
816//
817// AtomicSimpleCPU Simulation Object
818//
819AtomicSimpleCPU *
820AtomicSimpleCPUParams::create()
821{
822 numThreads = 1;
823#if !FULL_SYSTEM
824 if (workload.size() != 1)
825 panic("only one workload allowed");
826#endif
827 return new AtomicSimpleCPU(this);
828}