46 #ifndef __CPU_BASE_HH__
47 #define __CPU_BASE_HH__
53 #include "config/the_isa.hh"
54 #if THE_ISA == NULL_ISA
57 #include "arch/interrupts.hh"
58 #include "arch/isa_traits.hh"
59 #include "arch/microcode_rom.hh"
67 #include "debug/Mwait.hh"
87 class CPUProgressEvent :
public Event
100 void interval(
Tick ival) { _interval = ival; }
101 Tick interval() {
return _interval; }
103 void repeatEvent(
bool repeat) { _repeatEvent = repeat; }
127 const uint32_t _socketId;
150 const unsigned int _cacheLineSize;
171 int cpuId()
const {
return _cpuId; }
174 uint32_t socketId()
const {
return _socketId; }
177 MasterID dataMasterId() {
return _dataMasterId; }
179 MasterID instMasterId() {
return _instMasterId; }
195 uint32_t taskId()
const {
return _taskId; }
197 void taskId(uint32_t
id) { _taskId =
id; }
199 uint32_t getPid()
const {
return _pid; }
200 void setPid(uint32_t pid) { _pid = pid; }
202 inline void workItemBegin() { numWorkItemsStarted++; }
203 inline void workItemEnd() { numWorkItemsCompleted++; }
205 Tick instCount() {
return instCnt; }
207 TheISA::MicrocodeRom microcodeRom;
214 getInterruptController(
ThreadID tid)
216 if (interrupts.empty())
219 assert(interrupts.size() > tid);
220 return interrupts[tid];
228 interrupts[tid]->post(int_num, index);
234 clearInterrupt(
ThreadID tid,
int int_num,
int index)
236 interrupts[tid]->clear(int_num, index);
242 interrupts[tid]->clearAll();
251 class ProfileEvent :
public Event
261 ProfileEvent *profileEvent;
273 static const uint32_t invldPid = std::numeric_limits<uint32_t>::max();
282 virtual void activateContext(
ThreadID thread_num);
286 virtual void suspendContext(
ThreadID thread_num);
289 virtual void haltContext(
ThreadID thread_num) {}
295 virtual ThreadContext *getContext(
int tn) {
return threadContexts[tn]; }
298 unsigned numContexts() {
return threadContexts.size(); }
302 {
return static_cast<ThreadID>(cid - threadContexts[0]->contextId()); }
305 typedef BaseCPUParams Params;
306 const Params *params()
const
307 {
return reinterpret_cast<const Params *
>(_params); }
308 BaseCPU(Params *params,
bool is_checker =
false);
311 void init()
override;
312 void startup()
override;
313 void regStats()
override;
315 void regProbePoints()
override;
317 void registerThreadContexts();
326 virtual void switchOut();
357 bool switchedOut()
const {
return _switchedOut; }
368 virtual void verifyMemoryMode()
const { };
395 inline unsigned int cacheLineSize()
const {
return _cacheLineSize; }
439 virtual Counter totalInsts()
const = 0;
441 virtual Counter totalOps()
const = 0;
480 uint64_t getCurrentInstCount(
ThreadID tid);
532 bool functionTracingEnabled;
533 std::ostream *functionTraceStream;
534 Addr currentFunctionStart;
535 Addr currentFunctionEnd;
536 Tick functionEntryTick;
537 void enableFunctionTrace();
538 void traceFunctionsInternal(
Addr pc);
544 void traceFunctions(
Addr pc)
546 if (functionTracingEnabled)
547 traceFunctionsInternal(pc);
550 static int numSimulatedCPUs() {
return cpuList.size(); }
555 int size = cpuList.size();
557 total += cpuList[
i]->totalInsts();
566 int size = cpuList.size();
568 total += cpuList[
i]->totalOps();
586 AddressMonitor *getCpuAddrMonitor(
ThreadID tid)
588 assert(tid < numThreads);
589 return &addressMonitor[tid];
592 Cycles syscallRetryLatency;
595 #endif // THE_ISA == NULL_ISA
597 #endif // __CPU_BASE_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Cycles is a wrapper class for representing cycle counts, i.e.
const std::string & name()
const PortID InvalidPortID
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
If you want a reference counting pointer to a mutable object, create it like this: ...
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
static int numSimulatedOps()
Queue of events sorted in time order.
std::unique_ptr< PMU > PMUUPtr
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
uint64_t Tick
Tick count type.
static void wakeup(ThreadID tid)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int64_t Counter
Statistics counter type.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
const FlagsType total
Print the total.
int16_t ThreadID
Thread index/ID type.
std::ostream CheckpointOut
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
virtual int threadId() const =0
A BaseMasterPort is a protocol-agnostic master port, responsible only for the structural connection t...
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
void serialize(CheckpointOut &cp) const override
void unserialize(CheckpointIn &cp) override
virtual const char * description() const
Return a C string describing the event.
int ContextID
Globally unique thread context ID.
const FlagsType init
This Stat is Initialized.
static int numSimulatedInsts()