Skip to content

Commit

Permalink
Raise exception in LSU when ROB is drained
Browse files Browse the repository at this point in the history
  • Loading branch information
h0lyalg0rithm committed Oct 31, 2023
1 parent 82504f6 commit a385d57
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/CPUFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ auto olympia::CPUFactory::bindTree_(sparta::RootTreeNode* root_node,
setTLB(*private_nodes_.at(num_of_cores)->getResourceAs<olympia::SimpleTLB>());
(core_tree_node->getChild("preloader")->getResourceAs<olympia::Preloader>())->
preload();
auto rob = core_tree_node->getChild("rob")->getResourceAs<olympia::ROB>()->getContainer();
auto lsu = core_tree_node->getChild("lsu")->getResourceAs<olympia::LSU>();
rob->registerForNotification<bool, LSU, &LSU::onRobDrained_>
(lsu, "rob_notif_channel");
}
}

Expand Down
8 changes: 8 additions & 0 deletions core/LSU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ namespace olympia
// Both cache and MMU try to drive the single BIU port at the same cycle
// Here we give cache the higher priority
ILOG("LSU construct: #" << node->getGroupIdx());
}

void LSU::onRobDrained_(const bool &val){
retire_done_and_is_drained_ = val;
}

LSU::~LSU() {
Expand All @@ -92,6 +95,11 @@ namespace olympia
<< ": "
<< memory_access_allocator_.getNumAllocated()
<< " MemoryAccessInfo objects allocated/created");

if(retire_done_and_is_drained_){
bool ldst_queue_empty_ = ldst_inst_queue_.empty();
sparta_assert(ldst_queue_empty_, "Issue queue has pending instructions");
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 3 additions & 2 deletions core/LSU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace olympia
// Type Name/Alias Declaration
////////////////////////////////////////////////////////////////////////////////


bool retire_done_and_is_drained_ = false;
class LoadStoreInstInfo;

using LoadStoreInstInfoPtr = sparta::SpartaSharedPointer<LoadStoreInstInfo>;
Expand Down Expand Up @@ -196,6 +196,8 @@ namespace olympia
SPARTA_ADDPAIR("state", &LoadStoreInstInfo::getState),
SPARTA_FLATTEN( &LoadStoreInstInfo::getMemoryAccessInfoPtr))
};

void onRobDrained_(const bool &val);
private:

using ScoreboardViews = std::array<std::unique_ptr<sparta::ScoreboardView>, core_types::N_REGFILES>;
Expand Down Expand Up @@ -293,7 +295,6 @@ namespace olympia
////////////////////////////////////////////////////////////////////////////////
// Callbacks
////////////////////////////////////////////////////////////////////////////////

// Send initial credits (ldst_inst_queue_size_) to Dispatch Unit
void sendInitialCredits_();

Expand Down
7 changes: 7 additions & 0 deletions core/ROB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ namespace olympia
// simulation continuing on.
ev_ensure_forward_progress_.setContinuing(false);

rob_drained_notif_source_.reset(new sparta::NotificationSource<bool>(
this->getContainer(),
"rob_notif_channel",
"Notification channel for rob",
"rob_notif_channel"
));
// Send initial credits to anyone that cares. Probably Dispatch.
sparta::StartupEvent(node, CREATE_SPARTA_HANDLER(ROB, sendInitialCredits_));
}
Expand Down Expand Up @@ -198,6 +204,7 @@ namespace olympia

void ROB::onStartingTeardown_() {
if ((reorder_buffer_.size() > 0) && (false == rob_stopped_simulation_)) {
rob_drained_notif_source_->postNotification(true);
std::cerr << "WARNING! Simulation is ending, but the ROB didn't stop it. Lock up situation?" << std::endl;
dumpDebugContent_(std::cerr);
}
Expand Down
2 changes: 2 additions & 0 deletions core/ROB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ namespace olympia
sparta::Event<> ev_ensure_forward_progress_{&unit_event_set_, "forward_progress_check",
CREATE_SPARTA_HANDLER(ROB, checkForwardProgress_)};

std::unique_ptr<sparta::NotificationSource<bool>> rob_drained_notif_source_;

void sendInitialCredits_();
void retireEvent_();
void robAppended_(const InstGroup &);
Expand Down

0 comments on commit a385d57

Please sign in to comment.