CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
amc::BlockHeader Class Reference

#include <AMCSpec.h>

Public Member Functions

 BlockHeader ()
 
 BlockHeader (const uint64_t *data)
 
 BlockHeader (unsigned int amc_no, unsigned int board_id, unsigned int size, unsigned int block=0)
 
unsigned int getAMCNumber () const
 
unsigned int getBlocks () const
 
unsigned int getBlockSize () const
 
unsigned int getBoardID () const
 
unsigned int getMore () const
 
unsigned int getSegmented () const
 
unsigned int getSize () const
 
 operator uint64_t () const
 
uint64_t raw () const
 
unsigned int validCRC () const
 

Private Attributes

uint64_t data_
 

Static Private Attributes

static const unsigned int AmcNo_mask = 0xf
 
static const unsigned int AmcNo_shift = 16
 
static const unsigned int BlkNo_mask = 0xff
 
static const unsigned int BlkNo_shift = 20
 
static const unsigned int BoardID_mask = 0xffff
 
static const unsigned int BoardID_shift = 0
 
static const unsigned int CRC_bit_shift = 56
 
static const unsigned int Enabled_bit_shift = 59
 
static const unsigned int Length_bit_shift = 62
 
static const unsigned int More_bit_shift = 61
 
static const unsigned int Present_bit_shift = 58
 
static const unsigned int Segmented_bit_shift = 60
 
static const unsigned int Size_mask = 0xffffff
 
static const unsigned int Size_shift = 32
 
static const unsigned int Valid_bit_shift = 57
 

Detailed Description

Definition at line 13 of file AMCSpec.h.

Constructor & Destructor Documentation

◆ BlockHeader() [1/3]

amc::BlockHeader::BlockHeader ( )
inline

Definition at line 15 of file AMCSpec.h.

15 : data_(0) {}
uint64_t data_
Definition: AMCSpec.h:54

◆ BlockHeader() [2/3]

amc::BlockHeader::BlockHeader ( const uint64_t *  data)
inline

Definition at line 16 of file AMCSpec.h.

16 : data_(data[0]) {}
uint64_t data_
Definition: AMCSpec.h:54
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ BlockHeader() [3/3]

amc::BlockHeader::BlockHeader ( unsigned int  amc_no,
unsigned int  board_id,
unsigned int  size,
unsigned int  block = 0 
)

Definition at line 11 of file AMCSpec.cc.

References AmcNo_mask, AmcNo_shift, BlkNo_mask, BlkNo_shift, groupFilesInBlocks::block, BoardID_mask, BoardID_shift, CRC_bit_shift, data_, Enabled_bit_shift, getBlocks(), Length_bit_shift, More_bit_shift, Present_bit_shift, Segmented_bit_shift, Size_mask, Size_shift, amc::split_block_size, and Valid_bit_shift.

11  {
12  // Determine size
13  unsigned int max_block_no = 0;
14  if (size >= 0x13ff)
15  max_block_no = (size - 1023) / 4096;
16 
17  if (block != max_block_no)
19  else if (block != 0)
20  size -= split_block_size * max_block_no;
21 
22  data_ = (static_cast<uint64_t>(size & Size_mask) << Size_shift) |
23  (static_cast<uint64_t>(block & BlkNo_mask) << BlkNo_shift) |
24  (static_cast<uint64_t>(amc_no & AmcNo_mask) << AmcNo_shift) |
25  (static_cast<uint64_t>(board_id & BoardID_mask) << BoardID_shift) | (1llu << Enabled_bit_shift) |
26  (1llu << Present_bit_shift);
27 
28  if (block == getBlocks() - 1) {
29  // Last block
30  data_ |= (1llu << CRC_bit_shift) | (1llu << Valid_bit_shift) | (1llu << Length_bit_shift);
31  }
32 
33  if (block == 0 && getBlocks() == 1) {
34  // Bits already zeroed - only one block
35  } else if (block == 0) {
36  // First of many blocks
37  data_ |= 1llu << More_bit_shift;
38  } else if (block == getBlocks() - 1) {
39  // Last of many blocks
40  data_ |= 1llu << Segmented_bit_shift;
41  } else {
42  // Intermediate of many blocks
43  data_ |= (1llu << More_bit_shift) | (1llu << Segmented_bit_shift);
44  }
45  }
size
Write out results.
static const unsigned int BoardID_mask
Definition: AMCSpec.h:44
static const unsigned int Size_shift
Definition: AMCSpec.h:37
static const unsigned int CRC_bit_shift
Definition: AMCSpec.h:52
unsigned int getBlocks() const
Definition: AMCSpec.cc:47
static const unsigned int Segmented_bit_shift
Definition: AMCSpec.h:48
static const unsigned int Present_bit_shift
Definition: AMCSpec.h:50
static const unsigned int AmcNo_shift
Definition: AMCSpec.h:41
static const unsigned int BlkNo_shift
Definition: AMCSpec.h:39
static const unsigned int Valid_bit_shift
Definition: AMCSpec.h:51
static const unsigned int BlkNo_mask
Definition: AMCSpec.h:40
static const unsigned int Size_mask
Definition: AMCSpec.h:38
static const unsigned int split_block_size
Definition: AMCSpec.h:9
static const unsigned int More_bit_shift
Definition: AMCSpec.h:47
uint64_t data_
Definition: AMCSpec.h:54
static const unsigned int AmcNo_mask
Definition: AMCSpec.h:42
static const unsigned int BoardID_shift
Definition: AMCSpec.h:43
unsigned long long uint64_t
Definition: Time.h:13
static const unsigned int Length_bit_shift
Definition: AMCSpec.h:46
static const unsigned int Enabled_bit_shift
Definition: AMCSpec.h:49

