next50 trigger mask in AliHLTGlobalEsdConverterComponent
[u/mrichter/AliRoot.git] / TRD / AliTRDtrapConfig.h
CommitLineData
ce4786b9 1#ifndef ALITRDTRAPCONFIG_H
2#define ALITRDTRAPCONFIG_H
36dc3337 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
2b2b540f 6// Configuration of the TRD TRAcklet Processor
7// (TRD Front-End Electronics)
5f006bd7 8//
2b2b540f 9// TRAP registers
10// TRAP data memory (DMEM)
ce4786b9 11
12#include <TObject.h>
2b2b540f 13#include <TNamed.h>
ce4786b9 14#include <TString.h>
8ea391e3 15#include <fstream>
0c4641ae 16using std::ostream;
ce4786b9 17
2b2b540f 18class AliTRDtrapConfig : public TNamed
ce4786b9 19{
20 public:
2b2b540f 21 AliTRDtrapConfig(const TString &name = "", const TString &title = "");
5f006bd7 22 ~AliTRDtrapConfig();
051af255 23
2b2b540f 24 // allocation
25 enum Alloc_t {
26 kAllocNone,
27 kAllocGlobal,
28 kAllocByDetector,
29 kAllocByHC,
30 kAllocByMCM,
31 kAllocByMergerType,
32 kAllocByLayer,
33 kAllocByMCMinSM,
34 kAllocLast
35 }; // possible granularities for allocation
36 // common to registers and DMEM
37
38 // registers
5f006bd7 39 enum TrapReg_t { kSML0,
40 kSML1,
ce4786b9 41 kSML2,
42 kSMMODE,
2b2b540f 43 kSMCMD,
ce4786b9 44 kNITM0,
45 kNITM1,
46 kNITM2,
47 kNIP4D,
48 kCPU0CLK,
49 kCPU1CLK,
50 kCPU2CLK,
51 kCPU3CLK,
52 kNICLK,
53 kFILCLK,
54 kPRECLK,
55 kADCEN,
56 kNIODE,
57 kNIOCE,
58 kNIIDE,
59 kNIICE,
5f006bd7 60 kARBTIM,
61 kIA0IRQ0,
62 kIA0IRQ1,
63 kIA0IRQ2,
64 kIA0IRQ3,
65 kIA0IRQ4,
66 kIA0IRQ5,
67 kIA0IRQ6,
68 kIA0IRQ7,
69 kIA0IRQ8,
70 kIA0IRQ9,
71 kIA0IRQA,
72 kIA0IRQB,
73 kIA0IRQC,
74 kIRQSW0,
75 kIRQHW0,
76 kIRQHL0,
77 kIA1IRQ0,
78 kIA1IRQ1,
79 kIA1IRQ2,
80 kIA1IRQ3,
81 kIA1IRQ4,
82 kIA1IRQ5,
83 kIA1IRQ6,
84 kIA1IRQ7,
85 kIA1IRQ8,
86 kIA1IRQ9,
87 kIA1IRQA,
88 kIA1IRQB,
89 kIA1IRQC,
90 kIRQSW1,
91 kIRQHW1,
92 kIRQHL1,
93 kIA2IRQ0,
94 kIA2IRQ1,
95 kIA2IRQ2,
96 kIA2IRQ3,
97 kIA2IRQ4,
98 kIA2IRQ5,
99 kIA2IRQ6,
100 kIA2IRQ7,
101 kIA2IRQ8,
102 kIA2IRQ9,
103 kIA2IRQA,
104 kIA2IRQB,
105 kIA2IRQC,
106 kIRQSW2,
107 kIRQHW2,
108 kIRQHL2,
109 kIA3IRQ0,
110 kIA3IRQ1,
111 kIA3IRQ2,
112 kIA3IRQ3,
113 kIA3IRQ4,
114 kIA3IRQ5,
115 kIA3IRQ6,
116 kIA3IRQ7,
117 kIA3IRQ8,
118 kIA3IRQ9,
119 kIA3IRQA,
120 kIA3IRQB,
121 kIA3IRQC,
122 kIRQSW3,
123 kIRQHW3,
124 kIRQHL3,
125 kCTGDINI,
126 kCTGCTRL,
127 kC08CPU0,
128 kC09CPU0,
129 kC10CPU0,
130 kC11CPU0,
131 kC12CPUA,
132 kC13CPUA,
133 kC14CPUA,
134 kC15CPUA,
135 kC08CPU1,
136 kC09CPU1,
137 kC10CPU1,
138 kC11CPU1,
139 kC08CPU2,
140 kC09CPU2,
141 kC10CPU2,
142 kC11CPU2,
143 kC08CPU3,
144 kC09CPU3,
145 kC10CPU3,
146 kC11CPU3,
147 kNMOD,
148 kNDLY,
149 kNED,
150 kNTRO,
151 kNRRO,
152 kNES,
153 kNTP,
154 kNBND,
155 kNP0,
156 kNP1,
157 kNP2,
158 kNP3,
159 kNCUT,
160 kTPPT0,
161 kTPFS,
162 kTPFE,
163 kTPPGR,
164 kTPPAE,
165 kTPQS0,
166 kTPQE0,
167 kTPQS1,
168 kTPQE1,
169 kEBD,
170 kEBAQA,
171 kEBSIA,
172 kEBSF,
173 kEBSIM,
174 kEBPP,
175 kEBPC,
176 kEBIS,
177 kEBIT,
178 kEBIL,
179 kEBIN,
180 kFLBY,
181 kFPBY,
182 kFGBY,
183 kFTBY,
184 kFCBY,
185 kFPTC,
186 kFPNP,
187 kFPCL,
188 kFGTA,
189 kFGTB,
190 kFGCL,
191 kFTAL,
192 kFTLL,
193 kFTLS,
194 kFCW1,
195 kFCW2,
196 kFCW3,
197 kFCW4,
198 kFCW5,
199 kTPFP,
200 kTPHT,
201 kTPVT,
202 kTPVBY,
203 kTPCT,
204 kTPCL,
205 kTPCBY,
206 kTPD,
207 kTPCI0,
208 kTPCI1,
209 kTPCI2,
210 kTPCI3,
211 kADCMSK,
212 kADCINB,
213 kADCDAC,
214 kADCPAR,
215 kADCTST,
216 kSADCAZ,
217 kFGF0,
218 kFGF1,
219 kFGF2,
220 kFGF3,
221 kFGF4,
222 kFGF5,
223 kFGF6,
224 kFGF7,
225 kFGF8,
226 kFGF9,
227 kFGF10,
228 kFGF11,
229 kFGF12,
230 kFGF13,
231 kFGF14,
232 kFGF15,
233 kFGF16,
234 kFGF17,
235 kFGF18,
236 kFGF19,
237 kFGF20,
238 kFGA0,
239 kFGA1,
240 kFGA2,
241 kFGA3,
242 kFGA4,
243 kFGA5,
244 kFGA6,
245 kFGA7,
246 kFGA8,
247 kFGA9,
248 kFGA10,
249 kFGA11,
250 kFGA12,
251 kFGA13,
252 kFGA14,
253 kFGA15,
254 kFGA16,
255 kFGA17,
256 kFGA18,
257 kFGA19,
258 kFGA20,
259 kFLL00,
260 kFLL01,
261 kFLL02,
262 kFLL03,
263 kFLL04,
264 kFLL05,
265 kFLL06,
266 kFLL07,
267 kFLL08,
268 kFLL09,
269 kFLL0A,
270 kFLL0B,
271 kFLL0C,
272 kFLL0D,
273 kFLL0E,
274 kFLL0F,
275 kFLL10,
276 kFLL11,
277 kFLL12,
278 kFLL13,
279 kFLL14,
280 kFLL15,
281 kFLL16,
282 kFLL17,
283 kFLL18,
284 kFLL19,
285 kFLL1A,
286 kFLL1B,
287 kFLL1C,
288 kFLL1D,
289 kFLL1E,
290 kFLL1F,
291 kFLL20,
292 kFLL21,
293 kFLL22,
294 kFLL23,
295 kFLL24,
296 kFLL25,
297 kFLL26,
298 kFLL27,
299 kFLL28,
300 kFLL29,
301 kFLL2A,
302 kFLL2B,
303 kFLL2C,
304 kFLL2D,
305 kFLL2E,
306 kFLL2F,
307 kFLL30,
308 kFLL31,
309 kFLL32,
310 kFLL33,
311 kFLL34,
312 kFLL35,
313 kFLL36,
314 kFLL37,
315 kFLL38,
316 kFLL39,
317 kFLL3A,
318 kFLL3B,
319 kFLL3C,
320 kFLL3D,
321 kFLL3E,
322 kFLL3F,
323 kPASADEL,
324 kPASAPHA,
325 kPASAPRA,
326 kPASADAC,
327 kPASACHM,
328 kPASASTL,
329 kPASAPR1,
330 kPASAPR0,
331 kSADCTRG,
332 kSADCRUN,
333 kSADCPWR,
334 kL0TSIM,
335 kSADCEC,
336 kSADCMC,
337 kSADCOC,
338 kSADCGTB,
339 kSEBDEN,
340 kSEBDOU,
341 kTPL00,
342 kTPL01,
343 kTPL02,
344 kTPL03,
345 kTPL04,
346 kTPL05,
347 kTPL06,
348 kTPL07,
349 kTPL08,
350 kTPL09,
351 kTPL0A,
352 kTPL0B,
353 kTPL0C,
354 kTPL0D,
355 kTPL0E,
356 kTPL0F,
357 kTPL10,
358 kTPL11,
359 kTPL12,
360 kTPL13,
361 kTPL14,
362 kTPL15,
363 kTPL16,
364 kTPL17,
365 kTPL18,
366 kTPL19,
367 kTPL1A,
368 kTPL1B,
369 kTPL1C,
370 kTPL1D,
371 kTPL1E,
372 kTPL1F,
373 kTPL20,
374 kTPL21,
375 kTPL22,
376 kTPL23,
377 kTPL24,
378 kTPL25,
379 kTPL26,
380 kTPL27,
381 kTPL28,
382 kTPL29,
383 kTPL2A,
384 kTPL2B,
385 kTPL2C,
386 kTPL2D,
387 kTPL2E,
388 kTPL2F,
389 kTPL30,
390 kTPL31,
391 kTPL32,
392 kTPL33,
393 kTPL34,
394 kTPL35,
395 kTPL36,
396 kTPL37,
397 kTPL38,
398 kTPL39,
399 kTPL3A,
400 kTPL3B,
401 kTPL3C,
402 kTPL3D,
403 kTPL3E,
404 kTPL3F,
405 kTPL40,
406 kTPL41,
407 kTPL42,
408 kTPL43,
409 kTPL44,
410 kTPL45,
411 kTPL46,
412 kTPL47,
413 kTPL48,
414 kTPL49,
415 kTPL4A,
416 kTPL4B,
417 kTPL4C,
418 kTPL4D,
419 kTPL4E,
420 kTPL4F,
421 kTPL50,
422 kTPL51,
423 kTPL52,
424 kTPL53,
425 kTPL54,
426 kTPL55,
427 kTPL56,
428 kTPL57,
429 kTPL58,
430 kTPL59,
431 kTPL5A,
432 kTPL5B,
433 kTPL5C,
434 kTPL5D,
435 kTPL5E,
436 kTPL5F,
437 kTPL60,
438 kTPL61,
439 kTPL62,
440 kTPL63,
441 kTPL64,
442 kTPL65,
443 kTPL66,
444 kTPL67,
445 kTPL68,
446 kTPL69,
447 kTPL6A,
448 kTPL6B,
449 kTPL6C,
450 kTPL6D,
451 kTPL6E,
452 kTPL6F,
453 kTPL70,
454 kTPL71,
455 kTPL72,
456 kTPL73,
457 kTPL74,
458 kTPL75,
459 kTPL76,
460 kTPL77,
461 kTPL78,
462 kTPL79,
463 kTPL7A,
464 kTPL7B,
465 kTPL7C,
466 kTPL7D,
467 kTPL7E,
468 kTPL7F,
469 kMEMRW,
470 kMEMCOR,
471 kDMDELA,
472 kDMDELS,
ce4786b9 473 kLastReg }; // enum of all TRAP registers, to be used for access to them
474
2b2b540f 475 Bool_t SetTrapRegAlloc(TrapReg_t reg, Alloc_t mode) { return fRegisterValue[reg].Allocate(mode); }
ce4786b9 476 Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det);
477 Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det, Int_t rob, Int_t mcm);
478
2b2b540f 479 Int_t GetTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
ce4786b9 480
ce4786b9 481 void ResetRegs();
482
2b2b540f 483 // data memory (DMEM)
484 Bool_t SetDmemAlloc(Int_t addr, Alloc_t mode);
485 Bool_t SetDmem(Int_t addr, UInt_t value, Int_t det);
051af255 486 Bool_t SetDmem(Int_t addr, UInt_t value, Int_t det, Int_t rob, Int_t mcm);
487 Bool_t SetDmem(Int_t addr, Int_t value) { return SetDmem(addr, (UInt_t) value); }
051af255 488 Bool_t SetDmem(Int_t addr, Int_t value, Int_t det, Int_t rob, Int_t mcm) { return SetDmem(addr, (UInt_t) value, det, rob, mcm); }
ce4786b9 489
8ea391e3 490 UInt_t GetDmemUnsigned(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
491
2b2b540f 492 void ResetDmem();
493
494 // access by 16-bit address
495 UInt_t Peek(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
496 Bool_t Poke(Int_t addr, UInt_t value, Int_t det, Int_t rob, Int_t mcm);
497
498 // helper methods
499 const char* GetRegName(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetName() : ""; }
500 UShort_t GetRegAddress(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetAddr() : 0; }
501 UShort_t GetRegNBits(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetNbits() : 0; }
502 UInt_t GetRegResetValue(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetResetValue() : 0; }
503
504 TrapReg_t GetRegByAddress(Int_t address) const;
505
506 Bool_t PrintTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
507 Bool_t PrintTrapAddr(Int_t addr, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
508
8ea391e3 509 void PrintMemDatx(ostream &os, Int_t addr) const;
510 void PrintMemDatx(ostream &os, Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
511 void PrintMemDatx(ostream &os, TrapReg_t reg) const;
512 void PrintMemDatx(ostream &os, TrapReg_t reg, Int_t det, Int_t rob, Int_t mcm) const;
513 void PrintDatx(ostream &os, UInt_t addr, UInt_t data, Int_t rob, Int_t mcm) const;
5f006bd7 514
6d976847 515 void PrintVerify(ostream &os, Int_t det, Int_t rob, Int_t mcm) const;
516
2b2b540f 517 static const Int_t fgkDmemStartAddress = 0xc000; // start address in TRAP GIO
518 static const Int_t fgkDmemWords = 0x400; // number of words in DMEM
ce4786b9 519
2b2b540f 520 static const Int_t fgkImemStartAddress = 0xe000; // start address in TRAP GIO
521 static const Int_t fgkImemWords = 0x1000; // number of words in IMEM
ce4786b9 522
2b2b540f 523 static const Int_t fgkDbankStartAddress = 0xf000; // start address in TRAP GIO
524 static const Int_t fgkDbankWords = 0x0100; // number of words in DBANK
5f006bd7 525
2b2b540f 526 class AliTRDtrapValue : public TObject {
527 public:
528 AliTRDtrapValue();
0aa63880 529 virtual ~AliTRDtrapValue();
051af255 530
2b2b540f 531 virtual Bool_t Allocate(Alloc_t mode);
051af255 532
2b2b540f 533 protected:
3df58e28 534 Bool_t SetData(UInt_t value);
535 Bool_t SetData(UInt_t value, Int_t det);
536 Bool_t SetData(UInt_t value, Int_t det, Int_t rob, Int_t mcm);
8ea391e3 537
3df58e28 538 UInt_t GetData(Int_t det, Int_t rob, Int_t mcm) const;
2b2b540f 539
540 Int_t GetIdx(Int_t det, Int_t rob, Int_t mcm) const;
541
542 private:
543 AliTRDtrapValue(const AliTRDtrapValue &rhs); // not implemented
544 AliTRDtrapValue& operator=(const AliTRDtrapValue &rhs); // not implemented
545
546 Alloc_t fAllocMode; // allocation mode
547 Int_t fSize; // array size
548 UInt_t *fData; //[fSize] data array
549 Bool_t *fValid; //[fSize] valid flag
ce4786b9 550
2b2b540f 551 static const Int_t fgkSize[kAllocLast]; // required array dimension for different allocation modes
552
553 ClassDef(AliTRDtrapValue, 1);
ce4786b9 554 };
555
2b2b540f 556 class AliTRDtrapRegister : public AliTRDtrapValue {
557 public:
558 AliTRDtrapRegister();
559 virtual ~AliTRDtrapRegister();
ce4786b9 560
2b2b540f 561 void Init(const char* name, Int_t addr, Int_t nBits, Int_t resetValue);
562 void Reset() { SetData(fResetValue); }
ce4786b9 563
2b2b540f 564 Bool_t SetValue(Int_t value, Int_t det) { return SetData(value, det); }
565 Bool_t SetValue(Int_t value, Int_t det, Int_t rob, Int_t mcm) { return SetData(value, det, rob, mcm); }
566
567 Int_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
568
569 const char* GetName() const { return fName.Data(); }
570 UShort_t GetAddr() const { return fAddr; }
571 UShort_t GetNbits() const { return fNbits; }
572 UInt_t GetResetValue() const { return fResetValue; }
573
574 protected:
575 AliTRDtrapRegister(const AliTRDtrapRegister &rhs);
576 AliTRDtrapRegister& operator=(const AliTRDtrapRegister &rhs);
577
578 // fixed properties of the register
579 // which do not need to be stored
580 TString fName; //! Name of the register
581 UShort_t fAddr; //! Address in GIO of TRAP
582 UShort_t fNbits; //! Number of bits, from 1 to 32
583 UInt_t fResetValue; //! reset value
584
585 ClassDef(AliTRDtrapRegister, 1);
ce4786b9 586 };
587
2b2b540f 588 class AliTRDtrapDmemWord : public AliTRDtrapValue {
589 public:
590 AliTRDtrapDmemWord() : AliTRDtrapValue(), fName(""), fAddr(0) {}
591 virtual ~AliTRDtrapDmemWord() {}
592
593 void Reset() { SetData(0); }
594
595 Bool_t SetValue(UInt_t value, Int_t det) { return SetData(value, det); }
596 Bool_t SetValue(UInt_t value, Int_t det, Int_t rob, Int_t mcm) { return SetData(value, det, rob, mcm); }
597
598 UInt_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
599
600 void SetAddress(UShort_t addr) { fAddr = addr; fName.Form("DMEM 0x%04x", fAddr); }
601 const char* GetName() const { return fName.Data(); }
602
603 protected:
604 AliTRDtrapDmemWord(const AliTRDtrapDmemWord &rhs); // not implemented
605 AliTRDtrapDmemWord& operator=(const AliTRDtrapDmemWord &rhs); // not implemented
606
607 TString fName;
608 UShort_t fAddr; //! address
609
610 ClassDef(AliTRDtrapDmemWord, 1);
ce4786b9 611 };
612
230a6a13 613 protected:
614 void InitRegs();
615
2b2b540f 616 // configuration registers
617 AliTRDtrapRegister fRegisterValue[kLastReg]; // array of TRAP register values in use
ce4786b9 618
2b2b540f 619 // DMEM
620 AliTRDtrapDmemWord fDmem[fgkDmemWords]; // TRAP data memory
621
2b2b540f 622 static const Int_t fgkMcmlistSize=256; // list of MCMs to which a value has to be written
623
624 static Bool_t fgRegAddressMapInitialized;
6170d369 625 static TrapReg_t fgRegAddressMap[0x400 + 0x200 + 0x4];
2b2b540f 626 static const Int_t fgkRegisterAddressBlockStart[];
627 static const Int_t fgkRegisterAddressBlockSize[];
36dc3337 628
629 private:
630 AliTRDtrapConfig& operator=(const AliTRDtrapConfig &rhs); // not implemented
631 AliTRDtrapConfig(const AliTRDtrapConfig& cfg); // not implemented
632
2b2b540f 633 ClassDef(AliTRDtrapConfig, 3);
ce4786b9 634};
635
636#endif