3 #ifndef ALITRDTRAPCONFIG_H
4 #define ALITRDTRAPCONFIG_H
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
8 // Configuration of the TRD TRAcklet Processor
9 // (TRD Front-End Electronics)
12 // TRAP data memory (DMEM)
20 class AliTRDtrapConfig : public TNamed
23 AliTRDtrapConfig(const TString &name = "", const TString &title = "");
37 }; // possible granularities for allocation
38 // common to registers and DMEM
41 enum TrapReg_t { kSML0,
475 kLastReg }; // enum of all TRAP registers, to be used for access to them
477 Bool_t SetTrapRegAlloc(TrapReg_t reg, Alloc_t mode) { return fRegisterValue[reg].Allocate(mode); }
478 Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det);
479 Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det, Int_t rob, Int_t mcm);
481 Int_t GetTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
485 // data memory (DMEM)
486 Bool_t SetDmemAlloc(Int_t addr, Alloc_t mode);
487 Bool_t SetDmem(Int_t addr, UInt_t value, Int_t det);
488 Bool_t SetDmem(Int_t addr, UInt_t value, Int_t det, Int_t rob, Int_t mcm);
489 Bool_t SetDmem(Int_t addr, Int_t value) { return SetDmem(addr, (UInt_t) value); }
490 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); }
492 UInt_t GetDmemUnsigned(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
496 // access by 16-bit address
497 UInt_t Peek(Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
498 Bool_t Poke(Int_t addr, UInt_t value, Int_t det, Int_t rob, Int_t mcm);
501 const char* GetRegName(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetName() : ""; }
502 UShort_t GetRegAddress(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetAddr() : 0; }
503 UShort_t GetRegNBits(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetNbits() : 0; }
504 UInt_t GetRegResetValue(TrapReg_t reg) const { return ((reg >= 0) && (reg < kLastReg)) ? fRegisterValue[reg].GetResetValue() : 0; }
506 TrapReg_t GetRegByAddress(Int_t address) const;
508 Bool_t PrintTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
509 Bool_t PrintTrapAddr(Int_t addr, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1) const;
511 void PrintMemDatx(ostream &os, Int_t addr) const;
512 void PrintMemDatx(ostream &os, Int_t addr, Int_t det, Int_t rob, Int_t mcm) const;
513 void PrintMemDatx(ostream &os, TrapReg_t reg) const;
514 void PrintMemDatx(ostream &os, TrapReg_t reg, Int_t det, Int_t rob, Int_t mcm) const;
515 void PrintDatx(ostream &os, UInt_t addr, UInt_t data, Int_t rob, Int_t mcm) const;
517 void PrintVerify(ostream &os, Int_t det, Int_t rob, Int_t mcm) const;
519 static const Int_t fgkDmemStartAddress = 0xc000; // start address in TRAP GIO
520 static const Int_t fgkDmemWords = 0x400; // number of words in DMEM
522 static const Int_t fgkImemStartAddress = 0xe000; // start address in TRAP GIO
523 static const Int_t fgkImemWords = 0x1000; // number of words in IMEM
525 static const Int_t fgkDbankStartAddress = 0xf000; // start address in TRAP GIO
526 static const Int_t fgkDbankWords = 0x0100; // number of words in DBANK
531 class AliTRDtrapValue : public TObject {
534 virtual ~AliTRDtrapValue() {}
536 virtual Bool_t Allocate(Alloc_t mode);
539 Bool_t SetData(UInt_t value);
540 Bool_t SetData(UInt_t value, Int_t det);
541 Bool_t SetData(UInt_t value, Int_t det, Int_t rob, Int_t mcm);
543 UInt_t GetData(Int_t det, Int_t rob, Int_t mcm) const;
545 Int_t GetIdx(Int_t det, Int_t rob, Int_t mcm) const;
548 AliTRDtrapValue(const AliTRDtrapValue &rhs); // not implemented
549 AliTRDtrapValue& operator=(const AliTRDtrapValue &rhs); // not implemented
551 Alloc_t fAllocMode; // allocation mode
552 Int_t fSize; // array size
553 UInt_t *fData; //[fSize] data array
554 Bool_t *fValid; //[fSize] valid flag
556 static const Int_t fgkSize[kAllocLast]; // required array dimension for different allocation modes
558 ClassDef(AliTRDtrapValue, 1);
561 class AliTRDtrapRegister : public AliTRDtrapValue {
563 AliTRDtrapRegister();
564 virtual ~AliTRDtrapRegister();
566 void Init(const char* name, Int_t addr, Int_t nBits, Int_t resetValue);
567 void Reset() { SetData(fResetValue); }
569 Bool_t SetValue(Int_t value, Int_t det) { return SetData(value, det); }
570 Bool_t SetValue(Int_t value, Int_t det, Int_t rob, Int_t mcm) { return SetData(value, det, rob, mcm); }
572 Int_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
574 const char* GetName() const { return fName.Data(); }
575 UShort_t GetAddr() const { return fAddr; }
576 UShort_t GetNbits() const { return fNbits; }
577 UInt_t GetResetValue() const { return fResetValue; }
580 AliTRDtrapRegister(const AliTRDtrapRegister &rhs);
581 AliTRDtrapRegister& operator=(const AliTRDtrapRegister &rhs);
583 // fixed properties of the register
584 // which do not need to be stored
585 TString fName; //! Name of the register
586 UShort_t fAddr; //! Address in GIO of TRAP
587 UShort_t fNbits; //! Number of bits, from 1 to 32
588 UInt_t fResetValue; //! reset value
590 ClassDef(AliTRDtrapRegister, 1);
593 class AliTRDtrapDmemWord : public AliTRDtrapValue {
595 AliTRDtrapDmemWord() : AliTRDtrapValue(), fName(""), fAddr(0) {}
596 virtual ~AliTRDtrapDmemWord() {}
598 void Reset() { SetData(0); }
600 Bool_t SetValue(UInt_t value, Int_t det) { return SetData(value, det); }
601 Bool_t SetValue(UInt_t value, Int_t det, Int_t rob, Int_t mcm) { return SetData(value, det, rob, mcm); }
603 UInt_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
605 void SetAddress(UShort_t addr) { fAddr = addr; fName.Form("DMEM 0x%04x", fAddr); }
606 const char* GetName() const { return fName.Data(); }
609 AliTRDtrapDmemWord(const AliTRDtrapDmemWord &rhs); // not implemented
610 AliTRDtrapDmemWord& operator=(const AliTRDtrapDmemWord &rhs); // not implemented
613 UShort_t fAddr; //! address
615 ClassDef(AliTRDtrapDmemWord, 1);
618 // configuration registers
619 AliTRDtrapRegister fRegisterValue[kLastReg]; // array of TRAP register values in use
622 AliTRDtrapDmemWord fDmem[fgkDmemWords]; // TRAP data memory
624 static const Int_t fgkMcmlistSize=256; // list of MCMs to which a value has to be written
626 static Bool_t fgRegAddressMapInitialized;
627 static TrapReg_t fgRegAddressMap[0x400 + 0x200 + 0x4];
628 static const Int_t fgkRegisterAddressBlockStart[];
629 static const Int_t fgkRegisterAddressBlockSize[];
632 AliTRDtrapConfig& operator=(const AliTRDtrapConfig &rhs); // not implemented
633 AliTRDtrapConfig(const AliTRDtrapConfig& cfg); // not implemented
635 ClassDef(AliTRDtrapConfig, 3);