#ifndef ALTROCOMMANDCODER_H #define ALTROCOMMANDCODER_H #include #include "../CentralHeaders/BitConstants.h" #include "../CentralHeaders/TpcException.h" using namespace std; //use when to compile on outdated slc #include #include #include class AltroCommandCoder{ public: AltroCommandCoder(); ~AltroCommandCoder(); //Per Channel Registers uint64_t sendK1(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t filtercoefficient1); uint64_t sendK1(uint32_t filtercoefficient1); uint64_t sendK2(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t filtercoefficient2); uint64_t sendK2(uint32_t filtercoefficient2); uint64_t sendK3(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t filtercoefficient3); uint64_t sendK3(uint32_t filtercoefficient3); uint64_t sendL1(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t filtercoefficient1); uint64_t sendL1(uint32_t filtercoefficient1); uint64_t sendL2(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t filtercoefficient2); uint64_t sendL2(uint32_t filtercoefficient2); uint64_t sendL3(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t filtercoefficient3); uint64_t sendL3(uint32_t filtercoefficient3); uint64_t sendVFPED(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t fixedPedestal); uint64_t sendVFPED(uint32_t fixedPedestal); uint64_t sendPMDTA(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t data); uint64_t sendPMDTA(uint32_t data); uint32_t receiveK1(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t receiveK2(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t receiveK3(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t receiveL1(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t receiveL2(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t receiveL3(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t receiveVFPED(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr);//ead vfpd ?? uint32_t receivePMDTA(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, uint32_t Data);//needed ? //Global Registers uint64_t sendZSTHR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t parameterZSTHR); uint64_t sendZSTHR(uint32_t parameterZSTHR); uint64_t sendBCTHR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t parameterBCTHR); uint64_t sendBCTHR(uint32_t parameterBCTHR); uint64_t sendTRCFG(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t parameterTRCFG); uint64_t sendTRCFG(uint32_t parameterTRCFG); uint64_t sendDPCFG(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t parameterDPCFG); uint64_t sendDPCFG(uint32_t parameterDPCFG); uint64_t sendDPCF2(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t parameterDPCF2); uint64_t sendDPCF2(uint32_t parameterDPCF2); uint64_t sendPMADD(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t addressofpedestalmem); uint64_t sendPMADD(uint32_t addressofpedestalmem); uint32_t receiveZSTHR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t receiveBCTHR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t receiveTRCFG(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t receiveDPCFG(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t receiveDPCF2(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t receivePMADD(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); //Status registers uint32_t receiveERSTR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t receiveADEVL(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr);//why no channel in vi ? uint32_t receiveTRCNT(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); //rest uint32_t sendWPINC(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t sendWPINC(); uint32_t sendRPINC(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t sendRPINC(); uint32_t sendSWTRG(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t sendSWTRG(); uint32_t sendTRCLR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t sendTRCLR(); uint32_t sendERCLR(uint32_t branch, uint32_t FECaddr, uint32_t chipaddr); uint32_t sendERCLR(); //uint64_t sendCHRDO(uint32_t chipaddr, uint32_t channeladdr); //de-, coding utils uint32_t codeTCFParameter(double TCFPar); uint32_t getDecodedVFPED_VPD(uint32_t VFPED); uint32_t getDecodedVFPED_FPD(uint32_t VFPED); uint32_t codeZSTHR(uint32_t Offset, uint32_t ZS_THR); uint32_t decodeZSTHR_Offset(uint32_t parameterZSTHR); uint32_t decodeZSTHR_ZSTHR(uint32_t parameterZSTHR); uint32_t codeBCTHR(uint32_t THR_HI, uint32_t THR_LOW); uint32_t decodeBCTHR_THRHI(uint32_t parameterBCTHR); uint32_t decodeBCTHR_THRLOW(uint32_t parameterBCTHR); uint32_t codeTRCFG(uint32_t ACQ_START, uint32_t ACQ_END); uint32_t getDecodedTRCFG_ACQ_START(uint32_t parameterTRCFG); uint32_t getDecodedTRCFG_ACQ_END(uint32_t parameterTRCFG); uint32_t codeDPCFG(uint32_t ZS_CFG, uint32_t BC2_CFG, uint32_t BC1_CFG); uint32_t getDecodedDPCFG_ZS_CFG(uint32_t parameterDPCFG); uint32_t getDecodedDPCFG_BC2_CFG(uint32_t parameterDPCFG); uint32_t getDecodedDPCFG_BC1_CFG(uint32_t parameterDPCFG); uint32_t codeBC1_CFG(uint32_t FirstBaselineCorrectionMode, uint32_t Polarity); uint32_t getDecodedDPCFG_BC1_CFG_FirstBaselineCorrectionMode(uint32_t BC1_CFG); uint32_t getDecodedDPCFG_BC1_CFG_Polarity(uint32_t BC1_CFG); uint32_t codeBC2_CFG(uint32_t NumofExcludedPreS, uint32_t NumofExcludedPostS, uint32_t enable); uint32_t getDecodedDPCFG_BC2_CFG_NumofExcludedPreS(uint32_t BC2_CFG); uint32_t getDecodedDPCFG_BC2_CFG_NumofExcludedPostS(uint32_t BC2_CFG); uint32_t getDecodedDPCFG_BC2_CFG_enable(uint32_t BC2_CFG); uint32_t codeZS_CFG(uint32_t GlitchFilterConfig, uint32_t NumofExcludedPreS, uint32_t NumofExcludedPostS, uint32_t Enable); uint32_t getDecodedDPCFG_ZS_CFG_GlitchFilterConfig(uint32_t ZS_CFG); uint32_t getDecodedDPCFG_ZS_CFG_NumofExcludedPreS(uint32_t ZS_CFG); uint32_t getDecodedDPCFG_ZS_CFG_NumofExcludedPostS(uint32_t ZS_CFG); uint32_t getDecodedDPCFG_ZS_CFG_Enable(uint32_t ZS_CFG); uint32_t codeDPCF2(uint32_t PTRG, uint32_t NBUF, uint32_t FLT_EN, uint32_t PWSV); uint32_t getDecodedDPCF2_PTRG(uint32_t parameterDPCF2); uint32_t getDecodedDPCF2_NBUF(uint32_t parameterDPCF2); uint32_t getDecodedDPCF2_FLT_EN(uint32_t parameterDPCF2); uint32_t getDecodedDPCF2_PWSV(uint32_t parameterPCF2); uint32_t getDecodedERSTR_PTRG_ReadPointer(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_WritePointer(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_RemainingBuffer(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_FULL(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_EMPTY(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_ParityERROR(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_InstructionERROR(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_TriggerOverlap(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_MMU1SEU(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_MMU2SEU(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_INT1SEU(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_INT2SEU(uint32_t ERSTR); uint32_t getDecodedERSTR_PTRG_RDOERROR(uint32_t ERSTR); uint32_t getDecodedADEVL_HADD(uint32_t ADEVL); uint32_t getDecodedADEVL_EVL(uint32_t ADEVL); //AltroBusUtils uint32_t codeAddress(uint32_t Branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr); uint32_t codeAddress(uint32_t Branch, uint32_t hwaddr); uint32_t getDecodedAddressBranch(uint32_t Address); uint32_t getDecodedAddressFECaddr(uint32_t Address); uint32_t getDecodedAddressChipaddr(uint32_t Address); uint32_t getDecodedAddressChanneladdr(uint32_t Address); enum eZerosuppressionMode{ DIN_FPD, // din - fpd DIN_FT, // din - f(t) DIN_FDIN, // din - f(din) DIN_FDIN_VPD, // din - f(din-vpd) DIN_VPD_FPD, // din - vpd - fpd DIN_VPD_FT, // din - vpd - f(t) DIN_VPD_FDIN, // din - vpd - f(din) DIN_VPD_FDIN_VPD, // din - vpd - f(din - vpd) FDIN_FPD, // f(din) - fpd FDIN_VPD_FPD, // f(din - vpd) - fpd FT_FPD, // f(t) - fpd FT_FT, // f(t) - f(t) FDIN_FDIN, // f(din) - f(din) FDIN_VPD_FDIN_VPD, // f(din - vpd) - f(din - vpd) DIN_FPD1, // din - fpd DIN_FPD2 // din - fpd }; private: enum eAltroCommand{ K1 = 0x0, // Filter Coefficient K1 K2 = 0x1, // Filter Coefficient K2 K3 = 0x2, // Filter Coefficient K3 L1 = 0x3, // Filter Coefficient L1 L2 = 0x4, // Filter Coefficient L2 L3 = 0x5, // Filter Coefficient L3 VFPED = 0x6, // Variable/Fixed Pedestal Data PMDTA = 0x7, // Chip Address + Event Length ZSTHR = 0x8, // Offset + Threshold BCTHR = 0x9, // Threshold High + Threshold Low (MAU) TRCFG = 0xA, // Trigger Delay + Number of Samples/Event DPCFG = 0xB, // ZSU + MAU + BSU configuration DPCF2 = 0xC, // Filter Enable + Number of Buffers + Pretrigger PMADD = 0xD, // Pedestal Memory Access NO1, // Not Used NO2, // Not Used ERSTR = 0x10, // Error + Status Register ADEVL = 0x11, // Pedestal Memory Address TRCNT = 0x12, // Trigger Counter NO3, // Not Used NO4, // Not Used NO5, // Not Used NO6, // Not Used NO7, // Not Used WPINC = 0x18, // Write Pointer Increase RPINC = 0x19, // Read Pointer Increase CHRDO = 0x1A, // Channel Readout SWTRG = 0x1B, // Software Trigger TRCLR = 0x1C, // Clear Trigger Counter ERCLR = 0x1D // Clear Error Flag }; enum eScope{ LOCAL, // to one Altro Channel BROADCAST // to all Altro Channels }; int32_t instruction(eScope broadcast, uint32_t branch, uint32_t FECaddr, uint32_t chipaddr, uint32_t channeladdr, eAltroCommand commandcode); uint32_t getParity(uint32_t ino); }; #endif // ALTROCOMMANDCODER_H