#include "tprLLO.hh" #include #include #include using namespace TprLLO; std::string AxiVersion::buildStamp() const { uint32_t tmp[64]; for(unsigned i=0; i<64; i++) tmp[i] = BuildStamp[i]; return std::string(reinterpret_cast(tmp)); } void XBar::setEvr( XBar::InMode m ) { outMap[2] = m==XBar::StraightIn ? 0:2; } void XBar::setEvr( XBar::OutMode m ) { outMap[0] = m==XBar::StraightOut ? 2:0; } void XBar::setTpr( XBar::InMode m ) { outMap[3] = m==XBar::StraightIn ? 1:3; } void XBar::setTpr( XBar::OutMode m ) { outMap[1] = m==XBar::StraightOut ? 3:1; } void XBar::dump() const { for(unsigned i=0; i<4; i++) printf("Out[%d]: %d\n",i,outMap[i]); } #define REGCPY(name) { name = o.name; usleep(1000); } TprCore::TprCore(const TprCore& o) { REGCPY(SOFcounts); REGCPY(EOFcounts); REGCPY(Msgcounts); REGCPY(CRCerrors); REGCPY(RxRecClks); REGCPY(RxRstDone); REGCPY(RxDecErrs); REGCPY(RxDspErrs); REGCPY(CSR); REGCPY(TxRefClks); REGCPY(BypassCnts); } TprCore& TprCore::operator=(const TprCore& o) { REGCPY(SOFcounts); REGCPY(EOFcounts); REGCPY(Msgcounts); REGCPY(CRCerrors); REGCPY(RxRecClks); REGCPY(RxRstDone); REGCPY(RxDecErrs); REGCPY(RxDspErrs); REGCPY(CSR); REGCPY(TxRefClks); REGCPY(BypassCnts); return *this; } bool TprCore::clkSel () const { uint32_t v = CSR; return v&(1<<4); } void TprCore::clkSel (bool lcls2) { volatile uint32_t v = CSR; v = lcls2 ? (v|(1<<4)) : (v&~(1<<4)); CSR = v; } bool TprCore::modeSelEn () const { uint32_t v = CSR; return v&(1<<10); } void TprCore::modeSelEn (bool enable) { volatile uint32_t v = CSR; v = enable ? (v|(1<<10)) : (v&~(1<<10)); CSR = v; } bool TprCore::modeSel () const { uint32_t v = CSR; return v&(1<<9); } void TprCore::modeSel (bool lcls2) { volatile uint32_t v = CSR; v = lcls2 ? (v|(1<<9)) : (v&~(1<<9)); CSR = v; } bool TprCore::rxPolarity() const { uint32_t v = CSR; return v&(1<<2); } void TprCore::rxPolarity(bool p) { volatile uint32_t v = CSR; v = p ? (v|(1<<2)) : (v&~(1<<2)); CSR = v; usleep(10); CSR = v|(1<<3); usleep(10); CSR = v&~(1<<3); } void TprCore::resetRx() { volatile uint32_t v = CSR; CSR = (v|(1<<3)); usleep(10); CSR = (v&~(1<<3)); } void TprCore::resetRxPll() { volatile uint32_t v = CSR; CSR = (v|(1<<7)); usleep(10); CSR = (v&~(1<<7)); } void TprCore::resetCounts() { volatile uint32_t v = CSR; CSR = (v|1); usleep(10); CSR = (v&~1); } bool TprCore::vsnErr() const { volatile uint32_t v = CSR; return v & (1<<8); } void TprCore::dump() const { unsigned csr = CSR; printf("CSR : %08x", csr); if (csr & 0x2) printf(" [linkUp]"); printf("\n"); printf("SOFcounts: %08x\n", SOFcounts); printf("EOFcounts: %08x\n", EOFcounts); printf("Msgcounts: %08x\n", Msgcounts); printf("CRCerrors: %08x\n", CRCerrors); printf("RxRecClks: %08x\n", RxRecClks); printf("RxRstDone: %08x\n", RxRstDone); printf("RxDecErrs: %08x\n", RxDecErrs); printf("RxDspErrs: %08x\n", RxDspErrs); printf("TxRefClks: %08x\n", TxRefClks); printf("BypDone : %04x\n", (BypassCnts>> 0)&0xffff); printf("BypResets: %04x\n", (BypassCnts>>16)&0xffff); } void TprCore::dump(TprCore& cache) const { TprCore c(*this); printf("CSR : %08x", c.CSR); if (c.CSR & 0x2) printf(" [linkUp]"); printf("\n"); printf("SOFcounts: %08x %d\n", c.SOFcounts, c.SOFcounts-cache.SOFcounts); printf("EOFcounts: %08x %d\n", c.EOFcounts, c.EOFcounts-cache.EOFcounts); printf("Msgcounts: %08x %d\n", c.Msgcounts, c.Msgcounts-cache.Msgcounts); printf("CRCerrors: %08x %d\n", c.CRCerrors, c.CRCerrors-cache.CRCerrors); printf("RxRecClks: %08x %f MHz\n", c.RxRecClks, 16.e-6*double(c.RxRecClks-cache.RxRecClks)); printf("RxRstDone: %08x %d\n", c.RxRstDone, c.RxRstDone-cache.RxRstDone); printf("RxDecErrs: %d\n", c.RxDecErrs-cache.RxDecErrs); printf("RxDspErrs: %d\n", c.RxDspErrs-cache.RxDspErrs); printf("TxRefClks: %f MHz\n", 16.e-6*double(c.TxRefClks-cache.TxRefClks)); cache = c; }