43 #ifndef __CPU_O3_CPU_HH__ 44 #define __CPU_O3_CPU_HH__ 53 #include "arch/types.hh" 55 #include "config/the_isa.hh" 65 #include "params/DerivO3CPU.hh" 176 void drainSanityCheck()
const;
179 bool isCpuDrained()
const;
218 void init()
override;
224 {
return activeThreads.size(); }
230 void deactivateThread(
ThreadID tid);
256 void updateThreadPriority();
265 void addThreadToExitingList(
ThreadID tid);
268 bool isThreadExiting(
ThreadID tid)
const;
274 void scheduleThreadExitEvent(
ThreadID tid);
311 {
return globalSeqNum++; }
320 void setVectorsAsReady(
ThreadID tid);
331 Fault getInterrupts();
334 void processInterrupts(
const Fault &interrupt);
373 { vecMode = vec_mode; }
378 template<
typename VecElem,
int LaneIdx>
383 return regFile.readVecLane<
VecElem, LaneIdx>(phys_reg);
389 template<
typename VecElem>
394 return regFile.readVecLane<
VecElem>(phys_reg);
398 template<
typename LD>
403 return regFile.setVecLane(phys_reg, val);
435 template<
typename VecElem>
441 return readVecLane<VecElem>(phys_reg);
446 template<
typename LD>
508 ListIt addInst(
const DynInstPtr &inst);
511 void instDone(
ThreadID tid,
const DynInstPtr &inst);
516 void removeFrontInst(
const DynInstPtr &inst);
520 void removeInstsNotInROB(
ThreadID tid);
526 inline void squashInstIt(
const ListIt &instIt,
ThreadID tid);
529 void cleanUpRemovedInsts();
552 std::set<InstSeqNum> snList;
571 typename CPUPolicy::IEW
iew;
586 typename CPUPolicy::RenameMap renameMap[Impl::MaxThreads];
589 typename CPUPolicy::RenameMap commitRenameMap[Impl::MaxThreads];
592 typename CPUPolicy::ROB
rob;
682 return thread[tid]->getTC();
723 return iew.ldstQueue.pushRequest(inst, isLoad, data, size, addr,
724 flags, res, std::move(amo_op), byte_enable);
730 return this->iew.ldstQueue.read(req, load_idx);
736 return this->iew.ldstQueue.write(req, data, store_idx);
743 return this->fetch.getInstPort();
750 return this->iew.ldstQueue.getDataPort();
793 #endif // __CPU_O3_CPU_HH__
#define panic(...)
This implements a cprintf based panic() function.
struct IsAapcs64Hfa< E[N], typename std::enable_if< std::is_floating_point< E >::value &&N<=4 >::type > :public std::true_type{};template< typename T, typename Enabled=void >struct IsAapcs64Hva :public std::false_type {};template< typename E, size_t N >struct IsAapcs64Hva< E[N], typename std::enable_if< IsAapcs64ShortVector< E >::value &&N<=4 >::type > :public std::true_type{};template< typename T, typename Enabled=void >struct IsAapcs64Hxa :public std::false_type {};template< typename T >struct IsAapcs64Hxa< T, typename std::enable_if< IsAapcs64Hfa< T >::value||IsAapcs64Hva< T >::value >::type > :public std::true_type{};struct Aapcs64ArgumentBase{ template< typename T > static T loadFromStack(ThreadContext *tc, Aapcs64::State &state) { size_t align=std::max< size_t >(8, alignof(T));size_t size=roundUp(sizeof(T), 8);state.nsaa=roundUp(state.nsaa, align);TypedBufferArg< T > val(state.nsaa);val.copyIn(tc->getVirtProxy());state.nsaa+=size;return gtoh(*val, ArmISA::byteOrder(tc));}};template< typename Float >struct Argument< Aapcs64, Float, typename std::enable_if< std::is_floating_point< Float >::value||IsAapcs64ShortVector< Float >::value >::type > :public Aapcs64ArgumentBase{ static Float get(ThreadContext *tc, Aapcs64::State &state) { if(state.nsrn<=state.MAX_SRN) { RegId id(VecRegClass, state.nsrn++);return tc->readVecReg(id).laneView< Float, 0 >();} return loadFromStack< Float >(tc, state);}};template< typename Float >struct Result< Aapcs64, Float, typename std::enable_if< std::is_floating_point< Float >::value||IsAapcs64ShortVector< Float >::value >::type >{ static void store(ThreadContext *tc, const Float &f) { RegId id(VecRegClass, 0);auto reg=tc-> readVecReg(id)
RegVal readMiscReg(RegIndex misc_reg) override
Reads a misc.
virtual void unserializeThread(CheckpointIn &cp, ThreadID tid)
Unserialize one thread.
std::vector< ThreadID > tids
Available thread ids in the cpu.
Stats::Scalar timesIdled
Stat for total number of times the CPU is descheduled.
Ports are used to interface objects to each other.
void demapDataPage(Addr vaddr, uint64_t asn)
bool removeInstsThisCycle
Records if instructions need to be removed this cycle due to being retired or squashed.
const VecPredRegContainer & readVecPredReg(const RegId &id) const override
Fault write(LSQRequest *req, uint8_t *data, int store_idx)
CPU write function, forwards write to LSQ.
Cycles is a wrapper class for representing cycle counts, i.e.
VecLaneT< VecElem, true > readVecLane(PhysRegIdPtr phys_reg) const
Read physical vector register lane.
std::unordered_map< ThreadID, bool > exitingThreads
This is a list of threads that are trying to exit.
void setArchVecLane(int reg_idx, int lId, ThreadID tid, const LD &val)
Write a lane of the destination vector register.
virtual void drainResume()
Resume execution after a successful drain.
void demapInstPage(Addr vaddr, uint64_t asn)
Class that has various thread state, such as the status, the current instruction being processed...
System * system
Pointer to the system.
void scheduleTickEvent(Cycles delay)
Schedule tick event, regardless of its current state.
std::vector< Thread * > thread
Pointers to all of the threads in the CPU.
Port & getInstPort() override
Used by the fetch unit to get a hold of the instruction port.
Vector Register Abstraction This generic class is the model in a particularization of MVC...
Simple physical register file class.
Stats::Formula ipc
Stat for the IPC per thread.
Stats::Scalar intRegfileReads
CPUPolicy::FetchStruct FetchStruct
void squash()
Squash the current event.
bool isDraining() const
Is the CPU draining?
Stats::Scalar vecPredRegfileWrites
void setIntReg(RegIndex reg_idx, RegVal val) override
Sets an integer register to a value.
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Fault read(LSQRequest *req, int load_idx)
CPU read function, forwards read to LSQ.
Stats::Vector committedInsts
Stat for the number of committed instructions per thread.
Stats::Scalar vecRegfileReads
Status _status
Overall CPU status.
CPUPolicy::Decode decode
The decode stage.
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
void activity()
Records that there is activity this cycle.
BaseO3CPU(BaseCPUParams *params)
RegVal readFloatReg(RegIndex reg_idx) const override
CPUPolicy::FreeList freeList
The free list.
Stats::Scalar miscRegfileReads
EventFunctionWrapper threadExitEvent
The exit event used for terminating all ready-to-exit threads.
A vector of scalar stats.
ProbePointArg< std::pair< DynInstPtr, PacketPtr > > * ppDataAccessComplete
void setVecLane(PhysRegIdPtr phys_reg, const LD &val)
Write a lane of the destination vector register.
Stats::Vector committedOps
Stat for the number of committed ops (including micro ops) per thread.
void setCCReg(RegIndex reg_idx, RegVal val) override
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
TimeBuffer< TimeStruct > timeBuffer
The main time buffer to do backwards communication.
CPUPolicy::Fetch fetch
The fetch stage.
This is a simple scalar statistic, like a counter.
CPUPolicy::ROB rob
The re-order buffer.
DrainState
Object drain/handover states.
void setVecLane(const RegId ®, const LaneData< LaneSize::Byte > &val) override
Write a lane of the destination vector register.
void deactivateStage(const int idx)
Deactivates a stage.
void setMiscReg(RegIndex misc_reg, RegVal val) override
Sets a misc.
bool squashed() const
Check whether the event is squashed.
DrainState drainState() const
Return the current drain state of an object.
std::map< ThreadID, unsigned > threadMap
Mapping for system thread id to cpu id.
RegVal readCCReg(RegIndex reg_idx) const override
int numActiveThreads()
Returns the Number of Active Threads in the CPU.
Stats::Formula totalCpi
Stat for the total CPI.
virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const
Serialize a single thread.
virtual Counter totalInsts() const =0
void setFloatReg(RegIndex reg_idx, RegVal val) override
Implements a simple scoreboard to track which registers are ready.
std::list< ThreadID > activeThreads
Active Threads List.
Port & getDataPort() override
Get the dcache port (used to find block size for translations).
CPUPolicy::RenameStruct RenameStruct
Enums::VecRegRenameMode vecRenameMode() const
Returns current vector renaming mode.
virtual void takeOverFrom(BaseCPU *cpu)
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
uint64_t Tick
Tick count type.
Addr instAddr() const override
Reads this thread's PC.
VecPredReg::Container VecPredRegContainer
Stats::Scalar miscRegfileWrites
Stats::Scalar intRegfileWrites
typename LSQ< O3CPUImpl >::LSQRequest LSQRequest
void activateStage(const int idx)
Marks a stage as active.
CPUPolicy::Commit commit
The commit stage.
Cycles lastRunningCycle
The cycle that the CPU was last running, used for statistics.
TheISA::PCState pcState() const override
Reads this thread's PC state.
void startup() override
startup() is the final initialization call before simulation.
ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not...
CPUPolicy::DecodeStruct DecodeStruct
ProbePointArg< PacketPtr > * ppInstAccessComplete
TimeBuffer< DecodeStruct > decodeQueue
The decode stage's instruction queue.
EventFunctionWrapper tickEvent
The tick event used for scheduling CPU ticks.
void schedule(Event &event, Tick when)
TimeBuffer< FetchStruct > fetchQueue
The fetch stage's instruction queue.
Tick lastActivatedCycle
The cycle that the CPU was last activated by a new thread.
static void wakeup(ThreadID tid)
void setMiscRegNoEffect(RegIndex misc_reg, RegVal val) override
Sets a misc.
virtual void verifyMemoryMode() const
Verify that the system is in a memory mode supported by the CPU.
int instcount
Count of total number of dynamic instructions in flight.
void unscheduleTickEvent()
Unschedule tick event, regardless of its current state.
void activateStage(const StageIdx idx)
Changes a stage's status to active within the activity recorder.
void reschedule(Event &event, Tick when, bool always=false)
virtual Counter totalOps() const =0
void setVecElem(const RegId ®, const VecElem &val) override
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void regStats()
Callback to set stat parameters.
Stats::Scalar fpRegfileReads
int64_t Counter
Statistics counter type.
Enums::VecRegRenameMode vecMode
The rename mode of the vector registers.
Stats::Scalar fpRegfileWrites
MicroPC microPC() const override
Reads this thread's next PC.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Stats::Scalar vecRegfileWrites
Stats::Scalar quiesceCycles
Stat for total number of cycles the CPU spends descheduled due to a quiesce operation or waiting for ...
void halt()
Halts the CPU.
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
Reads a miscellaneous register.
std::queue< ListIt > removeList
List of all the instructions that will be removed at the end of this cycle.
virtual void switchOut()
Prepare for another CPU to take over execution.
CPUPolicy::TimeStruct TimeStruct
Typedefs from the Impl to get the structs that each of the time buffers should use.
Stats::Formula cpi
Stat for the CPI per thread.
Checker< Impl > * checker
Pointer to the checker, which can dynamically verify instruction results at run time.
bool scheduled() const
Determine if the current event is scheduled.
FreeList class that simply holds the list of free integer and floating point registers.
int16_t ThreadID
Thread index/ID type.
StageIdx
Enum to give each stage a specific index, so when calling activateStage() or deactivateStage(), they can specify which stage is being activated/deactivated.
void setVecPredReg(const RegId ®, const VecPredRegContainer &val) override
ProbePointArg generates a point for the class of Arg.
void regProbePoints() override
Register probe points for this object.
ThreadContext * tcBase(ThreadID tid)
Returns a pointer to a thread context.
void syscall(Fault *fault) override
Executes a syscall in SE mode.
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
TimeBuffer< IEWStruct > iewQueue
The IEW stage's instruction queue.
VecRegContainer & getWritableVecReg(const RegId &id) override
Read vector register operand for modification, hierarchical indexing.
std::ostream CheckpointOut
VecReg::Container VecRegContainer
O3ThreadState< Impl > Thread
uint16_t ElemIndex
Logical vector register elem index type.
InstSeqNum getAndIncrementInstSeq()
Get the current instruction sequence number, and increment it.
PhysRegFile regFile
The register file.
XReg readVecElem(VReg src, int index, int eSize)
Read a single NEON vector element.
void vecRenameMode(Enums::VecRegRenameMode vec_mode)
Sets the current vector renaming mode.
ActivityRecorder activityRec
The activity recorder; used to tell if the CPU has any activity remaining or if it can go to idle and...
Stats::Scalar vecPredRegfileReads
Stats::Scalar idleCycles
Stat for total number of cycles the CPU spends descheduled.
Generic predicate register container.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
DrainState drain() override
Provide a default implementation of the drain interface for objects that don't need draining...
Stats::Scalar ccRegfileReads
InstSeqNum globalSeqNum
The global sequence number counter.
virtual void demapPage(Addr vaddr, uint64_t asn)=0
TimeBuffer< RenameStruct > renameQueue
The rename stage's instruction queue.
CPUPolicy::IEWStruct IEWStruct
Scoreboard scoreboard
Integer Register Scoreboard.
Derived ThreadContext class for use with the O3CPU.
Register ID: describe an architectural register with its class and index.
Memory operation metadata.
virtual void haltContext(ThreadID thread_num)
Notify the CPU that the indicated context is now halted.
CPUPolicy::IEW iew
The issue/execute/writeback stages.
void demapPage(Addr vaddr, uint64_t asn)
std::list< DynInstPtr >::iterator ListIt
std::vector< TheISA::ISA * > isa
std::list< DynInstPtr > instList
List of all the instructions in flight.
Fault pushRequest(const DynInstPtr &inst, bool isLoad, uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, AtomicOpFunctorPtr amo_op=nullptr, const std::vector< bool > &byte_enable=std::vector< bool >())
CPU pushRequest function, forwards request to LSQ.
Vector Lane abstraction Another view of a container.
Impl::DynInstPtr DynInstPtr
GenericISA::DelaySlotPCState< MachInst > PCState
O3ThreadState< Impl > ImplState
O3ThreadState< Impl > * thread
Pointer to the thread state that this TC corrseponds to.
VecLaneT< VecElem, true > readVecLane(PhysRegIdPtr phys_reg) const
Read physical vector register lane.
std::shared_ptr< FaultBase > Fault
const Params * params() const
std::list< int > cpuWaitList
Threads Scheduled to Enter CPU.
Addr nextInstAddr() const override
Reads this thread's next PC.
RegVal readIntReg(RegIndex reg_idx) const override
VecLaneT< VecElem, true > readArchVecLane(int reg_idx, int lId, ThreadID tid) const
Read architectural vector register lane.
Stats::Formula totalIpc
Stat for the total IPC.
void deactivateStage(const StageIdx idx)
Changes a stage's status to inactive within the activity recorder.
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
FullO3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time ...
void activityThisCycle()
Records that there was time buffer activity this cycle.
Stats::Scalar ccRegfileWrites
CPUPolicy::Rename rename
The dispatch stage.
VecPredRegContainer & getWritableVecPredReg(const RegId &id) override