test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

amc::BlockHeader::BlockHeader ( )
inline

Definition at line 15 of file AMCSpec.h.

15 : data_(0) {};
uint64_t data_
Definition: AMCSpec.h:54
amc::BlockHeader::BlockHeader ( const uint64_t *  data)
inline

Definition at line 16 of file AMCSpec.h.

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, 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.

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

Member Function Documentation

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().

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
unsigned int amc::BlockHeader::getBlocks ( ) const

Definition at line 54 of file AMCSpec.cc.

References getSize(), and findQualityFiles::size.

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

55  {
56  // The first block of a segmented event has a size of 1023, all
57  // following have a max size of 4096. Segmentation only happens
58  // for AMC payloads >= 0x13ff 64 bit words.
59  unsigned int size = getSize();
60  if (size >= 0x13ff)
61  return (size - 1023) / 4096 + 1;
62  return 1;
63  }
unsigned int getSize() const
Definition: AMCSpec.h:30
tuple size
Write out results.
unsigned int amc::BlockHeader::getBlockSize ( ) const

Definition at line 66 of file AMCSpec.cc.

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

67  {
68  // More and not Segmented means the first of multiple blocks. For
69  // these, getSize() returns the total size of the AMC packet, not the
70  // size of the first block.
71  if (getMore() && !getSegmented())
72  return split_block_size;
73  return getSize();
74  }
unsigned int getMore() const
Definition: AMCSpec.h:31
static const unsigned int split_block_size
Definition: AMCSpec.h:9
unsigned int getSize() const
Definition: AMCSpec.h:30
unsigned int getSegmented() const
Definition: AMCSpec.h:32
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().

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
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
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
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(), and getBlockSize().

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
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
uint64_t amc::BlockHeader::raw ( ) const
inline

Definition at line 23 of file AMCSpec.h.

References data_.

23 { return data_; };
uint64_t data_
Definition: AMCSpec.h:54
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

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

Definition at line 42 of file AMCSpec.h.

Referenced by BlockHeader(), and getAMCNumber().

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

Definition at line 41 of file AMCSpec.h.

Referenced by BlockHeader(), and getAMCNumber().

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

Definition at line 40 of file AMCSpec.h.

Referenced by BlockHeader().

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

Definition at line 39 of file AMCSpec.h.

Referenced by BlockHeader().

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

Definition at line 44 of file AMCSpec.h.

Referenced by BlockHeader(), and getBoardID().

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

Definition at line 43 of file AMCSpec.h.

Referenced by BlockHeader(), and getBoardID().

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

Definition at line 52 of file AMCSpec.h.

Referenced by BlockHeader(), and validCRC().

uint64_t amc::BlockHeader::data_
private
const unsigned int amc::BlockHeader::Enabled_bit_shift = 59
staticprivate

Definition at line 49 of file AMCSpec.h.

Referenced by BlockHeader().

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

Definition at line 46 of file AMCSpec.h.

Referenced by BlockHeader().

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

Definition at line 47 of file AMCSpec.h.

Referenced by BlockHeader(), and getMore().

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

Definition at line 50 of file AMCSpec.h.

Referenced by BlockHeader().

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

Definition at line 48 of file AMCSpec.h.

Referenced by BlockHeader(), and getSegmented().

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

Definition at line 38 of file AMCSpec.h.

Referenced by BlockHeader(), and getSize().

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

Definition at line 37 of file AMCSpec.h.

Referenced by BlockHeader(), and getSize().

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

Definition at line 51 of file AMCSpec.h.

Referenced by BlockHeader().