From: <ro...@us...> - 2009-07-31 10:37:56
|
Revision: 2173 http://nscldaq.svn.sourceforge.net/nscldaq/?rev=2173&view=rev Author: ron-fox Date: 2009-07-31 10:37:45 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Fix errors in my understanding of how variable block reads actually work. Modified Paths: -------------- trunk/llnlReadout/devices/CNADC2530.cpp trunk/llnlReadout/vmusb/CVMUSB.cpp trunk/llnlReadout/vmusb/CVMUSB.h trunk/llnlReadout/vmusb/CVMUSBReadoutList.cpp trunk/llnlReadout/vmusb/CVMUSBReadoutList.h Modified: trunk/llnlReadout/devices/CNADC2530.cpp =================================================================== --- trunk/llnlReadout/devices/CNADC2530.cpp 2009-07-29 11:05:47 UTC (rev 2172) +++ trunk/llnlReadout/devices/CNADC2530.cpp 2009-07-31 10:37:45 UTC (rev 2173) @@ -257,8 +257,8 @@ { // Get the register page and list mode data addresses. - uint32_t csr = m_pConfiguration->getIntegerParameter("-csr"); - uint32_t list = m_pConfiguration->getIntegerParameter("-memory"); + uint32_t csr = m_pConfiguration->getUnsignedParameter("-csr"); + uint32_t list = m_pConfiguration->getUnsignedParameter("-memory"); uint16_t listRegister = (uint16_t)((list >> 16) & 0xffe0); // Value for list register. // Check the validity of the -csr. If valid, program the memory base. @@ -301,7 +301,7 @@ bool zerosuppress = m_pConfiguration->getBoolParameter("-zerosuppress"); controller.vmeWrite16(csr + REG_VECTOR, initamod, vector); - controller.vmeWrite16(csr + REG_EVENTSREQ, initamod, events); + controller.vmeWrite16(csr + REG_EVENTSREQ, initamod, events - 1); // IRQ when > than this controller.vmeWrite16(csr + REG_LLD, initamod, lldToRegister(lld)); controller.vmeWrite16(csr + REG_HLD, initamod, hldToRegister(hld)); controller.vmeWrite16(csr + REG_FULLNESS, initamod, 0); @@ -355,8 +355,9 @@ // as otherwise I can't make this work with the VM-USB // - list.addBlockCountRead16(m_csr + REG_CSR + REG_LISTWL, initamod); // Get the block read count - list.addMaskedCountBlockRead32(m_eventBase, readamod, 0xffff); // count set up above. + list.addRead16(m_csr + REG_LISTWL, initamod); // Add length to buffer. + list.addBlockCountRead16(m_csr + REG_LISTWL, 0xffff, initamod); // Get the block read count + list.addMaskedCountBlockRead32(m_eventBase, readamod); // count set up above. // We're going to zero the offset regiseter so the next set of events is also @@ -365,9 +366,14 @@ list.addWrite16(m_csr + REG_LISTWL, initamod, 0); list.addWrite16(m_csr + REG_LISTWH, initamod, 0); + // Zero the event count register so we don't just interrupt again: + + list.addWrite16(m_csr + REG_EVENTSL, initamod, 0); + list.addWrite16(m_csr + REG_EVENTSH, initamod, 0); + // Rearm the module. - list.addWrite16(m_csr + REG_CSR, initamod, m_csr); + list.addWrite16(m_csr + REG_CSR, initamod, m_csrValue); } /*! Modified: trunk/llnlReadout/vmusb/CVMUSB.cpp =================================================================== --- trunk/llnlReadout/vmusb/CVMUSB.cpp 2009-07-29 11:05:47 UTC (rev 2172) +++ trunk/llnlReadout/vmusb/CVMUSB.cpp 2009-07-31 10:37:45 UTC (rev 2173) @@ -416,25 +416,7 @@ return readRegister(ScalerB); } -////////////////////////////////////////////////////////////////////////// -/*! - Write the count extract register. This register is a mask that - determines which bits of a datum read from the VME are a count - of the transfers to use for a subsequent block transfer. - \param value : uint32_t - new mask value. -*/ -void -CVMUSB::writeCountExtractMask(uint32_t value) -{ - writeRegister(ExtractMask, value); -} -uint32_t -CVMUSB::readCountExtractMask() -{ - return readRegister(ExtractMask); -} ///////////////////////////////////////////////////////////////////// /*! @@ -700,32 +682,34 @@ Do an 8 bit read in to the number data regiser. I believe we don't get this data into the output buffer. \param address (uint32_t) - Address from which the read is done. + \param mask (uint32_t) - Count extract mask. \param amod (uint8_t) - Address modifier for the transfer. */ int -CVMUSB::vmeReadBlockCount8(uint32_t address, uint8_t amod) +CVMUSB::vmeReadBlockCount8(uint32_t address, uint32_t mask, uint8_t amod) { CVMUSBReadoutList list; uint8_t data; size_t readCount; - list.addBlockCountRead8(address, amod); + list.addBlockCountRead8(address, mask, amod); int status = executeList(list, &data, sizeof(uint8_t), &readCount); return status; } /*! Do a 16 bit read to the number data register. See above. \param address (uint32_t) - Address from which the read is done. + \param mask (uint32_t) - Count extract mask. \param amod (uint8_t) - Address modifier for the transfer. */ int -CVMUSB::vmeReadBlockCount16(uint32_t address, uint8_t amod) +CVMUSB::vmeReadBlockCount16(uint32_t address, uint32_t mask, uint8_t amod) { CVMUSBReadoutList list; uint8_t data; size_t readCount; - list.addBlockCountRead16(address, amod); + list.addBlockCountRead16(address, mask, amod); int status = executeList(list, &data, sizeof(uint8_t), &readCount); return status; } @@ -733,16 +717,17 @@ Do a 32 bit read to the number data register. See above: \param address (uint32_t) - Address from which the read is done. + \param mask (uint32_t) - Count extract mask. \param amod (uint8_t) - Address modifier for the transfer. */ int -CVMUSB::vmeReadBlockCount32(uint32_t address, uint8_t amod) +CVMUSB::vmeReadBlockCount32(uint32_t address, uint32_t mask, uint8_t amod) { CVMUSBReadoutList list; uint8_t data; size_t readCount; - list.addBlockCountRead32(address, amod); + list.addBlockCountRead32(address, mask, amod); int status = executeList(list, &data, sizeof(uint8_t), &readCount); return status; } @@ -755,19 +740,17 @@ variable block read or variable fifo read. \param address (uint32_t) Starting address of the block transfer. \param amod (uint8_t) Address modifier for the transfer. - \param mask (uint32_t) Mask that specifies where the count lives in - the data read by vmeReadBlockCountxx \param data (void*) Pointer to the buffer to receive the transfer. \param maxCount (size_t) Size of the buffer in longwords. \param countTransferred (size_t*) Pointer to where the actual transfer count is stored. */ int -CVMUSB::vmeVariableBlockRead(uint32_t address, uint8_t amod, uint32_t mask, +CVMUSB::vmeVariableBlockRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred) { CVMUSBReadoutList list; - list.addMaskedCountBlockRead32(address, amod, mask); + list.addMaskedCountBlockRead32(address, amod); *countTransferred = 0; // In case of failure. int status = executeList(list, data, maxCount*sizeof(uint32_t), countTransferred); *countTransferred = *countTransferred/sizeof(uint32_t); @@ -779,8 +762,6 @@ \param address (uint32_t) Starting address of the block transfer. In this case, this is the only address from which data are transferred. \param amod (uint8_t) Address modifier for the transfer. - \param mask (uint32_t) Mask that specifies where the count lives in - the data read by vmeReadBlockCountxx \param data (void*) Pointer to the buffer to receive the transfer. \param maxCount (size_t) Size of the buffer in longwords. \param countTransferred (size_t*) Pointer to where the actual transfer count is stored. @@ -788,11 +769,11 @@ */ int -CVMUSB::vmeVariableFifoRead(uint32_t address, uint8_t amod, uint32_t mask, +CVMUSB::vmeVariableFifoRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred) { CVMUSBReadoutList list; - list.addMaskedCountFifoRead32(address, amod, mask); + list.addMaskedCountFifoRead32(address, amod); *countTransferred = 0; // In case of failure. int status = executeList(list, data, maxCount*sizeof(uint32_t), countTransferred); *countTransferred = *countTransferred/sizeof(uint32_t); Modified: trunk/llnlReadout/vmusb/CVMUSB.h =================================================================== --- trunk/llnlReadout/vmusb/CVMUSB.h 2009-07-29 11:05:47 UTC (rev 2172) +++ trunk/llnlReadout/vmusb/CVMUSB.h 2009-07-31 10:37:45 UTC (rev 2173) @@ -127,8 +127,6 @@ uint32_t readScalerA(); uint32_t readScalerB(); - void writeCountExtractMask(uint32_t value); - uint32_t readCountExtractMask(); void writeVector(int which, uint32_t value); uint32_t readVector(int which); @@ -159,12 +157,12 @@ // Support for immediate counted VME variable block transfer operations: // See comments prior to CVMEReadoutList::addBlockCountMask - int vmeReadBlockCount8(uint32_t address, uint8_t amod); - int vmeReadBlockCount16(uint32_t address, uint8_t amod); - int vmeReadBlockCount32(uint32_t address, uint8_t amod); - int vmeVariableBlockRead(uint32_t address, uint8_t amod, uint32_t mask, + int vmeReadBlockCount8(uint32_t address, uint32_t mask, uint8_t amod); + int vmeReadBlockCount16(uint32_t address, uint32_t mask, uint8_t amod); + int vmeReadBlockCount32(uint32_t address, uint32_t mask, uint8_t amod); + int vmeVariableBlockRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred); - int vmeVariableFifoRead(uint32_t address, uint8_t amod, uint32_t mask, + int vmeVariableFifoRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred); // List operations. Modified: trunk/llnlReadout/vmusb/CVMUSBReadoutList.cpp =================================================================== --- trunk/llnlReadout/vmusb/CVMUSBReadoutList.cpp 2009-07-29 11:05:47 UTC (rev 2172) +++ trunk/llnlReadout/vmusb/CVMUSBReadoutList.cpp 2009-07-31 10:37:45 UTC (rev 2173) @@ -360,7 +360,7 @@ Number of \em longwords to transfer. */ void -CVMUSBReadoutList::addBlockRead32(uint32_t baseAddress, uint8_t amod, +CVMUSBReadoutList::addBlockRead32(uint32_t baseAddress, uint8_t amod, size_t transfers) { addBlockRead(baseAddress, transfers, @@ -478,39 +478,45 @@ Add an 8 bit transfer that reads the number data for a variable length transfer: \param address (uint32_t) - Address from which the byte is read. + \param mask : uint32_t + count extraction mask. \param amod (uint8_t) - Address modifier of the read.. */ void -CVMUSBReadoutList::addBlockCountRead8(uint32_t address, uint8_t amod) +CVMUSBReadoutList::addBlockCountRead8(uint32_t address, uint32_t mask, uint8_t amod) { addRead8(address, amod); - lastTransferIsNumberData(); + lastTransferIsNumberData(mask); } /*! Add a 16 bit transfer that reads number data for a variable length transfer: \param address (uint32_t) - VME address from which the 16 bit word is read. + \param mask : uint32_t + count extraction mask. \param amod (uint8_t) - address modifier. */ void -CVMUSBReadoutList::addBlockCountRead16(uint32_t address, uint8_t amod) +CVMUSBReadoutList::addBlockCountRead16(uint32_t address, uint32_t mask, uint8_t amod) { addRead16(address, amod); - lastTransferIsNumberData(); + lastTransferIsNumberData(mask); } /*! Add a 32 bit tranfer that reads number data for a variable length transfer: \param address (uint32_t) - Vme address from which the 32 bit long is read. + \param mask : uint32_t + count extraction mask. \param amod (uint8_t) - address modifier. */ void -CVMUSBReadoutList::addBlockCountRead32(uint32_t address, uint8_t amod) +CVMUSBReadoutList::addBlockCountRead32(uint32_t address, uint32_t mask, uint8_t amod) { addRead32(address, amod); - lastTransferIsNumberData(); + lastTransferIsNumberData(mask); } /*! @@ -522,37 +528,39 @@ \param address (uint32_t) Address of the transfer. \param amod (uint8_t_) address modifier to use for the transfers. - \param mask (uint32_t) mask for transfer count extraction. */ void -CVMUSBReadoutList::addMaskedCountBlockRead32(uint32_t address, uint8_t amod, uint32_t mask) +CVMUSBReadoutList::addMaskedCountBlockRead32(uint32_t address, uint8_t amod) { - addBlockRead32(address, amod, 0); // Count comes from ND and mask. - m_list.push_back(mask); // The extraction mask follows a normal block read setup. + addBlockRead32(address, amod, 1); // Actual count comes from ND and mask. + // nonzero is required to ensure stack words actually + // get generated } /*! Add a variable length block transfer from a FIFO. The list must contain a prior read of the number data (e.g. addBlockCountReadxx) prior to this with no intervening block transfers \param address(uint32_t) address of the fifo. \param amod (uint8_t) transfer address modifier. - \param mask (uint32_t) mask for transfer count extraction. */ void -CVMUSBReadoutList::addMaskedCountFifoRead32(uint32_t address, uint8_t amod, uint32_t mask) +CVMUSBReadoutList::addMaskedCountFifoRead32(uint32_t address, uint8_t amod) { - addFifoRead32(address, amod, 0); - m_list.push_back(mask); // THe extraction mask follows a normal block read setup). + addFifoRead32(address, amod, 1); // Actual count comes from ND and mask. + // nonzero is required to ensure stack words actually + // get generated } + /* * Utility function used to turn a single shot read in the list into * a number data read. The last two words in the stack are assumed to describe * the transfer. The mode word will get the modeND bit set: */ void -CVMUSBReadoutList::lastTransferIsNumberData() +CVMUSBReadoutList::lastTransferIsNumberData(uint32_t mask) { size_t modeIndex = m_list.size() - 2; m_list[modeIndex] |= modeND; + m_list.push_back(mask); } Modified: trunk/llnlReadout/vmusb/CVMUSBReadoutList.h =================================================================== --- trunk/llnlReadout/vmusb/CVMUSBReadoutList.h 2009-07-29 11:05:47 UTC (rev 2172) +++ trunk/llnlReadout/vmusb/CVMUSBReadoutList.h 2009-07-31 10:37:45 UTC (rev 2173) @@ -118,11 +118,11 @@ // as with all block reads, only 32 bit transfers are supported. // - void addBlockCountRead8(uint32_t address, uint8_t amod); - void addBlockCountRead16(uint32_t address, uint8_t amod); - void addBlockCountRead32(uint32_t address, uint8_t amod); - void addMaskedCountBlockRead32(uint32_t address, uint8_t amod, uint32_t mask); - void addMaskedCountFifoRead32(uint32_t address, uint8_t amod, uint32_t mask); + void addBlockCountRead8(uint32_t address, uint32_t mask, uint8_t amod); + void addBlockCountRead16(uint32_t address, uint32_t mask, uint8_t amod); + void addBlockCountRead32(uint32_t address, uint32_t mask, uint8_t amod); + void addMaskedCountBlockRead32(uint32_t address, uint8_t amod); + void addMaskedCountFifoRead32(uint32_t address, uint8_t amod); // Miscellaneous: @@ -168,7 +168,7 @@ uint32_t dataStrobes(uint32_t address); void addBlockRead(uint32_t base, size_t transfers, uint32_t startingMode); - void lastTransferIsNumberData(); + void lastTransferIsNumberData(uint32_t mask); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |