Master

The memory interface Master class is the interface for initiating a memory transaction. Each Master class object will be coupled with one or more Slave objects.

Master objects in C++ are referenced by the following shared pointer typedef:

typedef std::shared_ptr<rogue::interfaces::memory::Master> rogue::interfaces::memory::MasterPtr

Shared pointer alias for Master.

The class description is shown below:

class Master

Master endpoint for memory transactions.

Master initiates transactions on a memory bus tree. Each master connects to one downstream Slave or Hub, and hub levels may be chained. Hub offsets are applied to transaction addresses as requests propagate toward leaf slave devices.

Subclassed by rogue::interfaces::memory::Block, rogue::interfaces::memory::Hub, rogue::interfaces::memory::TcpServer

Public Functions

Master()

Constructs a memory master instance.

This constructor is a low-level C++ allocation path. Prefer create() when shared ownership or Python exposure is required.

virtual ~Master()

Destroys the memory master instance.

virtual void stop()

Stops the interface and releases runtime resources.

void setSlave(std::shared_ptr<rogue::interfaces::memory::Slave> slave)

Sets the downstream slave or hub.

Transactions generated by this master are forwarded to this target. The target may be a leaf slave or a hub that forwards to lower levels. Exposed as _setSlave() in Python.

Parameters:

slave – Downstream slave or hub pointer.

std::shared_ptr<rogue::interfaces::memory::Slave> getSlave()

Returns the configured downstream slave or hub.

Exposed as _getSlave() in Python.

Returns:

Downstream slave or hub pointer.

uint32_t reqSlaveId()

Queries the downstream slave ID.

Forwards the request to the lowest-level slave servicing this master path. This is used to determine which masters share an address space. Exposed as _reqSlaveId() in Python.

Returns:

Unique 32-bit slave ID.

std::string reqSlaveName()

Queries the downstream slave name.

Forwards the request to the lowest-level slave servicing this master path. This allows the system to determine which memory Masters share an address space. Exposed as _reqSlaveName() in Python.

Returns:

Slave name string.

uint32_t reqMinAccess()

Queries minimum access size in bytes for this interface path.

Request is forwared to the lowest-level slave to determine the minimum transaction size. Exposed as _reqMinAccess() in Python.

Returns:

Minimum transaction size in bytes.

uint32_t reqMaxAccess()

Queries maximum access size in bytes for this interface path.

Request is forwared to the lowest-level slave to determine the maximum transaction size. Exposed as _reqMaxAccess() in Python.

Returns:

Maximum transaction size in bytes.

uint64_t reqAddress()

Queries the address offset of the next downstream layer.

Returns the relative offset of the connected slave/hub and does not include any local master offset. Exposed as _reqAddress() in Python.

Returns:

Downstream relative address offset.

std::string getError()

Returns the last transaction error string.

Exposed as _getError() in Python.

Returns:

Error string for the last transaction sequence.

void clearError()

Clears the stored transaction error string.

Exposed as _clearError() in Python.

void setTimeout(uint64_t timeout)

Sets the timeout value for future transactions.

Timeout controls how long the master waits for transaction completion. Exposed as _setTimeout() in Python.

Parameters:

timeout – Timeout value in microseconds. A value of 0 leaves the current timeout unchanged.

uint32_t reqTransaction(uint64_t address, uint32_t size, void *data, uint32_t type)

Starts a new transaction.

Creates a transaction object and forwards it to the lowest-level slave in the memory tree. The address is relative to the next layer offset and multiple transactions may be pending simultaneously. Not exposed to Python (see reqTransactionPy).

Parameters:
  • address – Relative 64-bit transaction address.

  • sizeTransaction size in bytes.

  • data – Pointer to transaction data storage.

  • typeTransaction type constant.

Returns:

32-bit transaction ID.

uint32_t reqTransactionPy(uint64_t address, boost::python::object p, uint32_t size, uint32_t offset, uint32_t type)

Python variant of reqTransaction.

Uses a Python buffer-protocol object instead of a raw C++ data pointer. Exposed to Python as _reqTransaction().

p may be any object exporting the buffer protocol (for example bytearray, bytes, memoryview, or a contiguous NumPy array). For Read/Verify transactions, p should be a writable contiguous buffer so returned data can be written into it.

Parameters:
  • address – Relative 64-bit transaction address.

  • p – Python buffer-protocol object containing transaction bytes.

  • sizeTransaction size in bytes.

  • offset – Byte offset within p.

  • typeTransaction type constant.

