The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::RegisterBase::Definition Struct Reference

Describes an architected Register. More...

#include <Register.hpp>

Public Types

typedef uint16_t HintsT
 Register hint flags. The flags are not part of sparta but should be defined by the model.
 
typedef uint16_t RegDomainT
 Register Domain. The flags are not part of sparta but should be defined by the model.
 

Public Attributes

const ident_type id
 ID. Must be unique within a register set.
 
const char * name
 String identifier for this register which distinguishes it from its neighbors. Must adhere to TreeNode::validateName. Must NOT be NULL.
 
const group_num_type group_num
 Numeric identifer for the group to which this register belongs. This identifies the group for fast lookups in a register set by group. It is up to the user of a RegisterSet to give meaning to group numbers. Group numbers must consistently map to the same group string within a RegisterSet. If set to anything but GROUP_NUM_NONE, group must be set to something other than sparta::TreeNode::GROUP_NAME_NONE. Internally, a lookup-vector is built for fast queries, so low numbers should be used.
 
const char * group
 String name of group in which this register resides (e.g. gpr). Must NOT be NULL. See sparta::TreeNode::TreeNode. It is up to the user of a RegisterSet to give meaning to group names. All Definitions in the same RegisterSet must contain consistent (group_num:group) mappings.
 
const group_idx_type group_idx
 Index of register within group. See sparta::TreeNode::TreeNode. Internally, a lookup-vector is built for fast queries, so low indexes should be used.
 
const char * desc
 Description. Must NOT be NULL.
 
const size_type bytes
 Size of this register in bytes. Non-byte multiples are not supported.
 
const std::vector< Field::Definitionfields
 Vector of field definitions. Use like so for empty fields: { name, group_num,..., bytes, {}, aliases ... }; and like so for values { name, group_num,..., bytes, { {"afield","right here",0,1} }, aliases ... };.
 
const std::vector< bank_idx_typebank_membership
 Vector of bank indexes of banks in which this register is accessible.
 
const char ** aliases
 Null-terminated array of of char*s (e.g. {"a", "b", 0}). If there are no aliases, this may be 0.
 
const ident_type subset_of
 ID of register of which this is a subset. If INVALID_ID, has no effect.
 
const size_type subset_offset
 Offset (in Bytes) into regster of which this is a subset. subset_offset+(this->bytes) must be <= the size (bytes) of the register of which this is a subset (this->subset_of). This field has no effect if subset_of=INVALID_ID.
 
const unsigned char * initial_value
 Initial value of this register.
 
const HintsT hints
 
const RegDomainT regdomain
 
const bool writable = true
 Writable flag, taken from the register definition.
 

Detailed Description

Describes an architected Register.

Can be constructed with initializer list as in:

