#ifndef TPRLLO_HH #define TPRLLO_HH #include #include #include #include #include #include namespace TprLLO { // // Firmware registers // class AxiVersion { public: std::string buildStamp() const; public: volatile uint32_t FpgaVersion; volatile uint32_t ScratchPad; volatile uint32_t DeviceDnaHigh; volatile uint32_t DeviceDnaLow; volatile uint32_t FdSerialHigh; volatile uint32_t FdSerialLow; volatile uint32_t MasterReset; volatile uint32_t FpgaReload; volatile uint32_t FpgaReloadAddress; volatile uint32_t Counter; volatile uint32_t FpgaReloadHalt; volatile uint32_t reserved_11[0x100-11]; volatile uint32_t UserConstants[64]; volatile uint32_t reserved_0x140[0x200-0x140]; volatile uint32_t BuildStamp[64]; volatile uint32_t reserved_0x240[0x4000-0x240]; }; class XBar { public: enum InMode { StraightIn , LoopIn }; enum OutMode { StraightOut, LoopOut }; void setEvr( InMode m ); void setEvr( OutMode m ); void setTpr( InMode m ); void setTpr( OutMode m ); void dump() const; public: volatile uint32_t outMap[4]; }; class TprCore { public: TprCore(const TprCore&); TprCore& operator=(const TprCore&); bool clkSel () const; void clkSel (bool lcls2); bool modeSelEn () const; void modeSelEn (bool); bool modeSel () const; void modeSel (bool lcls2); bool rxPolarity () const; void rxPolarity (bool p); void resetRx (); void resetRxPll (); void resetCounts(); bool vsnErr () const; void dump() const; void dump(TprCore&) const; public: volatile uint32_t SOFcounts; volatile uint32_t EOFcounts; volatile uint32_t Msgcounts; volatile uint32_t CRCerrors; volatile uint32_t RxRecClks; volatile uint32_t RxRstDone; volatile uint32_t RxDecErrs; volatile uint32_t RxDspErrs; volatile uint32_t CSR; uint32_t reserved; volatile uint32_t TxRefClks; volatile uint32_t BypassCnts; volatile uint32_t FrameVersion; }; // // Memory map of TPR registers (EvrCardG2 BAR 1) // class LockApp { public: volatile uint32_t ready; volatile uint32_t phase; volatile uint32_t phaseN; volatile uint32_t valid; volatile uint32_t clks; volatile uint32_t tmoCnt; volatile uint32_t refMarkCnt; volatile uint32_t testMarkCnt; volatile uint32_t timingRst; volatile uint32_t txDataNC; volatile uint32_t txDataSC; volatile uint32_t psincdec; volatile uint32_t loopbackNC; volatile uint32_t loopbackSC; volatile uint32_t rxmode; volatile uint32_t ncTrigDelay; public: #define REGCPY(name) { name = o.name; usleep(1000); } LockApp() {} LockApp(const LockApp& o) { REGCPY(ready); REGCPY(phase); REGCPY(phaseN); REGCPY(valid); REGCPY(clks); REGCPY(tmoCnt); REGCPY(refMarkCnt); REGCPY(testMarkCnt); REGCPY(txDataNC); REGCPY(txDataSC); } LockApp& operator=(const LockApp& o) { REGCPY(ready); REGCPY(phase); REGCPY(phaseN); REGCPY(valid); REGCPY(clks); REGCPY(tmoCnt); REGCPY(refMarkCnt); REGCPY(testMarkCnt); REGCPY(txDataNC); REGCPY(txDataSC); return *this; } void dump(LockApp& cache) const { LockApp cc(*this); unsigned ph = cc.phase; unsigned phN = cc.phaseN; unsigned va = cc.valid; printf("ready %c\n",cc.ready?'T':'F'); printf("phase 0x%x [%f]\n", ph , double(ph )/double(va)); printf("phaseN 0x%x [%f]\n", phN, double(phN)/double(va)); printf("clks %u\n", cc.clks); printf("tmocnt %u %d\n", cc.tmoCnt, cc.tmoCnt-cache.tmoCnt); printf("refcnt %u %d\n", cc.refMarkCnt, cc.refMarkCnt-cache.refMarkCnt); printf("tstcnt %u %d\n", cc.testMarkCnt, cc.testMarkCnt-cache.testMarkCnt); printf("timRst %u\n", cc.timingRst&3); printf("txNC %05x\n", cc.txDataNC&0x3ffff); printf("txSC %05x\n", cc.txDataSC&0x3ffff); cache = cc; } }; class LockCore { public: uint32_t reserved_0 [(0x10000)>>2]; AxiVersion version; // 0x00010000 uint32_t reserved_10000[(0x40000-0x20000)>>2]; // boot_mem is here XBar xbar; // 0x00040000 uint32_t reserved_30010[(0x60000-0x40010)>>2]; LockApp app; // 0x00060000 uint32_t reserved_80000[(0x20000-sizeof(LockApp))/4]; TprCore coreNC; // 0x00080000 uint32_t reserved_C0000[(0x40000-sizeof(TprCore))/4]; TprCore coreSC; // 0x000C0000 uint32_t reserved_END [(0x40000-sizeof(TprCore))/4]; }; }; #endif