StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fms_fm101_2011_a.cc
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 14 Jan 2011
5 //
6 
7 #include "bits.hh"
8 #include "fms_fm101_2011_a.hh"
9 
10 void fms_fm101_2011_a(Board& fm101, int t)
11 {
12  int* channels = (int*)fm101.channels[t];
13 
14  // Board sum thresholds
15  const int R0 = fm101.registers[0];
16  const int R1 = fm101.registers[1];
17  const int R2 = fm101.registers[2];
18 
19  // High tower bits
20  int HT0 = 0;
21  int HT1 = 0;
22 
23  // Board sum bits
24  int BS0 = 0;
25  int BS1 = 0;
26  int BS2 = 0;
27 
28  // Quadrant sums
29  int Sum[4];
30 
31  for (int i = 0; i < 4; ++i) {
32  int fm001out = channels[i];
33 
34  // OR the HT0 bits from the four quadrants together, and likewise
35  // for the HT1 bits. Output the results to the Layer-2 DSM (2 bits)
36  HT0 |= btest(fm001out,30);
37  HT1 |= btest(fm001out,31);
38 
39  // Compare the 24 5-bit Sum values to three thresholds (BSum0,
40  // BSum1, BSum2). OR the results together, and output them to the
41  // Layer-2 DSM (3 bits, not muxed)
42  int SumD = getbits(fm001out,0 ,5);
43  int SumC = getbits(fm001out,5 ,5);
44  int SumBC = getbits(fm001out,10,5);
45  int SumB = getbits(fm001out,15,5);
46  int SumAB = getbits(fm001out,20,5);
47  int SumA = getbits(fm001out,25,5);
48 
49  BS0 |= SumA > R0 || SumAB > R0 || SumB > R0 || SumBC > R0 || SumC > R0 || SumD > R0;
50  BS1 |= SumA > R1 || SumAB > R1 || SumB > R1 || SumBC > R1 || SumC > R1 || SumD > R1;
51  BS2 |= SumA > R2 || SumAB > R2 || SumB > R2 || SumBC > R2 || SumC > R2 || SumD > R2;
52 
53  // Compute the 7-bit total SumA+SumB+SumC+SumD for each of the four quadrants
54  Sum[i] = SumA+SumB+SumC+SumD;
55 
56  // Extract the low-order 6 bits from each of the 7-bit sums. If the
57  // high-order bit is 1, set the result to 111111.
58  if (Sum[i] > 63) Sum[i] = 63;
59  }
60 
61  // Output the resulting 4 6-bit sums to the Layer-2 DSM (24 bits)
62  fm101.output[t] = Sum[0] | Sum[1] << 6 | Sum[2] << 12 | Sum[3] << 18 | BS0 << 24 | BS1 << 25 | BS2 << 26 | HT0 << 27 | HT1 << 28;
63 }
Definition: Board.hh:14