Skip to content

Commit

Permalink
modified return type of some store function, and reorder the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
MayneMei committed Nov 1, 2024
1 parent c18dd7b commit ab4466e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
27 changes: 13 additions & 14 deletions core/LSU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace olympia
replay_buffer_("replay_buffer", p->replay_buffer_size, getClock()),
replay_buffer_size_(p->replay_buffer_size),
replay_issue_delay_(p->replay_issue_delay),
ready_queue_(),
store_buffer_("store_buffer", p->ldst_inst_queue_size, getClock()), // Add this line
store_buffer_size_(p->ldst_inst_queue_size),
ready_queue_(),
load_store_info_allocator_(sparta::notNull(OlympiaAllocators::getOlympiaAllocators(node))
->load_store_info_allocator),
memory_access_allocator_(sparta::notNull(OlympiaAllocators::getOlympiaAllocators(node))
Expand All @@ -33,7 +33,7 @@ namespace olympia
cache_read_stage_(cache_lookup_stage_
+ 1), // Get data from the cache in the cycle after cache lookup
complete_stage_(
cache_read_stage_
cache_read_stage_
+ p->cache_read_stage_length), // Complete stage is after the cache read stage
ldst_pipeline_("LoadStorePipeline", (complete_stage_ + 1),
getClock()), // complete_stage_ + 1 is number of stages
Expand Down Expand Up @@ -277,15 +277,14 @@ namespace olympia
if (inst_ptr->isStoreInst())
{
auto oldest_store = getOldestStore_();
sparta_assert(oldest_store && oldest_store->getUniqueID() == inst_ptr->getUniqueID(),
sparta_assert(oldest_store && oldest_store->getInstPtr()->getUniqueID() == inst_ptr->getUniqueID(),
"Attempting to retire store out of order! Expected: "
<< (oldest_store ? oldest_store->getUniqueID() : 0)
<< (oldest_store ? oldest_store->getInstPtr()->getUniqueID() : 0)
<< " Got: " << inst_ptr->getUniqueID());

// Remove from store buffer and commit to cache
auto store_info_ptr_ = createLoadStoreInst_(inst_ptr);
out_cache_lookup_req_.send(oldest_store->getMemoryAccessInfoPtr());
store_buffer_.erase(store_buffer_.begin());;
out_cache_lookup_req_.send(store_info_ptr_->getMemoryAccessInfoPtr());
++stores_retired_;
}

Expand Down Expand Up @@ -631,7 +630,7 @@ namespace olympia
{
mem_access_info_ptr->setDataReady(true);
ILOG("Load using forwarded data from store buffer: " << inst_ptr
<< " from store: " << forwarding_store);
<< " from store: " << forwarding_store->getInstPtr());
}
else
{
Expand Down Expand Up @@ -948,22 +947,22 @@ namespace olympia
ILOG("Store added to store buffer: " << inst_ptr);
}

InstPtr LSU::findYoungestMatchingStore_(uint64_t addr)
LoadStoreInstInfoPtr LSU::findYoungestMatchingStore_(uint64_t addr)
{
InstPtr matching_store = nullptr;
LoadStoreInstInfoPtr matching_store = nullptr;

for (auto it = store_buffer_.begin(); it != store_buffer_.end(); ++it)
{
auto & store = *it;
if (store->getTargetVAddr() == addr)
if (store->getInstPtr()->getTargetVAddr() == addr)
{
matching_store = store;
}
}
return matching_store;
}

InstPtr LSU::getOldestStore_() const
LoadStoreInstInfoPtr LSU::getOldestStore_() const
{
if(store_buffer_.empty()) {
return nullptr;
Expand Down Expand Up @@ -1449,11 +1448,11 @@ namespace olympia
{
auto sb_iter = store_buffer_.begin();
while(sb_iter != store_buffer_.end()) {
auto store_ptr = *sb_iter;
if(criteria.includedInFlush(store_ptr)) {
auto inst_ptr = (*sb_iter)->getInstPtr();
if(criteria.includedInFlush(inst_ptr)) {
auto delete_iter = sb_iter++;
store_buffer_.erase(delete_iter);
ILOG("Flushed store from store buffer: " << store_ptr);
ILOG("Flushed store from store buffer: " << inst_ptr);
} else {
++sb_iter;
}
Expand Down
14 changes: 7 additions & 7 deletions core/LSU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace olympia
PARAMETER(uint32_t, ldst_inst_queue_size, 8, "LSU ldst inst queue size")
PARAMETER(uint32_t, replay_buffer_size, ldst_inst_queue_size, "Replay buffer size")
PARAMETER(uint32_t, replay_issue_delay, 3, "Replay Issue delay")
PARAMETER(uint32_t, store_buffer_size, ldst_inst_queue_size, "Size of the store buffer")
// PARAMETER(uint32_t, store_buffer_size, ldst_inst_queue_size, "Size of the store buffer")
// LSU microarchitecture parameters
PARAMETER(
bool, allow_speculative_load_exec, true,
Expand Down Expand Up @@ -138,6 +138,10 @@ namespace olympia
const uint32_t replay_buffer_size_;
const uint32_t replay_issue_delay_;

// Store Buffer
sparta::Buffer<LoadStoreInstInfoPtr> store_buffer_;
const uint32_t store_buffer_size_;

sparta::PriorityQueue<LoadStoreInstInfoPtr> ready_queue_;
// MMU unit
bool mmu_busy_ = false;
Expand Down Expand Up @@ -168,10 +172,6 @@ namespace olympia
using LoadStorePipeline = sparta::Pipeline<LoadStoreInstInfoPtr>;
LoadStorePipeline ldst_pipeline_;

// Store Buffer
sparta::Buffer<InstPtr> store_buffer_;
const uint32_t store_buffer_size_;

// LSU Microarchitecture parameters
const bool allow_speculative_load_exec_;

Expand Down Expand Up @@ -267,10 +267,10 @@ namespace olympia
void allocateInstToStoreBuffer_(const InstPtr & inst_ptr);

// Search store buffer in FIFO order for youngest matching store
InstPtr findYoungestMatchingStore_(uint64_t addr);
LoadStoreInstInfoPtr findYoungestMatchingStore_(uint64_t addr);

// get oldest store
InstPtr getOldestStore_() const;
LoadStoreInstInfoPtr getOldestStore_() const;

bool olderStoresExists_(const InstPtr & inst_ptr);

Expand Down

0 comments on commit ab4466e

Please sign in to comment.