Commit 047e8e2c authored by Guy De Souza's avatar Guy De Souza

Merge branch 'nr_initialsync' of...

Merge branch 'nr_initialsync' of https://gitlab.eurecom.fr/oai/openairinterface5g into nr_initialsync
parents a9ccf1ca 054ac83d
...@@ -1063,18 +1063,14 @@ set(PHY_LDPCSRC ...@@ -1063,18 +1063,14 @@ set(PHY_LDPCSRC
) )
set(PHY_POLARSRC set(PHY_POLARSRC
${OPENAIR1_DIR}/PHY/CODING/nrPolar_init.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_init.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/get_3GPP_info_bit_pattern.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/get_crc_generator_matrix.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/get_PC_bit_pattern.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion_2.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_crc.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_crc.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_interleave.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "SIMULATION/TOOLS/defs.h" #include "SIMULATION/TOOLS/sim.h"
......
/*
* 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
*/
#include "nrPolar_tools/nr_polar_defs.h" #include "nrPolar_tools/nr_polar_defs.h"
#include "nrPolar_tools/nr_polar_pbch_defs.h" #include "nrPolar_tools/nr_polar_pbch_defs.h"
...@@ -8,6 +29,7 @@ void nr_polar_init(t_nrPolar_params* polarParams, int messageType) { ...@@ -8,6 +29,7 @@ void nr_polar_init(t_nrPolar_params* polarParams, int messageType) {
} else if (messageType == 1) { //PBCH } else if (messageType == 1) { //PBCH
polarParams->n_max = NR_POLAR_PBCH_N_MAX; polarParams->n_max = NR_POLAR_PBCH_N_MAX;
polarParams->i_il = NR_POLAR_PBCH_I_IL; polarParams->i_il = NR_POLAR_PBCH_I_IL;
polarParams->i_seg = NR_POLAR_PBCH_I_SEG;
polarParams->n_pc = NR_POLAR_PBCH_N_PC; polarParams->n_pc = NR_POLAR_PBCH_N_PC;
polarParams->n_pc_wm = NR_POLAR_PBCH_N_PC_WM; polarParams->n_pc_wm = NR_POLAR_PBCH_N_PC_WM;
polarParams->i_bil = NR_POLAR_PBCH_I_BIL; polarParams->i_bil = NR_POLAR_PBCH_I_BIL;
...@@ -22,19 +44,29 @@ void nr_polar_init(t_nrPolar_params* polarParams, int messageType) { ...@@ -22,19 +44,29 @@ void nr_polar_init(t_nrPolar_params* polarParams, int messageType) {
polarParams->crc_generator_matrix=crc24c_generator_matrix(polarParams->payloadBits); polarParams->crc_generator_matrix=crc24c_generator_matrix(polarParams->payloadBits);
polarParams->G_N = nr_polar_kronecker_power_matrices(polarParams->n); polarParams->G_N = nr_polar_kronecker_power_matrices(polarParams->n);
//polar_encoder vectors:
polarParams->nr_polar_crc = malloc(sizeof(uint8_t) * polarParams->crcParityBits);
polarParams->nr_polar_cPrime = malloc(sizeof(uint8_t) * polarParams->K);
polarParams->nr_polar_d = malloc(sizeof(uint8_t) * polarParams->N);
//Polar Coding vectors
polarParams->nr_polar_u = malloc(sizeof(uint8_t) * polarParams->N); //Decoder: nr_polar_uHat
polarParams->nr_polar_cPrime = malloc(sizeof(uint8_t) * polarParams->K); //Decoder: nr_polar_cHat
polarParams->nr_polar_b = malloc(sizeof(uint8_t) * polarParams->K); //Decoder: nr_polar_bHat
} else if (messageType == 2) { //UCI } else if (messageType == 2) { //UCI
} }
polarParams->Q_0_Nminus1 = nr_polar_sequence_pattern(polarParams->n); polarParams->Q_0_Nminus1 = nr_polar_sequence_pattern(polarParams->n);
polarParams->interleaving_pattern = (uint16_t *)malloc(sizeof(uint16_t) * polarParams->K); polarParams->interleaving_pattern = malloc(sizeof(uint16_t) * polarParams->K);
nr_polar_interleaving_pattern(polarParams->K, polarParams->i_il, polarParams->interleaving_pattern); nr_polar_interleaving_pattern(polarParams->K, polarParams->i_il, polarParams->interleaving_pattern);
polarParams->rate_matching_pattern = (uint16_t *)malloc(sizeof(uint16_t) * polarParams->encoderLength); polarParams->rate_matching_pattern = malloc(sizeof(uint16_t) * polarParams->encoderLength);
uint16_t *J = malloc(sizeof(uint16_t) * polarParams->N); uint16_t *J = malloc(sizeof(uint16_t) * polarParams->N);
nr_polar_rate_matching_pattern(polarParams->rate_matching_pattern, J, nr_polar_subblock_interleaver_pattern, nr_polar_rate_matching_pattern(polarParams->rate_matching_pattern, J,
polarParams->K, polarParams->N, polarParams->encoderLength); nr_polar_subblock_interleaver_pattern, polarParams->K, polarParams->N, polarParams->encoderLength);
polarParams->information_bit_pattern = malloc(sizeof(uint8_t) * polarParams->N); polarParams->information_bit_pattern = malloc(sizeof(uint8_t) * polarParams->N);
......
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
void get_3GPP_info_bit_pattern(uint16_t K, uint16_t n_PC, uint16_t Q_N_length, uint8_t E_r, uint8_t* P, uint16_t* Q_N, uint8_t** info_bit_pattern)
{
// GET_3GPP_INFO_BIT_PATTERN Obtain the 3GPP information bit pattern,
// according to Section 5.4.1.1 of 3GPP TS 38.212
//
// I should be an integer scalar. It specifies the number of bits in the
// information, CRC and PC bit sequence. It should be no greater than N or E.
//
// Q_N should be a row vector comprising N number of unique integers in the
// range 1 to N. Each successive element of Q_N provides the index of the
// next most reliable input to the polar encoder kernal, where the first
// element of Q_N gives the index of the least reliable bit and the last
// element gives the index of the most reliable bit.
//
// rate_matching_pattern should be a vector comprising E_r number of
// integers, each having a value in the range 1 to N. Each integer
// identifies which one of the N outputs from the polar encoder kernal
// provides the corresponding bit in the encoded bit sequence e.
//
// mode should have the value 'repetition', 'puncturing' or 'shortening'.
// This specifies how the rate matching has been achieved. 'repetition'
// indicates that some outputs of the polar encoder kernal are repeated in
// the encoded bit sequence two or more times. 'puncturing' and
// 'shortening' indicate that some outputs of the polar encoder kernal
// have been excluded from the encoded bit sequence. In the case of
// 'puncturing' these excluded bits could have values of 0 or 1. In the
// case of 'shortening' these excluded bits are guaranteed to have values
// of 0.
//
// info_bit_pattern will be a vector comprising N number of logical
// elements, each having the value true or false. The number of elements
// in info_bit_pattern having the value true will be I. These elements
// having the value true identify the positions of the information and
// CRC bits within the input to the polar encoder kernal. The
// information bit arrangement can be achieved according to
// u(info_bit_pattern) = a.
int I=K+n_PC;
if (I > Q_N_length) //I=K+n_PC
{
fprintf(stderr, "I=K+n_PC should be no greater than N.");
exit(-1);
}
if (I > E_r)
{
fprintf(stderr, "I=K+n_PC should be no greater than E.");
exit(-1);
}
//This is how the rate matching is described in TS 38.212
int J[Q_N_length];
int i,j;
for (j=0; j<Q_N_length; j++)
{
i=floor(32*(double)j/Q_N_length);
J[j] = P[i]*(Q_N_length/32)+(j%(Q_N_length/32));
}
//Q_Ftmp_N = [];
int Q_Ftmp_N_length= Q_N_length-E_r;
if (E_r < Q_N_length)
{
if ((double)(I)/E_r <= (double)7/16) // puncturing
{
//Q_Ftmp_N_length = Q_Ftmp_N_length + N-E;
if (E_r >= (double)3*Q_N_length/4)
{
//Q_Ftmp_N = [Q_Ftmp_N,0:ceil(3*N/4-E/2)-1];
Q_Ftmp_N_length = Q_Ftmp_N_length + ceil(3*Q_N_length/4-(double)E_r/2);
} else
{
//Q_Ftmp_N = [Q_Ftmp_N,0:ceil(9*N/16-E/4)-1];
Q_Ftmp_N_length = Q_Ftmp_N_length + ceil(9*Q_N_length/16-(double)E_r/4);
}
}
}
int* Q_Ftmp_N = (int *)malloc(sizeof(int)*Q_Ftmp_N_length);
if (Q_Ftmp_N == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
if (E_r < Q_N_length)
{
if ((double)I/E_r <= 7/16) // puncturing
{
for (j=0; j<Q_N_length-E_r; j++)
{
Q_Ftmp_N[j] = J[j];
}
if (E_r >= 3*Q_N_length/4)
{
for (j=0; j<ceil(3*Q_N_length/4-(double)E_r/2); j++)
{
Q_Ftmp_N[Q_N_length-E_r+1+j] = j;
}
} else
{
for (j=0; j<ceil(9*Q_N_length/16-(double)E_r/4); j++)
{
Q_Ftmp_N[Q_N_length-E_r+1+j] = j;
}
}
} else // shortening
{
for (j=E_r; j<Q_N_length; j++)
{
Q_Ftmp_N[j-E_r] = J[j];
}
}
}
//Q_Itmp_N = setdiff(Q_N-1,Q_Ftmp_N,'stable'); // -1 because TS 38.212 assumes that indices start at 0, not 1 like in Matlab
int Q_Itmp_N_length = Q_N_length;
int Q_Itmp_N_common[Q_N_length];
for(i=0; i<Q_N_length; i++)
{
Q_Itmp_N_common[i]=0; //1 if in common, otherwise 0
for (j=0; j<Q_Ftmp_N_length; j++)
{
if((int)Q_N[i]==Q_Ftmp_N[j])
{
Q_Itmp_N_common[i]=1;
Q_Itmp_N_length--;
break;
}
}
}
free(Q_Ftmp_N);
if (Q_Itmp_N_length < I)
{
fprintf(stderr, "Too many pre-frozen bits.");
exit(-1);
}
int* Q_Itmp_N = (int *)malloc(sizeof(int)*Q_Itmp_N_length);
if (Q_Itmp_N == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
j=0;
for(i=0; i<Q_N_length; i++)
{
if(!Q_Itmp_N_common[i]) //if not commonc
{
Q_Itmp_N[j]=(int)Q_N[i];
j++;
}
}
int* Q_I_N = (int *)malloc(sizeof(int)*(I));
if (Q_I_N == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
//Q_I_N=Q_Itmp_N(end-I+1:end);
for (j=Q_Itmp_N_length-(I); j<Q_Itmp_N_length; j++)
{
Q_I_N[j-(Q_Itmp_N_length-(I))]=Q_Itmp_N[j];
}
free(Q_Itmp_N);
//info_bit_pattern(Q_I_N+1) = true;
*info_bit_pattern = (uint8_t *)malloc(sizeof(uint8_t)*Q_N_length);
if (*info_bit_pattern == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for(j=0; j<Q_N_length; j++)
{
(*info_bit_pattern)[j]=0;
for(i=0; i<I; i++)
{
if(Q_I_N[i]==j)
{
(*info_bit_pattern)[j]=1;
break;
}
}
}
free(Q_I_N);
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
void get_PC_bit_pattern(uint16_t Q_N_length, uint16_t n_PC, uint8_t n_PC_wm, uint16_t* Q_N, uint8_t* info_bit_pattern, uint8_t** PC_bit_pattern)
{
// GET_PC_BIT_PATTERN Obtain the Parity Check (PC) bit pattern,
// according to Section 5.3.1.2 of 3GPP TS 38.212
//
// info_bit_pattern should be a vector comprising N number of logical
// elements, each having the value true or false. The number of elements
// in info_bit_pattern having the value true should be I, where
// I = A+P+n_PC. These elements having the value true identify the
// positions of the information, CRC and PC bits within the input to the
// polar encoder kernal.
//
// Q_N should be a row vector comprising N number of unique integers in the
// range 1 to N. Each successive element of Q_N provides the index of the
// next most reliable input to the polar encoder kernal, where the first
// element of Q_N gives the index of the least reliable bit and the last
// element gives the index of the most reliable bit.
//
// n_PC should be an integer scalar. It specifies the number of PC bits to
// use, where n_PC should be no greater than I.
//
// n_PC_wm should be an integer scalar. It specifies the number of PC bits
// that occupy some of the most reliable positions at the input to the
// polar encoder kernal. The remaining n_PC-n_PC_wm PC bits occupy some of
// the least reliable positions at the input to the polar encoder kernal.
// n_PC_wm should be no greater than n_PC.
//
// PC_bit_pattern will be a vector comprising N number of logical
// elements, each having the value true or false. The number of elements
// in PC_bit_pattern having the value true will be n_PC.
// These elements having the value true identify the positions of the
// PC bits within the input to the polar encoder kernal.
//N = length(info_bit_pattern); -> Q_N_length
//I = sum(info_bit_pattern);
int totInfoBit =0;
int j,i;
for (j=0; j<Q_N_length; j++)
{
if(info_bit_pattern[j])
totInfoBit++;
}
if (n_PC > totInfoBit)
{
fprintf(stderr, "n_PC should be no greater than totInfoBit.");
exit(-1);
}
if (n_PC_wm > n_PC)
{
fprintf(stderr, "n_PC_wm should be no greater than n_PC.");
exit(-1);
}
//Q_I = 1:N;
int* Q_I = (int*) malloc(sizeof(int)*Q_N_length);
if (Q_I == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for (j=0; j<Q_N_length; j++)
{
Q_I[j]=j+1;
}
//Q_N_I = intersect(Q_N, Q_I(info_bit_pattern), 'stable');
int Q_N_I_length=0;
int* Q_N_common = (int*) malloc(sizeof(int)*Q_N_length);
if (Q_N_common == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for (j=0; j<Q_N_length; j++) //init
{
Q_N_common[j]=0;
}
for (j=0; j<Q_N_length; j++) //look in Q_I
{
if(info_bit_pattern[j])
{
//Q_I(info_bit_pattern)
for (i=0; i<Q_N_length; i++) //look in Q_N
{
if(Q_N[i]+1==Q_I[j])
{
Q_N_common[i]=1;
Q_N_I_length++;
break;
}
}
}
}
free(Q_I);
int* Q_N_I = (int*) malloc(sizeof(int)*Q_N_I_length);
if (Q_N_I == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
i=0;
for(j=0; j<Q_N_length; j++)
{
if(Q_N_common[j])
{
Q_N_I[i]=Q_N[j]+1;
i++;
}
}
free(Q_N_common);
//int G_N = get_G_N(N);
//int w_g = sum(G_N,2);
//useless, I do this
int* w_g = (int*) malloc(sizeof(int)*Q_N_length);
if (w_g == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
w_g[0]=1;
w_g[1]=2;
int counter=2;
int n = log2(Q_N_length);
for(i=0; i<n-1; i++) //n=log2(N)
{
for(j=0; j<counter; j++)
{
w_g[counter+j]=w_g[j]*2;
}
counter = counter*2;
}
//Q_tilde_N_I = Q_N_I(n_PC+1:end); % This is what it says in TS 38.212
int* Q_tilde_N_I = (int*) malloc(sizeof(int)*(Q_N_I_length-n_PC));
if (Q_tilde_N_I == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
int* Q_tilde_N_I_flip = (int*) malloc(sizeof(int)*(Q_N_I_length-n_PC));
if (Q_tilde_N_I_flip == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for (i=0; i<Q_N_I_length-n_PC; i++)
{
Q_tilde_N_I[i]=Q_N_I[n_PC+i];
//Q_tilde_N_I_flip = fliplr(Q_tilde_N_I);
Q_tilde_N_I_flip[Q_N_I_length-n_PC-i-1] = Q_tilde_N_I[i];
}
//%Q_tilde_N_I = Q_N_I(n_PC-n_PC_wm+1:end); % I think that this would be slightly more elegant
//[w_g_sorted, indices] = sort(w_g(Q_tilde_N_I_flip));
int* w_g_sorted = (int*) malloc(sizeof(int)*(Q_N_I_length-n_PC));
if (w_g_sorted == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
int* indices = (int*) malloc(sizeof(int)*(Q_N_I_length-n_PC));
if (indices == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for (i=0; i<Q_N_I_length-n_PC; i++)
{
w_g_sorted[i]=w_g[Q_tilde_N_I_flip[i]-1]; // w_g(Q_tilde_N_I_flip), yet to sort
indices[i] = i;
}
free(Q_tilde_N_I);
free(w_g);
//bubble sort
int tempToSwap=0;
for (i = 0; i < (Q_N_I_length-n_PC)-1; i++)
{
for (j = 0; j < (Q_N_I_length-n_PC)-i-1; j++)
{
if (w_g_sorted[j] > w_g_sorted[j+1]) //then swap
{
tempToSwap = w_g_sorted[j];
w_g_sorted[j] = w_g_sorted[j+1];
w_g_sorted[j+1] = tempToSwap;
tempToSwap = indices[j];
indices[j] = indices[j+1];
indices[j+1] = tempToSwap;
}
}
}
free(w_g_sorted);
//Q_N_PC = [Q_N_I(1:n_PC-n_PC_wm), Q_tilde_N_I_flip(indices(1:n_PC_wm))];
int* Q_N_PC = (int*) malloc(sizeof(int)*(n_PC));
if (Q_N_PC == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for (i=0; i<n_PC-n_PC_wm; i++)
{
Q_N_PC[i]=Q_N_I[i]; //Q_N_PC = [Q_N_I(1:n_PC-n_PC_wm), ...
}
free(Q_N_I);
for (i=0; i<n_PC_wm; i++)
{
Q_N_PC[n_PC-n_PC_wm+i] = Q_tilde_N_I_flip[indices[i]];//... Q_tilde_N_I_flip(indices(1:n_PC_wm))];
}
free(Q_tilde_N_I_flip);
free(indices);
//PC_bit_pattern = false(1,N);
//PC_bit_pattern(Q_N_PC) = true;
*PC_bit_pattern = (uint8_t*) malloc(sizeof(uint8_t)*(Q_N_length));
if (*PC_bit_pattern == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for (i=0; i<Q_N_length; i++)
{
(*PC_bit_pattern)[i]=0;
for (j=0; j<n_PC; j++)
{
if (Q_N_PC[j]-1==i)
{
(*PC_bit_pattern)[i]=1;
break;
}
}
}
//free(Q_I);
//free(Q_N_common);
//free(Q_N_I);
//free(w_g);
//free(Q_tilde_N_I);
//free(Q_tilde_N_I_flip);
//free(w_g_sorted);
//free(indices);
free(Q_N_PC);
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
void get_crc_generator_matrix(uint8_t A, uint8_t P, uint8_t* crc_polynomial_pattern, uint8_t*** G_P)
{
// GET_CRC_GENERATOR_MATRIX Obtain a Cyclic Redudancy Check (CRC) generator
// matrix.
//
// A should be an integer scalar. It specifies the number of bits in the
// information bit sequence.
//
// crc_polynomial_pattern should be a binary row vector comprising P+1
// number of bits, each having the value 0 or 1. These bits parameterise a
// Cyclic Redundancy Check (CRC) comprising P bits. Each bit provides the
// coefficient of the corresponding element in the CRC generator
// polynomial. From left to right, the bits provide the coefficients for
// the elements D^P, D^P-1, D^P-2, ..., D^2, D, 1.
//
// G_P will be a K by P binary matrix. The CRC bits can be generated
// according to mod(a*G_P,2).
*G_P = (uint8_t **)malloc(A * sizeof(uint8_t *));
if (*G_P == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
int i,j;
for (i=0; i<A; i++)
{
(*G_P)[i] = (uint8_t *)malloc(P * sizeof(uint8_t));
if ((*G_P)[i] == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
}
if(A>0)
{
//G_P(end,:) = crc_polynomial_pattern(2:end);
for(i=0; i<P; i++)
{
(*G_P)[A-1][i] = crc_polynomial_pattern[i+1];
}
//for k = A-1:-1:1
// G_P(k,:) = xor([G_P(k+1,2:end),0],G_P(k+1,1)*crc_polynomial_pattern(2:end));
//end
for(j=A-2; j>-1; j--)
{
for(i=0; i<P; i++)
{
(*G_P)[j][i]=0; //init with zeros
}
for(i=1; i<P; i++)
{
if( (*G_P)[j+1][i] != ( (*G_P)[j+1][0])*crc_polynomial_pattern[i]) //xor
(*G_P)[j][i-1]=1;
}
if(0 != ( (*G_P)[j+1][0])*crc_polynomial_pattern[P]) //xor
(*G_P)[j][P-1]=1;
}
}
printf("G_P=\n");
for(i=0; i<A; i++)
{
for(j=0; j<P; j++)
{
printf("%i ", (int)(*G_P)[i][j]);
}
printf("\n");
}
}
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray){//First 2 parameters are in bytes. void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray){//First 2 parameters are in bytes.
......
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" /*
* 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
crc table initialization * except in compliance with the License.
* You may obtain a copy of the License at
*********************************************************/ *
/*static unsigned int crc24cTable[256]; * http://www.openairinterface.org/?page_id=698
static unsigned short crc11Table[256]; *
static unsigned char crc6Table[256]; * 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.
unsigned int crc24c (unsigned char * inptr, int bitlen) * See the License for the specific language governing permissions and
{ * limitations under the License.
*-------------------------------------------------------------------------------
int octetlen, resbit; * For more information about the OpenAirInterface (OAI) Software Alliance:
unsigned int crc = 0; * contact@openairinterface.org
octetlen = bitlen / 8; */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ crc24cTable[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
crc = (crc << resbit) ^ crc24cTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
return crc;
}
unsigned int crc11 (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; // Change in octets
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ (crc11Table[(*inptr++) ^ (crc >> 24)] << 16);
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc11Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
return crc;
}
unsigned int crc6 (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; // Change in octets
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = crc6Table[(*inptr++) ^ (crc >> 24)] << 24;
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc6Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 24);
return crc; #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
}
uint8_t check_crc(uint8_t *decoded_bytes, uint16_t len, uint8_t crc_type)
{
uint8_t crc_len,temp;
uint16_t oldcrc,crc;
switch (crc_type) {
case 0: //CRC24_A:
case 1: //CRC24_B:
crc_len=3;
break;
case 2: //CRC16:
crc_len=2;
break;
case 3: //CRC8:
crc_len=1;
break;
default:
crc_len=3;
}
// check the CRC
oldcrc= *((unsigned int *)(&decoded_bytes[(len>>3)-crc_len]));
switch (crc_type) {
case 0: //CRC24_A:
oldcrc&=0x00ffffff;
crc = crc24a(decoded_bytes,len-24)>>8;
temp=((uint8_t *)&crc)[2];
((uint8_t *)&crc)[2] = ((uint8_t *)&crc)[0];
((uint8_t *)&crc)[0] = temp;
break;
case 1: //CRC24_B:
oldcrc&=0x00ffffff;
crc = crc24b(decoded_bytes,len-24)>>8;
temp=((uint8_t *)&crc)[2];
((uint8_t *)&crc)[2] = ((uint8_t *)&crc)[0];
((uint8_t *)&crc)[0] = temp;
break;
case 2: //CRC16:
oldcrc&=0x0000ffff;
crc = crc16(decoded_bytes,len-16)>>16;
break;
case 3: //CRC8:
oldcrc&=0x000000ff;
crc = crc6(decoded_bytes,len-8)>>24;
break;
default:
printf("FATAL: Unknown CRC\n");
return(255);
break;
}
printf("old CRC %x, CRC %x \n",oldcrc,crc);
return (crc == oldcrc);
}*/
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){ uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){
...@@ -244,23 +134,3 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits){ ...@@ -244,23 +134,3 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits){
return crc_generator_matrix; return crc_generator_matrix;
} }
#ifdef DEBUG_CRC
/*******************************************************************/
/** Test code
/*******************************************************************/
#include <stdio.h>
main()
{
unsigned char test[] = "Thebigredfox";
crcTableInit();
//printf("%x\n", crcbit(test, sizeof(test) - 1, poly24a));
//printf("%x\n", crc24a(test, (sizeof(test) - 1)*8));
printf("%x\n", crcbit(test, sizeof(test) - 1, poly6));
printf("%x\n", crc6(test, (sizeof(test) - 1)*8));
}
#endif
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K, void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K,
uint16_t *Q_I_N, uint16_t *Q_PC_N, uint8_t n_PC){ int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC){
uint16_t k=0; uint16_t k=0;
uint8_t flag; uint8_t flag;
......
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
void nr_polar_bit_insertion_2(uint8_t* u, uint8_t* b, uint8_t* info_bit_pattern, uint8_t* PC_bit_pattern, uint16_t N)
{
int PC_circular_buffer_length=5;
int i, j;
int k=0;
int* y = (int*) malloc(sizeof(int)*PC_circular_buffer_length);
if (y == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
for(i=0; i<PC_circular_buffer_length; i++)
{
y[i]=0;
}
int tempToShift;
//for n=0:N-1
printf("u = ");
for(i=0; i<N; i++)
{
//y = [y(2:end),y(1)];
tempToShift=y[0];
for (j=0; j<PC_circular_buffer_length-1; j++)
{
y[j]=y[j+1];
}
y[PC_circular_buffer_length-1]=tempToShift;
//if info_bit_pattern(n+1)
// if PC_bit_pattern(n+1)
// u(n+1) = y(1);
// else
// u(n+1) = b(k+1);
// k=k+1;
// y(1) = xor(y(1),u(n+1));
if (info_bit_pattern[i])
{
if (PC_bit_pattern[i])
{
u[i] = y[1];
} else
{
u[i] = b[k];
k++;
y[1] = ( y[1]!=u[i]);
}
} else
{
u[i]=0;
}
printf("%i ", u[i]);
}
free(y);
}
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_polar_channel_interleaver_pattern(uint16_t *cip, uint8_t I_BIL, uint16_t E){ void nr_polar_channel_interleaver_pattern(uint16_t *cip, uint8_t I_BIL, uint16_t E){
......
/*
* 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 PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h
* \brief Defines the constant variables for polar coding of the DCI from 38-212, V15.1.1 2018-04.
* \author
* \date 2018
* \version 0.1
* \company Eurecom
* \email:
* \note
* \warning
*/
#ifndef __NR_POLAR_DCI_DEFS__H__
#define __NR_POLAR_DCI_DEFS__H__
//Sec. 7.3.3: Channel Coding
#define NR_POLAR_DCI_N_MAX 9 //uint8_t
#define NR_POLAR_DCI_I_IL 1 //uint8_t
//#define NR_POLAR_DCI_I_SEG 0 //uint8_t
#define NR_POLAR_DCI_N_PC 0 //uint8_t
#define NR_POLAR_DCI_N_PC_WM 0 //uint8_t
//Sec. 7.3.4: Rate Matching
#define NR_POLAR_DCI_I_BIL 0 //uint8_t
#endif
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" /*
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" * 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
*/
/* /*
* Return values: * Return values:
...@@ -7,8 +25,17 @@ ...@@ -7,8 +25,17 @@
* -1 --> All list entries have failed the CRC checks * -1 --> All list entries have failed the CRC checks
*/ */
int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarParams, uint8_t listSize, #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
double *aPrioriPayload, uint8_t pathMetricAppr){ #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
int8_t polar_decoder(
double *input,
uint8_t *output,
t_nrPolar_params *polarParams,
uint8_t listSize,
double *aPrioriPayload,
uint8_t pathMetricAppr)
{
uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
...@@ -27,8 +54,6 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara ...@@ -27,8 +54,6 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara
bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2);
} }
uint8_t **crc_generator_matrix=crc24c_generator_matrix(polarParams->payloadBits); //G_P
uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3
uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2
for (int i = 0; i < polarParams->K; i++){ for (int i = 0; i < polarParams->K; i++){
...@@ -38,7 +63,7 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara ...@@ -38,7 +63,7 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara
for (int i=0; i<polarParams->payloadBits; i++) { for (int i=0; i<polarParams->payloadBits; i++) {
for (int j=0; j<polarParams->crcParityBits; j++) { for (int j=0; j<polarParams->crcParityBits; j++) {
tempECGM[i][j]=crc_generator_matrix[i][j]; tempECGM[i][j]=polarParams->crc_generator_matrix[i][j];
} }
} }
for (int i=polarParams->payloadBits; i<polarParams->K; i++) { for (int i=polarParams->payloadBits; i<polarParams->K; i++) {
...@@ -203,9 +228,9 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara ...@@ -203,9 +228,9 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara
for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i];
if (decoderIterationCheck==0) { if (decoderIterationCheck==0) {
//perror("[SCL polar decoder] All list entries have failed the CRC checks."); //perror("[SCL polar decoder] All list entries have failed the CRC checks.");
free(crc_generator_matrix);
free(d_tilde); free(d_tilde);
free(pathMetric); free(pathMetric);
free(crcState);
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
...@@ -221,34 +246,30 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara ...@@ -221,34 +246,30 @@ int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarPara
for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i;
nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize);
uint8_t *nr_polar_uHat = malloc(sizeof(uint8_t) * polarParams->N);
uint8_t *nr_polar_cHat = malloc(sizeof(uint8_t) * polarParams->K);
uint8_t *nr_polar_bHat = malloc(sizeof(uint8_t) * polarParams->K);
for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) {
if ( crcState[listIndex[i]] == 1 ) { if ( crcState[listIndex[i]] == 1 ) {
for (int j = 0; j < polarParams->N; j++) nr_polar_uHat[j]=bit[j][0][listIndex[i]]; for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_u[j]=bit[j][0][listIndex[i]];
//Extract the information bits (û to ĉ) //Extract the information bits (û to ĉ)
nr_polar_info_bit_extraction(nr_polar_uHat, nr_polar_cHat, polarParams->information_bit_pattern, polarParams->N); nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N);
//Deinterleaving (ĉ to b) //Deinterleaving (ĉ to b)
nr_polar_deinterleaver(nr_polar_cHat, nr_polar_bHat, polarParams->interleaving_pattern, polarParams->K); nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K);
//Remove the CRC (â) //Remove the CRC (â)
for (int j = 0; j < polarParams->payloadBits; j++) output[j]=nr_polar_bHat[j]; for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_b[j];
break; break;
} }
} }
free(crc_generator_matrix);
free(d_tilde); free(d_tilde);
free(pathMetric); free(pathMetric);
free(nr_polar_uHat); free(crcState);
free(nr_polar_cHat);
free(nr_polar_bHat);
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K);
nr_free_uint8_t_2D_array(tempECGM, polarParams->K);
return(0); return(0);
} }
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU, void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU,
......
/*
* 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
*/
#ifndef __NR_POLAR_DEFS__H__ #ifndef __NR_POLAR_DEFS__H__
#define __NR_POLAR_DEFS__H__ #define __NR_POLAR_DEFS__H__
...@@ -9,9 +30,10 @@ ...@@ -9,9 +30,10 @@
static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 };
typedef struct nrPolar_params { struct nrPolar_params {
uint8_t n_max; uint8_t n_max;
uint8_t i_il; uint8_t i_il;
uint8_t i_seg;
uint8_t n_pc; uint8_t n_pc;
uint8_t n_pc_wm; uint8_t n_pc_wm;
uint8_t i_bil; uint8_t i_bil;
...@@ -25,7 +47,7 @@ typedef struct nrPolar_params { ...@@ -25,7 +47,7 @@ typedef struct nrPolar_params {
uint16_t *interleaving_pattern; uint16_t *interleaving_pattern;
uint16_t *rate_matching_pattern; uint16_t *rate_matching_pattern;
uint16_t *Q_0_Nminus1; const uint16_t *Q_0_Nminus1;
int16_t *Q_I_N; int16_t *Q_I_N;
int16_t *Q_F_N; int16_t *Q_F_N;
int16_t *Q_PC_N; int16_t *Q_PC_N;
...@@ -34,9 +56,17 @@ typedef struct nrPolar_params { ...@@ -34,9 +56,17 @@ typedef struct nrPolar_params {
uint8_t **crc_generator_matrix; //G_P uint8_t **crc_generator_matrix; //G_P
uint8_t **G_N; uint8_t **G_N;
} t_nrPolar_params;
void polar_encoder(uint8_t *input, uint8_t *channel_input, t_nrPolar_params* polarParams); //polar_encoder vectors:
uint8_t *nr_polar_crc;
uint8_t *nr_polar_b;
uint8_t *nr_polar_cPrime;
uint8_t *nr_polar_u;
uint8_t *nr_polar_d;
} __attribute__ ((__packed__));
typedef struct nrPolar_params t_nrPolar_params;
void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_params* polarParams);
int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarParams, int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarParams,
uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr); uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr);
...@@ -45,31 +75,23 @@ void nr_polar_init(t_nrPolar_params* polarParams, int messageType); ...@@ -45,31 +75,23 @@ void nr_polar_init(t_nrPolar_params* polarParams, int messageType);
uint8_t** nr_polar_kronecker_power_matrices(uint8_t n); uint8_t** nr_polar_kronecker_power_matrices(uint8_t n);
uint16_t* nr_polar_sequence_pattern(uint8_t n); const uint16_t* nr_polar_sequence_pattern(uint8_t n);
uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max); uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max);
void nr_polar_channel_interleaver_pattern(uint16_t *cip, uint8_t I_BIL, void nr_polar_channel_interleaver_pattern(uint16_t *cip, uint8_t I_BIL,
uint16_t E); uint16_t E);
void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, uint8_t *P_i_, void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_,
uint16_t K, uint16_t N, uint16_t E); uint16_t K, uint16_t N, uint16_t E);
void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp,
uint16_t K, uint16_t N, uint16_t E); uint16_t K, uint16_t N, uint16_t E);
void nr_polar_rate_matcher(uint8_t *input, unsigned char *output, uint16_t *pattern, uint16_t size);
void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_); void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_);
void nr_polar_interleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N,
uint16_t size); uint16_t *J, const uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E,
void nr_polar_deinterleaver(uint8_t *input, uint8_t *output, uint16_t *pattern,
uint16_t size);
void nr_polar_info_bit_pattern(uint8_t *ibp, uint16_t *Q_I_N, int16_t *Q_F_N,
uint16_t *J, uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E,
uint8_t n_PC); uint8_t n_PC);
void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output,
...@@ -78,7 +100,7 @@ void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, ...@@ -78,7 +100,7 @@ void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output,
void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray); void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray);
void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N,
uint16_t K, uint16_t *Q_I_N, uint16_t *Q_PC_N, uint8_t n_PC); uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC);
void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2, void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2,
uint8_t *output, uint16_t row, uint16_t col); uint8_t *output, uint16_t row, uint16_t col);
...@@ -109,4 +131,20 @@ void updateCrcChecksum2(uint8_t **crcChecksum, uint8_t **crcGen, ...@@ -109,4 +131,20 @@ void updateCrcChecksum2(uint8_t **crcChecksum, uint8_t **crcGen,
uint8_t listSize, uint32_t i2, uint8_t len); uint8_t listSize, uint32_t i2, uint8_t len);
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len); void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len);
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits);
uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits);
uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits);
static inline void nr_polar_rate_matcher(uint8_t *input, unsigned char *output, uint16_t *pattern, uint16_t size) {
for (int i=0; i<size; i++) output[i]=input[pattern[i]];
}
static inline void nr_polar_interleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, uint16_t size) {
for (int i=0; i<size; i++) output[i]=input[pattern[i]];
}
static inline void nr_polar_deinterleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, uint16_t size) {
for (int i=0; i<size; i++) output[pattern[i]]=input[i];
}
#endif #endif
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
void polar_encoder(uint8_t *input, uint8_t *channel_input, t_nrPolar_params *polarParams){ void polar_encoder(
/*//Create the Transport Block. uint8_t *input,
unsigned int payload=0xb3f02c82; uint8_t *output,
uint8_t pbchTransportBlockSize = ( polarParams->K / (8*sizeof(uint8_t)) ); t_nrPolar_params *polarParams)
uint8_t *pbchTransportBlock = malloc(pbchTransportBlockSize); {
memcpy(pbchTransportBlock,&payload,sizeof(payload));
//Attach CRC to the Transport Block. (a to b)
uint32_t crc = crc24c(&payload, NR_POLAR_PBCH_PAYLOAD_BITS)>>8;
pbchTransportBlock[NR_POLAR_PBCH_PAYLOAD_BITS>>3] = ((uint8_t*)&crc)[2];
pbchTransportBlock[1+(NR_POLAR_PBCH_PAYLOAD_BITS>>3)] = ((uint8_t*)&crc)[1];
pbchTransportBlock[2+(NR_POLAR_PBCH_PAYLOAD_BITS>>3)] = ((uint8_t*)&crc)[0];*/
/* /*
* Bytewise operations * Bytewise operations
*/ */
//Calculate CRC. //Calculate CRC.
uint8_t *nr_polar_crc = malloc(sizeof(uint8_t) * polarParams->crcParityBits);
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(input, polarParams->crc_generator_matrix, nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(input, polarParams->crc_generator_matrix,
nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits); polarParams->nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits);
for (uint8_t i = 0; i < polarParams->crcParityBits; i++) nr_polar_crc[i] = (nr_polar_crc[i] % 2); for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2);
//Attach CRC to the Transport Block. (a to b) //Attach CRC to the Transport Block. (a to b)
uint8_t *nr_polar_b = malloc(sizeof(uint8_t) * polarParams->K); for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_b[i] = input[i];
for (uint16_t i = 0; i < polarParams->payloadBits; i++) nr_polar_b[i] = input[i]; for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++)
for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) nr_polar_b[i]= nr_polar_crc[i-(polarParams->payloadBits)]; polarParams->nr_polar_b[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)];
//Interleaving (c to c') //Interleaving (c to c')
uint8_t *nr_polar_cPrime = malloc(sizeof(uint8_t) * polarParams->K); nr_polar_interleaver(polarParams->nr_polar_b, polarParams->nr_polar_cPrime, polarParams->interleaving_pattern, polarParams->K);
nr_polar_interleaver(nr_polar_b, nr_polar_cPrime, polarParams->interleaving_pattern, polarParams->K);
//Bit insertion (c' to u) //Bit insertion (c' to u)
uint8_t *nr_polar_u = malloc(sizeof(uint8_t) * polarParams->N); nr_polar_bit_insertion(polarParams->nr_polar_cPrime, polarParams->nr_polar_u, polarParams->N, polarParams->K,
nr_polar_bit_insertion(nr_polar_cPrime, nr_polar_u, polarParams->N, polarParams->K,
polarParams->Q_I_N, polarParams->Q_PC_N, polarParams->n_pc); polarParams->Q_I_N, polarParams->Q_PC_N, polarParams->n_pc);
//Encoding (u to d) //Encoding (u to d)
uint8_t *pbch_polar_encoder_output = malloc(sizeof(uint8_t) * polarParams->N); nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_u, polarParams->G_N, polarParams->nr_polar_d, polarParams->N, polarParams->N);
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(nr_polar_u, polarParams->G_N, pbch_polar_encoder_output, polarParams->N, polarParams->N); for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2);
for (uint16_t i = 0; i < polarParams->N; i++) pbch_polar_encoder_output[i] = (pbch_polar_encoder_output[i] % 2);
//Rate matching //Rate matching
//Sub-block interleaving (d to y) and Bit selection (y to e) //Sub-block interleaving (d to y) and Bit selection (y to e)
nr_polar_rate_matcher(pbch_polar_encoder_output, channel_input, polarParams->rate_matching_pattern, polarParams->encoderLength); nr_polar_rate_matcher(polarParams->nr_polar_d, output, polarParams->rate_matching_pattern, polarParams->encoderLength);
//free(pbchTransportBlock);
free(nr_polar_crc);
free(nr_polar_b);
free(nr_polar_cPrime);
free(nr_polar_u);
free(pbch_polar_encoder_output);
} }
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_polar_info_bit_pattern(uint8_t *ibp, uint16_t *Q_I_N, int16_t *Q_F_N, void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N,
uint16_t *J, uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E, uint16_t *J, const uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E,
uint8_t n_PC) { uint8_t n_PC) {
int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final
......
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){ void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){
...@@ -27,11 +48,3 @@ void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){ ...@@ -27,11 +48,3 @@ void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){
} }
} }
} }
void nr_polar_interleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, uint16_t size) {
for (int i=0; i<size; i++) output[i]=input[pattern[i]];
}
void nr_polar_deinterleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, uint16_t size) {
for (int i=0; i<size; i++) output[pattern[i]]=input[i];
}
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
uint8_t (*const(G_N_1[])) = { uint8_t (*const(G_N_1[])) = {
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2, void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2,
......
/*
* 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
*/
#include <math.h> #include <math.h>
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
......
/* /*
* Defines the constant variables for polar coding of the PBCH. * 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 PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h
* \brief Defines the constant variables for polar coding of the PBCH from 38-212, V15.1.1 2018-04.
* \author
* \date 2018
* \version 0.1
* \company Eurecom
* \email:
* \note
* \warning
*/
#ifndef __NR_POLAR_PBCH_DEFS__H__ #ifndef __NR_POLAR_PBCH_DEFS__H__
#define __NR_POLAR_PBCH_DEFS__H__ #define __NR_POLAR_PBCH_DEFS__H__
...@@ -10,14 +38,15 @@ ...@@ -10,14 +38,15 @@
#define NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS 3 #define NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS 3
//Assumed 3 by 3GPP when NR_POLAR_PBCH_L>8 to meet false alarm rate requirements. //Assumed 3 by 3GPP when NR_POLAR_PBCH_L>8 to meet false alarm rate requirements.
//Ref. 38-212 v15.0.1, Section 7.1.4: Channel Coding //Sec. 7.1.4: Channel Coding
#define NR_POLAR_PBCH_N_MAX 9 //uint8_t #define NR_POLAR_PBCH_N_MAX 9 //uint8_t
#define NR_POLAR_PBCH_I_IL 1 //uint8_t #define NR_POLAR_PBCH_I_IL 1 //uint8_t
#define NR_POLAR_PBCH_I_SEG 0 //uint8_t
#define NR_POLAR_PBCH_N_PC 0 //uint8_t #define NR_POLAR_PBCH_N_PC 0 //uint8_t
#define NR_POLAR_PBCH_N_PC_WM 0 //uint8_t #define NR_POLAR_PBCH_N_PC_WM 0 //uint8_t
//#define NR_POLAR_PBCH_N 512 //uint16_t //#define NR_POLAR_PBCH_N 512 //uint16_t
//Ref. 38-212 v15.0.1, Section 7.1.5: Rate Matching //Sec. 7.1.5: Rate Matching
#define NR_POLAR_PBCH_I_BIL 0 //uint8_t #define NR_POLAR_PBCH_I_BIL 0 //uint8_t
#define NR_POLAR_PBCH_E 864 //uint16_t #define NR_POLAR_PBCH_E 864 //uint16_t
......
/*
* 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
*/
#include <math.h> #include <math.h>
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){
uint8_t i; uint8_t i;
uint16_t *d, *y, ind; uint16_t *d, *y, ind;
...@@ -58,7 +79,3 @@ void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16 ...@@ -58,7 +79,3 @@ void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16
} }
} }
void nr_polar_rate_matcher(uint8_t *input, unsigned char *output, uint16_t *pattern, uint16_t size) {
for (int i=0; i<size; i++) output[i]=input[pattern[i]];
}
/*
* 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
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
static const uint16_t Q_0_Nminus1_1[2] = { 0, 1 }; static const uint16_t Q_0_Nminus1_1[2] = { 0, 1 };
...@@ -14,6 +35,6 @@ static const uint16_t Q_0_Nminus1_10[1024] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, ...@@ -14,6 +35,6 @@ static const uint16_t Q_0_Nminus1_10[1024] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 64,
static const uint16_t *Q_0_Nminus1[11] = { NULL, Q_0_Nminus1_1, Q_0_Nminus1_2, Q_0_Nminus1_3, Q_0_Nminus1_4, static const uint16_t *Q_0_Nminus1[11] = { NULL, Q_0_Nminus1_1, Q_0_Nminus1_2, Q_0_Nminus1_3, Q_0_Nminus1_4,
Q_0_Nminus1_5, Q_0_Nminus1_6, Q_0_Nminus1_7, Q_0_Nminus1_8, Q_0_Nminus1_9, Q_0_Nminus1_10 }; Q_0_Nminus1_5, Q_0_Nminus1_6, Q_0_Nminus1_7, Q_0_Nminus1_8, Q_0_Nminus1_9, Q_0_Nminus1_10 };
uint16_t* nr_polar_sequence_pattern(uint8_t n){ const uint16_t* nr_polar_sequence_pattern(uint8_t n){
return Q_0_Nminus1[n]; return Q_0_Nminus1[n];
} }
/*
* 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 PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h
* \brief Defines the constant variables for polar coding of the UCI from 38-212, V15.1.1 2018-04.
* \author
* \date 2018
* \version 0.1
* \company Eurecom
* \email:
* \note
* \warning
*/
#ifndef __NR_POLAR_UCI_DEFS__H__
#define __NR_POLAR_UCI_DEFS__H__
#endif
...@@ -158,7 +158,6 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d ...@@ -158,7 +158,6 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d
fprintf(fp,"\n%d,",((short *)data)[i]); fprintf(fp,"\n%d,",((short *)data)[i]);
} }
printf("\n erennnnnnnnnnnnnnn: length :%d",length);
break; break;
case 12 : // case eren for log2_maxh real unsigned 8 bit case 12 : // case eren for log2_maxh real unsigned 8 bit
...@@ -170,10 +169,8 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d ...@@ -170,10 +169,8 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d
if (format != 10 && format !=11 && format !=12 && format != 13 && format != 15) { if (format != 10 && format !=11 && format !=12 && format != 13 && format != 15) {
fprintf(fp,"];\n"); fprintf(fp,"];\n");
fclose(fp); fclose(fp);
return(0);
} else if (format == 10 || format ==11 || format == 12 || format == 13 || format == 15) { } else if (format == 10 || format ==11 || format == 12 || format == 13 || format == 15) {
fclose(fp); fclose(fp);
return(0);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment