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