LCOV - code coverage report
Current view: top level - wibmod/src/WIB1 - ADC_ASIC_reg_mapping.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 58 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 7 0

            Line data    Source code
       1              : #include "wibmod/WIB1/ADC_ASIC_reg_mapping.hh"
       2              : #include <iostream>
       3              : 
       4            0 : ADC_ASIC_reg_mapping::ADC_ASIC_reg_mapping(): BITS()
       5              : {
       6            0 : }
       7              : 
       8            0 : void ADC_ASIC_reg_mapping::set_ch(uint8_t chip, uint8_t chn, uint8_t d, uint8_t pcsr, 
       9              :        uint8_t pdsr, uint8_t slp, uint8_t tstin)
      10              : {
      11            0 :   uint8_t tmp_d = ((d<<4)&0xF0);
      12            0 :   uint8_t tmp_d0 = (tmp_d & 0x80)>>3;
      13            0 :   uint8_t tmp_d1 = (tmp_d & 0x40)>>1;
      14            0 :   uint8_t tmp_d2 = (tmp_d & 0x20)<<1;
      15            0 :   uint8_t tmp_d3 = (tmp_d & 0x10)<<3;
      16            0 :   tmp_d = tmp_d0 + tmp_d1 + tmp_d2 + tmp_d3;
      17              : 
      18            0 :   unsigned long chn_reg = (tmp_d&0xF0) + ((pcsr&0x01)<<3) + ((pdsr&0x01)<<2) + ((slp&0x01)<<1) + ((tstin&0x01)<<0);
      19              : 
      20            0 :   std::bitset<8> bits(chn_reg);
      21            0 :   size_t start_pos = (8*16+16)*chip + (16-chn)*8;
      22            0 :   for(size_t iBit=0; iBit < 8; iBit++)
      23              :   {
      24            0 :     BITS[iBit+start_pos-8] = bits[iBit];
      25              :   }
      26            0 : }
      27            0 : void ADC_ASIC_reg_mapping::set_global(uint8_t chip, uint8_t f4, uint8_t f5, uint8_t slsb, 
      28              :                 uint8_t res4, uint8_t res3, uint8_t res2, 
      29              :                 uint8_t res1, uint8_t res0, uint8_t clk0, 
      30              :                 uint8_t clk1, uint8_t frqc, uint8_t engr, 
      31              :                 uint8_t f0, uint8_t f1, uint8_t f2, uint8_t f3)
      32              : {
      33            0 :   std::bitset<16> bits;
      34            0 :   bits[ 0] = res0 & 0x1;
      35            0 :   bits[ 1] = res1 & 0x1;
      36            0 :   bits[ 2] = res2 & 0x1;
      37            0 :   bits[ 3] = res3 & 0x1;
      38            0 :   bits[ 4] = res4 & 0x1;
      39            0 :   bits[ 5] = slsb & 0x1;
      40            0 :   bits[ 6] = f5 & 0x1;
      41            0 :   bits[ 7] = f4 & 0x1;
      42            0 :   bits[ 8] = f3 & 0x1;
      43            0 :   bits[ 9] = f2 & 0x1;
      44            0 :   bits[10] = f1 & 0x1;
      45            0 :   bits[11] = f0 & 0x1;
      46            0 :   bits[12] = engr & 0x1;
      47            0 :   bits[13] = frqc & 0x1;
      48            0 :   bits[14] = clk1 & 0x1;
      49            0 :   bits[15] = clk0 & 0x1;
      50              : 
      51            0 :   size_t start_pos = (8*16+16)*chip + 16*8;
      52            0 :   for(size_t iBit=0; iBit < 16; iBit++)
      53              :   {
      54            0 :     BITS[iBit+start_pos] = bits[iBit];
      55              :   }
      56            0 : }
      57            0 : void ADC_ASIC_reg_mapping::set_chip(uint8_t chip, 
      58              :                 uint8_t d, uint8_t pcsr, uint8_t pdsr, 
      59              :                 uint8_t slp, uint8_t tstin, uint8_t f4, uint8_t f5, 
      60              :                 uint8_t slsb, uint8_t res4, uint8_t res3, 
      61              :                 uint8_t res2, uint8_t res1, uint8_t res0, 
      62              :                 uint8_t clk0, uint8_t clk1, uint8_t frqc, 
      63              :                 uint8_t engr, uint8_t f0, uint8_t f1, 
      64              :                 uint8_t f2, uint8_t f3)
      65              : {
      66            0 :   for (size_t chn=0; chn<16; chn++)
      67              :   {
      68            0 :     set_ch(chip, chn, d, pcsr, pdsr, slp, tstin);
      69              :   }
      70              : 
      71            0 :   set_global( chip,
      72              :               f4, f5, slsb, res4, res3, res2, res1, res0,
      73              :               clk0, clk1, frqc, engr, f0, f1, f2, f3);
      74            0 : }
      75              : 
      76            0 : void ADC_ASIC_reg_mapping::set_board(uint8_t d, uint8_t pcsr, uint8_t pdsr, 
      77              :                 uint8_t slp, uint8_t tstin, uint8_t f4, uint8_t f5, 
      78              :                 uint8_t slsb, uint8_t res4, uint8_t res3, 
      79              :                 uint8_t res2, uint8_t res1, uint8_t res0, 
      80              :                 uint8_t clk0, uint8_t clk1, uint8_t frqc, 
      81              :                 uint8_t engr, uint8_t f0, uint8_t f1, 
      82              :                 uint8_t f2, uint8_t f3)
      83              : {
      84              : 
      85            0 :   for (size_t chip=0; chip<8; chip++)
      86              :   {
      87            0 :     set_chip(chip,
      88              :              d, pcsr, pdsr, slp, tstin,
      89              :              f4, f5, slsb, res4, res3, res2, res1, res0,
      90              :              clk0, clk1, frqc, engr, f0, f1, f2, f3);
      91              :   }
      92            0 : }
      93              : 
      94            0 : std::bitset<1152> ADC_ASIC_reg_mapping::get_bits() const
      95              : {
      96            0 :   return BITS;
      97              : }
      98              : 
      99            0 : void ADC_ASIC_reg_mapping::print() const
     100              : {
     101            0 :   std::cout << "ADC_ASIC_reg_mapping (binary):" << std::endl;
     102            0 :   std::string bitString = BITS.to_string<char,std::string::traits_type,std::string::allocator_type>();
     103            0 :   for(size_t iLine=0; iLine < 36; iLine++)
     104              :   {
     105            0 :     for(size_t iByte=0; iByte < 4; iByte++)
     106              :     {
     107            0 :       for(size_t iBit=0; iBit < 8; iBit++)
     108              :       {
     109            0 :         std::cout << bitString[iLine*32+iByte*8+iBit];
     110              :       }
     111            0 :       std::cout << ' ';
     112              :     }
     113            0 :     std::cout << std::endl;
     114              :   }
     115              :   //std::cout << BITS << std::endl;
     116            0 : }
        

Generated by: LCOV version 2.0-1