Member Function Documentation

◆ getAMCNumber()

unsigned int amc::BlockHeader::getAMCNumber ( ) const
inline

Definition at line 28 of file AMCSpec.h.

References AmcNo_mask, AmcNo_shift, and data_.

Referenced by amc::Packet::finalize(), and omtf::OmtfUnpacker::produce().

28 { return (data_ >> AmcNo_shift) & AmcNo_mask; };
static const unsigned int AmcNo_shift
Definition: AMCSpec.h:41
uint64_t data_
Definition: AMCSpec.h:54
static const unsigned int AmcNo_mask
Definition: AMCSpec.h:42

◆ getBlocks()

unsigned int amc::BlockHeader::getBlocks ( ) const

Definition at line 47 of file AMCSpec.cc.

References getSize().

Referenced by amc::Packet::block(), BlockHeader(), and amc::Packet::blocks().

47  {
48  // The first block of a segmented event has a size of 1023, all
49  // following have a max size of 4096. Segmentation only happens
50  // for AMC payloads >= 0x13ff 64 bit words.
51  unsigned int size = getSize();
52  if (size >= 0x13ff)
53  return (size - 1023) / 4096 + 1;
54  return 1;
55  }
size
Write out results.
unsigned int getSize() const
Definition: AMCSpec.h:30

◆ getBlockSize()

unsigned int amc::BlockHeader::getBlockSize ( ) const

Definition at line 57 of file AMCSpec.cc.

References getMore(), getSegmented(), getSize(), and amc::split_block_size.

57  {
58  // More and not Segmented means the first of multiple blocks. For
59  // these, getSize() returns the total size of the AMC packet, not the
60  // size of the first block.
61  if (getMore() && !getSegmented())
62  return split_block_size;
63  return getSize();
64  }
static const unsigned int split_block_size
Definition: AMCSpec.h:9
unsigned int getMore() const
Definition: AMCSpec.h:31
unsigned int getSize() const
Definition: AMCSpec.h:30
unsigned int getSegmented() const
Definition: AMCSpec.h:32

◆ getBoardID()

unsigned int amc::BlockHeader::getBoardID ( ) const
inline

Definition at line 29 of file AMCSpec.h.

References BoardID_mask, BoardID_shift, and data_.

Referenced by amc::Packet::finalize(), and omtf::OmtfUnpacker::produce().

29 { return (data_ >> BoardID_shift) & BoardID_mask; };
static const unsigned int BoardID_mask
Definition: AMCSpec.h:44
uint64_t data_
Definition: AMCSpec.h:54
static const unsigned int BoardID_shift
Definition: AMCSpec.h:43

◆ getMore()

unsigned int amc::BlockHeader::getMore ( ) const
inline

Definition at line 31 of file AMCSpec.h.

References data_, and More_bit_shift.

Referenced by getBlockSize().

31 { return (data_ >> More_bit_shift) & 1; };
static const unsigned int More_bit_shift
Definition: AMCSpec.h:47
uint64_t data_
Definition: AMCSpec.h:54

◆ getSegmented()

unsigned int amc::BlockHeader::getSegmented ( ) const
inline

Definition at line 32 of file AMCSpec.h.

References data_, and Segmented_bit_shift.

Referenced by getBlockSize().

32 { return (data_ >> Segmented_bit_shift) & 1; };
static const unsigned int Segmented_bit_shift
Definition: AMCSpec.h:48
uint64_t data_
Definition: AMCSpec.h:54

◆ getSize()

unsigned int amc::BlockHeader::getSize ( ) const
inline

