00001 #include "otsdaq-components/DAQHardware/FSSRPurdueFirmware.h" 00002 00003 //#include "otsdaq-components/DAQHardware/FSSRFirmwareDefinitions.h" 00004 //#include "otsdaq-core/BitManipulator/BitManipulator.h" 00005 //#include "otsdaq-components/DetectorHardware/FSSRROCDefinitions.h" 00006 00007 #include "otsdaq-components/DAQHardware/FrontEndFirmwareBase.h" 00008 #include "otsdaq-components/DAQHardware/PurdueFirmwareCore.h" 00009 #include "otsdaq-components/DAQHardware/OtsUDPFirmwareCore.h" 00010 00011 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00012 #include "otsdaq-core/Macros/CoutMacros.h" 00013 #include <sys/socket.h> 00014 #include <netinet/in.h> 00015 #include <arpa/inet.h> 00016 00017 #include <iostream> 00018 #include <cstdlib> 00019 00020 using namespace ots; 00021 00022 00023 //======================================================================================================================== 00024 FSSRPurdueFirmware::FSSRPurdueFirmware(std::string communicationFirmwareType, 00025 unsigned int communicationFirmwareVersion, 00026 unsigned int applicationFirmwareVersion) 00027 : FSSRFirmwareBase (communicationFirmwareType,communicationFirmwareVersion,applicationFirmwareVersion) 00028 {} 00029 // //choose: OtsUDPFirmwareCore or PurdueFirmwareCore 00030 // if(communicationFirmwareType == FrontEndFirmwareBase::PURDUE_CORE_FIRMWARE_NAME) 00031 // communicationFirmwareInstance_ = new PurdueFirmwareCore(communicationFirmwareVersion); 00032 // if(communicationFirmwareType == FrontEndFirmwareBase::OTS_CORE_FIRMWARE_NAME) 00033 // communicationFirmwareInstance_ = new OtsUDPFirmwareCore(communicationFirmwareVersion); 00034 // else 00035 // { 00036 // __SS__ << "Unknown firmware type choice: " << choice << std::endl; 00037 // __COUT_ERR__ << ss.str(); 00038 // __SS_THROW__; 00039 // } 00040 // 00041 // 00042 // //make protocol a class member 00043 // //protocolInstance_ = new OtsFirmwareCore(version);//AUG-17-2017 RAR dissociated because function calls are entirely independent from PURDUE firmware calls // //FrontEndFirmwareBase::getInstance(type,version); 00044 // //assert(protocolInstance_ != NULL); 00045 // //returns either new OtsUDPFirmware or new PurdueFirmwareCore, 00046 // //now we can call write/read etc with protocol->write, protocol->read, etc 00047 //} 00048 00049 //======================================================================================================================== 00050 FSSRPurdueFirmware::~FSSRPurdueFirmware(void) 00051 { 00052 //delete protocolInstance_; 00053 //protocolInstance_ = NULL; 00054 } 00055 00056 //======================================================================================================================== 00057 void FSSRPurdueFirmware::init(void) 00058 { } 00059 /* 00060 //======================================================================================================================== 00061 std::string FSSRPurdueFirmware::configureClocks(std::string source, double frequency) 00062 { 00063 std::cout << __COUT_HDR_FL__ << "Writing Clock configuration!" << std::endl; 00064 00065 std::string buffer; 00066 //NoNeedNowwrite(buffer, ETHIO_DESTINATION_PORT, 0x0000b798); // Listen port for ethio stuff 00067 00068 setPacketSizeStripCSR(6); 00069 setExternalBCOClockSourceStripCSR(source); //(source) 00070 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); // Reset CSR - reset trigger counter, external 27 MHz clock 00071 00072 resetDCMStripCSR(true); 00073 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); // Set reset to DCM 00074 00075 resetDCMStripCSR(false); 00076 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); // Clear reset to DCM 00077 00078 ; 00079 //FIXME? Does Nothing RAR Aug 2017// OtsUDPFirmwareCore::waitClear(buffer, STRIP_CSR, waitDCMResetStripCSR()); // Wait for DCM to lock 00080 00081 OtsUDPFirmwareCore::write(buffer, STRIP_TRIM_CSR, 0x00002000); // MCLKB edge for channel 5 // was 0x00002000 00082 00083 setFrequencyFromClockState(buffer, frequency); 00084 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00085 00086 resetDCMStripCSR(true); 00087 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00088 00089 resetDCMStripCSR(false); 00090 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00091 00092 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_CSR, waitDCMResetStripCSR()); // Wait for DCM to lock 00093 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue :" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00094 00095 return buffer; 00096 } 00097 00098 //======================================================================================================================== 00099 std::string FSSRPurdueFirmware::resetDetector(int channel) 00100 { 00101 std::cout << __COUT_HDR_FL__ << "Resetting detector!" << std::endl; 00102 std::string buffer; 00103 if (channel == -1)//reset all channels 00104 { 00105 //write(buffer,STRIP_RESET,0xd000003f); // Issue reset 00106 OtsUDPFirmwareCore::write(buffer, STRIP_RESET, 0xf000003f); // Issue reset // was 0xf000003f 00107 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_RESET, 0xf0000000); // Wait for reset to complete // was 0xf0000000 00108 } else 00109 { 00110 OtsUDPFirmwareCore::write(buffer, STRIP_RESET, 0xf000003f); // Issue reset 00111 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_RESET, 0xf0000000); // Wait for reset to complete 00112 } 00113 00114 return buffer; 00115 } 00116 00117 //======================================================================================================================== 00118 std::string FSSRPurdueFirmware::enableTrigger(void) 00119 { 00120 std::string buffer; 00121 std::cout << __COUT_HDR_FL__ << "Enabling Trigger!!!" << std::endl; 00122 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue in :" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00123 00124 setHaltStripCSR(1);//WARNING THIS IS CLEARED BY THE MASTER BUT IF THERE IS NO MASTER NOTHING WORKS UNLESS THE BIT IS UNSET 00125 //setHaltStripCSR(0);//WARNING THIS IS CLEARED BY THE MASTER BUT IF THERE IS NO MASTER NOTHING WORKS UNLESS THE BIT IS UNSET 00126 sendTriggerDataStripCSR(true); 00127 sendTriggerNumberStripCSR(true); 00128 sendBCOStripCSR(true); 00129 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00130 00131 stripTriggerCSRRegisterValue_ = 0; 00132 BCOOffset(4); 00133 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_CSR, stripTriggerCSRRegisterValue_); // BCO offset // was 0x00000004 00134 00135 // write(buffer,STRIP_TRIG_INPUT_0,0x1f060040); // FSSR GOTHIT trigger input - timed in for the 27 MHz external clock 00136 // write(buffer,STRIP_TRIG_INPUT_3,0x3f874040); // Unbiased trigger input + external trigger 00137 00138 configureStripTriggerUnbiased(buffer); 00139 00140 configureTriggerInputs(buffer); 00141 00142 //FIXME for IP .36 the number to set is 0x20401000 00143 00144 if (OtsUDPFirmwareCore::version_ == 1) 00145 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_3, 0x20401000); // Turn on streaming hits along with BCO data 00146 else if (OtsUDPFirmwareCore::version_ == 2) 00147 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_3, 0x20301000); // Turn on streaming hits along with BCO data 00148 else 00149 { 00150 __SS__ << "what version is this?" << 00151 OtsUDPFirmwareCore::version_ << std::endl; 00152 __COUT_ERR__ << "\n" << ss.str(); 00153 __SS_THROW__; 00154 } 00155 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue out:" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00156 std::cout << __COUT_HDR_FL__ << "Done enabling Trigger!!!" << std::endl; 00157 00158 return buffer; 00159 } 00160 00161 //======================================================================================================================== 00162 void FSSRPurdueFirmware::readBurstDestinationIP(std::string& buffer) 00163 { 00164 OtsUDPFirmwareCore::read(buffer, (uint64_t)0x0000000100000006); 00165 } 00166 00167 //======================================================================================================================== 00168 void FSSRPurdueFirmware::readBurstDestinationMAC(std::string& buffer) 00169 { 00170 OtsUDPFirmwareCore::read(buffer, (uint64_t)0x0000000100000007); 00171 } 00172 00173 //======================================================================================================================== 00174 void FSSRPurdueFirmware::readBurstDestinationPort(std::string& buffer) 00175 { 00176 OtsUDPFirmwareCore::read(buffer, (uint64_t)0x0000000100000008); 00177 } 00178 00179 //======================================================================================================================== 00180 void FSSRPurdueFirmware::writeBurstDestinationIP(std::string& buffer, const uint64_t value) 00181 { 00182 OtsUDPFirmwareCore::write(buffer, (uint64_t)0x0000000100000006, value); 00183 } 00184 00185 //======================================================================================================================== 00186 void FSSRPurdueFirmware::writeBurstDestinationMAC(std::string& buffer, const uint64_t value) 00187 { 00188 OtsUDPFirmwareCore::write(buffer, (uint64_t)0x0000000100000007, value); 00189 } 00190 00191 //======================================================================================================================== 00192 void FSSRPurdueFirmware::writeBurstDestinationPort(std::string& buffer, const uint64_t value) 00193 { 00194 OtsUDPFirmwareCore::write(buffer, 0x0000000100000008, value); 00195 } 00196 00197 //======================================================================================================================== 00198 std::string FSSRPurdueFirmware::resetBCO(void) 00199 { 00200 std::cout << __COUT_HDR_FL__ << "Reset BCO!!!" << std::endl; 00201 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue in :" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00202 std::string buffer; 00203 00204 resetTriggerCounterStripCSR(buffer); 00205 //write(buffer, STRIP_CSR, stripCSRRegisterValue_);//the write is done in the reset 00206 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue :" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00207 00208 //msg->Write(STRIP_SC_CSR,0x90000b95|(chmask<<16)); 00209 //write(buffer,STRIP_SC_CSR,0x900f0b95);// This is the <SCR,set> command with the bit set to sync SHIFT with BCO=0. 00210 00211 00212 enableBCOStripCSR(true); 00213 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00214 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue out:" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00215 std::cout << __COUT_HDR_FL__ << "Done reset BCO!!!" << std::endl; 00216 00217 return buffer; 00218 } 00219 00220 //======================================================================================================================== 00221 std::string FSSRPurdueFirmware::startStream(bool channel0, bool channel1, bool channel2, bool channel3, bool channel4, bool channel5) 00222 { 00223 std::cout << __COUT_HDR_FL__ << "Start Stream!" << std::endl; 00224 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue in:" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00225 std::string buffer; 00226 00227 std::cout << __COUT_HDR_FL__ << " channel0 " << channel0 << " channel1 " << channel1 << " channel2 " << channel2 << " channel3 " << channel3 << " channel4 " << channel4 << " channel5 " << channel5 << std::endl; 00228 00229 enableChannelsStripCSR(channel0, channel1, channel2, channel3, channel4, channel5); 00230 // if (version_ == 1) 00231 // enableChannelsStripCSR(true, true, true, true, false, false); 00232 // else if (version_ == 2) 00233 // enableChannelsStripCSR(true, true, true, true, true, true); 00234 00235 enableStreamStripCSR(true); // Turn on streaming hits along with BCO data // was 0x0f000f30 00236 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00237 00238 std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue out:" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl; 00239 std::cout << __COUT_HDR_FL__ << "Done start Stream!" << std::endl; 00240 00241 return buffer; 00242 } 00243 00244 //======================================================================================================================== 00245 std::string FSSRPurdueFirmware::stopStream(void) 00246 { 00247 std::string buffer; 00248 enableChannelsStripCSR(false, false, false, false, false, false); 00249 enableStreamStripCSR(false); 00250 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00251 return buffer; 00252 } 00253 00254 //======================================================================================================================== 00255 void FSSRPurdueFirmware::makeDACSequence(FirmwareSequence<uint64_t>& sequence, 00256 unsigned int channel, const ROCStream& rocStream) 00257 { 00258 const ROCDACs& rocDACs = rocStream.getROCDACs(); 00259 for (DACList::const_iterator it = rocDACs.getDACList().begin(); it 00260 != rocDACs.getDACList().end(); it++) 00261 { 00262 //if(it->first != "SendData" && it->first != "RejectHits") continue; 00263 uint64_t data = FSSRROCDefinitions::makeDACWriteCommand( 00264 rocStream.getFEWROCAddress(), it->first, it->second.second); 00265 sequence.pushBack(ChannelFIFOAddress[channel], data); 00266 sequence.pushBack(ChannelFIFOAddress[channel], 00267 BitManipulator::insertBits(data, (uint64_t) 0x48, 56, 8)); 00268 //set WRITE 00269 sequence.pushBack(ChannelFIFOAddress[channel], 00270 BitManipulator::insertBits(data, (uint64_t) 1, 60, 1)); 00271 //clr WRITE 00272 sequence.pushBack(ChannelFIFOAddress[channel], 00273 BitManipulator::insertBits(data, (uint64_t) 0, 60, 1)); 00274 //clr TALK 00275 sequence.pushBack(ChannelFIFOAddress[channel], 00276 BitManipulator::insertBits(data, (uint64_t) 0, 62, 1)); 00277 sequence.pushBack(ChannelFIFOAddress[channel], 00278 BitManipulator::insertBits(data, (uint64_t) 0x40, 56, 8)); 00279 //break; 00280 } 00281 } 00282 00283 //======================================================================================================================== 00284 void FSSRPurdueFirmware::makeDACSequence(FirmwareSequence<uint32_t>& sequence, 00285 unsigned int channel, const ROCStream& rocStream) 00286 { 00287 const ROCDACs& rocDACs = rocStream.getROCDACs(); 00288 for (DACList::const_iterator it = rocDACs.getDACList().begin(); it 00289 != rocDACs.getDACList().end(); it++) 00290 { 00291 //RYAN 00292 //if(it->first != "SendData" && it->first != "RejectHits") continue; 00293 uint64_t data = FSSRROCDefinitions::makeDACWriteCommand(rocStream.getFEWROCAddress(), it->first, it->second.second); 00294 //sequence.pushBack(ChannelFIFOAddress[channel], data); 00295 //sequence.pushBack(ChannelFIFOAddress[channel], BitManipulator::insertBits(data,(uint32_t)0x48,56,8)); 00296 //set WRITE 00297 //sequence.pushBack(ChannelFIFOAddress[channel], BitManipulator::insertBits(data,(uint32_t)1,60,1)); 00298 //clr WRITE 00299 //sequence.pushBack(ChannelFIFOAddress[channel], BitManipulator::insertBits(data,(uint32_t)0,60,1)); 00300 //clr TALK 00301 //sequence.pushBack(ChannelFIFOAddress[channel], BitManipulator::insertBits(data,(uint32_t)0,62,1)); 00302 //sequence.pushBack(ChannelFIFOAddress[channel], BitManipulator::insertBits(data,(uint32_t)0x40,56,8)); 00303 00304 00305 //if(it->first != "SendData" && it->first != "RejectHits") continue; 00306 uint32_t data = FSSRROCDefinitions::makeDACWriteHeader( 00307 rocStream.getFEWROCAddress(), it->first); 00308 //Insert channel 00309 BitManipulator::insertBits(data, 1, 16 + channel, 1); 00310 sequence.pushBack(ChannelFIFOAddress[channel], it->second.second); 00311 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first << " value: " 00312 << it->second.second << std::hex << " -> Data: " << data << std::dec 00313 << std::endl; 00314 sequence.pushBack(STRIP_SC_CSR, data); 00315 } 00316 } 00317 00318 //======================================================================================================================== 00319 void FSSRPurdueFirmware::makeDACBuffer(std::string& buffer, 00320 unsigned int channel, const ROCStream& rocStream) 00321 { 00322 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Channel: " << channel << std::endl; 00323 const ROCDACs& rocDACs = rocStream.getROCDACs(); 00324 for (DACList::const_iterator it = rocDACs.getDACList().begin(); it != rocDACs.getDACList().end(); it++) 00325 { 00326 std::string bufferElement; 00327 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement, STRIP_SC_CSR, 0x80000000); 00328 uint32_t registerHeader = 0; 00329 //FIXME This must go in the FSSRROCDefinitions stuff 00330 if (it->first != "RejectHits" && it->first != "SendData") 00331 { 00332 OtsUDPFirmwareCore::write(bufferElement, ChannelFIFOAddress[channel], it->second.second); 00333 registerHeader = FSSRROCDefinitions::makeDACWriteHeader( 00334 rocStream.getFEWROCAddress(), it->first); 00335 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader << std::dec << std::endl; 00336 //Insert channel 00337 BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1); 00338 } 00339 else 00340 { 00341 if (it->second.second == 1 || it->second.second == 2) 00342 { 00343 registerHeader = FSSRROCDefinitions::makeDACSetHeader( 00344 rocStream.getFEWROCAddress(), it->first); 00345 //Insert channel 00346 BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1); 00347 } 00348 else if (it->second.second == 0 || it->second.second == 5) 00349 { 00350 registerHeader = FSSRROCDefinitions::makeDACResetHeader( 00351 rocStream.getFEWROCAddress(), it->first); 00352 //Insert channel 00353 BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1); 00354 } 00355 else 00356 std::cout << __COUT_HDR_FL__ << "Register value for : " << it->first 00357 << " doesn't have a value I expect -> value = " 00358 << it->second.second << std::endl; 00359 00360 } 00361 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader << std::dec << std::endl; 00362 OtsUDPFirmwareCore::write(bufferElement, STRIP_SC_CSR, registerHeader); 00363 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement, STRIP_SC_CSR, 0x80000000); 00364 00365 //buffer.push_back(bufferElement); 00366 buffer += bufferElement; 00367 //break; 00368 } 00369 } 00370 00371 //======================================================================================================================== 00372 void FSSRPurdueFirmware:: makeDACBuffer(std::vector<std::string>& buffer, unsigned int channel, const ROCStream& rocStream) 00373 { 00374 00375 std::cout << __COUT_HDR_FL__ << "\tMaking DAC Buffer" << std::endl; 00376 00377 int limitCount = 0; 00378 unsigned int singleVectorCount = 0; 00379 00380 std::string alternateBuffer; 00381 00382 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Channel: " << channel << std::endl; 00383 const ROCDACs& rocDACs = rocStream.getROCDACs(); 00384 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Number of DACs: " << rocDACs.getDACList().size() << std::endl; 00385 std::string bufferElement; 00386 for (DACList::const_iterator it = rocDACs.getDACList().begin(); it != rocDACs.getDACList().end(); it++) 00387 { 00388 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement, STRIP_SC_CSR, 0x80000000); 00389 uint32_t registerHeader = 0; 00390 //FIXME This must go in the FSSRROCDefinitions stuff 00391 if (it->first != "RejectHits" && it->first != "SendData") 00392 { 00393 OtsUDPFirmwareCore::write(bufferElement, ChannelFIFOAddress[channel], it->second.second); 00394 registerHeader = FSSRROCDefinitions::makeDACWriteHeader( 00395 rocStream.getFEWROCAddress(), it->first); 00396 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader << std::dec << std::endl; 00397 //Insert channel 00398 BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1); 00399 } 00400 else 00401 { 00402 if (it->second.second == 1 || it->second.second == 2) 00403 { 00404 registerHeader = FSSRROCDefinitions::makeDACSetHeader( 00405 rocStream.getFEWROCAddress(), it->first); 00406 //Insert channel 00407 BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1); 00408 } 00409 else if (it->second.second == 0 || it->second.second == 5) 00410 { 00411 registerHeader = FSSRROCDefinitions::makeDACResetHeader( 00412 rocStream.getFEWROCAddress(), it->first); 00413 //Insert channel 00414 BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1); 00415 } 00416 else 00417 std::cout << __COUT_HDR_FL__ << "Register value for : " << it->first 00418 << " doesn't have a value I expect -> value = " 00419 << it->second.second << std::endl; 00420 00421 } 00422 //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader << std::dec << std::endl; 00423 OtsUDPFirmwareCore::write(bufferElement, STRIP_SC_CSR, registerHeader); 00424 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement, STRIP_SC_CSR, 0x80000000); 00425 00426 //alternateBuffer += bufferElement; 00427 limitCount++; 00428 singleVectorCount++; 00429 00430 if (limitCount == STIB_DAC_WRITE_MAX) 00431 { 00432 std::cout << __COUT_HDR_FL__ << "\tBuffer lenght:" << bufferElement.size() << std::endl; 00433 buffer.push_back(bufferElement); 00434 limitCount = 0; 00435 bufferElement.clear(); 00436 } 00437 else if (singleVectorCount == rocDACs.getDACList().size()) //case for imcomplete packet 00438 { 00439 buffer.push_back(bufferElement); 00440 } 00441 00442 //buffer.push_back(bufferElement); 00443 //break; 00444 } 00445 std::cout << __COUT_HDR_FL__ << "\tDone making DAC Buffer" << std::endl; 00446 00447 } 00448 00449 //======================================================================================================================== 00450 void FSSRPurdueFirmware::makeMaskBuffer(std::string& buffer, unsigned int channel, 00451 const ROCStream& rocStream) 00452 { 00453 std::cout << __COUT_HDR_FL__ << "Making mask! " << std::endl; 00454 makeMaskBuffer(buffer, channel, rocStream, "Kill"); 00455 // makeMaskSequence(buffer, channel, rocStream, "Inject"); 00456 } 00457 00458 //======================================================================================================================== 00459 void FSSRPurdueFirmware::makeMaskBuffer(std::string& buffer, unsigned int channel, const ROCStream& rocStream, const std::string& registerName) 00460 { 00461 std::cout << __COUT_HDR_FL__ << "\tMaking mask! " << std::endl; 00462 int chipId = rocStream.getFEWROCAddress(); 00463 std::string mask = rocStream.getROCMask(); 00464 std::cout << __COUT_HDR_FL__ << "\tMask length: " << mask.length() << std::endl; 00465 00466 unsigned int data[4] = { 0, 0, 0, 0 }; 00467 00468 char val; 00469 //int j = 0; 00470 for (unsigned int d = 0; d < 4; d++) 00471 { //d goes from 0 to 4. 4 bytes 00472 //std::cout << __COUT_HDR_FL__ << "---------------------" << d << "-------------------" << std::endl; 00473 for (unsigned int m = 0; m < 8 * 4; m++) 00474 { //m goes from 0 to 31, since each byte has 8 bits, there are 32 bits 00475 val = mask[(8 * 4 * d) + m]; //assigns to val the value of the corresponding bit. 0-31, 32-63, 64-95, 96-127. it goes through each of the 128 bits 00476 //std::cout << __COUT_HDR_FL__ << "---------------------" << j++ << std::endl; 00477 //std::cout << __COUT_HDR_FL__ << "data[" << d << "] before: " << std::hex << data[d] << std::dec << std::endl; 00478 data[d] |= (unsigned int) atoi(&val) << (8 * 4 - 1 - m); 00479 //std::cout << __COUT_HDR_FL__ << "(unsigned int) atoi(&val): " << (unsigned int) atoi(&val) << std::endl; 00480 //std::cout << __COUT_HDR_FL__ << "data[" << d << "] after: " << std::hex << data[d] << std::dec << std::endl; 00481 //std::cout << __COUT_HDR_FL__ << std::hex << "D: " << data[d] << " Val: " << (unsigned int)atoi(&val) << " index: " << std::dec << (8*4-1-m) << " bit: " << mask[(8*4*d)+m] << std::dec << std::endl; 00482 } 00483 // 00484 } 00485 00486 int i, ierr; 00487 unsigned int w; 00488 unsigned char len = 4; 00489 unsigned char addr = 17;//Kill 00490 unsigned char bitMask = 1 << channel; 00491 unsigned char inst = WRITE; 00492 00493 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_SC_CSR, 0x80000000); 00494 00495 for (i = 0; i < 4; i++) 00496 //write(buffer, STRIP_SCI + 4 * i, data[i]); 00497 OtsUDPFirmwareCore::write(buffer, STRIP_SCI + 4 * (4 - i - 1), data[i]); 00498 00499 w = 0x80000000 | (len << 24) | (bitMask << 16) | (inst << 10) | (addr << 5) | chipId; 00500 00501 //ierr = OtsUDPFirmwareCore::write(buffer, STRIP_SC_CSR, w); 00502 OtsUDPFirmwareCore::write(buffer, STRIP_SC_CSR, w); 00503 00504 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_SC_CSR, 0x80000000); 00505 } 00506 00507 //======================================================================================================================== 00508 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint64_t>& sequence, 00509 unsigned int channel, const ROCStream& rocStream) 00510 { 00511 std::cout << __COUT_HDR_FL__ << "Making mask! " << std::endl; 00512 makeMaskSequence(sequence, channel, rocStream, "Kill"); 00513 // makeMaskSequence(sequence, channel, rocStream, "Inject"); 00514 } 00515 00516 //======================================================================================================================== 00517 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint32_t>& sequence, 00518 unsigned int channel, const ROCStream& rocStream) 00519 { 00520 std::cout << __COUT_HDR_FL__ << "Making mask! " << std::endl; 00521 makeMaskSequence(sequence, channel, rocStream, "Kill"); 00522 // makeMaskSequence(channel,rocStream,sequence,"Inject"); 00523 } 00524 00525 //======================================================================================================================== 00526 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint64_t>& sequence, 00527 unsigned int channel, const ROCStream& rocStream, 00528 const std::string& registerName) 00529 { 00530 int chipId = rocStream.getFEWROCAddress();//9, 14 or 21 bcast 00531 std::string mask = rocStream.getROCMask(); 00532 std::cout << __COUT_HDR_FL__ << "Mask length: " << mask.length() << std::endl; 00533 00534 uint64_t uInt64Data = 0; 00535 std::string stringData = ""; 00536 00537 //have to manually set every bit for mask writes. 00538 //reset fifo 00539 //download every bit (shift_in and shift_ctrl) to fifo (setup muxes and control lines) 00540 //configure muxes for readout 00541 //commence readout 00542 00543 //FIFO Controls - byte 5 (7:0) 00544 //7 - FIFO Clock 00545 //6 - Shift Ctrl bit 00546 //MASK_CELL_H - Shift In bit 00547 //MUX Controls - byte 0 (7:0) 00548 //7 - Read En/Output MUX sel (1 for masks) 00549 //1 - Write En for mux 00550 //0 - Reset Fifo 00551 00552 //reset fifo 00553 BitManipulator::insertBits(uInt64Data, 0x1, 56, 8); 00554 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00555 00556 //configure fifo for write 00557 BitManipulator::insertBits(uInt64Data, 0x2, 56, 8); 00558 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00559 00560 //Download every bit (shift_in and shift_control) to fifo (setup muxes and control lines) 00561 //Bit 7 of data is FIFO clock, bit 6 is shift_control, bit 5 is shift_in 00562 //start bits (ctrl 0, data 0 => ctrl 1, data 0) 00563 00564 BitManipulator::insertBits(uInt64Data, 0x40, 16, 8);//(0<<7) | (1<<6) | (0<<5) 00565 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00566 BitManipulator::insertBits(uInt64Data, 0xc0, 16, 8);//(1<<7) | (1<<6) | (0<<5) -> clock the data in the fifo 00567 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00568 00569 stringData = FSSRROCDefinitions::makeMaskWriteCommand(chipId, 00570 registerName, mask); 00571 00572 uint8_t data; 00573 for (unsigned int s = 0; s < stringData.length(); s++) 00574 for (int b = 8 - 1; b >= 0 && (s * 8 + 8 - b < 13 + 128); b--) 00575 { 00576 //std::cout << __COUT_HDR_FL__ << "S: " << s << " val: " << stringData.data()[s] << " b: " << b << " bit: " << ((stringData.data()[s]>>b)&1) << std::endl; 00577 data = 0x40 | (((stringData.data()[s] >> b) & 1) << 5); 00578 BitManipulator::insertBits(uInt64Data, (uint64_t) data, 16, 8); 00579 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00580 data |= 0x80; 00581 BitManipulator::insertBits(uInt64Data, (uint64_t) data, 16, 8); 00582 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00583 } 00584 00585 //reset Shift Control 00586 BitManipulator::insertBits(uInt64Data, 0x0, 16, 8); 00587 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00588 BitManipulator::insertBits(uInt64Data, 0x80, 16, 8); 00589 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00590 00591 //configure muxes for readout 00592 BitManipulator::insertBits(uInt64Data, 0x0, 56, 8); 00593 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00594 00595 //commence readout 00596 BitManipulator::insertBits(uInt64Data, 0x80, 56, 8); 00597 sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data); 00598 00599 } 00600 00601 //======================================================================================================================== 00602 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint32_t>& sequence, 00603 unsigned int channel, const ROCStream& rocStream, 00604 const std::string& registerName) 00605 {} 00606 00607 //======================================================================================================================== 00608 std::string FSSRPurdueFirmware::readCSRRegister() 00609 { 00610 std::string buffer; 00611 OtsUDPFirmwareCore::read(buffer,STRIP_CSR); 00612 return buffer; 00613 } 00614 00615 //======================================================================================================================== 00616 void FSSRPurdueFirmware::setFrequencyFromClockState(std::string& buffer, double frequency) 00617 { 00618 std::cout << __COUT_HDR_FL__ << "Setting up clock frequency!!!" << std::endl; 00619 00620 int quotient; 00621 int numerator; 00622 int denominator; 00623 double realClockFrequency; 00624 00625 if (BitManipulator::readBits(stripCSRRegisterValue_, 17, 1) == 1) //if fastBCO is enabled 00626 quotient = 4; 00627 else //normal cases 00628 quotient = 8; 00629 00630 if (isClockStateExternal()) //base freq: 54MHz 00631 { 00632 realClockFrequency = EXTERNAL_CLOCK_FREQUENCY / quotient; //this is the REAL frequency being used 00633 } 00634 else //base freq: 66.667MHz 00635 { 00636 realClockFrequency = INTERNAL_CLOCK_FREQUENCY / quotient; //this is the REAL frequency being used 00637 } 00638 00639 double factor = frequency / realClockFrequency; 00640 00641 //The device needs the denominator and the denominator to be load into a 5 bit register 00642 //It will take two initial numerator and denominator bigger than necessary (to do not loose precision) 00643 //and divide them for their gcd. If they still do not fit in 5 bit, they are trunked (divided by 2) 00644 //untill they are less than 32 00645 numerator = factor * 100; //we will work with 2 digits precision after the decimal point 00646 denominator = 100; 00647 00648 do 00649 { 00650 //We will need the GCD at some point in order to simplify fractions //taken from other sources 00651 int gcd = numerator; 00652 int rest = denominator; 00653 int tmp; 00654 00655 while (rest != 0) 00656 { 00657 tmp = rest; 00658 rest = gcd % tmp; 00659 gcd = tmp; 00660 } 00661 //Done finding the GCD 00662 00663 if (gcd == 1) //if there's no GCD, just divide by 2 to find the nearest approssimation with less bits 00664 { 00665 numerator /= 2; 00666 denominator /= 2; 00667 } 00668 else 00669 { 00670 numerator /= gcd; 00671 denominator /= gcd; 00672 } 00673 00674 } 00675 while (denominator >= 32 || numerator >= 32); 00676 std::cout << __COUT_HDR_FL__ << "Numerator: " << numerator << std::endl; 00677 std::cout << __COUT_HDR_FL__ << "Denominator: " << denominator << std::endl; 00678 setFrequencyRatio(buffer, numerator, denominator); 00679 std::cout << __COUT_HDR_FL__ << "Done with clock frequency setup!!!" << std::endl; 00680 } 00681 //======================================================================================================================== 00682 bool FSSRPurdueFirmware::isClockStateExternal() //returns true if the clock state is External 00683 { 00684 if (BitManipulator::readBits(stripCSRRegisterValue_, 16, 1) == 1) 00685 return true; 00686 else 00687 return false; 00688 } 00689 00690 //======================================================================================================================== 00691 void FSSRPurdueFirmware::setCSRRegister(uint32_t total) 00692 { 00693 stripCSRRegisterValue_ = total; 00694 } 00695 00696 //======================================================================================================================== 00697 void FSSRPurdueFirmware::writeCSRRegister(std::string& buffer) 00698 { 00699 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00700 } 00701 00702 //======================================================================================================================== 00703 void FSSRPurdueFirmware::setPacketSizeStripCSR(uint32_t size) 00704 { 00705 if (size > 31) 00706 std::cout << __COUT_HDR_FL__ 00707 << "ERROR: Maximum packet size is 31 while here you are trying to set " 00708 << size << " packets!" << std::endl; 00709 BitManipulator::insertBits(stripCSRRegisterValue_, size, 3, 5); 00710 //write(buffer,STRIP_CSR, stripSCRRegisterValue_); 00711 } 00712 00713 //======================================================================================================================== 00714 void FSSRPurdueFirmware::enableChannelsStripCSR(bool channel0, bool channel1, 00715 bool channel2, bool channel3, bool channel4, bool channel5) 00716 { 00717 BitManipulator::insertBits(stripCSRRegisterValue_, ((uint32_t) channel0) 00718 + ((uint32_t) channel1 << 1) + ((uint32_t) channel2 << 2) 00719 + ((uint32_t) channel3 << 3) + ((uint32_t) channel4 << 4) 00720 + ((uint32_t) channel5 << 5), 8, 6); 00721 } 00722 00723 //======================================================================================================================== 00724 void FSSRPurdueFirmware::setExternalBCOClockSourceStripCSR(std::string clockSource) 00725 { 00726 if (clockSource == "External") 00727 BitManipulator::insertBits(stripCSRRegisterValue_, 1, 16, 1); 00728 else if (clockSource == "Internal") 00729 BitManipulator::insertBits(stripCSRRegisterValue_, 0, 16, 1); 00730 } 00731 00732 //======================================================================================================================== 00733 void FSSRPurdueFirmware::setHaltStripCSR(bool set) 00734 { 00735 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) set, 17, 1); 00736 } 00737 00738 //======================================================================================================================== 00739 void FSSRPurdueFirmware::enableBCOStripCSR(bool enable) 00740 { 00741 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) enable, 19, 1); 00742 } 00743 00744 //======================================================================================================================== 00745 void FSSRPurdueFirmware::flushBuffersStripCSR(void) 00746 { 00747 BitManipulator::insertBits(stripCSRRegisterValue_, 1, 20, 1); 00748 } 00749 00750 //======================================================================================================================== 00751 void FSSRPurdueFirmware::resetTriggerCounterStripCSR(std::string& buffer) 00752 { 00753 BitManipulator::insertBits(stripCSRRegisterValue_, 1, 21, 1); 00754 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00755 00756 BitManipulator::insertBits(stripCSRRegisterValue_, 0, 21, 1); 00757 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); 00758 } 00759 00760 //======================================================================================================================== 00761 void FSSRPurdueFirmware::resetBCOCounterStripCSR(void) 00762 { 00763 BitManipulator::insertBits(stripCSRRegisterValue_, 1, 22, 1); 00764 } 00765 00766 //======================================================================================================================== 00767 void FSSRPurdueFirmware::enableTriggerStripCSR(bool enable) 00768 { 00769 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) enable, 23, 1); 00770 } 00771 00772 //======================================================================================================================== 00773 void FSSRPurdueFirmware::sendTriggerDataStripCSR(bool send) 00774 { 00775 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) send, 24, 1); 00776 } 00777 00778 //======================================================================================================================== 00779 void FSSRPurdueFirmware::sendTriggerNumberStripCSR(bool send) 00780 { 00781 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) send, 25, 1); 00782 } 00783 00784 //======================================================================================================================== 00785 void FSSRPurdueFirmware::sendBCOStripCSR(bool send) 00786 { 00787 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) send, 26, 1); 00788 } 00789 00790 //======================================================================================================================== 00791 void FSSRPurdueFirmware::enableStreamStripCSR(bool enable) 00792 { 00793 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) enable, 27, 1); 00794 } 00795 00796 //======================================================================================================================== 00797 void FSSRPurdueFirmware::resetDCMStripCSR(bool clear) 00798 { 00799 BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) clear, 31, 1); 00800 } 00801 00802 //======================================================================================================================== 00803 uint32_t FSSRPurdueFirmware::waitDCMResetStripCSR(void) 00804 { 00805 uint32_t bitToCheck = 0; 00806 BitManipulator::insertBits(bitToCheck, 1, 31, 2); 00807 return bitToCheck; 00808 } 00809 00810 //======================================================================================================================== 00811 void FSSRPurdueFirmware::resetDAC(void) 00812 { 00813 BitManipulator::insertBits(stripResetRegisterValue_, 1, 27, 1); 00814 } 00815 00816 //======================================================================================================================== 00817 void FSSRPurdueFirmware::resetLink(bool channel0, bool channel1, bool channel2, 00818 bool channel3, bool channel4, bool channel5) 00819 { 00820 stripResetRegisterValue_ = 0; 00821 BitManipulator::insertBits(stripResetRegisterValue_, 00822 ((uint32_t) channel0) + ((uint32_t) channel1 << 1) 00823 + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3) 00824 + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5), 00825 0, 6); 00826 BitManipulator::insertBits(stripResetRegisterValue_, 1, 29, 1); 00827 00828 // write(buffer, STRIP_RESET, (1<<28) + 00829 // ((uint32_t)channel0) + 00830 // ((uint32_t)channel1<<1) + 00831 // ((uint32_t)channel2<<2) + 00832 // ((uint32_t)channel3<<3) + 00833 // ((uint32_t)channel4<<4) + 00834 // ((uint32_t)channel5<<5) 00835 ); 00836 00837 } 00838 00839 //======================================================================================================================== 00840 void FSSRPurdueFirmware::clearErrors(bool channel0, bool channel1, bool channel2, 00841 bool channel3, bool channel4, bool channel5) 00842 { 00843 stripResetRegisterValue_ = 0; 00844 BitManipulator::insertBits(stripResetRegisterValue_, 00845 ((uint32_t) channel0) + ((uint32_t) channel1 << 1) 00846 + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3) 00847 + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5), 00848 0, 6); 00849 BitManipulator::insertBits(stripResetRegisterValue_, 1, 29, 1); 00850 } 00851 00852 //======================================================================================================================== 00853 void FSSRPurdueFirmware::clearFIFO(bool channel0, bool channel1, bool channel2, 00854 bool channel3, bool channel4, bool channel5) 00855 { 00856 stripResetRegisterValue_ = 0; 00857 BitManipulator::insertBits(stripResetRegisterValue_, 00858 ((uint32_t) channel0) + ((uint32_t) channel1 << 1) 00859 + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3) 00860 + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5), 00861 0, 6); 00862 BitManipulator::insertBits(stripResetRegisterValue_, 1, 30, 1); 00863 } 00864 00865 //======================================================================================================================== 00866 void FSSRPurdueFirmware::resetChip(bool channel0, bool channel1, bool channel2, 00867 bool channel3, bool channel4, bool channel5) 00868 { 00869 stripResetRegisterValue_ = 0; 00870 BitManipulator::insertBits(stripResetRegisterValue_, 00871 ((uint32_t) channel0) + ((uint32_t) channel1 << 1) 00872 + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3) 00873 + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5), 00874 0, 6); 00875 BitManipulator::insertBits(stripResetRegisterValue_, 1, 31, 1); 00876 } 00877 00878 //======================================================================================================================== 00879 void FSSRPurdueFirmware::setFrequencyRatio(std::string& buffer, int numerator, int denominator) 00880 { 00881 //The device need to load numerator minus one and denominator minus one, with an internal address of 0x50 and 052 respectively 00882 OtsUDPFirmwareCore::write(buffer, STRIP_BCO_DCM, 0x80500000 + (numerator - 1)); // Set BCOCLK numerator // was 0x80500003 00883 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_BCO_DCM, 0xf0000000); // Wait DCM write to finish // was 0x80000000 00884 00885 OtsUDPFirmwareCore::write(buffer, STRIP_BCO_DCM, 0x80520000 + (denominator - 1)); // Set BCOCLK denominator // was 0x80520001 00886 //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_BCO_DCM, 0xf0000000); // Wait DCM write to finish - BCO frequency should be 13.513 MHz // was 0x80000000 00887 } 00888 00889 //======================================================================================================================== 00890 void FSSRPurdueFirmware::BCOOffset(uint32_t offset) 00891 { 00892 BitManipulator::insertBits(stripTriggerCSRRegisterValue_, offset, 0, 4); 00893 } 00894 00895 //======================================================================================================================== 00896 void FSSRPurdueFirmware::selectSpyFIFO(uint32_t input) 00897 { 00898 BitManipulator::insertBits(stripTriggerCSRRegisterValue_, input, 4, 3); 00899 } 00900 00901 //======================================================================================================================== 00902 void FSSRPurdueFirmware::halt(bool halt) 00903 { 00904 BitManipulator::insertBits(stripTriggerCSRRegisterValue_, (uint32_t) halt, 7, 1); 00905 } 00906 00907 //======================================================================================================================== 00908 void FSSRPurdueFirmware::configureStripTriggerUnbiased(std::string& buffer) 00909 { 00910 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_UNBIASED, 0x002805c); // Configure unbiased trigger 00911 } 00912 00913 //======================================================================================================================== 00914 void FSSRPurdueFirmware::configureTriggerInputs(std::string& buffer) 00915 { 00916 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_0, 0x3f440000); // FSSR GOTHIT trigger input channel 0,1 00917 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_1, 0x3f440000); // FSSR GOTHIT trigger input channel 2,3 00918 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_2, 0x0); // FSSR GOTHIT trigger input channel 4,5 00919 } 00920 00921 //======================================================================================================================== 00922 std::string FSSRPurdueFirmware::resetSlaveBCO(void) 00923 { 00924 std::string buffer; 00925 OtsUDPFirmwareCore::write(buffer, (uint64_t)0xc5000000, (uint64_t)0x00000008); 00926 return buffer; 00927 } 00928 00929 //======================================================================================================================== 00930 void FSSRPurdueFirmware::chipID(uint32_t size) 00931 { 00932 BitManipulator::insertBits(stripSCRegisterValue_, size, 0, 5); 00933 } 00934 00935 //======================================================================================================================== 00936 void FSSRPurdueFirmware::addressSlowControls(uint32_t size) 00937 { 00938 BitManipulator::insertBits(stripSCRegisterValue_, size, 5, 5); 00939 } 00940 00941 //======================================================================================================================== 00942 void FSSRPurdueFirmware::instructionSlowControls(uint32_t size) 00943 { 00944 BitManipulator::insertBits(stripSCRegisterValue_, size, 10, 3); 00945 } 00946 00947 //======================================================================================================================== 00948 void FSSRPurdueFirmware::channelreadSelect(uint32_t size) 00949 { 00950 BitManipulator::insertBits(stripSCRegisterValue_, size, 13, 3); 00951 } 00952 00953 //======================================================================================================================== 00954 void FSSRPurdueFirmware::channelMask(uint32_t size) 00955 { 00956 BitManipulator::insertBits(stripSCRegisterValue_, size, 16, 8); 00957 } 00958 00959 //======================================================================================================================== 00960 void FSSRPurdueFirmware::bitsLength(uint32_t length) 00961 { 00962 BitManipulator::insertBits(stripSCRegisterValue_, length, 26, 3); 00963 } 00964 00965 00966 //======================================================================================================================== 00967 void FSSRPurdueFirmware::syncFallingBCO(bool sync) 00968 { 00969 BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)sync, 28, 1); 00970 } 00971 00972 //======================================================================================================================== 00973 void FSSRPurdueFirmware::syncRisingBCO(bool sync) 00974 { 00975 BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)sync, 29, 1); 00976 } 00977 00978 //======================================================================================================================== 00979 void FSSRPurdueFirmware::setRaw(bool set) 00980 { 00981 BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)set, 30, 1); 00982 } 00983 00984 //======================================================================================================================== 00985 void FSSRPurdueFirmware::initSlowControls(bool init) 00986 { 00987 BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)init, 31, 1); 00988 } 00989 00990 //======================================================================================================================== 00991 void FSSRPurdueFirmware::resetCount(bool reset) 00992 { 00993 BitManipulator::insertBits(stripAnalysisCSRRegisterValue_, (uint32_t)reset, 30, 1); 00994 } 00995 00996 //======================================================================================================================== 00997 void FSSRPurdueFirmware::setBCO_0(uint32_t void FSSRPurdueFirmware::BCOOffset(uint32_t offset) 00998 { 00999 BitManipulator::insertBits(stripTrigCSRRegisterValue_, offset, 0, 4); 01000 }input) 01001 { 01002 BitManipulator::insertBits(trigInputRegisterValue_, input, 0, 8); 01003 } 01004 01005 //======================================================================================================================== 01006 void FSSRPurdueFirmware::setBCO_1(uint32_t input) 01007 { 01008 BitManipulator::insertBits(trigInputRegisterValue_, input, 8, 8); 01009 } 01010 01011 //======================================================================================================================== 01012 void FSSRPurdueFirmware::trimFracBCO_0(uint32_t input) 01013 { 01014 BitManipulator::insertBits(trigInputRegisterValue_, input, 16, 4); 01015 } 01016 01017 //======================================================================================================================== 01018 void FSSRPurdueFirmware::trimFracBCO_1(uint32_t input) 01019 { 01020 BitManipulator::insertBits(trigInputRegisterValue_, input, 20, 4); 01021 } 01022 01023 //======================================================================================================================== 01024 void FSSRPurdueFirmware::enable_0(bool enable) 01025 { 01026 BitManipulator::insertBits(trigInputRegisterValue_, (uint32_t)enable, 28, 1); 01027 } 01028 01029 //======================================================================================================================== 01030 void FSSRPurdueFirmware::enable_1(bool enable) 01031 { 01032 BitManipulator::insertBits(trigInputRegisterValue_, (uint32_t)enable, 29, 1); 01033 } 01034 01035 */