PRBS

The Prbs class provides both a PRBS transmitter and receiver.

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

typedef std::shared_ptr<rogue::utilities::Prbs> rogue::utilities::PrbsPtr

The class description is shown below:

class Prbs : public rogue::interfaces::stream::Slave, public rogue::interfaces::stream::Master

PRBS generator/checker that can act as both stream master and slave.

The engine can transmit deterministic pseudo-random patterns and verify received patterns for bit-error testing. It supports one-shot frame generation and optional background transmit mode.

Threading model:

  • Receive checking executes synchronously in the thread calling acceptFrame().

  • Optional periodic transmit mode (enable()) runs in an internal TX thread that repeatedly calls genFrame().

  • Counters, LFSR state, and configuration shared between RX/TX paths are protected by an internal mutex.

Public Functions

Prbs()

Constructs a PRBS instance with default taps and width.

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

~Prbs()

Destroys the PRBS instance and stops background generation.

void setWidth(uint32_t width)

Sets generator/checker data width.

Parameters:

width – Data width in bits.

void setTaps(uint32_t tapCnt, uint8_t *taps)

Configures LFSR taps.

Parameters:
  • tapCnt – Number of tap entries in taps.

  • taps – Pointer to tap index array.

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

Configures LFSR taps from a Python sequence.

Parameters:

p – Python object containing tap values.

void sendCount(bool state)

Enables or disables transmission of sequence counters in payload.

Parameters:

state – True to include counters in generated data.

void genFrame(uint32_t size)

Generates and transmits one PRBS frame.

Parameters:

size – Payload size in bytes.

void enable(uint32_t size)

Enables periodic background frame generation.

Starts an internal TX worker thread if one is not already running. Generated frames use the configured TX period from setTxPeriod().

Parameters:

size – Payload size in bytes for generated frames.

void disable()

Disables periodic background frame generation.

Stops and joins the internal TX worker thread started by enable().

bool getRxEnable()

Returns whether RX checking is enabled.

Returns:

True when RX checking is enabled.

void setRxEnable(bool state)

Enables or disables RX checking.

Parameters:

state – True to validate incoming PRBS frames.

uint32_t getRxErrors()

Returns RX error count.

Returns:

Number of receive-side check failures.

uint32_t getRxCount()

Returns RX frame count.

Returns:

Number of received frames.

uint64_t getRxBytes()

Returns RX byte count.

Returns:

Total received payload bytes.

double getRxRate()

Returns computed RX frame rate.

Returns:

Receive frame rate in frames/second.

double getRxBw()

Returns computed RX bandwidth.

Returns:

Receive bandwidth in bytes/second.

double getTxRate()

Returns computed TX frame rate.

Returns:

Transmit frame rate in frames/second.

void setTxPeriod(uint32_t txPeriod)

Sets background TX period.

Parameters:

txPeriod – Period in microseconds between generated frames.

uint32_t getTxPeriod()

Returns configured background TX period.

Returns:

TX period in microseconds.

double getTxBw()

Returns computed TX bandwidth.

Returns:

Transmit bandwidth in bytes/second.

uint32_t getTxErrors()

Returns TX error count.

Returns:

Number of transmit-side generation errors.

uint32_t getTxCount()

Returns TX frame count.

Returns:

Number of transmitted frames.

uint64_t getTxBytes()

Returns TX byte count.

Returns:

Total transmitted payload bytes.

void checkPayload(bool state)

Enables or disables payload checking.

Parameters:

state – True to validate payload contents.

void genPayload(bool state)

Enables or disables payload generation.

Parameters:

state – True to generate PRBS payload bytes.

void resetCount()

Resets RX/TX counters and statistics.

virtual void acceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame)

Accepts a frame from an upstream master.

Parameters:

frame – Received stream frame.

Public Static Functions

static std::shared_ptr<rogue::utilities::Prbs> create()

Creates a PRBS generator/checker instance.

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 PRBS object.

static void setup_python()

Registers Python bindings for this class.