$treeview $search $mathjax $extrastylesheet
otsdaq_components
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_FSSRFirmware_h_ 00002 #define _ots_FSSRFirmware_h_ 00003 00004 #include <string> 00005 00006 #include "otsdaq-components/DAQHardware/FirmwareSequence.h" /* for FirmwareSequence */ 00007 #include "otsdaq-components/DetectorConfiguration/ROCStream.h" /* for ROCStream */ 00008 00009 //#include "otsdaq-components/DAQHardware/PurdueFirmwareCore.h" 00010 00011 namespace ots 00012 { 00013 // - FrontEndFirmwareBase (all virtual read, write, setDest, init) *functions are not 00014 // pure virtual, rather throw exceptions if not overridden to allow setDest to go unused, 00015 // for example. 00016 // - OtsUDPFirmwareCore (inherits and implements FrontEndFirmwareBase) 00017 // - PurdueFirmwareCore (inherits and implements FrontEndFirmwareBase) 00018 // 00019 // - FSSRFirmwareBase (takes ONLY parameter for communication type. Does not inherit 00020 // from anything). *Implements 90-100% base fssr functionality: 00021 // - FSSROtsFirmware (inherits from FSSRApplicationFirmwareBase only and overrides 00022 // any 10% special functions) 00023 // - FSSRPurdueFirmware (inherits from FSSRApplicationFirmwareBase only and overrides 00024 // any 10% special functions) FSSRFirmwareBase::setCSR() 00025 // { 00026 // Communication->write(CSR); 00027 // } 00028 // 00029 // - At PLUGIN level (takes parameter for communication AND application firmware 00030 // type. ALSO -PRESTON WAS partially RIGHT - inherit from FrontEndFirmwareBase AND 00031 // FSSRFirmwareBase. ) * implement all the base functions using the pointers: 00032 // 00033 // PLUGIN::PLUGIN(commType,appType) 00034 // { 00035 // If(appType == otsApp) 00036 // FSSFirmware = FSSROtsFirmware(commType); //IMPORTANT pass comm 00037 // type Else FSSFirmware = 00038 // FSSRPurdueFirmware(commType); //IMPORTANT pass comm type 00039 // } 00040 // 00041 // PLUGIN::whatever() 00042 // { 00043 // FSSFirmware->read(); 00044 // FSSFirmware->setCSR(); //will call override version if implemented 00045 // } 00046 // 00047 // * This way the FE interface plugin code is exactly the same for both cases, just 00048 // modified by type strings. 00049 // * Since only modified by type strings, this means there only needs to be one FE 00050 // plugin class! Types controlled by configuration. 00051 00052 class FrontEndFirmwareBase; 00053 00054 class FSSRFirmwareBase 00055 { 00056 public: 00057 FSSRFirmwareBase(const std::string& communicationFirmwareType, 00058 unsigned int communicationFirmwareVersion = -1, 00059 unsigned int version = -1); 00060 virtual ~FSSRFirmwareBase(void); 00061 void init(void); 00062 00063 std::string universalRead(char* address); 00064 std::string universalWrite(char* address, char* data); 00065 00066 // virtual void setDataDestination (std::string& buffer, 00067 // const std::string& ip, const uint16_t port);// {__SS__; 00068 // __THROW__(ss.str() + "Illegal call to undefined base class member function"); 00069 // return;}; 00070 uint32_t createRegisterFromValue(std::string& readBuffer, std::string& receivedValue); 00071 00072 // FEW specific methods 00073 std::string configureClocks(std::string source, double frequency); 00074 std::string resetDetector(int channel = -1); 00075 std::string enableTrigger(void); 00076 // virtual void setDataDestination (std::string& buffer, const std::string& ip, const 00077 // uint16_t port); std::string setDataDestination (std::string ip, uint32_t port); 00078 00079 void resetDCM(std::string& buffer); 00080 void alignReadOut(std::string& buffer, unsigned int sensor, unsigned int chip); 00081 void makeDACSequence(FirmwareSequence<uint64_t>& sequence, 00082 unsigned int channel, 00083 const ROCStream& rocStream); 00084 void makeDACSequence(FirmwareSequence<uint32_t>& sequence, 00085 unsigned int channel, 00086 const ROCStream& rocStream); 00087 void makeMaskSequence(FirmwareSequence<uint64_t>& sequence, 00088 unsigned int channel, 00089 const ROCStream& rocStream); 00090 void makeMaskSequence(FirmwareSequence<uint32_t>& sequence, 00091 unsigned int channel, 00092 const ROCStream& rocStream); 00093 00094 void makeDACBuffer(std::string& buffer, 00095 unsigned int channel, 00096 const ROCStream& rocStream); 00097 void makeDACBuffer(std::vector<std::string>& buffer, 00098 unsigned int channel, 00099 const ROCStream& rocStream); 00100 void makeMaskBuffer(std::string& buffer, 00101 unsigned int channel, 00102 const ROCStream& rocStream); 00103 void setFrequencyFromClockState(std::string& buffer, double frequency); 00104 bool isClockStateExternal(void); 00105 00106 std::string readFromAddress(uint64_t address); 00107 00108 // FER specific methods 00109 std::string resetBCO(void); 00110 std::string armBCOReset(void); 00111 std::string startStream(bool channel0, 00112 bool channel1, 00113 bool channel2, 00114 bool channel3, 00115 bool channel4, 00116 bool channel5); 00117 std::string stopStream(void); 00118 00119 void makeMaskSequence(FirmwareSequence<uint64_t>& sequence, 00120 unsigned int channel, 00121 const ROCStream& rocStream, 00122 const std::string& registerName); 00123 void makeMaskSequence(FirmwareSequence<uint32_t>& sequence, 00124 unsigned int channel, 00125 const ROCStream& rocStream, 00126 const std::string& registerName); 00127 void makeMaskBuffer(std::string& buffer, 00128 unsigned int channel, 00129 const ROCStream& rocStream, 00130 const std::string& registerName); 00131 00132 void setCSRRegister(uint32_t total); 00133 00134 // Set values for register STRIP_CSR (Strip Control Register) 00135 // STRIP_CSR = 0xc4000000 00136 // Byte 4------------------- 00137 // 31 DCM_RESET 00138 // 30 BCO_LOCKED 00139 // 29 MCCLK_LOCKED 00140 // 28 unused 00142 // 27 STREAM_ENABLE 00143 // 26 SEND_BCO 00144 // 25 SEND_TRIG_NUM 00145 // 24 SEND_TRIG 00146 // Byte 3------------------- 00147 // 23 TRIG_ENABLE 00148 // 22 BCO_CLEAR 00149 // 21 TRIG_NUM_CLEAR 00150 // 20 FLUSH 00152 // 19 ARM_BCO_RESET 00153 // 18-17 unused 00154 // 16 EXT_BCO 00155 // Byte 2------------------- 00156 // 15-14 IDLE_COUNT 00157 // 13-8 MODULE_ENABLE 00158 // Byte 1------------------- 00159 // 7-3 PACKET_SIZE 00160 // 2-0 N_CHANNELS 00161 00162 uint32_t stripCSRRegisterValue_; 00163 void setPacketSizeStripCSR(uint32_t size); 00164 void enableChannelsStripCSR(bool channel0, 00165 bool channel1, 00166 bool channel2, 00167 bool channel3, 00168 bool channel4, 00169 bool channel5); 00170 void setExternalBCOClockSourceStripCSR(std::string clockSource); 00171 // void setHaltStripCSR (bool set);//2018-10-24 00172 // Doesn't exist???? 00173 void armBCOResetCSR(void); 00174 void flushBuffersStripCSR(void); 00175 void resetTriggerCounterStripCSR(std::string& buffer); 00176 void resetBCOCounterStripCSR(void); 00177 void enableTriggerStripCSR(bool enable); 00178 void sendTriggerDataStripCSR(bool send); 00179 void sendTriggerNumberStripCSR(bool send); 00180 void sendBCOStripCSR(bool send); 00181 void enableStreamStripCSR(bool enable); 00182 void resetDCMStripCSR(bool clear); 00183 uint32_t waitDCMResetStripCSR(void); 00184 std::string readCSRRegister(void); 00185 00186 std::string readSCCSRRegister(void); 00187 00188 uint32_t stripResetRegisterValue_; 00189 // Set values for register STRIP_RESET (Strip Reset) 00190 void resetStripResetRegisterValue(void) { stripResetRegisterValue_ = 0; } 00191 void resetDAC(void); 00192 void resetLink(bool channel0, 00193 bool channel1, 00194 bool channel2, 00195 bool channel3, 00196 bool channel4, 00197 bool channel5); 00198 void clearErrors(bool channel0, 00199 bool channel1, 00200 bool channel2, 00201 bool channel3, 00202 bool channel4, 00203 bool channel5); 00204 void clearFIFO(bool channel0, 00205 bool channel1, 00206 bool channel2, 00207 bool channel3, 00208 bool channel4, 00209 bool channel5); 00210 void resetChip(bool channel0, 00211 bool channel1, 00212 bool channel2, 00213 bool channel3, 00214 bool channel4, 00215 bool channel5); 00216 00217 uint32_t stripBCODCMRegisterValue_; 00218 void setFrequencyRatio(std::string& buffer, int numerator, int denominator); 00219 00220 void configureStripTriggerUnbiased(std::string& buffer); 00221 void configureTriggerInputs(std::string& buffer); 00222 00223 // STRIP_TRIG_CSR = 0xc40000060 00224 uint32_t stripTriggerCSRRegisterValue_; 00225 00226 // Registers setters 00227 void BCOOffset(uint32_t offset); 00228 void selectSpyFIFO(uint32_t input); 00229 void halt(bool halt); 00230 00231 std::string resetSlaveBCO(void); 00232 00233 static const std::string PURDUE_FIRMWARE_NAME; 00234 static const std::string OTS_FIRMWARE_NAME; 00235 00236 FrontEndFirmwareBase* communicationFirmwareInstance_; 00237 00238 protected: 00239 unsigned int version_; 00240 const std::string communicationFirmwareType_; 00241 }; 00242 } 00243 00244 #endif