39 std::vector<uint32_t> fe_config,
40 std::vector<uint16_t> clk_phases,
43 uint8_t start_frame_mode_sel,
44 uint8_t start_frame_swap)
47 if (iFEMB < 1 || iFEMB > 4) {
48 BUException::WIB_BAD_ARGS e;
49 std::stringstream expstr;
50 expstr <<
"ConfigFEMB: iFEMB should be between 1 and 4: " << int(iFEMB);
51 e.Append(expstr.str().c_str());
55 BUException::WIB_BAD_ARGS e;
56 std::stringstream expstr;
57 expstr <<
"ConfigFEMB: pls_dac_mode is allowed to be 0 (off), 1 (FPGA), 2 (internal), but is: " << int(pls_mode);
58 e.Append(expstr.str().c_str());
61 if (start_frame_mode_sel > 1 || start_frame_swap > 1) {
62 BUException::WIB_BAD_ARGS e;
63 std::stringstream expstr;
64 expstr <<
"ConfigFEMB: start_frame_mode_sel and start_frame_swap must be 0 or 1";
65 e.Append(expstr.str().c_str());
69 if (fe_config.size() != 8) {
71 BUException::WIB_BAD_ARGS e;
72 std::stringstream expstr;
73 expstr <<
"Error: Expecting 9 Front End configuration options:" << std::endl
74 <<
"\t0: Gain" << std::endl
75 <<
"\t1: Shaping Time" << std::endl
76 <<
"\t2: High Baseline" << std::endl
77 <<
"\t3: High Leakage" << std::endl
78 <<
"\t4: Leakage x 10" << std::endl
79 <<
"\t5: AC Coupling" << std::endl
80 <<
"\t6: Buffer" << std::endl
81 <<
"\t7: Use External Clock" << std::endl;
82 e.Append(expstr.str().c_str());
85 std::cout <<
"Front End configuration options:" << std::endl
86 <<
"\t0:" << std::setw(22) << std::setfill(
' ') <<
"Gain " << fe_config[0] << std::endl
87 <<
"\t1:" << std::setw(22) << std::setfill(
' ') <<
"Shaping Time " << fe_config[1] << std::endl
88 <<
"\t2:" << std::setw(22) << std::setfill(
' ') <<
"High Baseline " << fe_config[2] << std::endl
89 <<
"\t3:" << std::setw(22) << std::setfill(
' ') <<
"High Leakage " << fe_config[3] << std::endl
90 <<
"\t4:" << std::setw(22) << std::setfill(
' ') <<
"Leakage x 10 " << fe_config[4] << std::endl
91 <<
"\t5:" << std::setw(22) << std::setfill(
' ') <<
"AC Coupling " << fe_config[5] << std::endl
92 <<
"\t6:" << std::setw(22) << std::setfill(
' ') <<
"Buffer " << fe_config[6] << std::endl
93 <<
"\t8:" << std::setw(22) << std::setfill(
' ') <<
"Use External Clock " << fe_config[7] << std::endl;
96 std::cout <<
"Pulser Mode: " << int(pls_mode) <<
" and DAC Value: " << int(pls_dac_val) << std::endl;
99 uint32_t slow_control_dnd =
Read(
"SYSTEM.SLOW_CONTROL_DND");
100 Write(
"SYSTEM.SLOW_CONTROL_DND", 1);
104 std::cout <<
"Error: Can't read registers from FEMB " << int(iFEMB) << std::endl;
107 BUException::FEMB_REG_READ_ERROR e;
108 std::stringstream expstr;
109 expstr <<
" for FEMB: " << int(iFEMB);
110 e.Append(expstr.str().c_str());
117 WriteFEMB(iFEMB,
"START_FRAME_MODE_SELECT", start_frame_mode_sel);
119 WriteFEMB(iFEMB,
"START_FRAME_SWAP", start_frame_swap);
155 uint32_t REG_LATCHLOC1_4_data = 0x04040404;
156 uint32_t REG_LATCHLOC5_8_data = 0x04040404;
158 WriteFEMB(iFEMB,
"ADC_LATCH_LOC_0TO3", REG_LATCHLOC1_4_data);
159 WriteFEMB(iFEMB,
"ADC_LATCH_LOC_4TO7", REG_LATCHLOC5_8_data);
162 uint8_t internal_daq_value = 0;
165 if (pls_dac_val >= 63) {
166 BUException::WIB_BAD_ARGS e;
167 std::stringstream expstr;
168 expstr <<
"ConfigFEMB: pls_dac_val is 6 bits for internal DAC, must be 0-63, but is: " << int(pls_dac_val);
169 e.Append(expstr.str().c_str());
172 internal_daq_value = pls_dac_val;
174 }
else if (pls_mode == 2)
176 if (pls_dac_val >= 32) {
177 BUException::WIB_BAD_ARGS e;
178 std::stringstream expstr;
179 expstr <<
"ConfigFEMB: pls_dac_val is 5 bits for FPGA DAC, must be 0-31, but is: " << int(pls_dac_val);
180 e.Append(expstr.str().c_str());
198 std::cout <<
"FEMB " << int(iFEMB) <<
" Successful SPI config" << std::endl;
201 if (clk_phases.size() == 0) {
202 clk_phases.push_back(0xFFFF);
206 std::cout <<
"Warning: FEMB " << int(iFEMB)
207 <<
" ADC FIFO not synced from expected phases, trying to hunt for phases" << std::endl;
210 std::cout <<
"Error: FEMB " << int(iFEMB) <<
" ADC FIFO could not be synced even after hunting" << std::endl;
212 uint16_t adc_fifo_sync = (
ReadFEMB(iFEMB, 6) & 0xFFFF0000) >> 16;
213 BUException::FEMB_ADC_SYNC_ERROR e;
214 std::stringstream expstr;
215 expstr <<
" after hunting. ";
216 expstr <<
" FEMB: " << int(iFEMB);
217 expstr <<
" sync: " << std::bitset<16>(adc_fifo_sync);
218 expstr <<
" phases: ";
219 expstr << std::hex << std::setfill(
'0') << std::setw(2) <<
ReadFEMB(iFEMB,
"ADC_ASIC_CLK_PHASE_SELECT");
220 expstr << std::hex << std::setfill(
'0') << std::setw(2) <<
ReadFEMB(iFEMB,
"ADC_ASIC_CLK_PHASE_SELECT_2");
221 e.Append(expstr.str().c_str());
228 uint16_t adc_fifo_sync = (
ReadFEMB(iFEMB, 6) & 0xFFFF0000) >> 16;
229 BUException::FEMB_ADC_SYNC_ERROR e;
230 std::stringstream expstr;
231 expstr <<
" after trying all in list. ";
232 expstr <<
" FEMB: " << int(iFEMB);
233 expstr <<
" sync: " << std::bitset<16>(adc_fifo_sync);
234 expstr <<
" phases tried: " << std::endl;
235 for (
size_t iclk_phase = 0; iclk_phase < clk_phases.size(); iclk_phase++) {
236 expstr <<
" " << std::hex << std::setfill(
'0') << std::setw(4) << clk_phases[iclk_phase] << std::endl;
238 e.Append(expstr.str().c_str());
242 uint16_t adc_fifo_sync = (
ReadFEMB(iFEMB, 6) & 0xFFFF0000) >> 16;
243 std::cout <<
"FEMB " << int(iFEMB) <<
" Final ADC FIFO sync: " << std::bitset<16>(adc_fifo_sync) << std::endl;
244 std::cout <<
"FEMB " << int(iFEMB) <<
" Final Clock Phases: " << std::hex << std::setfill(
'0') << std::setw(2)
245 <<
ReadFEMB(iFEMB,
"ADC_ASIC_CLK_PHASE_SELECT") << std::hex << std::setfill(
'0') << std::setw(2)
246 <<
ReadFEMB(iFEMB,
"ADC_ASIC_CLK_PHASE_SELECT_2") << std::endl;
265 Write(
"SYSTEM.SLOW_CONTROL_DND", slow_control_dnd);
282 std::vector<uint32_t> fake_samples,
283 uint8_t start_frame_mode_sel,
284 uint8_t start_frame_swap)
287 if (iFEMB < 1 || iFEMB > 4) {
288 BUException::WIB_BAD_ARGS e;
289 std::stringstream expstr;
290 expstr <<
"ConfigFEMBFakeData: iFEMB should be between 1 and 4: " << int(iFEMB);
291 e.Append(expstr.str().c_str());
294 if (start_frame_mode_sel > 1 || start_frame_swap > 1) {
295 BUException::WIB_BAD_ARGS e;
296 std::stringstream expstr;
297 expstr <<
"ConfigFEMBFakeData: start_frame_mode_sel and start_frame_swap must be 0 or 1";
298 e.Append(expstr.str().c_str());
301 if (fake_mode == 1 && fake_word > 0xFFF) {
302 BUException::WIB_BAD_ARGS e;
303 std::stringstream expstr;
304 expstr <<
"ConfigFEMBFakeData: fake_word must be only 12 bits i.e. <= 4095, is: " << fake_word;
305 e.Append(expstr.str().c_str());
308 if (fake_mode == 2 && fake_samples.size() != 256) {
309 BUException::WIB_BAD_ARGS e;
310 std::stringstream expstr;
311 expstr <<
"ConfigFEMBFakeData: femb_samples must be 255 long, is: " << fake_samples.size();
312 e.Append(expstr.str().c_str());
315 if (fake_mode == 3 && femb_number > 0xF) {
316 BUException::WIB_BAD_ARGS e;
317 std::stringstream expstr;
318 expstr <<
"ConfigFEMBFakeData: femb_number must be only 4 bits i.e. <= 15, is: " << int(femb_number);
319 e.Append(expstr.str().c_str());
324 uint32_t slow_control_dnd =
Read(
"SYSTEM.SLOW_CONTROL_DND");
325 Write(
"SYSTEM.SLOW_CONTROL_DND", 1);
330 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 0);
333 WriteFEMB(iFEMB,
"START_FRAME_MODE_SELECT", start_frame_mode_sel);
335 WriteFEMB(iFEMB,
"START_FRAME_SWAP", start_frame_swap);
343 if (fake_mode == 1) {
344 WriteFEMB(iFEMB,
"DATA_TEST_PATTERN", fake_word);
346 if (fake_mode == 2) {
348 for (
size_t iSample = 0; iSample < 256; iSample++) {
349 WriteFEMB(iFEMB, 0x300 + iSample, fake_samples.at(iSample));
353 if (fake_mode == 3) {
354 WriteFEMB(iFEMB,
"FEMB_NUMBER", femb_number);
356 WriteFEMB(iFEMB,
"FEMB_TST_SEL", fake_mode);
362 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 9);
364 Write(
"SYSTEM.SLOW_CONTROL_DND", slow_control_dnd);
376 uint32_t clk_period = 5;
377 uint32_t clk_dis = 0;
378 uint32_t d14_rst_oft = 0 / clk_period;
379 uint32_t d14_rst_wdt = (45 / clk_period);
380 uint32_t d14_rst_inv = 1;
381 uint32_t d14_read_oft = 480 / clk_period;
382 uint32_t d14_read_wdt = 20 / clk_period;
383 uint32_t d14_read_inv = 1;
384 uint32_t d14_idxm_oft = 230 / clk_period;
385 uint32_t d14_idxm_wdt = 270 / clk_period;
386 uint32_t d14_idxm_inv = 0;
387 uint32_t d14_idxl_oft = 480 / clk_period;
388 uint32_t d14_idxl_wdt = 20 / clk_period;
389 uint32_t d14_idxl_inv = 0;
390 uint32_t d14_idl0_oft = 50 / clk_period;
391 uint32_t d14_idl0_wdt = (190 / clk_period) - 1;
392 uint32_t d14_idl1_oft = 480 / clk_period;
393 uint32_t d14_idl1_wdt = 20 / clk_period;
394 uint32_t d14_idl_inv = 0;
396 uint32_t d58_rst_oft = 0 / clk_period;
397 uint32_t d58_rst_wdt = (45 / clk_period);
398 uint32_t d58_rst_inv = 1;
399 uint32_t d58_read_oft = 480 / clk_period;
400 uint32_t d58_read_wdt = 20 / clk_period;
401 uint32_t d58_read_inv = 1;
402 uint32_t d58_idxm_oft = 230 / clk_period;
403 uint32_t d58_idxm_wdt = 270 / clk_period;
404 uint32_t d58_idxm_inv = 0;
405 uint32_t d58_idxl_oft = 480 / clk_period;
406 uint32_t d58_idxl_wdt = 20 / clk_period;
407 uint32_t d58_idxl_inv = 0;
408 uint32_t d58_idl0_oft = 50 / clk_period;
409 uint32_t d58_idl0_wdt = (190 / clk_period) - 1;
410 uint32_t d58_idl1_oft = 480 / clk_period;
411 uint32_t d58_idl1_wdt = 20 / clk_period;
412 uint32_t d58_idl_inv = 0;
439 uint32_t d14_read_step = 11;
440 uint32_t d14_read_ud = 0;
441 uint32_t d14_idxm_step = 9;
442 uint32_t d14_idxm_ud = 0;
443 uint32_t d14_idxl_step = 7;
444 uint32_t d14_idxl_ud = 0;
445 uint32_t d14_idl0_step = 12;
446 uint32_t d14_idl0_ud = 0;
447 uint32_t d14_idl1_step = 10;
448 uint32_t d14_idl1_ud = 0;
449 uint32_t d14_phase_en = 1;
451 uint32_t d58_read_step = 0;
452 uint32_t d58_read_ud = 0;
453 uint32_t d58_idxm_step = 5;
454 uint32_t d58_idxm_ud = 0;
455 uint32_t d58_idxl_step = 4;
456 uint32_t d58_idxl_ud = 1;
457 uint32_t d58_idl0_step = 3;
458 uint32_t d58_idl0_ud = 0;
459 uint32_t d58_idl1_step = 4;
460 uint32_t d58_idl1_ud = 0;
461 uint32_t d58_phase_en = 1;
467 (d14_rst_inv << 0) + (d14_read_inv << 1) + (d14_idxm_inv << 2) + (d14_idxl_inv << 3) + (d14_idl_inv << 4);
469 (d58_rst_inv << 0) + (d58_read_inv << 1) + (d58_idxm_inv << 2) + (d58_idxl_inv << 3) + (d58_idl_inv << 4);
470 uint32_t d_inv = d58_inv + (d14_inv << 5);
474 addr_data = clk_dis + (d_inv << 16);
477 addr_data = d58_rst_oft + (d14_rst_oft << 16);
480 addr_data = d58_rst_wdt + (d14_rst_wdt << 16);
483 addr_data = d58_read_oft + (d14_read_oft << 16);
486 addr_data = d58_read_wdt + (d14_read_wdt << 16);
489 addr_data = d58_idxm_oft + (d14_idxm_oft << 16);
492 addr_data = d58_idxm_wdt + (d14_idxm_wdt << 16);
495 addr_data = d58_idxl_oft + (d14_idxl_oft << 16);
498 addr_data = d58_idxl_wdt + (d14_idxl_wdt << 16);
501 addr_data = d58_idl0_oft + (d14_idl0_oft << 16);
504 addr_data = d58_idl0_wdt + (d14_idl0_wdt << 16);
507 addr_data = d58_idl1_oft + (d14_idl1_oft << 16);
510 addr_data = d58_idl1_wdt + (d14_idl1_wdt << 16);
514 for (
size_t i = 0; i < 4; i++) {
515 addr_data = d14_read_step + (d14_idxm_step << 16);
518 addr_data = d14_idxl_step + (d14_idl0_step << 16);
521 d14_phase_en = d14_phase_en ^ 1;
522 uint32_t d14_ud = d14_read_ud + (d14_idxm_ud << 1) + (d14_idxl_ud << 2) + (d14_idl0_ud << 3) + (d14_idl1_ud << 4) +
523 (d14_phase_en << 15);
524 addr_data = d14_idl1_step + (d14_ud << 16);
527 addr_data = d58_read_step + (d58_idxm_step << 16);
530 addr_data = d58_idxl_step + (d58_idl0_step << 16);
533 d58_phase_en = d58_phase_en ^ 1;
534 uint32_t d58_ud = d58_read_ud + (d58_idxm_ud << 1) + (d58_idxl_ud << 2) + (d58_idl0_ud << 3) + (d58_idl1_ud << 4) +
535 (d58_phase_en << 15);
536 addr_data = d58_idl1_step + (d58_ud << 16);
622 uint8_t highBaseline,
628 uint8_t internalDACControl,
629 uint8_t internalDACValue)
635 BUException::WIB_BAD_ARGS e;
636 std::stringstream expstr;
637 expstr <<
"gain should be between 0 and 3, but is: " << int(gain);
638 e.Append(expstr.str().c_str());
642 BUException::WIB_BAD_ARGS e;
643 std::stringstream expstr;
644 expstr <<
"shape should be between 0 and 3, but is: " << int(shape);
645 e.Append(expstr.str().c_str());
649 const size_t REG_SPI_BASE_WRITE = 0x200;
650 const size_t REG_SPI_BASE_READ = 0x250;
653 bool bypassOutputBuffer =
true;
654 bool useOutputMonitor =
false;
655 bool useCh16HighPassFilter =
false;
656 bool monitorBandgapNotTemp =
false;
657 bool monitorTempBandgapNotSignal =
false;
658 bool useTestCapacitance = (bool)internalDACControl;
663 else if (gain == 0x2)
669 else if (shape == 0x1)
671 else if (shape == 0x2)
673 else if (shape == 0x3)
677 if (highBaseline > 1) {
686 monitorBandgapNotTemp,
687 monitorTempBandgapNotSignal,
688 useCh16HighPassFilter,
703 monitorBandgapNotTemp,
704 monitorTempBandgapNotSignal,
705 useCh16HighPassFilter,
712 uint8_t offsetCurrentValue = 0;
716 bool useADCTestInput = 0;
719 bool lsbCurrentStearingPartialNotFull = 0;
725 bool enableOffsetCurrent = 0;
737 lsbCurrentStearingPartialNotFull,
754 const std::vector<uint32_t> regs = map.
get_regs();
755 const size_t nRegs = regs.size();
757 uint16_t adc_sync_status = 0xFFFF;
759 for (
unsigned iSPIWrite = 0; iSPIWrite < 2; iSPIWrite++) {
760 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 0);
763 std::cout <<
"ASIC SPI Write Registers..." << std::endl;
764 for (
size_t iReg = 0; iReg < nRegs; iReg++) {
765 WriteFEMB(iFEMB, REG_SPI_BASE_WRITE + iReg, regs[iReg]);
774 if (iSPIWrite == 1) {
776 bool spi_mismatch =
false;
777 for (
unsigned iSPIRead = 0; iSPIRead < 2; iSPIRead++) {
778 std::cout <<
"ASIC SPI Readback..." << std::endl;
779 std::vector<uint32_t> regsReadback(nRegs);
780 for (
size_t iReg = 0; iReg < nRegs; iReg++) {
781 uint32_t regReadback =
ReadFEMB(iFEMB, REG_SPI_BASE_READ + iReg);
782 regsReadback[iReg] = regReadback;
786 bool verbose =
false;
788 std::cout <<
"ASIC SPI register number, write val, read val:" << std::endl;
789 spi_mismatch =
false;
790 for (
size_t iReg = 0; iReg < nRegs; iReg++) {
792 std::cout << std::dec << std::setfill(
' ') << std::setw(3) << iReg <<
" " << std::hex << std::setfill(
'0')
793 << std::setw(8) << regs[iReg] <<
" " << std::hex << std::setfill(
'0') << std::setw(8)
794 << regsReadback[iReg] << std::endl;
796 if (regs[iReg] != regsReadback[iReg]) {
798 size_t asicFailNum = 0;
800 asicFailNum = (iReg - 1) / 9;
801 std::cout <<
"FE-ADC ASIC " << asicFailNum <<
" SPI faled" << std::endl;
809 std::cout <<
"FEMB ASIC SPI readback mismatch--problems communicating with ASICs for FEMB: " << int(iFEMB)
812 BUException::FEMB_SPI_READBACK_MISMATCH e;
813 std::stringstream expstr;
814 expstr <<
" for FEMB: " << int(iFEMB);
815 e.Append(expstr.str().c_str());
822 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 9);
824 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 9);
827 adc_sync_status = (uint16_t)
ReadFEMB(iFEMB,
"ADC_ASIC_SYNC_STATUS");
833 return adc_sync_status;
840 const uint32_t REG_SPI_BASE_WRITE = 0x200;
841 const uint32_t REG_SPI_BASE_READ = 0x250;
842 uint16_t adc_sync_status = 0xFFFF;
846 for (
unsigned iSPIWrite = 0; iSPIWrite < nTries; iSPIWrite++) {
847 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 0);
850 std::cout <<
"ASIC SPI Write Registers..." << std::endl;
855 std::vector<uint32_t> vals(nASICs);
856 for (
size_t iASIC = 0; iASIC < nASICs; iASIC++) {
857 uint32_t address = (REG_SPI_BASE_WRITE + 9 * iASIC + 8);
858 std::cout <<
"Writing address " << std::hex << std::setfill(
'0') << std::setw(8) << address << std::endl;
862 uint32_t shiftVal = value & mask;
863 uint32_t regMask = (mask << pos);
864 uint32_t initVal =
ReadFEMB(iFEMB, address);
865 uint32_t newVal = ((initVal & ~(regMask)) | (shiftVal << pos));
866 vals[iASIC] = newVal;
877 if (iSPIWrite == nTries - 1) {
879 bool spi_mismatch =
false;
880 for (
unsigned iSPIRead = 0; iSPIRead < 2; iSPIRead++) {
881 std::cout <<
"ASIC SPI Readback..." << std::endl;
882 std::vector<uint32_t> regsReadback(nASICs);
883 for (
size_t iASIC = 0; iASIC < nASICs; iASIC++) {
884 uint32_t regReadback =
ReadFEMB(iFEMB, (REG_SPI_BASE_READ + 9 * iASIC + 8));
885 regsReadback[iASIC] = regReadback;
889 std::cout <<
"ASIC SPI register number, write val, read val:" << std::endl;
890 spi_mismatch =
false;
891 for (
size_t iASIC = 0; iASIC < nASICs; iASIC++) {
892 std::cout << std::dec << std::setfill(
' ') << std::setw(3) << iASIC <<
" " << std::hex << std::setfill(
'0')
893 << std::setw(8) << vals[iASIC] <<
" " << std::hex << std::setfill(
'0') << std::setw(8)
894 << regsReadback[iASIC] << std::endl;
895 if (vals[iASIC] != regsReadback[iASIC]) {
897 size_t asicFailNum = 0;
899 asicFailNum = (iASIC - 1);
900 std::cout <<
"FE-ADC ASIC " << asicFailNum <<
" SPI faled" << std::endl;
907 BUException::WIB_ERROR e;
908 e.Append(
"SPI programming failure");
914 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 9);
916 WriteFEMB(iFEMB,
"STREAM_AND_ADC_DATA_EN", 9);
919 adc_sync_status = (uint16_t)
ReadFEMB(iFEMB,
"ADC_ASIC_SYNC_STATUS");
925 return adc_sync_status;
1083 uint32_t clk_phase_data0 = (clk_phase_data_start >> 8) & 0xFF;
1084 uint32_t clk_phase_data1 = clk_phase_data_start & 0xFF;
1085 uint32_t adc_fifo_sync = 1;
1087 uint32_t a_cs[8] = { 0xc000, 0x3000, 0x0c00, 0x0300, 0x00c0, 0x0030, 0x000c, 0x0003 };
1089 uint32_t a_mark[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
1091 uint32_t a_cnt[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1093 while (adc_fifo_sync) {
1095 adc_fifo_sync = (
ReadFEMB(iFEMB, 6) & 0xFFFF0000) >> 16;
1097 adc_fifo_sync = (
ReadFEMB(iFEMB, 6) & 0xFFFF0000) >> 16;
1100 std::cout <<
"FEMB " << int(iFEMB) <<
" ADC FIFO sync: " << std::bitset<16>(adc_fifo_sync) << std::endl;
1102 if (adc_fifo_sync == 0) {
1103 std::cout <<
"FEMB " << int(iFEMB) <<
" Successful SPI config and ADC FIFO synced" << std::endl;
1107 std::cout <<
" phase: " << std::hex << std::setw(2) << std::setfill(
'0') << clk_phase_data0;
1108 std::cout << std::hex << std::setw(2) << std::setfill(
'0') << clk_phase_data1 << std::endl;
1111 std::cout <<
"ERROR: sync not zero: " << std::bitset<16>(adc_fifo_sync) << std::endl;
1112 for (
int i = 0; i < 8; ++i) {
1113 uint32_t a = adc_fifo_sync & a_cs[i];
1114 uint32_t a_mark_xor = 0;
1117 a_mark_xor = a_mark[i] ^ 0xFF;
1118 if (a_cnt[i] == 1 || a_cnt[i] == 3) {
1119 clk_phase_data0 = ((clk_phase_data0 & a_mark[i]) ^ a_mark[i]) + (clk_phase_data0 & a_mark_xor);
1120 }
else if (a_cnt[i] == 2 || a_cnt[i] == 4) {
1121 clk_phase_data1 = ((clk_phase_data1 & a_mark[i]) ^ a_mark[i]) + (clk_phase_data1 & a_mark_xor);
1122 }
else if (a_cnt[i] >= 5) {
1129 uint16_t clk_phase_to_write = 0;
1130 clk_phase_to_write |= (clk_phase_data0 & 0xFF) << 8;
1131 clk_phase_to_write |= clk_phase_data1;
void set_board(uint8_t d=0, uint8_t pcsr=0, uint8_t pdsr=0, uint8_t slp=0, uint8_t tstin=0, uint8_t f4=0, uint8_t f5=0, uint8_t slsb=0, uint8_t res4=0, uint8_t res3=0, uint8_t res2=0, uint8_t res1=0, uint8_t res0=0, uint8_t clk0=0, uint8_t clk1=0, uint8_t frqc=0, uint8_t engr=0, uint8_t f0=0, uint8_t f1=0, uint8_t f2=0, uint8_t f3=0)