Definition at line 30 of file AMCSpec.h.

References data_, Size_mask, and Size_shift.

Referenced by amc::Packet::finalize(), getBlocks(), getBlockSize(), and omtf::OmtfUnpacker::produce().

30 { return (data_ >> Size_shift) & Size_mask; };
static const unsigned int Size_shift
Definition: AMCSpec.h:37
static const unsigned int Size_mask
Definition: AMCSpec.h:38
uint64_t data_
Definition: AMCSpec.h:54

◆ operator uint64_t()

amc::BlockHeader::operator uint64_t ( ) const
inline

Definition at line 21 of file AMCSpec.h.

References data_.

21 { return data_; };
uint64_t data_
Definition: AMCSpec.h:54

◆ raw()

uint64_t amc::BlockHeader::raw ( ) const
inline

Definition at line 23 of file AMCSpec.h.

References data_.

Referenced by omtf::OmtfUnpacker::produce().

23 { return data_; };
uint64_t data_
Definition: AMCSpec.h:54

◆ validCRC()

unsigned int amc::BlockHeader::validCRC ( ) const
inline

Definition at line 34 of file AMCSpec.h.

References CRC_bit_shift, and data_.

34 { return (data_ >> CRC_bit_shift) & 1; };
static const unsigned int CRC_bit_shift
Definition: AMCSpec.h:52
uint64_t data_
Definition: AMCSpec.h:54

Member Data Documentation

◆ AmcNo_mask

const unsigned int amc::BlockHeader::AmcNo_mask = 0xf
staticprivate

Definition at line 42 of file AMCSpec.h.

Referenced by BlockHeader(), and getAMCNumber().

◆ AmcNo_shift

const unsigned int amc::BlockHeader::AmcNo_shift = 16
staticprivate

Definition at line 41 of file AMCSpec.h.

Referenced by BlockHeader(), and getAMCNumber().

◆ BlkNo_mask

const unsigned int amc::BlockHeader::BlkNo_mask = 0xff
staticprivate

Definition at line 40 of file AMCSpec.h.

Referenced by BlockHeader().

◆ BlkNo_shift

const unsigned int amc::BlockHeader::BlkNo_shift = 20
staticprivate

Definition at line 39 of file AMCSpec.h.

Referenced by BlockHeader().

◆ BoardID_mask

const unsigned int amc::BlockHeader::BoardID_mask = 0xffff
staticprivate

Definition at line 44 of file AMCSpec.h.

Referenced by BlockHeader(), and getBoardID().

◆ BoardID_shift

const unsigned int amc::BlockHeader::BoardID_shift = 0
staticprivate

Definition at line 43 of file AMCSpec.h.

Referenced by BlockHeader(), and getBoardID().

◆ CRC_bit_shift

const unsigned int amc::BlockHeader::CRC_bit_shift = 56
staticprivate

Definition at line 52 of file AMCSpec.h.

Referenced by BlockHeader(), and validCRC().

◆ data_

uint64_t amc::BlockHeader::data_
private

◆ Enabled_bit_shift

const unsigned int amc::BlockHeader::Enabled_bit_shift = 59
staticprivate

Definition at line 49 of file AMCSpec.h.

Referenced by BlockHeader().

◆ Length_bit_shift

const unsigned int amc::BlockHeader::Length_bit_shift = 62
staticprivate

Definition at line 46 of file AMCSpec.h.

Referenced by BlockHeader().

◆ More_bit_shift

const unsigned int amc::BlockHeader::More_bit_shift = 61
staticprivate

Definition at line 47 of file AMCSpec.h.

Referenced by BlockHeader(), and getMore().

◆ Present_bit_shift

const unsigned int amc::BlockHeader::Present_bit_shift = 58
staticprivate

Definition at line 50 of file AMCSpec.h.

Referenced by BlockHeader().

◆ Segmented_bit_shift

const unsigned int amc::BlockHeader::Segmented_bit_shift = 60
staticprivate

Definition at line 48 of file AMCSpec.h.

Referenced by BlockHeader(), and getSegmented().

◆ Size_mask

const unsigned int amc::BlockHeader::Size_mask = 0xffffff
staticprivate

Definition at line 38 of file AMCSpec.h.

Referenced by BlockHeader(), and getSize().

◆ Size_shift

const unsigned int amc::BlockHeader::Size_shift = 32
staticprivate

Definition at line 37 of file AMCSpec.h.

Referenced by BlockHeader(), and getSize().

◆ Valid_bit_shift

const unsigned int amc::BlockHeader::Valid_bit_shift = 57
staticprivate

Definition at line 51 of file AMCSpec.h.

Referenced by BlockHeader().