SatCat5
satcat5::test::CfgRegister Class Reference

Detailed Description

Simulation of a single ConfigBus register.

See also
sim_cfgbus.h Each register write is saved for later inspection by the test script (i.e., write_count, write_next). Each register read depends on mode; it may echo the most recent write, read a single fixed value, or pull from a pre-populated queue.

Definition at line 30 of file sim_cfgbus.h.

#include <sim_cfgbus.h>

Inheritance diagram for satcat5::test::CfgRegister:
[legend]
Collaboration diagram for satcat5::test::CfgRegister:
[legend]

Public Member Functions

 CfgRegister ()
 Constructor for a single register. More...
 
unsigned read_count () const
 Total reads from this register.
 
unsigned write_count () const
 Total writes to this register.
 
void read_push (u32 val)
 Queue up a read for this register. More...
 
unsigned read_queue () const
 Number of queued responses. More...
 
u32 write_pop ()
 Pop one value from the recent write queue. More...
 
unsigned write_queue () const
 
satcat5::cfg::IoStatus read (unsigned regaddr, u32 &rdval) override
 Basic single-register read operation.
 
satcat5::cfg::IoStatus write (unsigned regaddr, u32 wrval) override
 Basic single-register write operation.
 
virtual satcat5::cfg::IoStatus read_array (unsigned regaddr, unsigned count, u32 *result)
 Bulk-read with auto-increment (regaddr, regaddr+1, ...) Bulk read/write operations are more efficient when controlling ConfigBus peripherals over a network interface.
 
virtual satcat5::cfg::IoStatus read_repeat (unsigned regaddr, unsigned count, u32 *result)
 Bulk-read the same register N times.
 
virtual satcat5::cfg::IoStatus write_array (unsigned regaddr, unsigned count, const u32 *data)
 Bulk-write with auto-increment (regaddr, regaddr+1, ...)
 
virtual satcat5::cfg::IoStatus write_repeat (unsigned regaddr, unsigned count, const u32 *data)
 Bulk-write the same register N times.
 
unsigned get_regaddr (unsigned dev, unsigned reg) const
 Convert device + register to combined address.
 
void register_irq (satcat5::cfg::Interrupt *obj)
 Add an interrupt handler. More...
 
void unregister_irq (satcat5::cfg::Interrupt *obj)
 Remove an interrupt handler.
 
unsigned count_irq () const
 Count attached interrupt handlers.
 
satcat5::cfg::Register get_register (unsigned dev, unsigned reg=0)
 Create register-map object for the given device address. More...
 
void irq_poll ()
 Poll all registered ConfigBus interrupt handlers. More...
 
void read_default_none ()
 Set default value for reads when the queue is empty. More...
 
void read_default_echo ()
 Set default value for reads when the queue is empty. More...
 
void read_default (u32 val)
 Set default value for reads when the queue is empty. More...
 

Protected Types

enum class  ReadMode { UNSAFE , STRICT , ECHO , CONSTANT }
 

Protected Attributes

std::deque< u32 > m_queue_rd
 
std::deque< u32 > m_queue_wr
 
ReadMode m_rd_mode
 
u32 m_rd_dval
 
unsigned m_rd_count
 
unsigned m_wr_count
 
volatile u32 * m_base_ptr
 
satcat5::util::List< satcat5::cfg::Interruptm_irq_list
 

Constructor & Destructor Documentation

◆ CfgRegister()

CfgRegister::CfgRegister ( )

Constructor for a single register.

For safety checking, registers cannot be read by default. Call read_default_* to set the appropriate mode.

Definition at line 15 of file sim_cfgbus.cc.

Member Function Documentation

◆ get_register()

Register ConfigBus::get_register ( unsigned  dev,
unsigned  reg = 0 
)
inherited

Create register-map object for the given device address.

(Or for a specific register, if the register address is specified.)

Definition at line 101 of file cfgbus_core.cc.

◆ irq_poll()

void ConfigBus::irq_poll ( )
inherited

Poll all registered ConfigBus interrupt handlers.

Issue callbacks to any that may have triggered. (This method should not usually be called directly.)

Definition at line 111 of file cfgbus_core.cc.

◆ read_default()

void CfgRegister::read_default ( u32  val)

Set default value for reads when the queue is empty.

The simulated register includes a queue of expected reads.

See also
read_push, read_count, read_queue. These methods set the behavior when that queue is empty:

Definition at line 34 of file sim_cfgbus.cc.

◆ read_default_echo()

void CfgRegister::read_default_echo ( )

Set default value for reads when the queue is empty.

The simulated register includes a queue of expected reads.

See also
read_push, read_count, read_queue. These methods set the behavior when that queue is empty:

Definition at line 29 of file sim_cfgbus.cc.

◆ read_default_none()

void CfgRegister::read_default_none ( )

Set default value for reads when the queue is empty.

The simulated register includes a queue of expected reads.

See also
read_push, read_count, read_queue. These methods set the behavior when that queue is empty:

Definition at line 24 of file sim_cfgbus.cc.

◆ read_push()

void CfgRegister::read_push ( u32  val)

Queue up a read for this register.

The read queue is populated by the mock or test infrastructure. Reads are pulled from the queue until it is empty, then follow the "default" policy set by the various "read_default" methods.

See also
read_default_none, read_default_echo, read_default

Definition at line 39 of file sim_cfgbus.cc.

◆ read_queue()

unsigned CfgRegister::read_queue ( ) const

Number of queued responses.

See also
read_push.

Definition at line 45 of file sim_cfgbus.cc.

◆ register_irq()

void ConfigBus::register_irq ( satcat5::cfg::Interrupt obj)
inherited

Add an interrupt handler.

Each ConfigBus interface has a single interrupt signal, which is the logical OR of interrupts from all attached peripherals. When any peripheral raises its interrupt signal, call irq_poll().

Definition at line 80 of file cfgbus_core.cc.

◆ write_pop()

u32 CfgRegister::write_pop ( )

Pop one value from the recent write queue.

Each write to the register is added to an queue, which can then be queried to verify that the written value is correct. Number of queued write values.

See also
write_pop.

Definition at line 52 of file sim_cfgbus.cc.


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