Line data Source code
1 : #include "wibmod/WIB1/ASIC_reg_mapping.hh"
2 : #include <iomanip>
3 : #include <iostream>
4 : #include <limits>
5 :
6 0 : ASIC_reg_mapping::ASIC_reg_mapping()
7 0 : : REGS(72)
8 : {
9 0 : }
10 :
11 : void
12 0 : ASIC_reg_mapping::set_board(const FE_ASIC_reg_mapping& fe_map, const ADC_ASIC_reg_mapping& adc_map)
13 : {
14 0 : const std::bitset<1152> fe_bits = fe_map.get_bits();
15 0 : const std::bitset<1152> adc_bits = adc_map.get_bits();
16 : const size_t chip_bits_len = 144;
17 0 : for (size_t iChip = 0; iChip < 8; iChip++) {
18 0 : std::bitset<chip_bits_len * 2> chip_bits;
19 0 : for (size_t iBit = 0; iBit < chip_bits_len; iBit++) {
20 0 : chip_bits[iBit] = adc_bits[iChip * chip_bits_len + iBit];
21 0 : chip_bits[iBit + chip_bits_len] = fe_bits[iChip * chip_bits_len + iBit];
22 : }
23 0 : for (size_t iReg = 0; iReg < 9; iReg++) {
24 0 : std::bitset<32> regBits;
25 0 : for (size_t iBit = 0; iBit < 32; iBit++) {
26 0 : regBits[iBit] = chip_bits[iBit + iReg * 32];
27 : }
28 0 : uint32_t regUInt = regBits.to_ulong();
29 0 : REGS[iChip * 9 + iReg] = regUInt;
30 : } // for iReg
31 : } // for iChip
32 0 : } // set_board
33 :
34 : std::vector<uint32_t>
35 0 : ASIC_reg_mapping::get_regs() const
36 : {
37 0 : return REGS;
38 : }
39 :
40 : void
41 0 : ASIC_reg_mapping::print() const
42 : {
43 0 : std::cout << "ASIC_reg_mapping (hex):" << std::endl;
44 :
45 0 : for (uint32_t i = 0; i < REGS.size(); ++i) {
46 0 : uint32_t reg = REGS[i];
47 0 : std::cout << std::hex << std::setfill('0') << std::setw(8) << reg << std::endl;
48 : // std::cout << reg << std::endl;
49 : }
50 0 : }
|