DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDEEthFrame.hpp
Go to the documentation of this file.
1
13
14#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDEETHFRAME_HPP_
15#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDEETHFRAME_HPP_
16
17#include "Utils.hpp"
18
20
21#include <algorithm> // For std::min
22#include <cassert> // For assert()
23#include <cstdint> // For uint32_t etc
24#include <cstdio>
25#include <cstdlib>
26#include <stdexcept> // For std::out_of_range
27
29
30// NOLINTBEGIN(build/unsigned)
31
39{
40public:
41 // The definition of the format is in terms of 64-bit words
42 using word_t = uint64_t;
43
44 static constexpr int s_bits_per_adc = 14;
45 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
46 static constexpr int s_time_samples_per_frame = 64;
47 static constexpr int s_channels_per_half_femb = 64;
48 static constexpr int s_half_fembs_per_frame = 1;
51
53 {
54 uint64_t reserved : 26;
55 uint64_t tde_errors : 16;
56 uint64_t tde_header : 10;
57 uint64_t version : 4;
58 uint64_t channel : 8;
59 uint64_t TAItime : 64;
60 };
61 static_assert(sizeof(TDEEthHeader) == 16);
62
66
74 uint16_t get_adc(int i_channel, int i_sample = 0) const;
75
77 void set_adc(int i_channel, int i_sample, uint16_t val);
78
80 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
81
83 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
84
86 uint8_t get_channel() const { return header.channel; }
87
89 void set_channel(const uint8_t new_channel) { header.channel = new_channel; }
90};
91static_assert(sizeof(TDEEthFrame) == sizeof(detdataformats::DAQEthHeader) + sizeof(TDEEthFrame::TDEEthHeader) +
94
95static_assert(std::endian::native == std::endian::little,
96 "The TDEEthFrame bitfield layout assumes little-endian architecture");
97static_assert(std::is_trivially_copyable_v<TDEEthFrame>,
98 "TDEEthFrame isn't trivially copyable and can't be safely std::memcpy'd");
99static_assert(std::is_standard_layout_v<TDEEthFrame>,
100 "TDEEthFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
101
102} // namespace dunedaq::fddetdataformats
103
104#include "detail/TDEEthFrame.hxx"
105
106// NOLINTEND(build/unsigned)
107
108#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDEETHFRAME_HPP_
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
static constexpr int s_channels_per_half_femb
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
uint16_t get_adc(int i_channel, int i_sample=0) const
Get the i_channel-th ADC value in the i_sample-th time sample.
void set_adc(int i_channel, int i_sample, uint16_t val)
Set the i_channel-th ADC value in the i_sample-th time sample to val.
static constexpr int s_time_samples_per_frame
uint8_t get_channel() const
Get the channel identifier of the frame.
static constexpr int s_num_adc_words_per_ts
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
detdataformats::DAQEthHeader daq_header
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
word_t adc_words[s_time_samples_per_frame][s_num_adc_words_per_ts]
static constexpr int s_half_fembs_per_frame
DAQEthHeader is a versioned and unified structure for every FE electronics.