peary::device::CaribouDevice

Caribou Device class definition. More…

#include <peary/device/CaribouDevice.hpp>

Inherits from peary::device::Device

Protected Types

Name
typedef utils::dictionary< utils::register_t< typename SCI::reg_type, typename SCI::data_type > > _registers
typedef utils::dictionary< hal::Resource > _periphery
typedef utils::dictionary< std::pair< utils::memory_map, utils::register_t< std::uintptr_t, std::uintptr_t > > > _memory

Public Functions

Name
CaribouDevice(const config::Configuration & config, const typename SCI::configuration_type & sciConfig)Default constructor for Caribou devices.
CaribouDevice(const config::Configuration config, const typename SCI::configuration_type sciConfig, const typename DRI::configuration_type driConfig)Default constructor for Caribou devices with the Data readout interface.
virtual std::string getFirmwareVersion() overrideReturn the firmware version string for reference.
virtual std::string getName() overrideReturn the human-readable device name.
virtual std::string getType() overrideReturn the human-readable device type.
uint8_t getBoardID()Return the identifier of the installed board.
uint16_t getChipID()Read the ID from the chip board if available.
std::string getDeviceName()Return the human-readable device name of the firmware currently loaded.
virtual void powerOn() overrideCall the device’s powerUp() function and toggle the powered state.
virtual void powerUp() =0Turn on the power supply for the attached device.
virtual void powerOff() overrideCall the device’s powerDown() function and toggle the powered state.
virtual void powerDown() =0Turn off power for the attached device.
virtual void daqStart() override =0Start the data acquisition.
virtual void daqStop() override =0Stop the data acquisition.
virtual void configure() overrideConfigure the device after power-up.
virtual void setRegister(std::string name, uintptr_t value) overrideSet a register on this device.
virtual void setSpecialRegister(const std::string & , uintptr_t )Set a special register on this device.
virtual uintptr_t getSpecialRegister(const std::string & )Get a special register on this device.
virtual uintptr_t getRegister(std::string name) overrideGet a register from this device.
virtual std::vector< std::pair< std::string, uintptr_t > > getRegisters() overrideGet all registers from this device.
virtual void reset() overrideSending reset signal to the device.
virtual void setVoltage(const std::string & name, double voltage) overrideSet voltage and current limit on the board resource.
virtual void setCurrentLimit(const std::string & name, double current_limit) overrideSet current limit on the board resource.
virtual void setCurrent(const std::string & name, double current, utils::Polarity polarity) overrideConfigure board current source.
virtual void switchOn(const std::string & name) overrideSwitch on the given board resource.
virtual void switchOff(const std::string & name) overrideSwitch off the given board resource.
virtual double getVoltage(const std::string & name) overrideGet voltage of the given board resource.
virtual double getCurrent(const std::string & name) overrideGet current from the given board resource.
virtual double getPower(const std::string & name) overrideGet power consumption of the given board resource.
bool getAlertStatus(const std::string & name)Get alert status from the given board resource.
double getTemperature(const std::string & name)Get temperature from the given board resource.
virtual void configureClock(const std::string & name, const std::any & config) overrideConfigure a clock output on the board.
virtual void disableClock(const std::string & name) overrideDisable a clock output on the board.
virtual bool isClockLocked(const std::string & name) overrideCheck if a clock output is locked.
virtual void setClockFrequency(const std::string & name, uint64_t frequency) overrideSet frequency of a clock output on the board.
virtual std::vector< std::string > listMemories() overrideList all memory registers.
virtual std::vector< std::string > listRegisters() overrideList all registers known to this device.
virtual std::vector< std::pair< std::string, std::string > > listResources() overrideList all periphery components and their types registered by this device.
virtual utils::pearyRawData getRawData() overrideRaw and decoded data readback.
virtual utils::pearyRawDataVector getRawData(const unsigned int noFrames) overrideRaw and decoded data readback.
virtual utils::pearydata getData() overrideRaw and decoded data readback.
virtual utils::pearydataVector getData(const unsigned int noFrames) overrideRaw and decoded data readback.
virtual void setMemory(const std::string & name, size_t offset, uintptr_t value) overrideSet memory register on this device.
virtual void setMemory(const std::string & name, uintptr_t value) overrideSet memory register on this device.
template virtual D getMemory(const std::string & name, size_t offset)Get memory register from this device.
virtual uintptr_t getMemory(const std::string & name, size_t offset) overrideGet memory register from this device.
template virtual D getMemory(const std::string & name)Get memory register from this device.
virtual uintptr_t getMemory(const std::string & name) overrideGet memory register from this device.
virtual std::vector< std::pair< std::string, uintptr_t > > getMemories() overrideGet all memory registers from this device.

