The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::RegisterBankTable< RegisterT > Class Template Reference

Container of register banks as a helper for RegisterSet. Instances of this class will be owned by a single RegisterSet. More...

#include <RegisterBankTable.hpp>

Public Types

typedef std::unordered_map< Register::group_idx_type, RegisterT * > RegisterMap
 Vector of registers owned externally. Available for lookup within a group by Register::Definition::group_idx_type.
 
typedef std::vector< RegisterT * > RegisterVector
 
typedef std::vector< RegisterMapGroupVector
 Vector of RegisterMap's used for lookup by numeric group number of type Register::Definition::group_num_type.
 
typedef std::vector< GroupVectorBankVector
 Vector of GroupVectors used for lookup by numeric bank index of type Register::Definition::bank_idx_type.
 

Public Member Functions

 RegisterBankTable ()
 Constructor.
 
virtual ~RegisterBankTable ()=default
 Destructor.
 
RegisterT::bank_idx_type getNumBanks () const
 Gets the total number of banks instantiated (even if they contain have no actual registers accessible). Note that banks are created between 0 and the highest bank index requested by a register.
 
RegisterT::group_idx_type getNumGroups () const
 Gets the number of register groups added to this table regardless of banks.
 
uint32_t getGroupSize (typename RegisterT::group_num_type group_num, typename RegisterT::bank_idx_type bank_num)
 Gets the number of registers in a group by its group num and bank.
 
GroupVectoroperator[] (typename RegisterT::bank_idx_type bank_idx)
 
GroupVectorat (typename RegisterT::bank_idx_type bank_idx)
 
uint32_t getNumRegisters () const
 Returns number of registers in this table. This excludes any registers added having no group number.
 
void setMinimumBankIndex (Register::bank_idx_type min_idx)
 Sets the minimum bank index for this register set, overriding the default of BANK_IDX_DEFAULT.
 
