Slave

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

typedef std::shared_ptr<rogue::interfaces::memory::Slave> rogue::interfaces::memory::SlavePtr

Shared pointer alias for Slave.

The class description is shown below:

class Slave : public rogue::EnableSharedFromThis<rogue::interfaces::memory::Slave>

Memory slave device.

The memory Slave device accepts and services transactions from one or more Master devices. The Slave device is normally sub-classed in either C++ or Python to provide an interfaces to hardware or the next level memory transaction protocol, such as SrpV0 or SrpV3. Examples of Slave sub-class implementations are included elsewhere in this document.

The Slave object provides mechanisms for tracking current transactions.

Subclassed by rogue::hardware::MemMap, rogue::hardware::axi::AxiMemMap, rogue::interfaces::memory::Emulate, rogue::interfaces::memory::Hub, rogue::interfaces::memory::SlaveWrap, rogue::interfaces::memory::TcpClient, rogue::protocols::srp::SrpV0, rogue::protocols::srp::SrpV3

Public Functions

Slave(uint32_t min, uint32_t max)

Constructs a memory slave.

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

min and max are stored as the local access-size contract and returned by default doMinAccess()/doMaxAccess() implementations.

Parameters:
  • min – Minimum transaction size this slave can accept, in bytes.

  • max – Maximum transaction size this slave can accept, in bytes.

virtual ~Slave()

Destroys the memory slave instance.

virtual void stop()

Stops the memory slave interface.

Base implementation is a no-op. Subclasses may override to stop worker threads or transport links.

void addTransaction(std::shared_ptr<rogue::interfaces::memory::Transaction> transaction)

Adds a transaction to the internal tracking map.

This method is called by the sub-class to add a transaction into the local tracking map for later retrieval. This is used when the transaction will be completed later as the result of protocol data being returned to the Slave.

Exposed to Python as _addTransaction().

Parameters:

transaction – Pointer to transaction as TransactionPtr.

std::shared_ptr<rogue::interfaces::memory::Transaction> getTransaction(uint32_t index)

Gets a transaction from the internal tracking map.

This method is called by the sub-class to retrieve an existing transaction using the unique transaction ID. If the transaction exists in the list the pointer to that transaction will be returned. If not a NULL pointer will be returned. When getTransaction() is called the map will also be checked for stale transactions which will be removed from the map.

Exposed to Python as _getTransaction().

Parameters:

index – ID of transaction to lookup.

Returns:

Pointer to transaction as TransactionPtr or NULL if not found.

uint32_t min()

Returns configured minimum transaction size.

Not exposed to Python.

Returns:

Minimum transaction size in bytes.

uint32_t max()

Returns configured maximum transaction size.

Not exposed to Python.

Returns:

Maximum transaction size in bytes.

uint32_t id()

Returns unique slave ID.

Not exposed to Python.

Returns:

Unique slave ID.

void setName(std::string name)

Sets slave name.

Exposed to Python as setName.

Parameters:

name – New slave name string.

std::string name()

Returns slave name.

Not exposed to Python.

Returns:

Slave name.

virtual uint32_t doSlaveId()

Services SlaveId request from a master.

Called by memory Master. Subclasses may override. Base implementation returns local slave ID. Not exposed to Python.

Returns:

Unique slave ID.

virtual std::string doSlaveName()

Services SlaveName request from a master.

Called by memory Master. Subclasses may override. Base implementation returns local slave name. Not exposed to Python.

Returns:

Slave name.

virtual uint32_t doMinAccess()

Services getMinAccess request from an attached master.

Base implementation returns local min() value. Subclasses may override. Exposed as _doMinAccess() to Python.

Returns:

Minimum transaction access size in bytes.

virtual uint32_t doMaxAccess()

Services getMaxAccess request from an attached master.

Base implementation returns local max() value. Subclasses may override. Exposed as _doMaxAccess() to Python.

Returns:

Maximum transaction access size in bytes.

virtual uint64_t doAddress()

Services getAddress request from an attached master.

Base implementation returns 0. Subclasses may override to contribute an address offset. Exposed as _doAddress() to Python.

Returns:

Address offset in bytes.

virtual void doTransaction(std::shared_ptr<rogue::interfaces::memory::Transaction> transaction)

Services a transaction request from an attached master.

It is possible for this method to be overridden in either a Python or C++ subclass. Examples of sub-classing a Slave is included elsewhere in this document.

Base implementation reports an unsupported-transaction error. Exposed to Python as _doTransaction().

Parameters:

transactionTransaction pointer as TransactionPtr.

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

Supports << operator usage from Python.

Parameters:

p – Python object expected to provide a memory Master.

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

Connects this slave to a master via chaining operator.

Equivalent to other->setSlave(this) semantics.

Parameters:

other – Memory master to connect.

Returns:

Reference to the passed master pointer.

Public Static Functions

static std::shared_ptr<rogue::interfaces::memory::Slave> create(uint32_t min, uint32_t max)

Creates a memory slave.

Exposed as rogue.interfaces.memory.Slave() to 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.

min and max define the default access-size contract (in bytes) reported by doMinAccess() and doMaxAccess(). The base Slave class stores and returns these values as provided; higher-level classes may layer additional semantics on top of them.

Parameters:
  • min – Minimum transaction size this slave can accept, in bytes.

  • max – Maximum transaction size this slave can accept, in bytes.

Returns:

Shared pointer to the created slave.

static void setup_python()

Registers this type with Python bindings.