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::Header Class Reference

#include <AMCSpec.h>

Public Member Functions

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
 
 Header ()
 
 Header (const uint64_t *data)
 
 Header (unsigned int amc_no, unsigned int board_id, unsigned int size, unsigned int block=0)
 
 operator uint64_t () const
 
uint64_t raw () 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 15 of file AMCSpec.h.

Constructor & Destructor Documentation

amc::Header::Header ( )
inline

Definition at line 17 of file AMCSpec.h.

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

Definition at line 18 of file AMCSpec.h.

18 : data_(data[0]) {};
uint64_t data_
Definition: AMCSpec.h:54
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Header::Header ( unsigned int  amc_no,
unsigned int  board_id,
unsigned int  size,
unsigned int  block = 0 
)

Definition at line 9 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.

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

Member Function Documentation

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

Definition at line 30 of file AMCSpec.h.

References AmcNo_mask, AmcNo_shift, and data_.

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

Definition at line 52 of file AMCSpec.cc.

References getSize(), and findQualityFiles::size.

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

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

Definition at line 64 of file AMCSpec.cc.

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

65  {
66  // More and not Segmented means the first of multiple blocks. For
67  // these, getSize() returns the total size of the AMC packet, not the
68  // size of the first block.
69  if (getMore() && !getSegmented())
70  return split_block_size;
71  return getSize();
72  }
unsigned int getSegmented() const
Definition: AMCSpec.h:34
static const unsigned int split_block_size
Definition: AMCSpec.h:13
unsigned int getSize() const
Definition: AMCSpec.h:32
unsigned int getMore() const
Definition: AMCSpec.h:33
unsigned int amc::Header::getBoardID ( ) const
inline

Definition at line 31 of file AMCSpec.h.

References BoardID_mask, BoardID_shift, and data_.

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

Definition at line 33 of file AMCSpec.h.

References data_, and More_bit_shift.

Referenced by getBlockSize().

33 { 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::Header::getSegmented ( ) const
inline

Definition at line 34 of file AMCSpec.h.

References data_, and Segmented_bit_shift.

Referenced by getBlockSize().

34 { return (data_ >> Segmented_bit_shift) & 1; };
uint64_t data_
Definition: AMCSpec.h:54
static const unsigned int Segmented_bit_shift
Definition: AMCSpec.h:48
unsigned int amc::Header::getSize ( ) const
inline

Definition at line 32 of file AMCSpec.h.

References data_, Size_mask, and Size_shift.

Referenced by getBlocks(), getBlockSize(), and amc::Packet::size().

32 { 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::Header::operator uint64_t ( ) const
inline

Definition at line 23 of file AMCSpec.h.

References data_.

23 { return data_; };
uint64_t data_
Definition: AMCSpec.h:54
uint64_t amc::Header::raw ( ) const
inline

Definition at line 25 of file AMCSpec.h.

References data_.

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

Member Data Documentation

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

Definition at line 42 of file AMCSpec.h.

Referenced by getAMCNumber(), and Header().

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

Definition at line 41 of file AMCSpec.h.

Referenced by getAMCNumber(), and Header().

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

Definition at line 40 of file AMCSpec.h.

Referenced by Header().

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

Definition at line 39 of file AMCSpec.h.

Referenced by Header().

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

Definition at line 44 of file AMCSpec.h.

Referenced by getBoardID(), and Header().

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

Definition at line 43 of file AMCSpec.h.

Referenced by getBoardID(), and Header().

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

Definition at line 52 of file AMCSpec.h.

Referenced by Header().

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

Definition at line 49 of file AMCSpec.h.

Referenced by Header().

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

Definition at line 46 of file AMCSpec.h.

Referenced by Header().

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

Definition at line 47 of file AMCSpec.h.

Referenced by getMore(), and Header().

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

Definition at line 50 of file AMCSpec.h.

Referenced by Header().

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

Definition at line 48 of file AMCSpec.h.

Referenced by getSegmented(), and Header().

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

Definition at line 38 of file AMCSpec.h.

Referenced by getSize(), and Header().

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

Definition at line 37 of file AMCSpec.h.

Referenced by getSize(), and Header().

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

Definition at line 51 of file AMCSpec.h.

Referenced by Header().