Protected Functions

Name
void register_resource(const std::string & name, const std::string & resource)Register a resource with the device.
void process_register_write(utils::register_t< typename SCI::reg_type, typename SCI::data_type > reg, uintptr_t value)Process writing to registers, ignoring special flags.
uintptr_t process_register_read(utils::register_t< typename SCI::reg_type, typename SCI::data_type > reg)Process reading from registers, ignoring special flags.
SCI::data_type send(const typename SCI::data_type & data)Write data to a device which does not contain internal register.
SCI::dataVector_type send(const std::vector< typename SCI::data_type > & data)Write data to a device which does not contain internal register.
std::pair< typename SCI::reg_type, typename SCI::data_type > send(const std::pair< typename SCI::reg_type, typename SCI::data_type > & data)Send data to a device containing internal registers.
SCI::dataVector_type send(const typename SCI::reg_type & reg, const std::vector< typename SCI::data_type > & data)Send data to a device containing internal registers.
std::vector< std::pair< typename SCI::reg_type, typename SCI::data_type > > send(const std::vector< std::pair< typename SCI::reg_type, typename SCI::data_type » & data)Send data to a device containing internal registers.
SCI::dataVector_type receive(const typename SCI::reg_type reg, const unsigned int length =1)Receive data from a device which does not contain internal register.
DRI::dataVector_type receiveData(const unsigned int length =1)Receive data from a device which does not contain internal register.
DRI::dataVector_type receiveData(const typename DRI::reg_type reg, const unsigned int length =1)Receive data from a device containing internal registers.
template <typename reg_type ,typename data_type > data_type obey_mask_write(utils::register_t< reg_type, data_type > reg, data_type regval, data_type regcurrval) constApply mask on the write regval.
template <typename reg_type ,typename data_type > data_type obey_mask_read(utils::register_t< reg_type, data_type > reg, data_type regval) constApply mask on the read regval.

Protected Attributes

Name
std::shared_ptr< B > _board
config::Configuration _config
std::map< std::string, typename SCI::data_type > _register_cache
const SCI::configuration_type _sciConfig
const DRI::configuration_type _driConfig

Additional inherited members

Public Functions inherited from peary::device::Device

Name
Device(const config::Configuration & )Default constructor for Caribou devices.
virtual ~Device()Default destructor for Caribou devices.
bool isManaged()Indicator flag for managed devices.
std::string getVersion()Return the software version string for reference.
std::vector< std::pair< std::string, std::size_t > > listCommands()Retrieve list of all available device-specifiv commands.
std::string command(const std::string & name, const std::vector< std::string > & args =std::vector< std::string >())Call device-specific command with a list of arguments.
std::string command(const std::string & name, const std::string & arg)Call device-specific command with a single argument.

Protected Attributes inherited from peary::device::Device

Name
utils::Dispatcher _dispatcher Command dispatcher for this device.

Friends inherited from peary::device::Device

Name
class DeviceManager

Detailed Description

  template <typename B ,
typename SCI ,
typename DRI  =SCI>
class peary::device::CaribouDevice;
  

Caribou Device class definition.

Template Parameters:

  • B Type of the hardware board class
  • SCI Type of the slow control interface
  • DRI Type of the data readout interface

this is the central device class from which all device implementations inherit. Some basic functionality is defined via purely virtual member functions which have to be implemented by every device instance. This enables the possibility of interfacing the devices independently via the common set of function calls, e.g., from a GUI or a commandline interface.

Protected Types Documentation

typedef _registers

  utils::dictionary<utils::register_t<typename SCI::reg_type, typename SCI::data_type> > peary::device::CaribouDevice< B, SCI, DRI >::_registers;
  

Register dictionary for the devices:

typedef _periphery

  utils::dictionary<hal::Resource> peary::device::CaribouDevice< B, SCI, DRI >::_periphery;
  

Periphery dictionary to access board components:

typedef _memory

  utils::dictionary<std::pair<utils::memory_map, utils::register_t<std::uintptr_t, std::uintptr_t> > > peary::device::CaribouDevice< B, SCI, DRI >::_memory;
  

Memory page dictionary to access FPGA registers:

Public Functions Documentation

function CaribouDevice

  CaribouDevice(
    const config::Configuration & config,
    const typename SCI::configuration_type & sciConfig
)
  

Default constructor for Caribou devices.

Parameters:

  • config Configuration object
  • sciConfig Configuration for the slow control interface

