StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
l1_fp201_2015_a.cc
1 #include "bits.hh"
2 #include "l1_fp201_2015_a.hh"
3 #include "fms_fm101_2015_a.hh"
4 #include "fms_fm103_2015_a.hh"
5 #include <stdio.h>
6 
7 //#include "registerHack.hh"
8 
9 static const int NBITBS=12;
10 static int DBS[NBITBS][NBITBS];
11 static const int tableBS[NBITBS][NBITBS]={
12  {0,0,0,0,0,0,0,0,0,0,0,0}, //SmST
13  {0,0,0,0,0,0,0,0,0,0,0,0}, //SmSM
14  {1,0,0,0,0,0,0,0,0,0,0,0}, //SmSB
15  {1,1,0,0,0,0,0,0,0,0,0,0}, //SmNB
16  {1,1,1,0,0,0,0,0,0,0,0,0}, //SmNM
17  {0,1,1,1,0,0,0,0,0,0,0,0}, //SmNT
18  {0,0,1,1,1,0,0,0,0,0,0,0}, //LgST
19  {0,0,0,1,1,1,0,0,0,0,0,0}, //LgSM
20  {1,0,0,0,1,1,1,0,0,0,0,0}, //LgSB
21  {1,1,0,0,0,1,1,1,0,0,0,0}, //LgNB
22  {1,1,1,0,0,0,1,1,1,0,0,0}, //LgNM
23  {0,1,1,1,0,0,0,1,1,1,0,0}};//LgNT
24 // Small Large
25 // South North Siuth North
26 // T M B B M T T M B B M T
27 
28 static const int NBITJp=6;
29 static int DJp[NBITJp][NBITJp];
30 static const int tableJp[NBITJp][NBITJp]={
31  {0,0,0,1,1,0}, //ST
32  {0,0,0,1,1,1}, //SM
33  {0,0,0,0,1,1}, //SB
34  {1,1,0,0,0,0}, //NB
35  {1,1,1,0,0,0}, //NM
36  {0,1,1,0,0,0}};//NT
37 // South North
38 // T M B B M T
39 
40 void l1_fp201_2015_a(Board& fp201, int t, int simdat){
41  const int JpThr0=fp201.registers[0];
42  const int JpThr1=fp201.registers[1];
43  const int JpThr2=fp201.registers[2];
44  //Hack until we know details of registers
45  //int JpThr0=JPthr0;
46  //int JpThr1=JPthr1;
47  //int JpThr2=JPthr2;
48 
49  //input
50  int* in;
51  if(simdat==0) {in=(int*)fp201.channels[t];}
52  else {in=(int*)fp201.dsmdata[t];}
53  int fm101 = in[3]; // small cells south
54  int fm102 = in[0]; // small cells north
55  int fm103 = in[1]; // large cells south
56  int fm104 = in[2]; // large cells north
57 
58  //BS
59  int smBS3 = getFM101_2015a_BS3(fm101) | getFM101_2015a_BS3(fm102);
60  int lgBS3 = getFM103_2015a_BS3(fm103) | getFM103_2015a_BS3(fm104);
61  int smBS2 = getFM101_2015a_BS2(fm101) | getFM101_2015a_BS2(fm102);
62  int lgBS2 = getFM103_2015a_BS2(fm103) | getFM103_2015a_BS2(fm104);
63  int smBS1 = getFM101_2015a_BS1T(fm101) | getFM101_2015a_BS1M(fm101) | getFM101_2015a_BS1B(fm101)
64  | getFM101_2015a_BS1T(fm102) | getFM101_2015a_BS1M(fm102) | getFM101_2015a_BS1B(fm102);
65  int lgBS1 = getFM103_2015a_BS1T(fm103) | getFM103_2015a_BS1M(fm103) | getFM103_2015a_BS1B(fm103)
66  | getFM103_2015a_BS1T(fm104) | getFM103_2015a_BS1M(fm104) | getFM103_2015a_BS1B(fm104);
67 
68  //DiBS
69  int DiBS=0;
70  memset(DBS,0,sizeof(DBS));
71  int bs1
72  = (getFM101_2015a_BS1T(fm101)<<0) | (getFM101_2015a_BS1M(fm101)<<1) | (getFM101_2015a_BS1B(fm101)<<2)
73  | (getFM101_2015a_BS1B(fm102)<<3) | (getFM101_2015a_BS1M(fm102)<<4) | (getFM101_2015a_BS1T(fm102)<<5)
74  | (getFM103_2015a_BS1T(fm103)<<6) | (getFM103_2015a_BS1M(fm103)<<7) | (getFM103_2015a_BS1B(fm103)<<8)
75  | (getFM103_2015a_BS1B(fm104)<<9) | (getFM103_2015a_BS1M(fm104)<<10)| (getFM103_2015a_BS1T(fm104)<<12);
76  fp201.userdata[t][0]=bs1;
77  for(int i=0; i<NBITBS; i++){
78  if(btest(bs1,i)){
79  for(int j=i+1; j<NBITBS; j++){
80  if(tableBS[j][i] & btest(bs1,j)) {DBS[j][i]=1; DiBS=1;}
81  }
82  }
83  }
84 
85  //Jp
86  int jp[NBITJp];
87  jp[0] = getFM101_2015a_JpT(fm101) + getFM103_2015a_JpT(fm103); //ST
88  jp[1] = getFM101_2015a_JpM(fm101) + getFM103_2015a_JpM(fm103); //SM
89  jp[2] = getFM101_2015a_JpB(fm101) + getFM103_2015a_JpB(fm103); //SB
90  jp[3] = getFM101_2015a_JpB(fm102) + getFM103_2015a_JpB(fm104); //NB
91  jp[4] = getFM101_2015a_JpM(fm102) + getFM103_2015a_JpM(fm104); //NM
92  jp[5] = getFM101_2015a_JpT(fm102) + getFM103_2015a_JpT(fm104); //NT
93  int JP2=0, JP1=0, JP0=0, jp0=0;
94  for(int i=0; i<NBITJp; i++){
95  if(jp[i]>JpThr2) JP2=1;
96  if(jp[i]>JpThr1) JP1=1;
97  if(jp[i]>JpThr0) {JP0=1; jp0+=(1<<i);}
98  }
99  fp201.userdata[t][1]=jp0;
100 
101  //DiJp
102  int DiJp=0;
103  memset(DJp,0,sizeof(DJp));
104  for(int i=0; i<NBITJp-1; i++){
105  if(btest(jp0,i)){
106  for(int j=i+1; j<NBITJp; j++){
107  if(tableJp[j][i] & btest(jp0,j)) {DJp[j][i]=1; DiJp=1;}
108  }
109  }
110  }
111 
112  fp201.output[t]
113  = smBS3<<0 | smBS2<<1 | smBS1<<2
114  | lgBS3<<3 | lgBS2<<4 | lgBS1<<5
115  | DiBS<<6
116  | JP2<<7 | JP1<<8 | JP0<<9
117  | DiJp<<10;
118 
119  //if(1){
120  if(PRINT){
121  printf("%s input FM101=%08x FM102=%08x FM103=%08x FM104=%08x\n",fp201.name,fm101,fm102,fm103,fm104);
122  printf("%s out=%08x smBS3/2/1=%1d %1d %1d lgBS3/2/1=%1d %1d %1d DiBS=%1d JP=%1d %1d %1d DiJp=%1d\n",
123  fp201.name,fp201.output[t],
124  smBS3,smBS2,smBS1,
125  lgBS3,lgBS2,lgBS1,
126  DiBS,
127  JP2,JP1,JP0,
128  DiJp);
129 
130  printf("%s DiBS bs1=%03x=",fp201.name,bs1);
131  for(int i=NBITBS-1; i>=0; i--) printf("%1x",btest(bs1,i));
132  printf("\n");
133  for(int j=0; j<NBITBS; j++){
134  printf("DiBS ");
135  for(int i=0; i<=j; i++){
136  printf(" %1d", DBS[j][i]);
137  }
138  printf("\n");
139  }
140 
141  printf("%s DiJp jp1=%02x=",fp201.name,jp0);
142  for(int i=NBITJp-1; i>=0; i--) printf("%1x",btest(jp0,i));
143  printf("\n");
144  for(int j=0; j<NBITJp; j++){
145  printf("DiJp ");
146  for(int i=0; i<NBITJp; i++){
147  printf(" %1d", DJp[j][i]);
148  }
149  printf("\n");
150  }
151  }
152 }
153 
154 int getFP201_2015a_bs0bits(Board& fp201, int t) {return fp201.userdata[t][0];}
155 int getFP201_2015a_jp1bits(Board& fp201, int t) {return fp201.userdata[t][1];}
Definition: Board.hh:14