6#include "sparta/decode/DecoderBase.hpp"
7#include "sparta/memory/AddressTypes.hpp"
9#include "sparta/pairs/SpartaKeyPairs.hpp"
10#include "sparta/simulation/State.hpp"
12#include "sparta/utils/SpartaSharedPointerAllocator.hpp"
26 class ExampleInstPairDef;
34 enum class Status : std::uint16_t{
45 enum class TargetUnit : std::uint16_t{
56 sparta::decode::DecoderBase decode_base;
58 uint32_t execute_time;
64 ExampleInst(
const sparta::decode::DecoderBase & static_inst,
66 uint32_t execute_time,
70 static_inst_(static_inst),
72 execute_time_(execute_time),
73 isStoreInst_(isStore),
74 status_(
"inst_status", clk, state),
75 status_state_(state) {}
79 Status state = Status::FETCHED) :
88 const sparta::decode::DecoderBase & getStaticInst()
const {
92 const Status & getStatus()
const {
93 return status_state_.getEnumValue();
96 bool getCompletedStatus()
const {
97 return getStatus() == core_example::ExampleInst::Status::COMPLETED;
100 void setStatus(Status status) {
102 status_.
write(status);
103 if(getStatus() == core_example::ExampleInst::Status::COMPLETED) {
104 if(ev_retire_ != 0) {
110 const TargetUnit& getUnit()
const {
115 ev_retire_ = rob_retire_event;
118 if(status_.
isValidNS() && status_.
readNS() == core_example::ExampleInst::Status::COMPLETED) {
123 void setVAdr(uint64_t vaddr) {
127 void setUniqueID(uint64_t uid) {
132 uint64_t getUniqueID()
const {
136 void setSpeculative(
bool spec) {
137 is_speculative_ = spec;
140 const char* getMnemonic()
const {
return static_inst_.mnemonic; }
141 uint32_t getOpCode()
const {
return static_inst_.encoding; }
142 uint64_t getVAdr()
const {
return vaddr_; }
143 uint64_t getRAdr()
const {
return vaddr_ | 0x3000; }
144 uint64_t getParentId()
const {
return 0; }
145 uint32_t getExecuteTime()
const {
return execute_time_; }
146 bool isSpeculative()
const {
return is_speculative_; }
147 bool isStoreInst()
const {
return isStoreInst_; }
151 const sparta::decode::DecoderBase static_inst_;
153 const uint32_t execute_time_ = 0;
154 bool isStoreInst_ =
false;
156 bool is_last_ =
false;
157 uint64_t unique_id_ = 0;
158 bool is_speculative_ =
false;
166 inline std::ostream &
operator<<(std::ostream & os,
const ExampleInst & inst) {
167 os << inst.getMnemonic();
172 inline std::ostream &
operator<<(std::ostream & os,
const ExampleInstPtr & inst) {
177 inline std::ostream &
operator<<(std::ostream & os,
const ExampleInst::TargetUnit & unit) {
179 case ExampleInst::TargetUnit::ALU0:
182 case ExampleInst::TargetUnit::ALU1:
185 case ExampleInst::TargetUnit::FPU:
188 case ExampleInst::TargetUnit::BR:
191 case ExampleInst::TargetUnit::LSU:
194 case ExampleInst::TargetUnit::ROB:
197 case ExampleInst::TargetUnit::N_TARGET_UNITS:
203 inline std::ostream &
operator<<(std::ostream & os,
const ExampleInst::Status & status) {
205 case ExampleInst::Status::FETCHED:
208 case ExampleInst::Status::DECODED:
211 case ExampleInst::Status::RENAMED:
214 case ExampleInst::Status::SCHEDULED:
217 case ExampleInst::Status::COMPLETED:
220 case ExampleInst::Status::RETIRED:
223 case ExampleInst::Status::__LAST:
243 SPARTA_REGISTER_PAIRS(SPARTA_ADDPAIR(
"DID", &ExampleInst::getUniqueID),
244 SPARTA_ADDPAIR(
"uid", &ExampleInst::getUniqueID),
245 SPARTA_ADDPAIR(
"mnemonic", &ExampleInst::getMnemonic),
246 SPARTA_ADDPAIR(
"complete", &ExampleInst::getCompletedStatus),
247 SPARTA_ADDPAIR(
"unit", &ExampleInst::getUnit),
248 SPARTA_ADDPAIR(
"latency", &ExampleInst::getExecuteTime),
249 SPARTA_ADDPAIR(
"raddr", &ExampleInst::getRAdr, std::ios::hex),
250 SPARTA_ADDPAIR(
"vaddr", &ExampleInst::getVAdr, std::ios::hex))
Defines the SharedData class.
Defines the SpartaSharedPointer class used for garbage collection.
Pair Definition class of the Example instruction that flows through the example/CoreModel.
Example instruction that flows through the example/CoreModel.
A representation of simulated time.
A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by mode...
void schedule()
Schedule this event with its pre-set delay using the pre-set Clock.
bool isValidNS() const
Is there data for the next cycle?
void write(const DataT &dat)
Write data for the next cycle view.
const DataT & readNS() const
Get a constant reference to the data that will be visible next cycle.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
A memory allocator complementing SpartaSharedPointer that reuses old memory.
Used for garbage collection, will delete the object it points to when all objects are finished using ...
The State class for watching transition between enum states.
void setValue(const EnumTValueType &val)
Set a new enum value explicit and fire observers.
uint64_t addr_t
Type for generic address representation in generic interfaces, errors and printouts within SPARTA.
std::ostream & operator<<(std::ostream &o, const SimulationInfo &info)
ostream insertion operator for SimulationInfo