Returns:

32-bit transaction ID.

void rshiftPy(boost::python::object p)

Supports >> operator usage from Python.

std::shared_ptr<rogue::interfaces::memory::Slave> &operator>>(std::shared_ptr<rogue::interfaces::memory::Slave> &other)

Connects this master to a slave via stream chaining operator.

void waitTransaction(uint32_t id)

Waits for transaction completion or timeout.

Passing 0 waits for all currently pending transactions. Exposed as _waitTransaction() in Python.

Parameters:

idTransaction ID to wait for, or 0 for all.

Public Static Functions

static std::shared_ptr<rogue::interfaces::memory::Master> create()

Creates a memory master instance.

Exposed as rogue.interfaces.memory.Master() in Python. This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returns std::shared_ptr ownership compatible with Rogue pointer typedefs.

Returns:

Shared pointer to the created master.

static void setup_python()

Registers this type with Python bindings.

static void copyBits(uint8_t *dstData, uint32_t dstLsb, uint8_t *srcData, uint32_t srcLsb, uint32_t size)

Copies bits between two byte arrays.

Copies size bits from srcData starting at bit srcLsb into dstData starting at bit dstLsb.

Bit numbering is least-significant-bit-first within each byte (bit 0 is the LSB of byte 0). The routine preserves destination bits outside the copied range and supports arbitrary unaligned source/destination bit offsets. When both offsets are byte-aligned, it uses a byte-copy fast path.

This helper underpins variable packing/unpacking logic in the memory layer. Exposed as _copyBits() in Python.

Parameters:
  • dstData – Destination byte array.

  • dstLsb – Least-significant destination bit index.

  • srcData – Source byte array.

  • srcLsb – Least-significant source bit index.

  • size – Number of bits to copy.

static void copyBitsPy(boost::python::object dst, uint32_t dstLsb, boost::python::object src, uint32_t srcLsb, uint32_t size)

Python wrapper for copyBits.

Accepts Python buffer-protocol objects, validates bounds, and copies size bits from src bit index srcLsb to dst bit index dstLsb. Bit numbering is least-significant-bit-first within each byte.

Exposed as _copyBits() in Python.

Parameters:
  • dst – Destination writable contiguous Python buffer.

  • dstLsb – Least-significant destination bit index.

  • src – Source Python buffer.

  • srcLsb – Least-significant source bit index.

  • size – Number of bits to copy.

static void setBits(uint8_t *dstData, uint32_t lsb, uint32_t size)

Sets a contiguous bit range in a byte array.

Sets size bits to 1 in dstData starting at bit lsb.

Bit numbering is least-significant-bit-first within each byte (bit 0 is the LSB of byte 0). Bits outside the requested range are left unchanged. For byte-aligned regions, it uses a byte-fill fast path.

This helper is used to build masks such as overlap and verify masks. Exposed as _setBits() in Python.

Parameters:
  • dstData – Destination byte array.

  • lsb – Least-significant bit index to set.

  • size – Number of bits to set.

static void setBitsPy(boost::python::object dst, uint32_t lsb, uint32_t size)

Python wrapper for setBits.

Accepts a Python writable contiguous buffer and sets size bits to 1 starting at bit lsb. Bit numbering is least-significant-bit-first within each byte.

Exposed as _setBits() in Python.

Parameters:
  • dst – Destination writable contiguous Python buffer.

  • lsb – Least-significant bit index to set.

  • size – Number of bits to set.

static bool anyBits(uint8_t *srcData, uint32_t lsb, uint32_t size)

Tests whether any bit in a range is set.

Checks size bits in srcData starting at bit lsb and returns true if at least one bit is 1.

Bit numbering is least-significant-bit-first within each byte (bit 0 is the LSB of byte 0). This helper is commonly used for overlap and mask checks. Exposed as _anyBits() in Python.

Parameters:
  • srcData – Source byte array to check.

  • lsb – Least-significant bit index to check.

  • size – Number of bits to check.

Returns:

true if any bit in the range is set; otherwise false.

static bool anyBitsPy(boost::python::object src, uint32_t lsb, uint32_t size)

Python wrapper for anyBits.

Accepts a Python buffer-protocol object and checks whether any bit is set in the requested range.

Exposed as _anyBits() in Python.

Parameters:
  • src – Source Python buffer to check.

  • lsb – Least-significant bit index to check.

  • size – Number of bits to check.

Returns:

true if any bit in the range is set; otherwise false.