Difference: AMC13DataUnpacking (3 vs. 4)

Revision 402 Jun 2014 - EricHazen

Line: 1 to 1
META TOPICPARENT name="AMC13CommonFirmwareProposal"
From CMS firmware 0x202 and onward the new event builder seems to be working.
Line: 27 to 27
 The last block can be identified by noticing that the bits (M,S)=(0,1) in the AMC information words in the block header.
Here are Wu's instructions for unpacking the data.
Here are Wu's instructions for unpacking the data:

Data decoding

The first word of an event always has the MSB byte as 0x51 or 0x52
The next word is the start of block word. Nibble 53-50 gives number of AMC modules with data in this
Following the start of block word are nAMC words of AMC summary. If bit 61 of the AMC summary word
(M bit) is not set, bit 55-32 has the actual number of words this AMC module in the block. If M bit
is set, number of words is always 4096 64 bit words. Summing them up gives the AMC payload size.
If none of the M bit is set, this is the last block of the event.
For a single block event, the event size is payload size + nAMC + 4
For a multi block event, the event size of the first block is payload size + nAMC + 3
For a multi block event, the event size of the block in the middle is payload size + nAMC + 2
For a multi block event, the event size of the last block is payload size + nAMC + 3
nAMC is given in the start of block word and could be different for blocks in the same event.
Bit 63-32 of the end of block word is the CRC of the block. CRC used is the Ethernet CRC-32
Please note that CRC calculation does not include the CDF end of event word.
To check the CRC of a block, first initialize the CRC to all 0.
CRC calculation is from bit 0 upwards to bit 63. The first 4 bytes of data use their 1's complement
(invert) in the CRC calculation, the rest of data will be used as is. CRC attached to the block(bit
63-32 of the block trailer) will also be included in the CRC check calculation. The final CRC value
must be 0xc704dd7b, otherwise there is an error in the block.
The polynomial is 
1 + x + x^2 + x^4 + x^5 + x^7 + x^8 + x^10 + x^11 + x^12 + x^16 +x^22 + x^23 +x^26 +x^32

How to get the total length of the event: (this requires every AMC has its length in the header)

1. get nAMC(number of AMC modules in the event) from bit 53-50 of the second word(first block header)
2. read nAMC words of AMC summary to get length(i) of each AMC and do the following calculation:
   Nblock(i) = intger((length(i)-1023)/4096) + 1
3. find the biggest Nblock(i) NblockMax = max(Nblock(i))
4. TotalLength = sum(length(i)) + sum(Nblock(i)) + NblockMax*2 + 2
  -- EricHazen - 26 May 2014 \ No newline at end of file
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback