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