nrLDPC_debug.h 4.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

/*!\file nrLDPC_lut.h
 * \brief Defines the debugging functions
 * \author Sebastian Wagner (TCL Communications) Email: <mailto:sebastian.wagner@tcl.com>
 * \date 27-03-2018
 * \version 1.0
 * \note
 * \warning
 */

#ifndef __NR_LDPC_DEBUG__H__
#define __NR_LDPC_DEBUG__H__

#include <stdio.h>

/**
   Enum with possible LDPC data buffers
 */
typedef enum nrLDPC_buffers {
    nrLDPC_buffers_LLR_PROC, /**< LLR processing buffer */
    nrLDPC_buffers_CN_PROC, /**< CN processing buffer */
    nrLDPC_buffers_CN_PROC_RES, /**< CN processing results buffer */
    nrLDPC_buffers_BN_PROC, /**< BN processing buffer */
    nrLDPC_buffers_BN_PROC_RES, /**< BN processing results buffer */
    nrLDPC_buffers_LLR_RES /**< LLR results buffer */
} e_nrLDPC_buffers;

/**
   \brief Writes N data samples to a file
   \param fileName Name of the file
   \param p_data Pointer to the data
   \param N Number of values to write
*/
static inline void nrLDPC_writeFile(const char* fileName, int8_t* p_data, const uint32_t N)
{
    FILE *f;
    uint32_t i;

    f = fopen(fileName, "a");

    // Newline indicating new data
    fprintf(f, "\n");
    for (i=0; i < N; i++)
    {
        fprintf(f, "%d, ", p_data[i]);
    }

    fclose(f);
}

/**
   \brief Creates empty new file
   \param fileName Name of the file
*/
static inline void nrLDPC_initFile(const char* fileName)
{
    FILE *f;

    f = fopen(fileName, "w");

    fprintf(f, " ");

    fclose(f);
}

/**
   \brief Writes data of predefined buffers to file
   \param buffer Enum of buffer name to write
*/
90
static inline void nrLDPC_debug_writeBuffer2File(e_nrLDPC_buffers buffer, t_nrLDPC_procBuf* p_procBuf)
91 92 93 94 95
{
    switch (buffer)
    {
    case nrLDPC_buffers_LLR_PROC:
    {
96
        nrLDPC_writeFile("llrProcBuf.txt", p_procBuf->llrProcBuf, NR_LDPC_MAX_NUM_LLR);
97 98 99 100
        break;
    }
    case nrLDPC_buffers_CN_PROC:
    {
101
        nrLDPC_writeFile("cnProcBuf.txt", p_procBuf->cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF);
102 103 104 105
        break;
    }
    case nrLDPC_buffers_CN_PROC_RES:
    {
106
        nrLDPC_writeFile("cnProcBufRes.txt", p_procBuf->cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF);
107 108 109 110
        break;
    }
    case nrLDPC_buffers_BN_PROC:
    {
111
        nrLDPC_writeFile("bnProcBuf.txt", p_procBuf->bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF);
112 113 114 115
        break;
    }
    case nrLDPC_buffers_BN_PROC_RES:
    {
116
        nrLDPC_writeFile("bnProcBufRes.txt", p_procBuf->bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF);
117 118 119 120
        break;
    }
    case nrLDPC_buffers_LLR_RES:
    {
121
        nrLDPC_writeFile("llrRes.txt", p_procBuf->llrRes, NR_LDPC_MAX_NUM_LLR);
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
        break;
    }
    }
}

/**
   \brief Initializes file for writing a buffer
   \param buffer Enum of buffer name to write
*/
static inline void nrLDPC_debug_initBuffer2File(e_nrLDPC_buffers buffer)
{
    switch (buffer)
    {
    case nrLDPC_buffers_LLR_PROC:
    {
        nrLDPC_initFile("llrProcBuf.txt");
        break;
    }
    case nrLDPC_buffers_CN_PROC:
    {
        nrLDPC_initFile("cnProcBuf.txt");
        break;
    }
    case nrLDPC_buffers_CN_PROC_RES:
    {
        nrLDPC_initFile("cnProcBufRes.txt");
        break;
    }
    case nrLDPC_buffers_BN_PROC:
    {
        nrLDPC_initFile("bnProcBuf.txt");
        break;
    }
    case nrLDPC_buffers_BN_PROC_RES:
    {
        nrLDPC_initFile("bnProcBufRes.txt");
        break;
    }
    case nrLDPC_buffers_LLR_RES:
    {
        nrLDPC_initFile("llrRes.txt");
        break;
    }
    }
}

/**
   \brief Prints 256 data type
   \param in Input to print
*/
static inline void nrLDPC_debug_print256i_epi8(__m256i* in)
{
    uint32_t i;

    for (i=0; i<32; i++)
    {
        mexPrintf("%d ", ((int8_t*)&in)[i]);
    }
}

#endif