scc  2022.4.0
SystemC components library
scc::bitfield_register< datatype_t > Class Template Reference

Register that can contain bitfields. More...

#include <tlm_target_bfs_register_base.h>

Inheritance diagram for scc::bitfield_register< datatype_t >:
Collaboration diagram for scc::bitfield_register< datatype_t >:

Public Member Functions

constexpr bitfield_register (sc_core::sc_module_name name, size_t offset, datatype_t resetValue=0, datatype_t writeMask=-1, datatype_t readMask=-1)
 
constexpr size_t size () const noexcept override
 
void reset () override
 reset the resource
 
bool write (const uint8_t *data, std::size_t length, uint64_t offset, sc_core::sc_time &d) override
 
bool read (uint8_t *data, std::size_t length, uint64_t offset, sc_core::sc_time &d) const override
 
bool write_dbg (const uint8_t *data, std::size_t length, uint64_t offset=0) override
 debug write to the resource More...
 
bool read_dbg (uint8_t *data, std::size_t length, uint64_t offset=0) const override
 debug read the data from the resource More...
 
constexpr datatype_t get () const
 
void put (datatype_t value)
 
void registerBitfield (abstract_bitfield< datatype_t > &bitfield)
 
constexpr operator datatype_t () const
 
bitfield_register< datatype_t > & operator= (datatype_t other)
 
void setWriteCallback (std::function< void(bitfield_register< datatype_t > &, datatype_t &valueToWrite)> callback)
 
void setReadCallback (std::function< void(const bitfield_register< datatype_t > &, datatype_t &result)> callback)
 
- Public Member Functions inherited from scc::resource_access_if
bool write (const uint8_t *data, std::size_t length, uint64_t offset=0)
 
bool read (uint8_t *data, std::size_t length, uint64_t offset=0) const
 

Public Attributes

const size_t offset
 

Protected Attributes

const datatype_t resetValue
 
const datatype_t writeMask
 
const datatype_t readMask
 
datatype_t storage
 
std::function< void(bitfield_register< datatype_t > &, datatype_t &)> writeCallback
 
std::function< void(const bitfield_register< datatype_t > &, datatype_t &)> readCallback
 
std::vector< std::reference_wrapper< abstract_bitfield< datatype_t > > > bitfields
 

Detailed Description

template<typename datatype_t>
class scc::bitfield_register< datatype_t >

Register that can contain bitfields.

Template Parameters
datatype_tDatatype of the register value

Definition at line 86 of file tlm_target_bfs_register_base.h.

Constructor & Destructor Documentation

◆ bitfield_register()

template<typename datatype_t >
constexpr scc::bitfield_register< datatype_t >::bitfield_register ( sc_core::sc_module_name  name,
size_t  offset,
datatype_t  resetValue = 0,
datatype_t  writeMask = -1,
datatype_t  readMask = -1 
)
inlineconstexpr
Parameters
nameThe name of this register
offsetOffset of the peripheral base address this register is mapped
resetValueThis value gets written to the register on a reset condition
writeMaskOnly bits that are set get overwritten on a write access. Cleared bits are left unchanged. This field has priority over the individual bitfields or the write callback.
readMaskBits that are cleared in this field always read as 0. Can be overridden in bitfields or the read callback.

Definition at line 99 of file tlm_target_bfs_register_base.h.

Member Function Documentation

◆ get()

template<typename datatype_t >
constexpr datatype_t scc::bitfield_register< datatype_t >::get ( ) const
inlineconstexpr
Returns
the data stored in this register

Definition at line 170 of file tlm_target_bfs_register_base.h.

◆ operator datatype_t()

template<typename datatype_t >
constexpr scc::bitfield_register< datatype_t >::operator datatype_t ( ) const
inlineconstexpr

Convenience function to access the stored data

Definition at line 181 of file tlm_target_bfs_register_base.h.

◆ operator=()

template<typename datatype_t >
bitfield_register<datatype_t>& scc::bitfield_register< datatype_t >::operator= ( datatype_t  other)
inline

Convenience function to update the stored data

Definition at line 185 of file tlm_target_bfs_register_base.h.

◆ put()

template<typename datatype_t >
void scc::bitfield_register< datatype_t >::put ( datatype_t  value)
inline

Updates the stored data with value

Definition at line 174 of file tlm_target_bfs_register_base.h.

◆ read_dbg()

template<typename datatype_t >
bool scc::bitfield_register< datatype_t >::read_dbg ( uint8_t *  data,
std::size_t  length,
uint64_t  offset = 0 
) const
inlineoverridevirtual

debug read the data from the resource

Parameters
databuffer to read the data into
lengthlength of data to read
offsetoffset of the data to read
Returns
true it the access is successful

Implements scc::resource_access_if.

Definition at line 158 of file tlm_target_bfs_register_base.h.

◆ setReadCallback()

template<typename datatype_t >
void scc::bitfield_register< datatype_t >::setReadCallback ( std::function< void(const bitfield_register< datatype_t > &, datatype_t &result)>  callback)
inline

Register a callback that gets called on read. Overwrites previously stored callbacks. Signature: void onRead(const bitfield_register<datatype_t>& reg, datatype_t& result)

Callback is called after the individual bitfields.

Definition at line 211 of file tlm_target_bfs_register_base.h.

◆ setWriteCallback()

template<typename datatype_t >
void scc::bitfield_register< datatype_t >::setWriteCallback ( std::function< void(bitfield_register< datatype_t > &, datatype_t &valueToWrite)>  callback)
inline

Register a callback that is called on write. Overwrites previously stored callbacks. Signature: void onWrite(bitfield_register<datatype_t>& reg, datatype_t& valueToWrite)

Callback is called after the individual bitfields.

If you want to change the value that gets written to the register change the value of the parameter valueToWrite. Direct writes to the register do not work.

Definition at line 201 of file tlm_target_bfs_register_base.h.

◆ size()

template<typename datatype_t >
constexpr size_t scc::bitfield_register< datatype_t >::size ( ) const
inlineconstexproverridevirtualnoexcept
Returns
The size of the register in bytes

Implements scc::resource_access_if.

Definition at line 110 of file tlm_target_bfs_register_base.h.

◆ write_dbg()

template<typename datatype_t >
bool scc::bitfield_register< datatype_t >::write_dbg ( const uint8_t *  data,
std::size_t  length,
uint64_t  offset = 0 
)
inlineoverridevirtual

debug write to the resource

Parameters
datato write
lengthof data to write
offsetof the data to write
Returns
true it the access is successful

Implements scc::resource_access_if.

Definition at line 150 of file tlm_target_bfs_register_base.h.


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