Hardware description
Platform headers select the board at compile time (target_arch in
config.cmake): hwdevice_zcu102.h (4 DMA channels, IRQ stride 4) or
hwdevice_zc706.h (2 DMA channels, IRQ stride 2). Shared constants live in
hwdevice_common.h. DMA scatter-gather descriptors sit in an 8 KiB BRAM at
0x80000000.
On ZCU102 the measurement GPIOs are one AXI-lite slave (meas_gpio_bank)
mapped at 0xB3200000 with a 256 KiB window. Each former axi_gpio is a
4 KiB slot: address = 0xB3200000 + slot * 0x1000. Slot numbers match
SLOT_* in the hardware design (src/hdl/meas_gpio_bank.v). Software
uses the same formula in hwdevice_zcu102.h. Most per-channel settings pack
channels 1/2 into GPIO_DATA and channels 3/4 into GPIO2_DATA of the
same slot (see GPIO).
Variables
Runtime DMA resolution (UIO paths and u-dma-buf physical addresses):
-
namespace nexmess
-
namespace components
-
namespace hwdevice
Functions
-
bool init_devices()
Resolve UIO paths and u-dma-buf physical addresses from sysfs.
Must be called once before creating DMA objects. Descriptor counts are derived from each u-dma-buf size divided by the default package size in bytes for that DMA product type (not the runtime measurement package size).
- Returns:
true on success.
-
const std::array<ResolvedDmaDevice, kDmaCount> &get_dmas_raw()
Returns the resolved raw DMA devices (one per ADC channel).
-
const std::array<ResolvedDmaDevice, kDmaCount> &get_dmas_count()
Returns the resolved count DMA devices.
-
const std::array<ResolvedDmaDevice, kDmaCount> &get_dmas_charge()
Returns the resolved charge DMA devices.
-
const std::array<ResolvedDmaDevice, kDmaCount> &get_dmas_fraction()
Returns the resolved fraction DMA devices.
-
const std::array<ResolvedDmaDevice, kDmaCount> &get_dmas_max()
Returns the resolved max DMA devices.
-
const std::array<ResolvedDmaDevice, kDmaCount> &get_dmas_risetime()
Returns the resolved risetime DMA devices.
-
uint32_t max_descriptors_per_dma()
Returns kLargestDescriptorCountPerDma.
-
bool init_devices()
-
namespace hwdevice
-
namespace components
Shared types used by both boards (GPIO packing, resolved DMA descriptors):
Functions
-
constexpr uint32_t pack_gpio_field(uint32_t current, GpioBitField field, uint32_t value)
Inserts value into a GPIO bitfield without touching other bits.
-
constexpr uint32_t unpack_gpio_field(uint32_t current, GpioBitField field)
Extracts a GPIO bitfield.
Variables
-
constexpr uint8_t kDmaProductCount = 6
Number of DMA product types (raw, count, charge, fraction, max, risetime).
-
constexpr uint32_t kDataWordSize64Bit = 8
The kDataWordSize64Bit constant represents the data word size for 64-bit DMA transfers in bytes.
-
constexpr uint32_t kDataWordSize32Bit = 4
The kDataWordSize32Bit constant represents the data word size for 32-bit DMA transfers in bytes (charge int32, fraction float32).
-
constexpr uint32_t kDataWordSize16Bit = 2
The kDataWordSize16Bit constant represents the data word size for 16-bit DMA transfers in bytes.
Note: Hardware still transfers 64-bit words, but each word contains 4 x 16-bit values packed together.
-
constexpr uint32_t kDefaultRawPackageSize = 0x400000
The kDefaultRawPackageSize constant represents the amount of transfers before each DMA interrupt.
The hardware packs together transfers into packages. This constant represents the amount of transfers per package. Calculating kDataWordSize64Bit * kDefaultRawPackageSize gives the number of bytes per package (see kDefaultRawPackageSizeBytes). It must match the package size set in the hardware design.
-
constexpr uint32_t kDefaultCountPackageSize = 0x80000
The kDefaultCountPackageSize constant represents the amount of transfers before each DMA interrupt.
-
constexpr uint32_t kDefaultChargePackageSize = 0x80000
The kDefaultChargePackageSize constant represents the amount of transfers before each DMA interrupt.
-
constexpr uint32_t kDefaultFractionPackageSize = 0x80000
The kDefaultFractionPackageSize constant represents the amount of transfers before each DMA interrupt.
-
constexpr uint32_t kDefaultMaxPackageSize = 0x80000
The kDefaultMaxPackageSize constant represents the amount of transfers before each DMA interrupt.
One uint16 value per event. 0x80000 words × 2 bytes = 1 MiB, matching three descriptors in the 3 MiB u-dma-buf.
-
constexpr uint32_t kDefaultRisetimePackageSize = 0x80000
The kDefaultRisetimePackageSize constant represents the amount of transfers before each DMA interrupt.
One uint16 value per event. 0x80000 words × 2 bytes = 1 MiB, matching three descriptors in the 3 MiB u-dma-buf.
-
constexpr uint32_t kDefaultRawPackageSizeBytes = kDataWordSize64Bit * kDefaultRawPackageSize
The kDefaultRawPackageSizeBytes constant represents the amount of bytes per package.
-
constexpr uint32_t kDefaultCountPackageSizeBytes = kDataWordSize64Bit * kDefaultCountPackageSize
The kDefaultCountPackageSizeBytes constant represents the amount of bytes per package.
-
constexpr uint32_t kDefaultChargePackageSizeBytes = kDataWordSize32Bit * kDefaultChargePackageSize
The kDefaultChargePackageSizeBytes constant represents the amount of bytes per package.
-
constexpr uint32_t kDefaultFractionPackageSizeBytes = kDataWordSize32Bit * kDefaultFractionPackageSize
The kDefaultFractionPackageSizeBytes constant represents the amount of bytes per package.
-
constexpr uint32_t kDefaultMaxPackageSizeBytes = kDataWordSize16Bit * kDefaultMaxPackageSize
The kDefaultMaxPackageSizeBytes constant represents the amount of bytes per package.
-
constexpr uint32_t kDefaultRisetimePackageSizeBytes = kDataWordSize16Bit * kDefaultRisetimePackageSize
The kDefaultRisetimePackageSizeBytes constant represents the amount of bytes per package.
-
constexpr uint32_t kDmaDescriptorBase = 0x80000000
The kDmaDescriptorBase constant represents the physical location of the DMA descriptor memory.
-
constexpr uint32_t kDmaDescriptorSize = 0x40U
The kDmaDescriptorSize constant represents the size of a DMA descriptor in bytes.
-
constexpr uint32_t kDmaRawUdmabufSize = 0x6000000U
Size of each raw-channel u-dma-buf reservation in the device tree.
-
constexpr uint32_t kDmaProductUdmabufSize = 0xC00000U
Size of each 64-bit count-channel u-dma-buf reservation.
3 descriptors × 4 MiB packages (0x80000 uint64 words).
-
constexpr uint32_t kDmaStbUdmabufSize = 0x600000U
Size of each stilbene charge/fraction u-dma-buf reservation.
3 descriptors × 2 MiB packages (0x80000 int32/float32 words).
-
constexpr uint32_t kDma16BitUdmabufSize = 0x300000U
Size of each 16-bit max/risetime u-dma-buf reservation.
3 descriptors × 1 MiB packages (0x80000 uint16 words).
-
constexpr uint32_t kDmaRawDescriptorPerDma = kDmaRawUdmabufSize / kDefaultRawPackageSizeBytes
The kDmaRawDescriptorPerDma constant represents the amount of DMA descriptors per raw DMA device.
Derived from the u-dma-buf size and the default raw package size in bytes.
-
constexpr uint32_t kDmaCountDescriptorPerDma = kDmaProductUdmabufSize / kDefaultCountPackageSizeBytes
The kDmaCountDescriptorPerDma constant represents the amount of DMA descriptors per count DMA device.
-
constexpr uint32_t kDmaChargeDescriptorPerDma = kDmaStbUdmabufSize / kDefaultChargePackageSizeBytes
The kDmaChargeDescriptorPerDma constant represents the amount of DMA descriptors per charge DMA device.
-
constexpr uint32_t kDmaFractionDescriptorPerDma = kDmaStbUdmabufSize / kDefaultFractionPackageSizeBytes
The kDmaFractionDescriptorPerDma constant represents the amount of DMA descriptors per integral fraction DMA device.
-
constexpr uint32_t kDmaMaxDescriptorPerDma = kDma16BitUdmabufSize / kDefaultMaxPackageSizeBytes
The kDmaMaxDescriptorPerDma constant represents the amount of DMA descriptors per max DMA device.
-
constexpr uint32_t kDmaRisetimeDescriptorPerDma = kDma16BitUdmabufSize / kDefaultRisetimePackageSizeBytes
The kDmaRisetimeDescriptorPerDma constant represents the amount of DMA descriptors per risetime DMA device.
-
constexpr uint32_t kLargestDescriptorCountPerDma = std::max({kDmaRawDescriptorPerDma, kDmaCountDescriptorPerDma, kDmaChargeDescriptorPerDma, kDmaFractionDescriptorPerDma, kDmaMaxDescriptorPerDma, kDmaRisetimeDescriptorPerDma,})
Largest descriptor ring depth across all DMA product types.
Not to be confused with kDmaMaxDescriptorPerDma (the Max product channel). Used for client-side descriptor tracking arrays.
-
struct DmaDeviceStatic
- #include <hwdevice_common.h>
Static DMA device description before sysfs resolution.
Register base and u-dma-buf device node are fixed per platform. UIO device path and buffer physical address are resolved at runtime from sysfs.
Public Members
-
uint32_t register_
AXI DMA register base (physical).
-
const char *udmabuf_device_
u-dma-buf device node (e.g. “/dev/udmabuf0”).
-
nexmess::components::dma::DmaPurpose purpose_of_use_
Purpose of this DMA engine.
-
uint32_t register_
-
struct ResolvedDmaDevice
- #include <hwdevice_common.h>
Fully resolved DMA device used at runtime.
Public Members
-
uint32_t register_
AXI DMA register base (physical).
-
uint32_t descriptor_offset_
Offset into descriptor BRAM at kDmaDescriptorBase.
-
uint32_t buffer_phys_addr_
Physical start address of the DMA buffer.
-
uint32_t descriptors_per_dma_
Descriptor ring depth for this engine.
-
const char *udmabuf_device_
u-dma-buf device node.
-
const char *uio_device_
UIO device node for interrupts.
-
nexmess::components::dma::DmaPurpose purpose_of_use_
Purpose of this DMA engine.
-
uint32_t register_
-
struct GpioChanLoc
- #include <hwdevice_common.h>
AXI-GPIO data-register location for one ADC channel.
data_reg_ 0 writes GPIO_DATA (offset 0), 1 writes GPIO2_DATA (offset 2).
-
struct GpioBitField
- #include <hwdevice_common.h>
Packed bitfield inside one AXI-GPIO data register.
data_reg_ 0 is GPIO_DATA, 1 is GPIO2_DATA.
Board-specific values (kDmaCount, DMA register bases, GPIO slot
addresses, kGpio*Ch maps) are in hwdevice_zcu102.h and
hwdevice_zc706.h. Only one of those headers is compiled in, selected by
target_arch. They are not inlined here because the constant names are
the same on both boards.