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
528 class AliTRDtrapValue : public TObject {
531 virtual ~AliTRDtrapValue();
533 virtual Bool_t Allocate(Alloc_t mode);
536 Bool_t SetData(UInt_t value);
537 Bool_t SetData(UInt_t value, Int_t det);
538 Bool_t SetData(UInt_t value, Int_t det, Int_t rob, Int_t mcm);
540 UInt_t GetData(Int_t det, Int_t rob, Int_t mcm) const;
542 Int_t GetIdx(Int_t det, Int_t rob, Int_t mcm) const;
545 AliTRDtrapValue(const AliTRDtrapValue &rhs); // not implemented
546 AliTRDtrapValue& operator=(const AliTRDtrapValue &rhs); // not implemented
548 Alloc_t fAllocMode; // allocation mode
549 Int_t fSize; // array size
550 UInt_t *fData; //[fSize] data array
551 Bool_t *fValid; //[fSize] valid flag
553 static const Int_t fgkSize[kAllocLast]; // required array dimension for different allocation modes
555 ClassDef(AliTRDtrapValue, 1);
558 class AliTRDtrapRegister : public AliTRDtrapValue {
560 AliTRDtrapRegister();
561 virtual ~AliTRDtrapRegister();
563 void Init(const char* name, Int_t addr, Int_t nBits, Int_t resetValue);
564 void Reset() { SetData(fResetValue); }
566 Bool_t SetValue(Int_t value, Int_t det) { return SetData(value, det); }
567 Bool_t SetValue(Int_t value, Int_t det, Int_t rob, Int_t mcm) { return SetData(value, det, rob, mcm); }
569 Int_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
571 const char* GetName() const { return fName.Data(); }
572 UShort_t GetAddr() const { return fAddr; }
573 UShort_t GetNbits() const { return fNbits; }
574 UInt_t GetResetValue() const { return fResetValue; }
577 AliTRDtrapRegister(const AliTRDtrapRegister &rhs);
578 AliTRDtrapRegister& operator=(const AliTRDtrapRegister &rhs);
580 // fixed properties of the register
581 // which do not need to be stored
582 TString fName; //! Name of the register
583 UShort_t fAddr; //! Address in GIO of TRAP
584 UShort_t fNbits; //! Number of bits, from 1 to 32
585 UInt_t fResetValue; //! reset value
587 ClassDef(AliTRDtrapRegister, 1);
590 class AliTRDtrapDmemWord : public AliTRDtrapValue {
592 AliTRDtrapDmemWord() : AliTRDtrapValue(), fName(""), fAddr(0) {}
593 virtual ~AliTRDtrapDmemWord() {}
595 void Reset() { SetData(0); }
597 Bool_t SetValue(UInt_t value, Int_t det) { return SetData(value, det); }
598 Bool_t SetValue(UInt_t value, Int_t det, Int_t rob, Int_t mcm) { return SetData(value, det, rob, mcm); }
600 UInt_t GetValue(Int_t det, Int_t rob, Int_t mcm) const { return GetData(det, rob, mcm); }
602 void SetAddress(UShort_t addr) { fAddr = addr; fName.Form("DMEM 0x%04x", fAddr); }
603 const char* GetName() const { return fName.Data(); }
606 AliTRDtrapDmemWord(const AliTRDtrapDmemWord &rhs); // not implemented
607 AliTRDtrapDmemWord& operator=(const AliTRDtrapDmemWord &rhs); // not implemented
610 UShort_t fAddr; //! address
612 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);