Added MEX tests for PBCH and Viterbi

This commit is contained in:
ismagom 2014-12-15 23:34:44 +00:00
parent e98f718806
commit 204fa85144
12 changed files with 45 additions and 8 deletions

View File

@ -37,6 +37,8 @@
#include "liblte/phy/common/phy_common.h"
#include "liblte/phy/utils/dft.h"
//#define LTE_FFT_NORMALIZE
typedef _Complex float cf_t; /* this is only a shortcut */
/* This is common for both directions */

View File

@ -42,6 +42,7 @@ typedef struct LIBLTE_API{
uint32_t K;
uint32_t framebits;
bool tail_biting;
float gain_quant;
uint32_t poly[3];
int (*decode) (void*, uint8_t*, uint8_t*, uint32_t);
void (*free) (void*);
@ -55,6 +56,9 @@ LIBLTE_API int viterbi_init(viterbi_t *q,
uint32_t max_frame_length,
bool tail_bitting);
LIBLTE_API void viterbi_set_gain_quant(viterbi_t *q,
float gain_quant);
LIBLTE_API void viterbi_free(viterbi_t *q);
LIBLTE_API int viterbi_decode_f(viterbi_t *q,

View File

@ -115,7 +115,8 @@ int chest_dl_init(chest_dl_t *q, lte_cell_t cell)
}
/* Set default time/freq filters */
float f[3]={0.15, 0.7, 0.15};
//float f[3]={0.15, 0.7, 0.15};
float f[3]={0.2, 0.6, 0.2};
chest_dl_set_filter_freq(q, f, 3);
float t[2]={0.1, 0.9};

View File

@ -53,8 +53,10 @@ int lte_fft_init_(lte_fft_t *q, lte_cp_t cp, uint32_t nof_prb, dft_dir_t dir) {
}
dft_plan_set_mirror(&q->fft_plan, true);
dft_plan_set_norm(&q->fft_plan, true);
dft_plan_set_dc(&q->fft_plan, true);
#ifdef LTE_FFT_NORMALIZE
dft_plan_set_norm(&q->fft_plan, true);
#endif
q->symbol_sz = (uint32_t) symbol_sz;
q->nof_symbols = CP_NSYMB(cp);

View File

@ -119,6 +119,7 @@ int init37(viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting)
q->K = 7;
q->R = 3;
q->framebits = framebits;
q->gain_quant = 32;
q->tail_biting = tail_biting;
q->decode = decode37;
q->free = free37;
@ -152,6 +153,7 @@ int init39(viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting)
q->R = 3;
q->framebits = framebits;
q->tail_biting = tail_biting;
q->gain_quant = 32;
q->decode = decode39;
q->free = free39;
if (q->tail_biting) {
@ -173,6 +175,10 @@ int init39(viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting)
}
}
void viterbi_set_gain_quant(viterbi_t *q, float gain_quant) {
q->gain_quant = gain_quant;
}
int viterbi_init(viterbi_t *q, viterbi_type_t type, uint32_t poly[3],
uint32_t max_frame_length, bool tail_bitting) {
switch (type) {
@ -206,7 +212,7 @@ int viterbi_decode_f(viterbi_t *q, float *symbols, uint8_t *data, uint32_t frame
} else {
len = 3 * (frame_length + q->K - 1);
}
vec_quant_fuc(symbols, q->symbols_uc, 32, 127.5, 255, len);
vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant, 127.5, 255, len);
return q->decode(q, q->symbols_uc, data, frame_length);
}

View File

@ -77,7 +77,6 @@ void *create_viterbi37_port(uint32_t polys[3], uint32_t len) {
free(vp);
return NULL ;
}
init_viterbi37_port(vp, 0);
return vp;
}
@ -179,7 +178,7 @@ int update_viterbi37_blk_port(void *p, uint8_t *syms, uint32_t nbits, uint32_t *
uint32_t i, bst=0;
uint32_t minmetric=UINT_MAX;
for (i=0;i<64;i++) {
if (vp->old_metrics->w[i] < minmetric) {
if (vp->old_metrics->w[i] <= minmetric) {
bst = i;
minmetric = vp->old_metrics->w[i];
}

View File

@ -67,6 +67,8 @@ ADD_TEST(viterbi_1000_2 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 2.0)
ADD_TEST(viterbi_1000_3 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 3.0)
ADD_TEST(viterbi_1000_4 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 4.5)
BuildMex(MEXNAME viterbi SOURCES viterbi_test_mex.c LIBRARIES lte_phy liblte_mex)
########################################################################
# CRC TEST
########################################################################

View File

@ -174,6 +174,8 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[MAX_PORTS], cf_t *x[M
vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2);
}
vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2);
// x[0] = r0·h0*/(|h0|+|h1|)+r1*·h1/(|h0|+|h1|)
vec_prod_conj_ccc(r0,h0,q->tmp1, nof_symbols/2);
vec_prod_conj_ccc(h1,r1,q->tmp2, nof_symbols/2);

View File

@ -33,6 +33,8 @@ ADD_TEST(pbch_test_50 pbch_test -p 1 -n 50 -c 50)
ADD_TEST(pbch_test_502 pbch_test -p 2 -n 50 -c 50)
ADD_TEST(pbch_test_504 pbch_test -p 4 -n 50 -c 50)
BuildMex(MEXNAME pbch SOURCES pbch_test_mex.c LIBRARIES lte_phy liblte_mex)
########################################################################
# PCFICH TEST

View File

@ -3,8 +3,8 @@
%% Cell-Wide Settings
% A structure |enbConfig| is used to configure the eNodeB.
Npackets = 50;
SNR_values =linspace(-5,3,8);
Npackets = 1;
SNR_values =20;%linspace(-5,3,8);
enbConfig.NDLRB = 15; % No of Downlink RBs in total BW
enbConfig.CyclicPrefix = 'Normal'; % CP length
@ -67,7 +67,7 @@ subframe_tx(pdcchIndices) = pdcchSymbols;
addpath('../../debug/lte/phy/lib/phch/test')
parfor snr_idx=1:length(SNR_values)
for snr_idx=1:length(SNR_values)
SNRdB = SNR_values(snr_idx);
for i=1:Npackets

View File

@ -61,6 +61,11 @@ LIBLTE_API int mexutils_write_cf(cf_t *buffer,
uint32_t nr,
uint32_t nc);
LIBLTE_API int mexutils_write_uint8(uint8_t *buffer,
mxArray **ptr,
uint32_t nr,
uint32_t nc);
LIBLTE_API int mexutils_read_f(const mxArray *ptr,
float **buffer);

View File

@ -25,6 +25,7 @@
*
*/
#include <string.h>
#include <complex.h>
#include "liblte/phy/common/phy_common.h"
#include "liblte/mex/mexutils.h"
@ -126,3 +127,14 @@ int mexutils_write_f(float *buffer, mxArray **ptr, uint32_t nr, uint32_t nc) {
}
}
int mexutils_write_uint8(uint8_t *buffer, mxArray **ptr, uint32_t nr, uint32_t nc) {
*ptr = mxCreateNumericMatrix(nr, nc, mxUINT8_CLASS, mxREAL);
if (*ptr) {
uint8_t *outr = (uint8_t*) mxGetPr(*ptr);
memcpy(outr, buffer, nr*nc*sizeof(uint8_t));
return nc*nr;
} else {
return -1;
}
}