scc  2022.4.0
SystemC components library
scc::impl::sc_register< DATATYPE > Class Template Reference

a simple register implementation More...

#include <register.h>

Inheritance diagram for scc::impl::sc_register< DATATYPE >:
Collaboration diagram for scc::impl::sc_register< DATATYPE >:

Public Types

using this_type = sc_register< DATATYPE >
 

Public Member Functions

 sc_register (sc_core::sc_module_name nm, DATATYPE &storage, const DATATYPE reset_val, resetable &owner, DATATYPE rdmask=get_max_uval< DATATYPE >(), DATATYPE wrmask=get_max_uval< DATATYPE >())
 the constructor More...
 
 ~sc_register ()=default
 desctructor
 
size_t size () const override
 get the size of this register in bytes More...
 
void reset () override
 reset the register
 
bool write (const uint8_t *data, size_t length, uint64_t offset, sc_core::sc_time &d) override
 write function from resource_access_if More...
 
bool read (uint8_t *data, size_t length, uint64_t offset, sc_core::sc_time &d) const override
 read function from resource_access_if More...
 
bool write_dbg (const uint8_t *data, size_t length, uint64_t offset=0) override
 debug write function from resource_access_if More...
 
bool read_dbg (uint8_t *data, size_t length, uint64_t offset=0) const override
 debug read function from resource_access_if More...
 
 operator DATATYPE () const
 cast operator to get underlying storage
 
DATATYPE get () const
 get the underlying storage More...
 
void put (DATATYPE data) const
 write to the underlying storage More...
 
this_typeoperator= (DATATYPE other)
 assignment operator More...
 
this_typeoperator|= (DATATYPE other)
 unary or More...
 
this_typeoperator&= (DATATYPE other)
 unary and More...
 
void set_read_cb (std::function< bool(const this_type &, DATATYPE &)> read_cb)
 set the read callback More...
 
void set_read_cb (std::function< bool(const this_type &, DATATYPE &, sc_core::sc_time &)> read_cb)
 
void set_write_cb (std::function< bool(this_type &, const DATATYPE &)> write_cb)
 set the write callback More...
 
void set_write_cb (std::function< bool(this_type &, const DATATYPE &, sc_core::sc_time &)> write_cb)
 
void trace (sc_core::sc_trace_file *trf) const override
 trace the register value to the given trace file More...
 
- Public Member Functions inherited from scc::resource_access_if
virtual bool write (const uint8_t *data, std::size_t length, uint64_t offset, sc_core::sc_time &d)=0
 
bool write (const uint8_t *data, std::size_t length, uint64_t offset=0)
 
virtual bool read (uint8_t *data, std::size_t length, uint64_t offset, sc_core::sc_time &d) const =0
 
bool read (uint8_t *data, std::size_t length, uint64_t offset=0) const
 
virtual bool write_dbg (const uint8_t *data, std::size_t length, uint64_t offset=0)=0
 debug write to the resource More...
 
virtual bool read_dbg (uint8_t *data, std::size_t length, uint64_t offset=0) const =0
 debug read the data from the resource More...
 
- Public Member Functions inherited from scc::traceable
virtual bool is_trace_enabled () const
 returns of this component shall be traced More...
 

Public Attributes

const DATATYPE res_val
 the reset value
 
const DATATYPE rdmask
 the SW read mask
 
const DATATYPE wrmask
 the SW write mask
 

Detailed Description

template<typename DATATYPE>
class scc::impl::sc_register< DATATYPE >

a simple register implementation

A simple register implementation taking a certain data type. The sc_register does not hold the value itself, the data storage needs to be provided. It only provides some resource access interface and handled callbacks for read and write accesses

Template Parameters
DATATYPE

Definition at line 73 of file register.h.

Constructor & Destructor Documentation

◆ sc_register()

template<typename DATATYPE >
scc::impl::sc_register< DATATYPE >::sc_register ( sc_core::sc_module_name  nm,
DATATYPE &  storage,
const DATATYPE  reset_val,
resetable owner,
DATATYPE  rdmask = get_max_uval<DATATYPE>(),
DATATYPE  wrmask = get_max_uval<DATATYPE>() 
)
inline

the constructor

Parameters
nmthe instance name
storagethe storage data structure
reset_valthe reset value
ownerthe owning object which needs to implement the resettable interface
rdmaskthe SW read mask
wrmaskthe SW write mask

Definition at line 88 of file register.h.

Member Function Documentation

◆ get()

template<typename DATATYPE >
DATATYPE scc::impl::sc_register< DATATYPE >::get ( ) const
inline

get the underlying storage

Returns

Definition at line 215 of file register.h.