function CaribouDevice

  CaribouDevice(
    const config::Configuration config,
    const typename SCI::configuration_type sciConfig,
    const typename DRI::configuration_type driConfig
)
  

Default constructor for Caribou devices with the Data readout interface.

Parameters:

  • config Configuration object
  • sciConfig Configuration for the slow control interface
  • driConfig Configuration for the data readout interface

function getFirmwareVersion

  virtual std::string getFirmwareVersion() override
  

Return the firmware version string for reference.

Return: Peary software version string

Reimplements: peary::device::Device::getFirmwareVersion

function getName

  inline virtual std::string getName() override
  

Return the human-readable device name.

Return: Device name

Reimplements: peary::device::Device::getName

function getType

  virtual std::string getType() override
  

Return the human-readable device type.

Return: Device type

Reimplements: peary::device::Device::getType

function getBoardID

  uint8_t getBoardID()
  

Return the identifier of the installed board.

Return: Board ID

function getChipID

  inline uint16_t getChipID()
  

Read the ID from the chip board if available.

Return: Chip ID, 0 if not available

Some chip boards feature an EPROM which stores a board ID and thus allows identification of the attached chip board.

function getDeviceName

  std::string getDeviceName()
  

Return the human-readable device name of the firmware currently loaded.

Return: Device name

function powerOn

  virtual void powerOn() override
  

Call the device’s powerUp() function and toggle the powered state.

Reimplements: peary::device::Device::powerOn

function powerUp

  virtual void powerUp() =0
  

Turn on the power supply for the attached device.

function powerOff

  virtual void powerOff() override
  

Call the device’s powerDown() function and toggle the powered state.

Reimplements: peary::device::Device::powerOff

function powerDown

  virtual void powerDown() =0
  

Turn off power for the attached device.

function daqStart

  virtual void daqStart() override =0
  

Start the data acquisition.

Reimplements: peary::device::Device::daqStart

function daqStop

  virtual void daqStop() override =0
  

Stop the data acquisition.

Reimplements: peary::device::Device::daqStop

function configure

  virtual void configure() override
  

Configure the device after power-up.

Reimplements: peary::device::Device::configure

function setRegister

  virtual void setRegister(
    std::string name,
    uintptr_t value
) override
  

Set a register on this device.

Parameters:

  • name Name of the register
  • value Value to be set

Reimplements: peary::device::Device::setRegister

function setSpecialRegister

  inline virtual void setSpecialRegister(
    const std::string & ,
    uintptr_t 
)
  

Set a special register on this device.

function getSpecialRegister

  inline virtual uintptr_t getSpecialRegister(
    const std::string & 
)
  

Get a special register on this device.

function getRegister

  virtual uintptr_t getRegister(
    std::string name
) override
  

Get a register from this device.

Parameters:

  • name Name of the register

Return: Value of the register

Reimplements: peary::device::Device::getRegister

function getRegisters

  virtual std::vector< std::pair< std::string, uintptr_t > > getRegisters() override
  

Get all registers from this device.

Return: Vector with pairs of register name and value

Reimplements: peary::device::Device::getRegisters

function reset

  virtual void reset() override
  

Sending reset signal to the device.

Reimplements: peary::device::Device::reset

function setVoltage

  virtual void setVoltage(
    const std::string & name,
    double voltage
) override
  

Set voltage and current limit on the board resource.

Parameters:

  • name Name of the resource
  • voltage Voltage to be set in V

Reimplements: peary::device::Device::setVoltage

function setCurrentLimit

  virtual void setCurrentLimit(
    const std::string & name,
    double current_limit
) override
  

Set current limit on the board resource.

Parameters:

  • name Name of the resource
  • current_limit current limit to be set in A

Reimplements: peary::device::Device::setCurrentLimit

function setCurrent

  virtual void setCurrent(
    const std::string & name,
    double current,
    utils::Polarity polarity
) override
  

Configure board current source.

Parameters:

  • name Name of the current source
  • current Current to be set in A
  • polarity Polarity of the source, HIGH or LOW

Reimplements: peary::device::Device::setCurrent

function switchOn

  inline virtual void switchOn(
    const std::string & name
) override
  

Switch on the given board resource.

Parameters:

  • name Name of the resource

Reimplements: peary::device::Device::switchOn

function switchOff

  inline virtual void switchOff(
    const std::string & name
) override
  

Switch off the given board resource.

Parameters:

  • name Name of the resource

Reimplements: peary::device::Device::switchOff

function getVoltage

  virtual double getVoltage(
    const std::string & name
) override
  

Get voltage of the given board resource.

Parameters:

  • name Name of the resource

Return: Voltage in V

