1 #ifndef ALITRDTRAPCONFIG_H
2 #define ALITRDTRAPCONFIG_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 // Configuration of the TRD TRAcklet Processor
7 // (TRD Front-End Electronics)
10 // TRAP data memory (DMEM)
18 class AliTRDtrapConfig : public TNamed
21 AliTRDtrapConfig(const TString &name = "", const TString &title = "");
35 }; // possible granularities for allocation
36 // common to registers and DMEM
39 enum TrapReg_t { kSML0,
473 kLastReg }; // enum of all TRAP registers, to be used for access to them
475 Bool_t SetTrapRegAlloc(TrapReg_t reg, Alloc_t mode) { return fRegisterValue[reg].Allocate(mode); }
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);
479 Int_t GetTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
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);
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); }
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); }
490 UInt_t GetDmemUnsigned(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
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);
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; }
504 TrapReg_t GetRegByAddress(Int_t address) const;
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;
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;
515 void PrintVerify(ostream &os, Int_t det, Int_t rob, Int_t mcm) const;
517 static const Int_t fgkDmemStartAddress = 0xc000; // start address in TRAP GIO
518 static const Int_t fgkDmemWords = 0x400; // number of words in DMEM
520 static const Int_t fgkImemStartAddress = 0xe000; // start address in TRAP GIO
521 static const Int_t fgkImemWords = 0x1000; // number of words in IMEM
523 static const Int_t fgkDbankStartAddress = 0xf000; // start address in TRAP GIO
524 static const Int_t fgkDbankWords = 0x0100; // number of words in DBANK
526 class AliTRDtrapValue : public TObject {
529 virtual ~AliTRDtrapValue();
531 virtual Bool_t Allocate(Alloc_t mode);
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);
538 UInt_t GetData(Int_t det, Int_t rob, Int_t mcm) const;
540 Int_t GetIdx(Int_t det, Int_t rob, Int_t mcm) const;
543 AliTRDtrapValue(const AliTRDtrapValue &rhs); // not implemented
544 AliTRDtrapValue& operator=(const AliTRDtrapValue &rhs); // not implemented
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
551 static const Int_t fgkSize[kAllocLast]; // required array dimension for different allocation modes
553 ClassDef(AliTRDtrapValue, 1);
556 class AliTRDtrapRegister : public AliTRDtrapValue {
558 AliTRDtrapRegister();
559 virtual ~AliTRDtrapRegister();
561 void Init(const char* name, Int_t addr, Int_t nBits, Int_t resetValue);
562 void Reset() { SetData(fResetValue); }
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); }
567 Int_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
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; }
575 AliTRDtrapRegister(const AliTRDtrapRegister &rhs);
576 AliTRDtrapRegister& operator=(const AliTRDtrapRegister &rhs);
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
585 ClassDef(AliTRDtrapRegister, 1);
588 class AliTRDtrapDmemWord : public AliTRDtrapValue {
590 AliTRDtrapDmemWord() : AliTRDtrapValue(), fName(""), fAddr(0) {}
591 virtual ~AliTRDtrapDmemWord() {}
593 void Reset() { SetData(0); }
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); }
598 UInt_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
600 void SetAddress(UShort_t addr) { fAddr = addr; fName.Form("DMEM 0x%04x", fAddr); }
601 const char* GetName() const { return fName.Data(); }
604 AliTRDtrapDmemWord(const AliTRDtrapDmemWord &rhs); // not implemented
605 AliTRDtrapDmemWord& operator=(const AliTRDtrapDmemWord &rhs); // not implemented
608 UShort_t fAddr; //! address
610 ClassDef(AliTRDtrapDmemWord, 1);
616 // configuration registers
617 AliTRDtrapRegister fRegisterValue[kLastReg]; // array of TRAP register values in use
620 AliTRDtrapDmemWord fDmem[fgkDmemWords]; // TRAP data memory
622 static const Int_t fgkMcmlistSize=256; // list of MCMs to which a value has to be written
624 static Bool_t fgRegAddressMapInitialized;
625 static TrapReg_t fgRegAddressMap[0x400 + 0x200 + 0x4];
626 static const Int_t fgkRegisterAddressBlockStart[];
627 static const Int_t fgkRegisterAddressBlockSize[];
630 AliTRDtrapConfig& operator=(const AliTRDtrapConfig &rhs); // not implemented
631 AliTRDtrapConfig(const AliTRDtrapConfig& cfg); // not implemented
633 ClassDef(AliTRDtrapConfig, 3);