◆ operator&=()

template<typename DATATYPE >
this_type & scc::impl::sc_register< DATATYPE >::operator&= ( DATATYPE  other)
inline

unary and

Parameters
otherthe other value
Returns
reference to this

Definition at line 252 of file register.h.

◆ operator=()

template<typename DATATYPE >
this_type & scc::impl::sc_register< DATATYPE >::operator= ( DATATYPE  other)
inline

assignment operator

Parameters
otherthe new value
Returns
reference to this

Definition at line 230 of file register.h.

◆ operator|=()

template<typename DATATYPE >
this_type & scc::impl::sc_register< DATATYPE >::operator|= ( DATATYPE  other)
inline

unary or

Parameters
otherthe other value
Returns
reference to this

Definition at line 241 of file register.h.

◆ put()

template<typename DATATYPE >
void scc::impl::sc_register< DATATYPE >::put ( DATATYPE  data) const
inline

write to the underlying storage

Parameters
datathe new value

Definition at line 222 of file register.h.

◆ read()

template<typename DATATYPE >
bool scc::impl::sc_register< DATATYPE >::read ( uint8_t *  data,
size_t  length,
uint64_t  offset,
sc_core::sc_time &  d 
) const
inlineoverride

read function from resource_access_if

Parameters
datato be read
lengthof data to be written in bytes
offsetof the write to the baseaddress of the register
doffset of the time in a time domain wrt. the SystemC simulator time (e.g. when using loosly-timed modeling)
Returns
true if access is successful

Definition at line 155 of file register.h.

◆ read_dbg()

template<typename DATATYPE >
bool scc::impl::sc_register< DATATYPE >::read_dbg ( uint8_t *  data,
size_t  length,
uint64_t  offset = 0 
) const
inlineoverride

debug read function from resource_access_if

This access should not cause any side effect!

Parameters
datato be read
lengthof data to be written in bytes
offsetof the write to the baseaddress of the register
Returns
true if access is successful

Definition at line 196 of file register.h.

◆ set_read_cb()

template<typename DATATYPE >
void scc::impl::sc_register< DATATYPE >::set_read_cb ( std::function< bool(const this_type &, DATATYPE &)>  read_cb)
inline

set the read callback

The read callback is triggered upon a read request without forwarding the annotated time this is primary for backward compatibility

Parameters
read_cbthe callback functor

Definition at line 265 of file register.h.

◆ set_write_cb() [1/2]

template<typename DATATYPE >
void scc::impl::sc_register< DATATYPE >::set_write_cb ( std::function< bool(this_type &, const DATATYPE &)>  write_cb)
inline

set the write callback

The write callback functor is triggered upon a write request without forwarding the annotated time this is primary for backward compatibility

Parameters
write_cbthe callback functor

Definition at line 286 of file register.h.

◆ set_write_cb() [2/2]

template<typename DATATYPE >
void scc::impl::sc_register< DATATYPE >::set_write_cb ( std::function< bool(this_type &, const DATATYPE &, sc_core::sc_time &)>  write_cb)
inline

set the write callback triggered upon a write request

Parameters
write_cb

Definition at line 302 of file register.h.

◆ size()

template<typename DATATYPE >
size_t scc::impl::sc_register< DATATYPE >::size ( ) const
inlineoverridevirtual

get the size of this register in bytes

Returns

Implements scc::resource_access_if.

Definition at line 109 of file register.h.

◆ trace()

template<typename DATATYPE >
void scc::impl::sc_register< DATATYPE >::trace ( sc_core::sc_trace_file *  trf) const
inlineoverride

trace the register value to the given trace file

Parameters
trfthe trace file

Definition at line 309 of file register.h.

◆ write()

template<typename DATATYPE >
bool scc::impl::sc_register< DATATYPE >::write ( const uint8_t *  data,
size_t  length,
uint64_t  offset,
sc_core::sc_time &  d 
)
inlineoverride

write function from resource_access_if

Parameters
datato be written
lengthof data to be written in bytes
offsetof the write to the baseaddress of the register
doffset of the time in a time domain wrt. the SystemC simulator time (e.g. when using loosly-timed modeling)
Returns
true if access is successful

Definition at line 134 of file register.h.

◆ write_dbg()

template<typename DATATYPE >
bool scc::impl::sc_register< DATATYPE >::write_dbg ( const uint8_t *  data,
size_t  length,
uint64_t  offset = 0 
)
inlineoverride

debug write function from resource_access_if

This access should not cause any side effect!

Parameters
datato be written
lengthof data to be written in bytes
offsetof the write to the baseaddress of the register
Returns
true if access is successful

Definition at line 178 of file register.h.


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