Reimplements: peary::device::Device::getVoltage

function getCurrent

  virtual double getCurrent(
    const std::string & name
) override
  

Get current from the given board resource.

Parameters:

  • name Name of the resource

Return: Current in A

Reimplements: peary::device::Device::getCurrent

function getPower

  virtual double getPower(
    const std::string & name
) override
  

Get power consumption of the given board resource.

Parameters:

  • name Name of the resource

Return: Power in W

Reimplements: peary::device::Device::getPower

function getAlertStatus

  bool getAlertStatus(
    const std::string & name
)
  

Get alert status from the given board resource.

Parameters:

  • name Name of the resource

Return: Alert status, true if alert is active

function getTemperature

  double getTemperature(
    const std::string & name
)
  

Get temperature from the given board resource.

Parameters:

  • name Name of the resource

Return: Temperature in degree Celsius

function configureClock

  virtual void configureClock(
    const std::string & name,
    const std::any & config
) override
  

Configure a clock output on the board.

Parameters:

  • name Name of the resource
  • config Configuration object for the clock

Reimplements: peary::device::Device::configureClock

function disableClock

  virtual void disableClock(
    const std::string & name
) override
  

Disable a clock output on the board.

Parameters:

  • name Name of the resource

Reimplements: peary::device::Device::disableClock

function isClockLocked

  virtual bool isClockLocked(
    const std::string & name
) override
  

Check if a clock output is locked.

Parameters:

  • name Name of the resource

Return: True if the clock is locked, false otherwise

Reimplements: peary::device::Device::isClockLocked

function setClockFrequency

  virtual void setClockFrequency(
    const std::string & name,
    uint64_t frequency
) override
  

Set frequency of a clock output on the board.

Parameters:

  • name Name of the resource
  • frequency Frequency in Hz

Reimplements: peary::device::Device::setClockFrequency

function listMemories

  virtual std::vector< std::string > listMemories() override
  

List all memory registers.

Return: Vector with names of all available memory pages

Reimplements: peary::device::Device::listMemories

List all memory registers (accessed through memory pages mapping) known to this device

function listRegisters

  virtual std::vector< std::string > listRegisters() override
  

List all registers known to this device.

Return: Vector with names of all available registers

Reimplements: peary::device::Device::listRegisters

function listResources

  virtual std::vector< std::pair< std::string, std::string > > listResources() override
  

List all periphery components and their types registered by this device.

Return: Vector with pairs of component name and component type

Reimplements: peary::device::Device::listResources

function getRawData

  virtual utils::pearyRawData getRawData() override
  

Raw and decoded data readback.

Return: Raw data structure

Reimplements: peary::device::Device::getRawData

function getRawData

  virtual utils::pearyRawDataVector getRawData(
    const unsigned int noFrames
) override
  

Raw and decoded data readback.

Parameters:

  • noFrames Number of frames to be read

Return: Vector of raw data frames

Reimplements: peary::device::Device::getRawData

function getData

  virtual utils::pearydata getData() override
  

Raw and decoded data readback.

Return: Decoded data structure

Reimplements: peary::device::Device::getData

function getData

  virtual utils::pearydataVector getData(
    const unsigned int noFrames
) override
  

Raw and decoded data readback.

Parameters:

  • noFrames Number of frames to be read

Return: Vector of decoded data frames

Reimplements: peary::device::Device::getData

function setMemory

  virtual void setMemory(
    const std::string & name,
    size_t offset,
    uintptr_t value
) override
  

Set memory register on this device.

Parameters:

  • name Name of the memory register
  • offset Offset to be applied to the base address of the memory register
  • value Value to be set

Reimplements: peary::device::Device::setMemory

function setMemory

  virtual void setMemory(
    const std::string & name,
    uintptr_t value
) override
  

Set memory register on this device.

Parameters:

  • name Name of the memory register
  • value Value to be set

Reimplements: peary::device::Device::setMemory

function getMemory

  template <typename D  =uintptr_t>
virtual D getMemory(
    const std::string & name,
    size_t offset
)
  

Get memory register from this device.

Parameters:

  • name Name of the memory register
  • offset Offset to be applied to the base address of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemory

  inline virtual uintptr_t getMemory(
    const std::string & name,
    size_t offset
) override
  

Get memory register from this device.

Parameters:

  • name Name of the memory register
  • offset Offset to be applied to the base address of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemory

  template <typename D  =uintptr_t>
virtual D getMemory(
    const std::string & name
)
  

Get memory register from this device.

Parameters:

  • name Name of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemory

  inline virtual uintptr_t getMemory(
    const std::string & name
) override
  