void addRegister (RegisterT *r)
 Adds a register to this table unless it is not a member of a group (See Register::getGroupNum.
 
bool canLookupRegister (typename RegisterT::group_num_type group_num, typename RegisterT::group_idx_type group_idx, typename RegisterT::bank_idx_type bank_idx) const noexcept
 
RegisterT * lookupRegister (typename RegisterT::group_num_type group_num, typename RegisterT::group_idx_type group_idx, typename RegisterT::bank_idx_type bank_idx)
 
const RegisterT * lookupRegister (typename RegisterT::group_num_type group_num, typename RegisterT::group_idx_type group_idx, typename RegisterT::bank_idx_type bank_idx) const
 
RegisterT * getRegister (typename RegisterT::group_num_type group_num, typename RegisterT::group_idx_type group_idx, typename RegisterT::bank_idx_type bank_idx)
 Gets a Register by group number and group index and throws an exception if it cannot be found.
 
virtual std::string stringize (bool pretty=false) const
 
void dump (std::ostream &out, bool detailed=false) const
 Dump this register bank table to an out stream. Banks will be columns and group num/id will be rows.
 

Protected Member Functions

void extendBanks_ (typename RegisterT::bank_idx_type num_banks)
 Extends the banks_ vector to contain num_banks entries.
 
void insertRegisterInBank_ (RegisterT *r, GroupVector &bank)
 Insert a register in a specific bank.
 

Detailed Description

template<typename RegisterT>
class sparta::RegisterBankTable< RegisterT >

Container of register banks as a helper for RegisterSet. Instances of this class will be owned by a single RegisterSet.

Contains a table of dimensions B (for each bank) and G (the number of groups in the register set which owns that instance of this object/ The number of registers in a group can vary between groups.

Banks and Groups effectively form a matrix of B,G dimensions.

This structure is not intended to be dynamic. It can be built, but does not expect changes to bank mappings at runtime

Definition at line 30 of file RegisterBankTable.hpp.

Member Typedef Documentation

◆ BankVector

template<typename RegisterT >
typedef std::vector<GroupVector> sparta::RegisterBankTable< RegisterT >::BankVector

Vector of GroupVectors used for lookup by numeric bank index of type Register::Definition::bank_idx_type.

Definition at line 65 of file RegisterBankTable.hpp.

◆ GroupVector

template<typename RegisterT >
typedef std::vector<RegisterMap> sparta::RegisterBankTable< RegisterT >::GroupVector

Vector of RegisterMap's used for lookup by numeric group number of type Register::Definition::group_num_type.

Definition at line 59 of file RegisterBankTable.hpp.

◆ RegisterMap

template<typename RegisterT >
typedef std::unordered_map<Register::group_idx_type, RegisterT *> sparta::RegisterBankTable< RegisterT >::RegisterMap

Vector of registers owned externally. Available for lookup within a group by Register::Definition::group_idx_type.

Definition at line 52 of file RegisterBankTable.hpp.

◆ RegisterVector

template<typename RegisterT >
typedef std::vector<RegisterT *> sparta::RegisterBankTable< RegisterT >::RegisterVector

Definition at line 53 of file RegisterBankTable.hpp.

Constructor & Destructor Documentation

◆ RegisterBankTable()

template<typename RegisterT >
sparta::RegisterBankTable< RegisterT >::RegisterBankTable ( )
inline

Constructor.

Definition at line 70 of file RegisterBankTable.hpp.

Member Function Documentation

◆ addRegister()

template<typename RegisterT >
void sparta::RegisterBankTable< RegisterT >::addRegister ( RegisterT *  r)
inline

Adds a register to this table unless it is not a member of a group (See Register::getGroupNum.

Parameters
rRegister to add to the banking table
Postcondition
Bank table will have a bank set capable of containing all entries in the register bank membership
getNumRegisters will increase unless this register's group_num is Register::GROUP_NUM_NONE
Exceptions
SpartaExceptionif r is nullptr, the definition of r has a bank_membership field with an index at or exceeding ERROR_MAX_BANK_IDX, or on index in the bank_membership along with the group number and group index already point to an existing register. If the bank_membership field of the register definition is empty, any register existing in any bank having the same group and index will cause an exception. If register has a group_num of Register::GROUP_NUM_NONE and a non-empty bank membership set, throws
Todo:
Use logger
Todo:
Use logger
Todo:
Use logger

Definition at line 189 of file RegisterBankTable.hpp.

Here is the call graph for this function:

◆ at()

template<typename RegisterT >
GroupVector & sparta::RegisterBankTable< RegisterT >::at ( typename RegisterT::bank_idx_type  bank_idx)
inline

Definition at line 139 of file RegisterBankTable.hpp.

◆ canLookupRegister()

template<typename RegisterT >
bool sparta::RegisterBankTable< RegisterT >::canLookupRegister ( typename RegisterT::group_num_type  group_num,
typename RegisterT::group_idx_type  group_idx,
typename RegisterT::bank_idx_type  bank_idx 
) const
inlinenoexcept

Definition at line 292 of file RegisterBankTable.hpp.

◆ dump()

template<typename RegisterT >
void sparta::RegisterBankTable< RegisterT >::dump ( std::ostream &  out,
bool  detailed = false 
) const
inline

Dump this register bank table to an out stream. Banks will be columns and group num/id will be rows.

Definition at line 382 of file RegisterBankTable.hpp.

Here is the call graph for this function:

◆ extendBanks_()

template<typename RegisterT >
void sparta::RegisterBankTable< RegisterT >::extendBanks_ ( typename RegisterT::bank_idx_type  num_banks)
inlineprotected

Extends the banks_ vector to contain num_banks entries.

Parameters
num_banksnumber of banks that must be contained in extendBanks
Postcondition
banks_.size() will be >= num_banks
Any Register in unbanked_regs_ will be accessible in the added banks (presumably it was already accessible in the original banks)

Definition at line 483 of file RegisterBankTable.hpp.

Here is the call graph for this function:

◆ getGroupSize()

template<typename RegisterT >
uint32_t sparta::RegisterBankTable< RegisterT >::getGroupSize ( typename RegisterT::group_num_type  group_num,
typename RegisterT::bank_idx_type  bank_num 
)
inline

Gets the number of registers in a group by its group num and bank.

Parameters
group_numNumber of group to get children from. If GROUP_NUM_NONE, will return 0.
Returns
Number of children in this group, including anonymous nodes. Aliases do not affect this result. If no group with the given num was specified, returns 0. This implies that the group was never created.
Exceptions
SpartaExceptionif referring to an invalid bank_num

Definition at line 114 of file RegisterBankTable.hpp.

◆ getNumBanks()

template<typename RegisterT >
RegisterT::bank_idx_type sparta::RegisterBankTable< RegisterT >::getNumBanks ( ) const
inline

Gets the total number of banks instantiated (even if they contain have no actual registers accessible). Note that banks are created between 0 and the highest bank index requested by a register.

Definition at line 91 of file RegisterBankTable.hpp.

◆ getNumGroups()

template<typename RegisterT >
RegisterT::group_idx_type sparta::RegisterBankTable< RegisterT >::getNumGroups ( ) const
inline

Gets the number of register groups added to this table regardless of banks.

Definition at line 100 of file RegisterBankTable.hpp.

◆ getNumRegisters()

template<typename RegisterT >
uint32_t sparta::RegisterBankTable< RegisterT >::getNumRegisters ( ) const
inline

Returns number of registers in this table. This excludes any registers added having no group number.

Definition at line 148 of file RegisterBankTable.hpp.

◆ getRegister()

template<typename RegisterT >
RegisterT * sparta::RegisterBankTable< RegisterT >::getRegister ( typename RegisterT::group_num_type  group_num,
typename RegisterT::group_idx_type  group_idx,
typename RegisterT::bank_idx_type  bank_idx 
)
inline

Gets a Register by group number and group index and throws an exception if it cannot be found.

Parameters
group_numGroup identifier number. Corresponds to sparta::Register::Definition::group_num
group_idxIndex within the given group. Corresponds to sparta::Register::Definition::group_idx
Returns
A non-nullptr Register. Guaranteed to return or throw
Exceptions
SpartaExeptionif the register cannot be found.
Note
This is a safe alternative to the lookupRegister method with bounds-checking, though with a performance penalty

Definition at line 337 of file RegisterBankTable.hpp.

◆ insertRegisterInBank_()

template<typename RegisterT >
void sparta::RegisterBankTable< RegisterT >::insertRegisterInBank_ ( RegisterT *  r,
GroupVector bank 
)
inlineprotected

Insert a register in a specific bank.

Parameters
rRegister to insert
bankGroupVector of the bank into which this register will be inserted.
Postcondition
Increases the group size of the given bank to contain the register
Increases the register map size of the group within this bank that contains the register
Exceptions
Mustnot throw. Check that the register can be added first

Definition at line 505 of file RegisterBankTable.hpp.

◆ lookupRegister() [1/2]

template<typename RegisterT >
RegisterT * sparta::RegisterBankTable< RegisterT >::lookupRegister ( typename RegisterT::group_num_type  group_num,
typename RegisterT::group_idx_type  group_idx,
typename RegisterT::bank_idx_type  bank_idx 
)
inline

Definition at line 301 of file RegisterBankTable.hpp.

◆ lookupRegister() [2/2]

template<typename RegisterT >
const RegisterT * sparta::RegisterBankTable< RegisterT >::lookupRegister ( typename RegisterT::group_num_type  group_num,
typename RegisterT::group_idx_type  group_idx,
typename RegisterT::bank_idx_type  bank_idx 
) const
inline

Definition at line 313 of file RegisterBankTable.hpp.

◆ operator[]()

template<typename RegisterT >
GroupVector & sparta::RegisterBankTable< RegisterT >::operator[] ( typename RegisterT::bank_idx_type  bank_idx)
inline

Definition at line 134 of file RegisterBankTable.hpp.

◆ setMinimumBankIndex()

template<typename RegisterT >
void sparta::RegisterBankTable< RegisterT >::setMinimumBankIndex ( Register::bank_idx_type  min_idx)
inline

Sets the minimum bank index for this register set, overriding the default of BANK_IDX_DEFAULT.

Parameters
min_idxMinimum bank index to be accessible. This is an index, so the minimum number of banks required will be min_idx+1
Note
This can only increase the number of banks currently represented

This ensures that a minimum number of banks are instantiated in this RegisterSet. Register set definitions can cause more banks to be instantiated though.

This is required if banked operation is required, but for som reason all registers in the RegisterSet are unbanked (available in every bank) because all of their definitions' bank_membership list are empty.

Definition at line 168 of file RegisterBankTable.hpp.

Here is the call graph for this function:

◆ stringize()

template<typename RegisterT >
virtual std::string sparta::RegisterBankTable< RegisterT >::stringize ( bool  pretty = false) const
inlinevirtual

Definition at line 369 of file RegisterBankTable.hpp.


The documentation for this class was generated from the following file: