15 stat_ipc_(&unit_stat_set_,
17 "Instructions retired per cycle",
19 "total_number_retired/cycles"),
20 num_retired_(&unit_stat_set_,
21 "total_number_retired",
22 "The total number of instructions retired by this core",
23 sparta::Counter::COUNT_NORMAL),
24 num_flushes_(&unit_stat_set_,
25 "total_number_of_flushes",
26 "The total number of flushes performed by the ROB",
27 sparta::Counter::COUNT_NORMAL),
28 num_to_retire_(p->num_to_retire),
29 num_insts_to_retire_(p->num_insts_to_retire),
30 reorder_buffer_(
"ReorderBuffer", p->retire_queue_depth,
31 node->getClock(), &unit_stat_set_)
39 in_reorder_buffer_write_.
44 FlushManager::FlushingCriteria));
57 info_logger_ <<
"ROB is destructing now, but you can still see this message";
60 void ROB::sendInitialCredits_()
62 out_reorder_buffer_credits_.
send(reorder_buffer_.
capacity());
63 ev_ensure_forward_progress_.
schedule(retire_timeout_interval_);
66 void ROB::retireEvent_() {
67 retireInstructions_();
68 if (reorder_buffer_.
size() > 0) {
69 ev_retire_.
schedule(sparta::Clock::Cycle(1));
80 void ROB::robAppended_(
const InstGroup &) {
81 for(
auto & i : in_reorder_buffer_write_.pullData()) {
82 reorder_buffer_.
push(i);
85 ev_retire_.
schedule(sparta::Clock::Cycle(0));
91 void ROB::handleFlush_(
const FlushManager::FlushingCriteria &)
94 out_reorder_buffer_credits_.
send(reorder_buffer_.
size());
95 reorder_buffer_.
clear();
98 void ROB::retireInstructions_() {
99 const uint32_t num_to_retire = std::min(reorder_buffer_.
size(), num_to_retire_);
102 info_logger_ <<
"Retire event, num to retire: " << num_to_retire;
105 uint32_t retired_this_cycle = 0;
106 for(uint32_t i = 0; i < num_to_retire; ++i)
108 auto & ex_inst_ptr = reorder_buffer_.
access(0);
109 auto & ex_inst = *ex_inst_ptr;
111 "Uh, oh! A speculative instruction is being retired: " << ex_inst);
112 if(ex_inst.getStatus() == ExampleInst::Status::COMPLETED)
115 ex_inst.setStatus(ExampleInst::Status::RETIRED);
116 if (ex_inst.isStoreInst()) {
117 out_rob_retire_ack_.send(ex_inst_ptr);
121 ++retired_this_cycle;
122 reorder_buffer_.
pop();
129 std::cout <<
"Retired " << num_retired_
130 <<
" instructions" << std::endl;
145 out_retire_flush_.
send(ex_inst.getUniqueID());
148 out_fetch_flush_redirect_.
send(ex_inst.getVAdr() + 4);
156 ex_inst.setLast(
true, &ev_retire_);
160 out_reorder_buffer_credits_.
send(retired_this_cycle);
165 void ROB::checkForwardProgress_()
167 if(
getClock()->currentCycle() - last_retirement_ >= retire_timeout_interval_)
170 e <<
"Been a while since we've retired an instruction. Is the pipe stalled indefinitely?";
173 ev_ensure_forward_progress_.
schedule(retire_timeout_interval_);
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
#define SPARTA_EXPECT_FALSE(x)
A macro for hinting to the compiler a particular condition should be considered most likely false.
#define CREATE_SPARTA_HANDLER_WITH_DATA(clname, meth, dataT)
#define CREATE_SPARTA_HANDLER(clname, meth)
File that defines the StartupEvent class.
Parameters for ROB model.
ROB(sparta::TreeNode *node, const ROBParameterSet *p)
Constructor for ROB.
static const char name[]
Name of this resource. Required by sparta::UnitFactory.
Cycle currentCycle() const
Get the current cycle (uses current tick from the Scheduler)
void send(const DataT &dat, sparta::Clock::Cycle rel_time=0)
Send data to bound receivers.
void schedule()
Schedule this event with its pre-set delay using the pre-set Clock.
bool observed() const noexcept
Is this NotificationSourceBase being observed at this node or an ancestor of any distance.
size_type size() const
Return the number of valid entries.
uint32_t capacity() const
Return the fixed size of this queue.
iterator push(const value_type &dat)
push data to the Queue.
value_type & access(uint32_t idx)
Read and return the data at the given index, reference, non-const method.
void enableCollection(TreeNode *parent)
Request that this queue begin collecting its contents for pipeline collection.
void clear()
Empty the queue.
void pop()
Pops the data at the front of the structure (oldest element) After pop iterator always points to the ...
Scheduler * getScheduler(const bool must_exist=true) const
const Clock * getClock() const
void setContinuing(bool continuing)
This event, if continuing == true, will keep the simulation running.
void setDelay(Clock::Cycle delay)
Set a fixed delay for this event.
void stopRunning()
Tell the scheduler to stop running.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
StartupEvent is a simple class for scheduling a starting event on the Scheduler. It does not support ...
Node in a composite tree representing a sparta Tree item.
void schedule()
Schedule this event with its pre-set delay using the pre-set Clock.
log::MessageSource info_logger_
Default info logger.
Macros for handling exponential backoff.