Get memory register from this device.

Parameters:

  • name Name of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemories

  virtual std::vector< std::pair< std::string, uintptr_t > > getMemories() override
  

Get all memory registers from this device.

Return: Vector with pairs of memory name and value

Reimplements: peary::device::Device::getMemories

Protected Functions Documentation

function register_resource

  void register_resource(
    const std::string & name,
    const std::string & resource
)
  

Register a resource with the device.

Parameters:

  • name Name of the resource
  • resource Name of the resource to be associated

This function registers a resource with the device, which can be used to control the device’s periphery components, such as voltage regulators, ADCs, etc.

function process_register_write

  void process_register_write(
    utils::register_t< typename SCI::reg_type, typename SCI::data_type > reg,
    uintptr_t value
)
  

Process writing to registers, ignoring special flags.

Parameters:

  • reg Register to be written
  • value Value of the register to be set

function process_register_read

  uintptr_t process_register_read(
    utils::register_t< typename SCI::reg_type, typename SCI::data_type > reg
)
  

Process reading from registers, ignoring special flags.

Parameters:

  • reg Register to be read

Return: Value of the register

function send

  SCI::data_type send(
    const typename SCI::data_type & data
)
  

Write data to a device which does not contain internal register.

Parameters:

  • data Data to be sent

Return: Data read back if readout is integral part of write operations

function send

  SCI::dataVector_type send(
    const std::vector< typename SCI::data_type > & data
)
  

Write data to a device which does not contain internal register.

Parameters:

  • data Data to be sent

Return: Data read back if readout is integral part of write operations

function send

  std::pair< typename SCI::reg_type, typename SCI::data_type > send(
    const std::pair< typename SCI::reg_type, typename SCI::data_type > & data
)
  

Send data to a device containing internal registers.

Parameters:

  • data Pair of register address and data to be sent

Return: Pair of register address and data read back if readout is integral part of write operations

function send

  SCI::dataVector_type send(
    const typename SCI::reg_type & reg,
    const std::vector< typename SCI::data_type > & data
)
  

Send data to a device containing internal registers.

Parameters:

  • reg Register address to which data is to be sent
  • data Data to be sent

Return: Data read back if readout is integral part of write operations

function send

  std::vector< std::pair< typename SCI::reg_type, typename SCI::data_type > > send(
    const std::vector< std::pair< typename SCI::reg_type, typename SCI::data_type >> & data
)
  

Send data to a device containing internal registers.

Parameters:

  • data Vector of pairs of register address and data to be sent

Return: Vector of pairs of register address and data read back if readout is integral part of write operations

function receive

  SCI::dataVector_type receive(
    const typename SCI::reg_type reg,
    const unsigned int length =1
)
  

Receive data from a device which does not contain internal register.

Parameters:

  • reg Register address from which data is to be read
  • length Number of data words to be read

Return: Data read back

function receiveData

  DRI::dataVector_type receiveData(
    const unsigned int length =1
)
  

Receive data from a device which does not contain internal register.

Parameters:

  • length Number of data words to be read

Return: Data read back

function receiveData

  DRI::dataVector_type receiveData(
    const typename DRI::reg_type reg,
    const unsigned int length =1
)
  

Receive data from a device containing internal registers.

Parameters:

  • reg Register address from which data is to be read
  • length Number of data words to be read

Return: Data read back

function obey_mask_write

  template <typename reg_type ,
typename data_type >
data_type obey_mask_write(
    utils::register_t< reg_type, data_type > reg,
    data_type regval,
    data_type regcurrval
) const
  

Apply mask on the write regval.

Parameters:

  • reg Register to be written
  • regval Value to be written
  • regcurrval Current value of the register

Return: New value to be written

function obey_mask_read

  template <typename reg_type ,
typename data_type >
data_type obey_mask_read(
    utils::register_t< reg_type, data_type > reg,
    data_type regval
) const
  

Apply mask on the read regval.

Parameters:

  • reg Register to be read
  • regval Value read from the register

Return: New value to be returned

Protected Attributes Documentation

variable _board

  std::shared_ptr< B > _board;
  

Instance of the Caribou Board abstraction layer library All register and hardware access should go through this interface.

variable _config

  config::Configuration _config;
  

Device configuration object

variable _register_cache

  std::map< std::string, typename SCI::data_type > _register_cache;
  

Register cache

variable _sciConfig

  const SCI::configuration_type _sciConfig;
  

Slow control interface configuration

variable _driConfig

  const DRI::configuration_type _driConfig;
  

Data Readout interface configuration


Updated on 2025-11-14 at 11:31:23 +0100