16#include "sparta/pairs/SpartaKeyPairs.hpp"
17#include "sparta/simulation/State.hpp"
19#include "sparta/utils/SpartaSharedPointerAllocator.hpp"
21#include "cache/TreePLRUReplacement.hpp"
23#include "CoreTypes.hpp"
24#include "FlushManager.hpp"
25#include "SimpleTLB.hpp"
26#include "SimpleDL1.hpp"
47 PARAMETER(uint32_t, ldst_inst_queue_size, 8,
"LSU ldst inst queue size")
49 PARAMETER(
bool, tlb_always_hit, false, "L1 TLB will always hit")
51 PARAMETER(uint64_t, dl1_line_size, 64, "DL1 line size (power of 2)")
52 PARAMETER(uint64_t, dl1_size_kb, 32, "Size of DL1 in KB (power of 2)")
53 PARAMETER(uint64_t, dl1_associativity, 8, "DL1 associativity (power of 2)")
54 PARAMETER(
bool, dl1_always_hit, false, "DL1 will always hit")
56 PARAMETER(uint32_t, issue_latency, 1, "Instruction issue latency")
57 PARAMETER(uint32_t, mmu_latency, 1, "MMU/TLB access latency")
58 PARAMETER(uint32_t, cache_latency, 1, "Cache access latency")
59 PARAMETER(uint32_t, complete_latency, 1, "Instruction complete latency")
72 << load_store_info_allocator.getNumAllocated()
73 <<
" LoadStoreInstInfo objects allocated/created"
77 << memory_access_allocator.getNumAllocated()
78 <<
" MemoryAccessInfo objects allocated/created"
96 using FlushCriteria = FlushManager::FlushingCriteria;
98 enum class PipelineStage
107 class MemoryAccessInfoPairDef;
115 enum class MMUState : std::uint32_t {
124 enum class CacheState : std::uint64_t {
136 ldst_inst_ptr_(inst_ptr),
137 phyAddrIsReady_(
false),
138 mmu_access_state_(MMUState::NO_ACCESS),
141 cache_access_state_(CacheState::NO_ACCESS) {}
147 const ExampleInstPtr & getInstPtr()
const {
return ldst_inst_ptr_; }
150 uint64_t getInstUniqueID()
const {
153 return inst_ptr ==
nullptr ? 0 : inst_ptr->getUniqueID();
156 void setPhyAddrStatus(
bool isReady) { phyAddrIsReady_ = isReady; }
157 bool getPhyAddrStatus()
const {
return phyAddrIsReady_; }
159 const MMUState & getMMUState()
const {
160 return mmu_access_state_.getEnumValue();
163 void setMMUState(
const MMUState & state) {
164 mmu_access_state_.setValue(state);
167 const CacheState & getCacheState()
const {
168 return cache_access_state_.getEnumValue();
170 void setCacheState(
const CacheState & state) {
171 cache_access_state_.setValue(state);
175 bool getPhyAddrIsReady()
const{
176 return phyAddrIsReady_;
185 bool phyAddrIsReady_;
213 SPARTA_REGISTER_PAIRS(SPARTA_ADDPAIR(
"DID", &MemoryAccessInfo::getInstUniqueID),
214 SPARTA_ADDPAIR(
"valid", &MemoryAccessInfo::getPhyAddrIsReady),
215 SPARTA_ADDPAIR(
"mmu", &MemoryAccessInfo::getMMUState),
216 SPARTA_ADDPAIR(
"cache", &MemoryAccessInfo::getCacheState),
217 SPARTA_FLATTEN( &MemoryAccessInfo::getInstPtr))
228 enum class IssuePriority : std::uint16_t
239 __LAST = NUM_OF_PRIORITIES
242 enum class IssueState : std::uint32_t
254 mem_access_info_ptr_(info_ptr),
255 rank_(IssuePriority::LOWEST),
256 state_(IssueState::NOT_READY) {}
261 return mem_access_info_ptr_->getInstPtr();
267 return mem_access_info_ptr_;
271 uint64_t getInstUniqueID()
const {
274 return mem_access_info_ptr ==
nullptr ? 0 : mem_access_info_ptr->getInstUniqueID();
277 void setPriority(
const IssuePriority & rank) {
278 rank_.setValue(rank);
281 const IssuePriority & getPriority()
const {
282 return rank_.getEnumValue();
285 void setState(
const IssueState & state) {
286 state_.setValue(state);
289 const IssueState & getState()
const {
290 return state_.getEnumValue();
294 bool isReady()
const {
return (getState() == IssueState::READY); }
298 if (that ==
nullptr) {
302 return (
static_cast<uint32_t
>(this->getPriority())
303 <
static_cast<uint32_t
>(that->getPriority()));
329 SPARTA_REGISTER_PAIRS(SPARTA_ADDPAIR(
"DID", &LoadStoreInstInfo::getInstUniqueID),
330 SPARTA_ADDPAIR(
"rank", &LoadStoreInstInfo::getPriority),
331 SPARTA_ADDPAIR(
"state", &LoadStoreInstInfo::getState),
332 SPARTA_FLATTEN( &LoadStoreInstInfo::getMemoryAccessInfoPtr))
372 LoadStoreIssueQueue ldst_inst_queue_;
373 const uint32_t ldst_inst_queue_size_;
376 SimpleTLB* tlb_cache_ =
nullptr;
377 const bool tlb_always_hit_;
378 bool mmu_busy_ =
false;
379 bool mmu_pending_inst_flushed =
false;
381 ExampleInstPtr mmu_pending_inst_ptr_ =
nullptr;
389 using DL1Handle = SimpleDL1::Handle;
390 DL1Handle dl1_cache_;
391 const bool dl1_always_hit_;
392 bool cache_busy_ =
false;
393 bool cache_pending_inst_flushed_ =
false;
395 ExampleInstPtr cache_pending_inst_ptr_ =
nullptr;
407 LoadStorePipeline ldst_pipeline_
408 {
"LoadStorePipeline",
static_cast<uint32_t
>(PipelineStage::NUM_STAGES),
getClock()};
411 const uint32_t issue_latency_;
412 const uint32_t mmu_latency_;
413 const uint32_t cache_latency_;
414 const uint32_t complete_latency_;
439 void sendInitialCredits_();
442 void getInstsFromDispatch_(
const ExampleInstPtr &);
445 void getAckFromBIU_(
const ExampleInstPtr &);
448 void getAckFromROB_(
const ExampleInstPtr &);
454 void handleMMULookupReq_();
457 void driveBIUPortFromMMU_();
460 void handleCacheLookupReq_();
463 void driveBIUPortFromCache_();
466 void completeInst_();
469 void handleFlush_(
const FlushCriteria &);
477 void appendIssueQueue_(
const LoadStoreInstInfoPtr &);
480 void popIssueQueue_(
const ExampleInstPtr &);
483 const LoadStoreInstInfoPtr & arbitrateInstIssue_();
486 bool isReadyToIssueInsts_()
const;
489 bool MMULookup_(
const MemoryAccessInfoPtr &);
492 void rehandleMMULookupReq_(
const ExampleInstPtr &);
495 void reloadTLB_(uint64_t);
498 bool cacheLookup_(
const MemoryAccessInfoPtr &);
501 void rehandleCacheLookupReq_(
const ExampleInstPtr &);
504 void reloadCache_(uint64_t);
507 void updateIssuePriorityAfterNewDispatch_(
const ExampleInstPtr &);
510 void updateIssuePriorityAfterTLBReload_(
const ExampleInstPtr &,
514 void updateIssuePriorityAfterCacheReload_(
const ExampleInstPtr &,
518 void updateIssuePriorityAfterStoreInstRetire_(
const ExampleInstPtr &);
521 template<
typename Comp>
522 void flushIssueQueue_(
const Comp &);
525 template<
typename Comp>
526 void flushLSPipeline_(
const Comp &);
529 inline std::ostream &
operator<<(std::ostream & os,
530 const core_example::LSU::MemoryAccessInfo::MMUState & mmu_access_state){
531 switch(mmu_access_state){
532 case LSU::MemoryAccessInfo::MMUState::NO_ACCESS:
535 case LSU::MemoryAccessInfo::MMUState::MISS:
538 case LSU::MemoryAccessInfo::MMUState::HIT:
541 case LSU::MemoryAccessInfo::MMUState::NUM_STATES:
547 inline std::ostream &
operator<<(std::ostream & os,
548 const core_example::LSU::MemoryAccessInfo::CacheState & cache_access_state){
549 switch(cache_access_state){
550 case LSU::MemoryAccessInfo::CacheState::NO_ACCESS:
553 case LSU::MemoryAccessInfo::CacheState::MISS:
556 case LSU::MemoryAccessInfo::CacheState::HIT:
559 case LSU::MemoryAccessInfo::CacheState::NUM_STATES:
565 inline std::ostream&
operator<<(std::ostream& os,
566 const core_example::LSU::LoadStoreInstInfo::IssuePriority& rank){
568 case LSU::LoadStoreInstInfo::IssuePriority::HIGHEST:
571 case LSU::LoadStoreInstInfo::IssuePriority::CACHE_RELOAD:
574 case LSU::LoadStoreInstInfo::IssuePriority::CACHE_PENDING:
577 case LSU::LoadStoreInstInfo::IssuePriority::MMU_RELOAD:
578 os <<
"(mmu_reload)";
580 case LSU::LoadStoreInstInfo::IssuePriority::MMU_PENDING:
581 os <<
"(mmu_pending)";
583 case LSU::LoadStoreInstInfo::IssuePriority::NEW_DISP:
586 case LSU::LoadStoreInstInfo::IssuePriority::LOWEST:
589 case LSU::LoadStoreInstInfo::IssuePriority::NUM_OF_PRIORITIES:
595 inline std::ostream&
operator<<(std::ostream& os,
596 const core_example::LSU::LoadStoreInstInfo::IssueState& state){
599 case LSU::LoadStoreInstInfo::IssueState::READY:
602 case LSU::LoadStoreInstInfo::IssueState::ISSUED:
605 case LSU::LoadStoreInstInfo::IssueState::NOT_READY:
608 case LSU::LoadStoreInstInfo::IssueState::NUM_STATES:
Defines the Buffer class used for buffering data.
Implementation of the Collectable class that allows a user to collect an object into an pipeViewer pi...
File that defines Data[In,Out]Port<DataT>
File that defines the EventSet class.
A set of sparta::Parameters per sparta::ResourceTreeNode.
#define PARAMETER(type, name, def, doc)
Parameter declaration.
Defines the Pipeline class.
File that defines the PortSet class.
File that defines the SignalInPort.
#define CREATE_SPARTA_HANDLER(clname, meth)
Defines the SpartaSharedPointer class used for garbage collection.
File that defines the StartupEvent class.
Basic Node framework in sparta device tree composite pattern.
File that defines the UniqueEvent class.
File that defines the Unit class, a common grouping of sets and loggers.
Parameters for LSU model.
LSUParameterSet(sparta::TreeNode *n)
Constructor for LSUParameterSet.
Pair Definition class of the load store instruction that flows through the example/CoreModel.
Pair Definition class of the Memory Access Information that flows through the example/CoreModel.
static const char name[]
name of this resource.
A data structure allowing appending at the end, beginning, or middle, but erase anywhere with collaps...
DataInPort receives data from sender using a DataOutPort.
DataOutPort is used for transferring any data to another module.
Generic container of Parameters.
ParameterSet()=delete
Default constructor disabled.
TreeNode * getContainer()
Gets the TreeNode (container) for this resource (if any)
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.
Node in a composite tree representing a sparta Tree item.
std::string getLocation() const override final
TreeNode()=delete
Not default-constructable.
const Clock * getClock() override
Walks up parents (starting with self) until a parent with an associated local clock is found,...
A type of Event that uniquely schedules itself on the schedule within a single time quantum....
The is the base class for user defined blocks in simulation.
sparta::EventSet unit_event_set_
The Unit's event set.
log::MessageSource debug_logger_
Default debug logger.
sparta::PortSet unit_port_set_
The Unit's Ports.
Class used to either manually or auto-collect an Annotation String object in a pipeline database.
Macros for handling exponential backoff.
std::ostream & operator<<(std::ostream &o, const SimulationInfo &info)
ostream insertion operator for SimulationInfo
@ Flush
Phase where flushing of pipelines, etc can occur.