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 % 60 0
Test Date: 2026-10-11 15:05:20 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()
       5            0 :   : BITS()
       6              : {
       7            0 : }
       8              : 
       9              : void
      10            0 : ADC_ASIC_reg_mapping::set_ch(uint8_t chip,
      11              :                              uint8_t chn,
      12              :                              uint8_t d,
      13              :                              uint8_t pcsr,
      14              :                              uint8_t pdsr,
      15              :                              uint8_t slp,
      16              :                              uint8_t tstin)
      17              : {
      18            0 :   uint8_t tmp_d = ((d << 4) & 0xF0);
      19            0 :   uint8_t tmp_d0 = (tmp_d & 0x80) >> 3;
      20            0 :   uint8_t tmp_d1 = (tmp_d & 0x40) >> 1;
      21            0 :   uint8_t tmp_d2 = (tmp_d & 0x20) << 1;
      22            0 :   uint8_t tmp_d3 = (tmp_d & 0x10) << 3;
      23            0 :   tmp_d = tmp_d0 + tmp_d1 + tmp_d2 + tmp_d3;
      24              : 
      25            0 :   unsigned long chn_reg =
      26            0 :     (tmp_d & 0xF0) + ((pcsr & 0x01) << 3) + ((pdsr & 0x01) << 2) + ((slp & 0x01) << 1) + ((tstin & 0x01) << 0);
      27              : 
      28            0 :   std::bitset<8> bits(chn_reg);
      29            0 :   size_t start_pos = (8 * 16 + 16) * chip + (16 - chn) * 8;
      30            0 :   for (size_t iBit = 0; iBit < 8; iBit++) {
      31            0 :     BITS[iBit + start_pos - 8] = bits[iBit];
      32              :   }
      33            0 : }
      34              : void
      35            0 : ADC_ASIC_reg_mapping::set_global(uint8_t chip,
      36              :                                  uint8_t f4,
      37              :                                  uint8_t f5,
      38              :                                  uint8_t slsb,
      39              :                                  uint8_t res4,
      40              :                                  uint8_t res3,
      41              :                                  uint8_t res2,
      42              :                                  uint8_t res1,
      43              :                                  uint8_t res0,
      44              :                                  uint8_t clk0,
      45              :                                  uint8_t clk1,
      46              :                                  uint8_t frqc,
      47              :                                  uint8_t engr,
      48              :                                  uint8_t f0,
      49              :                                  uint8_t f1,
      50              :                                  uint8_t f2,
      51              :                                  uint8_t f3)
      52              : {
      53            0 :   std::bitset<16> bits;
      54            0 :   bits[0] = res0 & 0x1;
      55            0 :   bits[1] = res1 & 0x1;
      56            0 :   bits[2] = res2 & 0x1;
      57            0 :   bits[3] = res3 & 0x1;
      58            0 :   bits[4] = res4 & 0x1;
      59            0 :   bits[5] = slsb & 0x1;
      60            0 :   bits[6] = f5 & 0x1;
      61            0 :   bits[7] = f4 & 0x1;
      62            0 :   bits[8] = f3 & 0x1;
      63            0 :   bits[9] = f2 & 0x1;
      64            0 :   bits[10] = f1 & 0x1;
      65            0 :   bits[11] = f0 & 0x1;
      66            0 :   bits[12] = engr & 0x1;
      67            0 :   bits[13] = frqc & 0x1;
      68            0 :   bits[14] = clk1 & 0x1;
      69            0 :   bits[15] = clk0 & 0x1;
      70              : 
      71            0 :   size_t start_pos = (8 * 16 + 16) * chip + 16 * 8;
      72            0 :   for (size_t iBit = 0; iBit < 16; iBit++) {
      73            0 :     BITS[iBit + start_pos] = bits[iBit];
      74              :   }
      75            0 : }
      76              : void
      77            0 : ADC_ASIC_reg_mapping::set_chip(uint8_t chip,
      78              :                                uint8_t d,
      79              :                                uint8_t pcsr,
      80              :                                uint8_t pdsr,
      81              :                                uint8_t slp,
      82              :                                uint8_t tstin,
      83              :                                uint8_t f4,
      84              :                                uint8_t f5,
      85              :                                uint8_t slsb,
      86              :                                uint8_t res4,
      87              :                                uint8_t res3,
      88              :                                uint8_t res2,
      89              :                                uint8_t res1,
      90              :                                uint8_t res0,
      91              :                                uint8_t clk0,
      92              :                                uint8_t clk1,
      93              :                                uint8_t frqc,
      94              :                                uint8_t engr,
      95              :                                uint8_t f0,
      96              :                                uint8_t f1,
      97              :                                uint8_t f2,
      98              :                                uint8_t f3)
      99              : {
     100            0 :   for (size_t chn = 0; chn < 16; chn++) {
     101            0 :     set_ch(chip, chn, d, pcsr, pdsr, slp, tstin);
     102              :   }
     103              : 
     104            0 :   set_global(chip, f4, f5, slsb, res4, res3, res2, res1, res0, clk0, clk1, frqc, engr, f0, f1, f2, f3);
     105            0 : }
     106              : 
     107              : void
     108            0 : ADC_ASIC_reg_mapping::set_board(uint8_t d,
     109              :                                 uint8_t pcsr,
     110              :                                 uint8_t pdsr,
     111              :                                 uint8_t slp,
     112              :                                 uint8_t tstin,
     113              :                                 uint8_t f4,
     114              :                                 uint8_t f5,
     115              :                                 uint8_t slsb,
     116              :                                 uint8_t res4,
     117              :                                 uint8_t res3,
     118              :                                 uint8_t res2,
     119              :                                 uint8_t res1,
     120              :                                 uint8_t res0,
     121              :                                 uint8_t clk0,
     122              :                                 uint8_t clk1,
     123              :                                 uint8_t frqc,
     124              :                                 uint8_t engr,
     125              :                                 uint8_t f0,
     126              :                                 uint8_t f1,
     127              :                                 uint8_t f2,
     128              :                                 uint8_t f3)
     129              : {
     130              : 
     131            0 :   for (size_t chip = 0; chip < 8; chip++) {
     132            0 :     set_chip(chip,
     133              :              d,
     134              :              pcsr,
     135              :              pdsr,
     136              :              slp,
     137              :              tstin,
     138              :              f4,
     139              :              f5,
     140              :              slsb,
     141              :              res4,
     142              :              res3,
     143              :              res2,
     144              :              res1,
     145              :              res0,
     146              :              clk0,
     147              :              clk1,
     148              :              frqc,
     149              :              engr,
     150              :              f0,
     151              :              f1,
     152              :              f2,
     153              :              f3);
     154              :   }
     155            0 : }
     156              : 
     157              : std::bitset<1152>
     158            0 : ADC_ASIC_reg_mapping::get_bits() const
     159              : {
     160            0 :   return BITS;
     161              : }
     162              : 
     163              : void
     164            0 : ADC_ASIC_reg_mapping::print() const
     165              : {
     166            0 :   std::cout << "ADC_ASIC_reg_mapping (binary):" << std::endl;
     167            0 :   std::string bitString = BITS.to_string<char, std::string::traits_type, std::string::allocator_type>();
     168            0 :   for (size_t iLine = 0; iLine < 36; iLine++) {
     169            0 :     for (size_t iByte = 0; iByte < 4; iByte++) {
     170            0 :       for (size_t iBit = 0; iBit < 8; iBit++) {
     171            0 :         std::cout << bitString[iLine * 32 + iByte * 8 + iBit];
     172              :       }
     173            0 :       std::cout << ' ';
     174              :     }
     175            0 :     std::cout << std::endl;
     176              :   }
     177              :   // std::cout << BITS << std::endl;
     178            0 : }
        

Generated by: LCOV version 2.0-1