const Register::group_num_type GROUP_ASPR = 0;
const Register::group_num_type GROUP_GPR = 1;
sparta::Register::Field::Definition aspr_fields[] =
;
{ {0, "aspr", 0, GROUP_ASPR, "aspr", 0, "This is ASPR 1", 4,
{ { "N", "Negative condition flag", 31, 31 },
{ "Z", "Zero condition flag", 30, 30 },
{ "C", "Carry condition flag", 29, 29 },
{ "V", "Overflow condition flag", 28, 28 },
{ "Q", "Overflow or saturation flag", 27, 27 },
{ "GE", "Greater than or equal flags", 23, 26 } },
nullptr, Register::INVALID_ID, 0},
{0, "r1", 1, GROUP_GPR, "gpr", 1, "This is GPR 1", {} , {BANK_IDX_DEFAULT}, nullptr, Register::INVALID_ID, 0, nullptr},
static constexpr ident_type INVALID_ID
Represents an invalid Register ID.
Definition Register.hpp:686
static constexpr bank_idx_type BANK_IDX_DEFAULT
Default index for bank when no bank is specified. A bank having this index will always exist.
Definition Register.hpp:127
uint32_t group_num_type
Numeric group identifier for register lookup.
Definition Register.hpp:87
static const Definition DEFINITION_END
Entry indicating the end of a sparta::Register::Definition array.
Definition Register.hpp:692
Describes an architected Register.
Definition Register.hpp:548
Todo:
Add omitted fields:
  • (address)
  • (por value or functor)
  • (r/w masks)
  • (access/privilege levels)

Definition at line 547 of file Register.hpp.

Member Typedef Documentation

◆ HintsT

Register hint flags. The flags are not part of sparta but should be defined by the model.

Definition at line 669 of file Register.hpp.

◆ RegDomainT

Register Domain. The flags are not part of sparta but should be defined by the model.

Definition at line 676 of file Register.hpp.

Member Data Documentation

◆ aliases

const char** sparta::RegisterBase::Definition::aliases

Null-terminated array of of char*s (e.g. {"a", "b", 0}). If there are no aliases, this may be 0.

Definition at line 644 of file Register.hpp.

◆ bank_membership

const std::vector<bank_idx_type> sparta::RegisterBase::Definition::bank_membership

Vector of bank indexes of banks in which this register is accessible.

Note
These indices are not necessarily equal to the simulated architecture's execution modes (or whatever determines which bank to access).
An empty set here means that the register is "unbanked" - and causes the register to be accessible in every bank.
The total number of banks in existance in the RegisterSet containing this register is dictated by the register having the highest index in its definition's bank_membership field (or 0 if no registers have any bank indices in their bank_membership fields). This can be overridden by RegisterSet::setMinimumBankIndex.
Do not duplicate indices in this list
An index in this list must not collide with any other register in the same register set having the same group number and group index In a non-banked system, leave this vector empty or add a single element containing BANK_IDX_DEFAULT. The indices in this vector needn't be defined ahead of time. The RegisterSet model will build its representation up as it encounters new bank indexes in this field.
Warning
Banking is implemented using using a dense array, so using large values can waste lost of host memory.

Definition at line 638 of file Register.hpp.

◆ bytes

const size_type sparta::RegisterBase::Definition::bytes

Size of this register in bytes. Non-byte multiples are not supported.

Definition at line 602 of file Register.hpp.

◆ desc

const char* sparta::RegisterBase::Definition::desc

Description. Must NOT be NULL.

Definition at line 596 of file Register.hpp.

◆ fields

const std::vector<Field::Definition> sparta::RegisterBase::Definition::fields

Vector of field definitions. Use like so for empty fields: { name, group_num,..., bytes, {}, aliases ... }; and like so for values { name, group_num,..., bytes, { {"afield","right here",0,1} }, aliases ... };.

Definition at line 610 of file Register.hpp.

◆ group

const char* sparta::RegisterBase::Definition::group

String name of group in which this register resides (e.g. gpr). Must NOT be NULL. See sparta::TreeNode::TreeNode. It is up to the user of a RegisterSet to give meaning to group names. All Definitions in the same RegisterSet must contain consistent (group_num:group) mappings.

Definition at line 583 of file Register.hpp.

◆ group_idx

const group_idx_type sparta::RegisterBase::Definition::group_idx

Index of register within group. See sparta::TreeNode::TreeNode. Internally, a lookup-vector is built for fast queries, so low indexes should be used.

Definition at line 591 of file Register.hpp.

◆ group_num

const group_num_type sparta::RegisterBase::Definition::group_num

Numeric identifer for the group to which this register belongs. This identifies the group for fast lookups in a register set by group. It is up to the user of a RegisterSet to give meaning to group numbers. Group numbers must consistently map to the same group string within a RegisterSet. If set to anything but GROUP_NUM_NONE, group must be set to something other than sparta::TreeNode::GROUP_NAME_NONE. Internally, a lookup-vector is built for fast queries, so low numbers should be used.

Definition at line 573 of file Register.hpp.

◆ hints

const HintsT sparta::RegisterBase::Definition::hints

Definition at line 670 of file Register.hpp.

◆ id

const ident_type sparta::RegisterBase::Definition::id

ID. Must be unique within a register set.

Definition at line 552 of file Register.hpp.

◆ initial_value

const unsigned char* sparta::RegisterBase::Definition::initial_value

Initial value of this register.

Definition at line 663 of file Register.hpp.

◆ name

const char* sparta::RegisterBase::Definition::name

String identifier for this register which distinguishes it from its neighbors. Must adhere to TreeNode::validateName. Must NOT be NULL.

Definition at line 559 of file Register.hpp.

◆ regdomain

const RegDomainT sparta::RegisterBase::Definition::regdomain

Definition at line 677 of file Register.hpp.

◆ subset_of

const ident_type sparta::RegisterBase::Definition::subset_of

ID of register of which this is a subset. If INVALID_ID, has no effect.

Definition at line 650 of file Register.hpp.

◆ subset_offset

const size_type sparta::RegisterBase::Definition::subset_offset

Offset (in Bytes) into regster of which this is a subset. subset_offset+(this->bytes) must be <= the size (bytes) of the register of which this is a subset (this->subset_of). This field has no effect if subset_of=INVALID_ID.

Definition at line 658 of file Register.hpp.

◆ writable

const bool sparta::RegisterBase::Definition::writable = true

Writable flag, taken from the register definition.

Definition at line 682 of file Register.hpp.


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