mirror of https://github.com/PentHertz/srsLTE.git
Added PUSCH DRMS signal generation
This commit is contained in:
parent
729519ac7e
commit
9a614ec9d1
|
@ -51,7 +51,7 @@ typedef struct LIBLTE_API {
|
|||
} refsignal_cs_t;
|
||||
|
||||
|
||||
LIBLTE_API int refsignal_cs_generate(refsignal_cs_t *q,
|
||||
LIBLTE_API int refsignal_cs_init(refsignal_cs_t *q,
|
||||
lte_cell_t cell);
|
||||
|
||||
LIBLTE_API void refsignal_cs_free(refsignal_cs_t *q);
|
||||
|
@ -66,12 +66,12 @@ LIBLTE_API int refsignal_cs_get_sf(lte_cell_t cell,
|
|||
cf_t *sf_symbols,
|
||||
cf_t *pilots);
|
||||
|
||||
LIBLTE_API uint32_t refsignal_fidx(lte_cell_t cell,
|
||||
LIBLTE_API uint32_t refsignal_cs_fidx(lte_cell_t cell,
|
||||
uint32_t l,
|
||||
uint32_t port_id,
|
||||
uint32_t m);
|
||||
|
||||
LIBLTE_API uint32_t refsignal_nsymbol(uint32_t l,
|
||||
LIBLTE_API uint32_t refsignal_cs_nsymbol(uint32_t l,
|
||||
lte_cp_t cp,
|
||||
uint32_t port_id);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#ifndef REFSIGNAL_UL_
|
||||
#define REFSIGNAL_DL_
|
||||
#define REFSIGNAL_UL_
|
||||
|
||||
/* Object to manage Downlink reference signals for channel estimation.
|
||||
*
|
||||
|
@ -35,49 +35,63 @@
|
|||
#include "liblte/config.h"
|
||||
#include "liblte/phy/common/phy_common.h"
|
||||
|
||||
#define NOF_GROUPS_U 30
|
||||
#define NOF_SEQUENCES_U 2
|
||||
#define NOF_DELTA_SS 30
|
||||
#define NOF_CSHIFT 8
|
||||
|
||||
typedef _Complex float cf_t;
|
||||
|
||||
// Number of references in a subframe: there are 2 symbols for port_id=0,1 x 2 slots x 2 refs per prb
|
||||
#define REFSIGNAL_NUM_SF(nof_prb, port_id) (((port_id)<2?8:4)*(nof_prb))
|
||||
#define REFSIGNAL_MAX_NUM_SF(nof_prb) REFSIGNAL_NUM_SF(nof_prb, 0)
|
||||
typedef struct LIBLTE_API {
|
||||
uint32_t cyclic_shift;
|
||||
uint32_t cyclic_shift_for_drms;
|
||||
uint32_t delta_ss;
|
||||
bool en_drms_2;
|
||||
}refsignal_ul_cfg_t;
|
||||
|
||||
#define REFSIGNAL_PILOT_IDX(i,l,cell) (2*cell.nof_prb*(l)+(i))
|
||||
typedef struct LIBLTE_API {
|
||||
refsignal_ul_cfg_t common;
|
||||
float beta_pusch;
|
||||
lte_hopping_method_t hopping_method;
|
||||
uint32_t nof_prb;
|
||||
}refsignal_drms_pusch_cfg_t;
|
||||
|
||||
typedef struct LIBLTE_API {
|
||||
refsignal_ul_cfg_t common;
|
||||
float beta_pucch;
|
||||
uint32_t nof_prb;
|
||||
}refsignal_drms_pucch_cfg_t;
|
||||
|
||||
|
||||
/** Cell-Specific Reference Signal */
|
||||
typedef struct LIBLTE_API {
|
||||
refsignal_ul_cfg_t common;
|
||||
float beta_pucch;
|
||||
uint32_t nof_prb;
|
||||
}refsignal_srs_cfg_t;
|
||||
|
||||
/** Uplink DeModulation Reference Signal (DMRS) */
|
||||
typedef struct LIBLTE_API {
|
||||
lte_cell_t cell;
|
||||
cf_t *pilots[2][NSUBFRAMES_X_FRAME]; // Saves the reference signal per subframe for ports 0,1 and ports 2,3
|
||||
} refsignal_cs_t;
|
||||
float *tmp_arg;
|
||||
uint32_t n_prs_pusch[NOF_DELTA_SS][NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha at refsignal_dl_init()
|
||||
uint32_t f_gh[NSLOTS_X_FRAME];
|
||||
uint32_t u_pucch[NSLOTS_X_FRAME];
|
||||
uint32_t v_pusch[NSLOTS_X_FRAME][NOF_DELTA_SS];
|
||||
} refsignal_ul_t;
|
||||
|
||||
|
||||
LIBLTE_API int refsignal_cs_generate(refsignal_cs_t *q,
|
||||
lte_cell_t cell);
|
||||
LIBLTE_API int refsignal_ul_init(refsignal_ul_t *q,
|
||||
lte_cell_t cell);
|
||||
|
||||
LIBLTE_API void refsignal_cs_free(refsignal_cs_t *q);
|
||||
LIBLTE_API void refsignal_ul_free(refsignal_ul_t *q);
|
||||
|
||||
LIBLTE_API int refsignal_cs_put_sf(lte_cell_t cell,
|
||||
uint32_t port_id,
|
||||
cf_t *pilots,
|
||||
cf_t *sf_symbols);
|
||||
LIBLTE_API bool refsignal_drms_pusch_cfg_isvalid(refsignal_ul_t *q,
|
||||
refsignal_drms_pusch_cfg_t *cfg);
|
||||
|
||||
LIBLTE_API int refsignal_cs_get_sf(lte_cell_t cell,
|
||||
uint32_t port_id,
|
||||
cf_t *sf_symbols,
|
||||
cf_t *pilots);
|
||||
LIBLTE_API int refsignal_dmrs_pusch_gen(refsignal_ul_t *q, refsignal_drms_pusch_cfg_t *cfg, uint32_t ns, cf_t *r_pusch);
|
||||
|
||||
LIBLTE_API uint32_t refsignal_fidx(lte_cell_t cell,
|
||||
uint32_t l,
|
||||
uint32_t port_id,
|
||||
uint32_t m);
|
||||
LIBLTE_API void refsignal_dmrs_pucch_gen(refsignal_ul_t *q, refsignal_drms_pucch_cfg_t *cfg, uint32_t ns, cf_t *r_pucch);
|
||||
|
||||
LIBLTE_API uint32_t refsignal_nsymbol(uint32_t l,
|
||||
lte_cp_t cp,
|
||||
uint32_t port_id);
|
||||
|
||||
LIBLTE_API uint32_t refsignal_cs_v(uint32_t port_id,
|
||||
uint32_t ref_symbol_idx);
|
||||
|
||||
LIBLTE_API uint32_t refsignal_cs_nof_symbols(uint32_t port_id);
|
||||
LIBLTE_API void refsignal_srs_gen(refsignal_ul_t *q, refsignal_srs_cfg_t *cfg, uint32_t ns, cf_t *r_srs);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -138,6 +138,9 @@ typedef enum LIBLTE_API {
|
|||
LTE_BPSK = 0, LTE_QPSK = 1, LTE_QAM16 = 2, LTE_QAM64 = 3
|
||||
} lte_mod_t;
|
||||
|
||||
typedef enum LIBLTE_API {
|
||||
HOPPING_OFF = 0, HOPPING_GROUP = 1, HOPPING_SEQUENCE = 2
|
||||
} lte_hopping_method_t;
|
||||
|
||||
typedef struct LIBLTE_API {
|
||||
int id;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
#include "liblte/phy/ch_estimation/chest_dl.h"
|
||||
#include "liblte/phy/ch_estimation/refsignal_dl.h"
|
||||
#include "liblte/phy/ch_estimation/refsignal_ul.h"
|
||||
|
||||
#include "liblte/phy/resampling/interp.h"
|
||||
#include "liblte/phy/resampling/decim.h"
|
||||
|
|
|
@ -63,7 +63,7 @@ int chest_dl_init(chest_dl_t *q, lte_cell_t cell)
|
|||
{
|
||||
bzero(q, sizeof(chest_dl_t));
|
||||
|
||||
ret = refsignal_cs_generate(&q->csr_signal, cell);
|
||||
ret = refsignal_cs_init(&q->csr_signal, cell);
|
||||
if (ret != LIBLTE_SUCCESS) {
|
||||
fprintf(stderr, "Error initializing CSR signal (%d)\n",ret);
|
||||
goto clean_exit;
|
||||
|
@ -285,9 +285,9 @@ static void interpolate_pilots(chest_dl_t *q, cf_t *ce, uint32_t port_id)
|
|||
|
||||
/* Interpolate in the frequency domain */
|
||||
for (l=0;l<nsymbols;l++) {
|
||||
uint32_t fidx_offset = refsignal_fidx(q->cell, l, port_id, 0);
|
||||
uint32_t fidx_offset = refsignal_cs_fidx(q->cell, l, port_id, 0);
|
||||
interp_linear_offset(&q->interp_lin, &pilot_avg(0),
|
||||
&ce[refsignal_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB],
|
||||
&ce[refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB],
|
||||
fidx_offset, RE_X_RB/2-fidx_offset);
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ float chest_dl_rssi(chest_dl_t *q, cf_t *input, uint32_t port_id) {
|
|||
float rssi = 0;
|
||||
uint32_t nsymbols = refsignal_cs_nof_symbols(port_id);
|
||||
for (l=0;l<nsymbols;l++) {
|
||||
cf_t *tmp = &input[refsignal_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB];
|
||||
cf_t *tmp = &input[refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB];
|
||||
rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * RE_X_RB);
|
||||
}
|
||||
return rssi/nsymbols;
|
||||
|
|
|
@ -83,11 +83,11 @@ uint32_t refsignal_cs_nof_symbols(uint32_t port_id)
|
|||
}
|
||||
}
|
||||
|
||||
inline uint32_t refsignal_fidx(lte_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m) {
|
||||
inline uint32_t refsignal_cs_fidx(lte_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m) {
|
||||
return 6*m + ((refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6);
|
||||
}
|
||||
|
||||
inline uint32_t refsignal_nsymbol(uint32_t l, lte_cp_t cp, uint32_t port_id) {
|
||||
inline uint32_t refsignal_cs_nsymbol(uint32_t l, lte_cp_t cp, uint32_t port_id) {
|
||||
if (port_id < 2) {
|
||||
if (l % 2) {
|
||||
return (l/2+1)*CP_NSYMB(cp) - 3;
|
||||
|
@ -103,7 +103,7 @@ inline uint32_t refsignal_nsymbol(uint32_t l, lte_cp_t cp, uint32_t port_id) {
|
|||
/** Allocates and precomputes the Cell-Specific Reference (CSR) signal for
|
||||
* the 20 slots in a subframe
|
||||
*/
|
||||
int refsignal_cs_generate(refsignal_cs_t * q, lte_cell_t cell)
|
||||
int refsignal_cs_init(refsignal_cs_t * q, lte_cell_t cell)
|
||||
{
|
||||
|
||||
uint32_t c_init;
|
||||
|
@ -146,7 +146,7 @@ int refsignal_cs_generate(refsignal_cs_t * q, lte_cell_t cell)
|
|||
uint32_t nsymbols = refsignal_cs_nof_symbols(2*p)/2;
|
||||
for (l = 0; l < nsymbols; l++) {
|
||||
/* Compute sequence init value */
|
||||
uint32_t lp = refsignal_nsymbol(l, cell.cp, 2*p);
|
||||
uint32_t lp = refsignal_cs_nsymbol(l, cell.cp, 2*p);
|
||||
c_init = 1024 * (7 * (ns + 1) + lp + 1) * (2 * cell.id + 1)
|
||||
+ 2 * cell.id + N_cp;
|
||||
|
||||
|
@ -205,7 +205,7 @@ int refsignal_cs_put_sf(lte_cell_t cell, uint32_t port_id, cf_t *pilots, cf_t *s
|
|||
{
|
||||
|
||||
for (l=0;l<refsignal_cs_nof_symbols(port_id);l++) {
|
||||
uint32_t nsymbol = refsignal_nsymbol(l, cell.cp, port_id);
|
||||
uint32_t nsymbol = refsignal_cs_nsymbol(l, cell.cp, port_id);
|
||||
/* Compute offset frequency index */
|
||||
fidx = ((refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6);
|
||||
for (i = 0; i < 2*cell.nof_prb; i++) {
|
||||
|
@ -234,7 +234,7 @@ int refsignal_cs_get_sf(lte_cell_t cell, uint32_t port_id, cf_t *sf_symbols, cf_
|
|||
sf_symbols != NULL)
|
||||
{
|
||||
for (l=0;l<refsignal_cs_nof_symbols(port_id);l++) {
|
||||
uint32_t nsymbol = refsignal_nsymbol(l, cell.cp, port_id);
|
||||
uint32_t nsymbol = refsignal_cs_nsymbol(l, cell.cp, port_id);
|
||||
/* Compute offset frequency index */
|
||||
fidx = ((refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6);
|
||||
for (i = 0; i < 2*cell.nof_prb; i++) {
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef compile
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
@ -39,6 +37,7 @@
|
|||
#include "liblte/phy/utils/debug.h"
|
||||
#include "liblte/phy/common/sequence.h"
|
||||
|
||||
#include "ul_rs_tables.h"
|
||||
|
||||
// n_drms_2 table 5.5.2.1.1-1 from 36.211
|
||||
uint32_t n_drms_2[8] = { 0, 6, 3, 4, 2, 8, 10, 9 };
|
||||
|
@ -47,179 +46,254 @@ uint32_t n_drms_2[8] = { 0, 6, 3, 4, 2, 8, 10, 9 };
|
|||
uint32_t n_drms_1[8] = { 0, 2, 3, 4, 6, 8, 9, 10 };
|
||||
|
||||
|
||||
/* Generation of the reference signal sequence according to Section 5.5.1 of 36.211 */
|
||||
int rs_sequence(ref_t * refs, uint32_t len, float alpha, uint32_t ns, uint32_t cell_id,
|
||||
refsignal_ul_cfg_t * cfg)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
// Calculate u and v
|
||||
uint32_t u, v;
|
||||
uint32_t f_ss = (((cell_id % 30) + cfg->delta_ss) % 30);
|
||||
printf("f_ss: %d\n", f_ss);
|
||||
if (cfg->group_hopping_en) {
|
||||
sequence_t seq;
|
||||
bzero(&seq, sizeof(sequence_t));
|
||||
sequence_LTE_pr(&seq, 160, cell_id / 30);
|
||||
uint32_t f_gh = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
f_gh += (((uint32_t) seq.c[8 * ns + i]) << i);
|
||||
}
|
||||
printf("f_gh: %u\n", f_gh);
|
||||
sequence_free(&seq);
|
||||
u = ((f_gh%30) + f_ss) % 30;
|
||||
} else {
|
||||
u = f_ss % 30;
|
||||
}
|
||||
|
||||
if (len < 6 * RE_X_RB) {
|
||||
v = 0;
|
||||
} else {
|
||||
if (!cfg->group_hopping_en && cfg->sequence_hopping_en) {
|
||||
sequence_t seq;
|
||||
bzero(&seq, sizeof(sequence_t));
|
||||
sequence_LTE_pr(&seq, 20, ((cell_id / 30) << 5) + f_ss);
|
||||
v = seq.c[ns];
|
||||
sequence_free(&seq);
|
||||
} else {
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
printf("u: %d, v: %d\n", u, v);
|
||||
if (len >= 3 * RE_X_RB) {
|
||||
uint32_t n_sz;
|
||||
uint32_t q;
|
||||
float q_hat;
|
||||
/* get largest prime n_zc<len */
|
||||
for (i = NOF_PRIME_NUMBERS - 1; i > 0; i--) {
|
||||
if (prime_numbers[i] < len) {
|
||||
n_sz = prime_numbers[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("n_sz: %d\n", n_sz);
|
||||
q_hat = (float) n_sz *(u + 1) / 31;
|
||||
if ((((uint32_t) (2 * q_hat)) % 2) == 0) {
|
||||
q = (uint32_t) (q_hat + 0.5) + v;
|
||||
} else {
|
||||
q = (uint32_t) (q_hat + 0.5) - v;
|
||||
}
|
||||
cf_t *x_q = malloc(sizeof(cf_t) * n_sz);
|
||||
if (!x_q) {
|
||||
perror("malloc");
|
||||
/** Computes n_prs values used to compute alpha as defined in 5.5.2.1.1 of 36.211 */
|
||||
static int generate_n_prs(refsignal_ul_t * q) {
|
||||
/* Calculate n_prs */
|
||||
uint32_t c_init;
|
||||
|
||||
sequence_t seq;
|
||||
bzero(&seq, sizeof(sequence_t));
|
||||
|
||||
for (uint32_t delta_ss=0;delta_ss<NOF_DELTA_SS;delta_ss++) {
|
||||
c_init = ((q->cell.id / 30) << 5) + (((q->cell.id % 30) + delta_ss) % 30);
|
||||
if (sequence_LTE_pr(&seq, 8 * CP_NSYMB(q->cell.cp) * 20, c_init)) {
|
||||
return LIBLTE_ERROR;
|
||||
}
|
||||
for (i = 0; i < n_sz; i++) {
|
||||
x_q[i] =
|
||||
cexpf(-I * M_PI * (float) q * (float) i * ((float) i + 1) / n_sz);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
refs[i].simbol = cfg->beta * cexpf(I * alpha * i) * x_q[i % n_sz];
|
||||
}
|
||||
free(x_q);
|
||||
} else {
|
||||
if (len == RE_X_RB) {
|
||||
for (i = 0; i < len; i++) {
|
||||
refs[i].simbol = cfg->beta * cexpf(I * (phi_M_sc_12[u][i] * M_PI / 4 + alpha * i));
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < len; i++) {
|
||||
refs[i].simbol = cfg->beta * cexpf(I * (phi_M_sc_24[u][i] * M_PI / 4 + alpha * i));
|
||||
for (uint32_t ns=0;ns<NSLOTS_X_FRAME;ns++) {
|
||||
uint32_t n_prs = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
n_prs += (seq.c[8 * CP_NSYMB(q->cell.cp) * ns + i] << i);
|
||||
}
|
||||
q->n_prs_pusch[delta_ss][ns] = n_prs;
|
||||
}
|
||||
}
|
||||
|
||||
sequence_free(&seq);
|
||||
return LIBLTE_SUCCESS;
|
||||
}
|
||||
|
||||
/** Computes sequence-group pattern f_gh according to 5.5.1.3 of 36.211 */
|
||||
static int generate_group_hopping_f_gh(refsignal_ul_t *q) {
|
||||
sequence_t seq;
|
||||
bzero(&seq, sizeof(sequence_t));
|
||||
|
||||
if (sequence_LTE_pr(&seq, 160, q->cell.id / 30)) {
|
||||
return LIBLTE_ERROR;
|
||||
}
|
||||
|
||||
for (uint32_t ns=0;ns<NSLOTS_X_FRAME;ns++) {
|
||||
uint32_t f_gh = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
f_gh += (((uint32_t) seq.c[8 * ns + i]) << i);
|
||||
}
|
||||
q->f_gh[ns] = f_gh;
|
||||
}
|
||||
|
||||
sequence_free(&seq);
|
||||
return LIBLTE_SUCCESS;
|
||||
}
|
||||
|
||||
/** Initializes refsignal_t object according to 3GPP 36.211 5.5.2
|
||||
static int generate_sequence_hopping_v(refsignal_ul_t *q) {
|
||||
sequence_t seq;
|
||||
bzero(&seq, sizeof(sequence_t));
|
||||
|
||||
for (uint32_t ns=0;ns<NSLOTS_X_FRAME;ns++) {
|
||||
for (uint32_t delta_ss=0;delta_ss<NOF_DELTA_SS;delta_ss++) {
|
||||
if (sequence_LTE_pr(&seq, 20, ((q->cell.id / 30) << 5) + (q->cell.id%30)+delta_ss)) {
|
||||
return LIBLTE_ERROR;
|
||||
}
|
||||
q->v_pusch[ns][delta_ss] = seq.c[ns];
|
||||
}
|
||||
}
|
||||
sequence_free(&seq);
|
||||
return LIBLTE_SUCCESS;
|
||||
}
|
||||
|
||||
/** Initializes refsignal_ul_t object according to 3GPP 36.211 5.5
|
||||
*
|
||||
*/
|
||||
int refsignal_init_LTEUL_drms_pusch(refsignal_t * q, uint32_t nof_prb, uint32_t prb_start,
|
||||
uint32_t nslot, lte_cell_t cell, refsignal_ul_cfg_t * cfg)
|
||||
int refsignal_ul_init(refsignal_ul_t * q, lte_cell_t cell)
|
||||
{
|
||||
|
||||
uint32_t i;
|
||||
int ret = LIBLTE_ERROR_INVALID_INPUTS;
|
||||
uint32_t n_prs;
|
||||
uint32_t M_sc;
|
||||
float alpha;
|
||||
|
||||
if (q != NULL && nslot < NSLOTS_X_FRAME && lte_cell_isvalid(&cell)) {
|
||||
if (q != NULL && lte_cell_isvalid(&cell)) {
|
||||
|
||||
bzero(q, sizeof(refsignal_t));
|
||||
|
||||
M_sc = nof_prb * RE_X_RB;
|
||||
|
||||
q->nof_refs = M_sc;
|
||||
q->nsymbols = 1;
|
||||
q->voffset = cell.id % 6;
|
||||
q->nof_prb = cell.nof_prb;
|
||||
|
||||
q->symbols_ref = malloc(sizeof(uint32_t) * 1);
|
||||
if (!q->symbols_ref) {
|
||||
bzero(q, sizeof(refsignal_ul_t));
|
||||
q->cell = cell;
|
||||
|
||||
// Allocate temporal buffer for computing signal argument
|
||||
q->tmp_arg = vec_malloc(RE_X_RB * q->cell.nof_prb * sizeof(cf_t));
|
||||
if (!q->tmp_arg) {
|
||||
perror("malloc");
|
||||
goto free_and_exit;
|
||||
}
|
||||
|
||||
if (CP_ISNORM(cell.cp)) {
|
||||
q->symbols_ref[0] = 3;
|
||||
} else {
|
||||
q->symbols_ref[0] = 2;
|
||||
}
|
||||
|
||||
q->refs = vec_malloc(q->nof_refs * sizeof(ref_t));
|
||||
if (!q->refs) {
|
||||
goto free_and_exit;
|
||||
}
|
||||
q->ch_est = vec_malloc(q->nof_refs * sizeof(cf_t));
|
||||
if (!q->ch_est) {
|
||||
goto free_and_exit;
|
||||
}
|
||||
|
||||
/* Calculate n_prs */
|
||||
uint32_t c_init;
|
||||
sequence_t seq;
|
||||
bzero(&seq, sizeof(sequence_t));
|
||||
c_init = ((cell.id / 30) << 5) + (((cell.id % 30) + cfg->delta_ss) % 30);
|
||||
ret = sequence_LTE_pr(&seq, 8 * CP_NSYMB(cell.cp) * 20, c_init);
|
||||
if (ret != LIBLTE_SUCCESS) {
|
||||
goto free_and_exit;
|
||||
}
|
||||
n_prs = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
n_prs += (seq.c[8 * CP_NSYMB(cell.cp) * nslot + i] << i);
|
||||
}
|
||||
sequence_free(&seq);
|
||||
|
||||
// Calculate cyclic shift alpha
|
||||
uint32_t n_cs =
|
||||
(n_drms_1[cfg->cyclic_shift] +
|
||||
n_drms_2[cfg->cyclic_shift_for_drms] + n_prs) % 12;
|
||||
alpha = 2 * M_PI * (n_cs) / 12;
|
||||
|
||||
printf("alpha: %g\n", alpha);
|
||||
// Precompute n_prs
|
||||
if (generate_n_prs(q)) {
|
||||
goto free_and_exit;
|
||||
}
|
||||
|
||||
if (rs_sequence(q->refs, M_sc, alpha, nslot, cell.id, cfg)) {
|
||||
fprintf(stderr, "Error generating RS sequence\n");
|
||||
goto free_and_exit;
|
||||
// Precompute group hopping values u.
|
||||
if (generate_group_hopping_f_gh(q)) {
|
||||
goto free_and_exit;
|
||||
}
|
||||
/* mapping to resource elements */
|
||||
for (i=0;i<M_sc;i++) {
|
||||
q->refs[i].freq_idx = prb_start*RE_X_RB + i;
|
||||
q->refs[i].time_idx = q->symbols_ref[0];
|
||||
|
||||
// Precompute sequence hopping values v. Uses f_ss_pusch
|
||||
if (generate_sequence_hopping_v(q)) {
|
||||
goto free_and_exit;
|
||||
}
|
||||
|
||||
|
||||
ret = LIBLTE_SUCCESS;
|
||||
}
|
||||
free_and_exit:
|
||||
if (ret == LIBLTE_ERROR) {
|
||||
refsignal_free(q);
|
||||
refsignal_ul_free(q);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
void refsignal_ul_free(refsignal_ul_t * q) {
|
||||
if (q->tmp_arg) {
|
||||
free(q->tmp_arg);
|
||||
}
|
||||
bzero(q, sizeof(refsignal_ul_t));
|
||||
}
|
||||
|
||||
|
||||
uint32_t largest_prime_lower_than(uint32_t x) {
|
||||
/* get largest prime n_zc<len */
|
||||
for (uint32_t i = NOF_PRIME_NUMBERS - 1; i > 0; i--) {
|
||||
if (prime_numbers[i] < x) {
|
||||
return prime_numbers[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void arg_r_uv_1prb(float *arg, uint32_t u) {
|
||||
for (int i = 0; i < RE_X_RB; i++) {
|
||||
arg[i] = phi_M_sc_12[u][i] * M_PI / 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void arg_r_uv_2prb(float *arg, uint32_t u) {
|
||||
for (int i = 0; i < 2*RE_X_RB; i++) {
|
||||
arg[i] = phi_M_sc_24[u][i] * M_PI / 4;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_q(uint32_t u, uint32_t v, uint32_t N_sz) {
|
||||
float q;
|
||||
float q_hat;
|
||||
float n_sz = (float) N_sz;
|
||||
|
||||
q_hat = n_sz *(u + 1) / 31;
|
||||
if ((((uint32_t) (2 * q_hat)) % 2) == 0) {
|
||||
q = q_hat + 0.5 + v;
|
||||
} else {
|
||||
q = q_hat + 0.5 - v;
|
||||
}
|
||||
return (uint32_t) q;
|
||||
}
|
||||
|
||||
static void arg_r_uv_mprb(float *arg, uint32_t M_sc, uint32_t u, uint32_t v) {
|
||||
|
||||
uint32_t N_sz = largest_prime_lower_than(M_sc);
|
||||
float q = get_q(u,v,N_sz);
|
||||
float n_sz = (float) N_sz;
|
||||
|
||||
for (uint32_t i = 0; i < M_sc; i++) {
|
||||
float m = (float) (i%N_sz);
|
||||
arg[i] = -M_PI * q * m * (m + 1) / n_sz;
|
||||
}
|
||||
}
|
||||
|
||||
/* Computes argument of r_u_v signal */
|
||||
static void compute_pusch_r_uv_arg(refsignal_ul_t *q, refsignal_drms_pusch_cfg_t *cfg, uint32_t u, uint32_t v) {
|
||||
if (cfg->nof_prb == 1) {
|
||||
arg_r_uv_1prb(q->tmp_arg, u);
|
||||
} else if (cfg->nof_prb == 2) {
|
||||
arg_r_uv_2prb(q->tmp_arg, u);
|
||||
} else {
|
||||
arg_r_uv_mprb(q->tmp_arg, RE_X_RB*cfg->nof_prb, u, v);
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculates alpha according to 5.5.2.1.1 of 36.211 */
|
||||
static float get_alpha(refsignal_ul_t *q, refsignal_ul_cfg_t *cfg, uint32_t ns) {
|
||||
uint32_t n_drms_2_val = 0;
|
||||
if (cfg->en_drms_2) {
|
||||
n_drms_2_val = n_drms_2[cfg->cyclic_shift_for_drms];
|
||||
}
|
||||
uint32_t n_cs = (n_drms_1[cfg->cyclic_shift] + n_drms_2_val + q->n_prs_pusch[cfg->delta_ss][ns]) % 12;
|
||||
|
||||
return 2 * M_PI * (n_cs) / 12;
|
||||
|
||||
}
|
||||
|
||||
bool refsignal_drms_pusch_cfg_isvalid(refsignal_ul_t *q, refsignal_drms_pusch_cfg_t *cfg) {
|
||||
if (cfg->common.cyclic_shift < NOF_CSHIFT &&
|
||||
cfg->common.cyclic_shift_for_drms < NOF_CSHIFT &&
|
||||
cfg->common.delta_ss < NOF_DELTA_SS &&
|
||||
cfg->nof_prb < q->cell.nof_prb) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Generate DRMS for PUSCH signal according to 5.5.2.1 of 36.211 */
|
||||
int refsignal_dmrs_pusch_gen(refsignal_ul_t *q, refsignal_drms_pusch_cfg_t *cfg, uint32_t ns, cf_t *r_pusch) {
|
||||
|
||||
int ret = LIBLTE_ERROR_INVALID_INPUTS;
|
||||
if (refsignal_drms_pusch_cfg_isvalid(q, cfg)) {
|
||||
ret = LIBLTE_ERROR;
|
||||
|
||||
// Get group hopping number u
|
||||
uint32_t f_gh=0;
|
||||
if (cfg->hopping_method == HOPPING_GROUP) {
|
||||
f_gh = q->f_gh[ns];
|
||||
}
|
||||
uint32_t u = (f_gh + (q->cell.id%30)+cfg->common.delta_ss)%30;
|
||||
|
||||
|
||||
// Get sequence hopping number v
|
||||
uint32_t v = 0;
|
||||
if (cfg->nof_prb >= 6 && cfg->hopping_method == HOPPING_SEQUENCE) {
|
||||
v = q->v_pusch[ns][cfg->common.delta_ss];
|
||||
}
|
||||
|
||||
// Compute signal argument
|
||||
compute_pusch_r_uv_arg(q, cfg, u, v);
|
||||
|
||||
// Add cyclic prefix alpha
|
||||
float alpha = get_alpha(q, &cfg->common, ns);
|
||||
|
||||
if (verbose == VERBOSE_DEBUG) {
|
||||
uint32_t N_sz = largest_prime_lower_than(cfg->nof_prb*RE_X_RB);
|
||||
DEBUG("Generating PUSCH DRMS sequence with parameters:\n",0);
|
||||
DEBUG("\tu: %d, v: %d, alpha: %f, N_sc: %d, root q: %d\n",
|
||||
u, v, alpha, N_sz, get_q(u,v,N_sz));
|
||||
}
|
||||
|
||||
vec_fprint_f(stdout, q->tmp_arg, RE_X_RB*cfg->nof_prb);
|
||||
|
||||
// Do complex exponential and adjust amplitude
|
||||
for (int i=0;i<RE_X_RB*cfg->nof_prb;i++) {
|
||||
r_pusch[i] = cfg->beta_pusch * cexpf(I*(q->tmp_arg[i] + alpha*i));
|
||||
}
|
||||
vec_fprint_c(stdout, r_pusch, RE_X_RB*cfg->nof_prb);
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void refsignal_dmrs_pucch_gen(refsignal_ul_t *q, refsignal_drms_pucch_cfg_t *cfg, uint32_t ns, cf_t *r_pucch) {
|
||||
|
||||
}
|
||||
|
||||
void refsignal_srs_gen(refsignal_ul_t *q, refsignal_srs_cfg_t *cfg, uint32_t ns, cf_t *r_srs) {
|
||||
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ int phi_M_sc_24[30][24] = {{-1, 3, 1,-3, 3,-1, 1, 3,-3, 3, 1, 3,-3, 3, 1, 1,-1,
|
|||
{ 1, 1,-1,-1,-3,-1, 3,-1, 3,-1, 1, 3, 1,-1, 3, 1, 3,-3,-3, 1,-1,-1, 1, 3}};
|
||||
|
||||
// Prime numbers used for Section 5.5.1.1 of 36.211
|
||||
#define NOF_PRIME_NUMBERS 309
|
||||
#define NOF_PRIME_NUMBERS 196
|
||||
uint32_t prime_numbers[NOF_PRIME_NUMBERS] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
|
||||
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
|
||||
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
|
||||
|
@ -112,16 +112,5 @@ uint32_t prime_numbers[NOF_PRIME_NUMBERS] = { 2, 3, 5, 7, 11, 13, 17,
|
|||
947, 953, 967, 971, 977, 983, 991, 997,1009,1013,
|
||||
1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,
|
||||
1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,
|
||||
1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,
|
||||
1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,
|
||||
1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,
|
||||
1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,
|
||||
1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,
|
||||
1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,
|
||||
1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,
|
||||
1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,
|
||||
1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,
|
||||
1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,
|
||||
1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,
|
||||
1993,1997,1999,2003,2011,2017,2027,2029,2039};
|
||||
1153,1163,1171,1181,1187,1193};
|
||||
|
||||
|
|
|
@ -45,15 +45,12 @@ BuildMex(MEXNAME chest SOURCES chest_test_dl_mex.c LIBRARIES lte_phy)
|
|||
# Uplink Channel Estimation TEST
|
||||
########################################################################
|
||||
|
||||
#ADD_EXECUTABLE(chest_test_ul chest_test_ul.c)
|
||||
#TARGET_LINK_LIBRARIES(chest_test_ul lte_phy)
|
||||
|
||||
#ADD_TEST(chest_test_ul_cellid0 chest_ul_test -c 0)
|
||||
#ADD_TEST(chest_test_ul_cellid1 chest_ul_test -c 1)
|
||||
#ADD_TEST(chest_test_ul_cellid2 chest_ul_test -c 2)
|
||||
|
||||
ADD_EXECUTABLE(refsignal_ul_test_all refsignal_ul_test.c)
|
||||
TARGET_LINK_LIBRARIES(refsignal_ul_test_all lte_phy)
|
||||
|
||||
|
||||
BuildMex(MEXNAME refsignal_pusch SOURCES refsignal_pusch_mex.c LIBRARIES lte_phy liblte_mex)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,249 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <complex.h>
|
||||
|
||||
#include "liblte/phy/phy.h"
|
||||
|
||||
lte_cell_t cell = {
|
||||
6, // nof_prb
|
||||
MAX_PORTS, // nof_ports
|
||||
1000, // cell_id
|
||||
CPNORM // cyclic prefix
|
||||
};
|
||||
|
||||
uint8_t *output_matlab = NULL;
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [recov]\n", prog);
|
||||
|
||||
printf("\t-r nof_prb [Default %d]\n", cell.nof_prb);
|
||||
printf("\t-e extended cyclic prefix [Default normal]\n");
|
||||
|
||||
printf("\t-c cell_id (1000 tests all). [Default %d]\n", cell.id);
|
||||
|
||||
printf("\t-o output matlab file [Default %s]\n",output_matlab?output_matlab:"None");
|
||||
printf("\t-v increase verbosity\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "recov")) != -1) {
|
||||
switch(opt) {
|
||||
case 'r':
|
||||
cell.nof_prb = atoi(argv[optind]);
|
||||
break;
|
||||
case 'e':
|
||||
cell.cp = CPEXT;
|
||||
break;
|
||||
case 'c':
|
||||
cell.id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'o':
|
||||
output_matlab = argv[optind];
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int check_mse(float mod, float arg, int n_port) {
|
||||
INFO("mod=%.4f, arg=%.4f, n_port=%d\n", mod, arg, n_port);
|
||||
switch(n_port) {
|
||||
case 0:
|
||||
if (mod > 0.029) {
|
||||
return -1;
|
||||
}
|
||||
if (arg > 0.029) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (mod > 0.012) {
|
||||
return -1;
|
||||
}
|
||||
if (arg > 0.012) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
if (mod > 3.33) {
|
||||
return -1;
|
||||
}
|
||||
if (arg > 0.63) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
chest_t eq;
|
||||
cf_t *input = NULL, *ce = NULL, *h = NULL;
|
||||
refsignal_t refs;
|
||||
int i, j, n_port, n_slot, cid, num_re;
|
||||
int ret = -1;
|
||||
int max_cid;
|
||||
FILE *fmatlab = NULL;
|
||||
float mse_mag, mse_phase;
|
||||
|
||||
parse_args(argc,argv);
|
||||
|
||||
if (output_matlab) {
|
||||
fmatlab=fopen(output_matlab, "w");
|
||||
if (!fmatlab) {
|
||||
perror("fopen");
|
||||
goto do_exit;
|
||||
}
|
||||
}
|
||||
|
||||
num_re = cell.nof_prb * RE_X_RB * CP_NSYMB(cell.cp);
|
||||
|
||||
input = malloc(num_re * sizeof(cf_t));
|
||||
if (!input) {
|
||||
perror("malloc");
|
||||
goto do_exit;
|
||||
}
|
||||
h = malloc(num_re * sizeof(cf_t));
|
||||
if (!h) {
|
||||
perror("malloc");
|
||||
goto do_exit;
|
||||
}
|
||||
ce = malloc(num_re * sizeof(cf_t));
|
||||
if (!ce) {
|
||||
perror("malloc");
|
||||
goto do_exit;
|
||||
}
|
||||
|
||||
if (cell.id == 1000) {
|
||||
cid = 0;
|
||||
max_cid = 504;
|
||||
} else {
|
||||
cid = cell.id;
|
||||
max_cid = cell.id;
|
||||
}
|
||||
|
||||
while(cid <= max_cid) {
|
||||
cell.id = cid;
|
||||
if (chest_init_LTEUL(&eq, cell)) {
|
||||
fprintf(stderr, "Error initializing equalizer\n");
|
||||
goto do_exit;
|
||||
}
|
||||
|
||||
for (n_slot=0;n_slot<NSLOTS_X_FRAME;n_slot++) {
|
||||
for (n_port=0;n_port<cell.nof_ports;n_port++) {
|
||||
|
||||
if (refsignal_init_LTEDL(&refs, n_port, n_slot, cell)) {
|
||||
fprintf(stderr, "Error initiating CRS slot=%d\n", i);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bzero(input, sizeof(cf_t) * num_re);
|
||||
for (i=0;i<num_re;i++) {
|
||||
input[i] = 0.5-rand()/RAND_MAX+I*(0.5-rand()/RAND_MAX);
|
||||
}
|
||||
|
||||
bzero(ce, sizeof(cf_t) * num_re);
|
||||
bzero(h, sizeof(cf_t) * num_re);
|
||||
|
||||
refsignal_put(&refs, input);
|
||||
|
||||
for (i=0;i<CP_NSYMB(cell.cp);i++) {
|
||||
for (j=0;j<cell.nof_prb * RE_X_RB;j++) {
|
||||
float x = -1+(float) i/CP_NSYMB(cell.cp) + cosf(2 * M_PI * (float) j/cell.nof_prb/RE_X_RB);
|
||||
h[i*cell.nof_prb * RE_X_RB+j] = (3+x) * cexpf(I * x);
|
||||
input[i*cell.nof_prb * RE_X_RB+j] *= h[i*cell.nof_prb * RE_X_RB+j];
|
||||
}
|
||||
}
|
||||
|
||||
chest_ce_slot_port(&eq, input, ce, n_slot, n_port);
|
||||
|
||||
mse_mag = mse_phase = 0;
|
||||
for (i=0;i<num_re;i++) {
|
||||
mse_mag += (cabsf(h[i]) - cabsf(ce[i])) * (cabsf(h[i]) - cabsf(ce[i])) / num_re;
|
||||
mse_phase += (cargf(h[i]) - cargf(ce[i])) * (cargf(h[i]) - cargf(ce[i])) / num_re;
|
||||
}
|
||||
|
||||
if (check_mse(mse_mag, mse_phase, n_port)) {
|
||||
goto do_exit;
|
||||
}
|
||||
|
||||
if (fmatlab) {
|
||||
fprintf(fmatlab, "input=");
|
||||
vec_fprint_c(fmatlab, input, num_re);
|
||||
fprintf(fmatlab, ";\n");
|
||||
fprintf(fmatlab, "h=");
|
||||
vec_fprint_c(fmatlab, h, num_re);
|
||||
fprintf(fmatlab, ";\n");
|
||||
fprintf(fmatlab, "ce=");
|
||||
vec_fprint_c(fmatlab, ce, num_re);
|
||||
fprintf(fmatlab, ";\n");
|
||||
chest_fprint(&eq, fmatlab, n_slot, n_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
chest_free(&eq);
|
||||
cid+=10;
|
||||
INFO("cid=%d\n", cid);
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
do_exit:
|
||||
|
||||
if (ce) {
|
||||
free(ce);
|
||||
}
|
||||
if (input) {
|
||||
free(input);
|
||||
}
|
||||
if (h) {
|
||||
free(h);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
printf("OK\n");
|
||||
} else {
|
||||
printf("Error at cid=%d, slot=%d, port=%d\n",cid, n_slot, n_port);
|
||||
}
|
||||
|
||||
exit(ret);
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "liblte/phy/phy.h"
|
||||
#include "liblte/mex/mexutils.h"
|
||||
|
||||
/** MEX function to be called from MATLAB to test the channel estimator
|
||||
*/
|
||||
|
||||
#define UECFG prhs[0]
|
||||
#define PUSCHCFG prhs[1]
|
||||
#define NOF_INPUTS 2
|
||||
|
||||
void help()
|
||||
{
|
||||
mexErrMsgTxt
|
||||
("[seq] = liblte_refsignal_pusch(ueConfig, puschConfig)\n\n");
|
||||
}
|
||||
|
||||
extern int indices[2048];
|
||||
|
||||
/* the gateway function */
|
||||
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
|
||||
{
|
||||
lte_cell_t cell;
|
||||
refsignal_ul_t refs;
|
||||
refsignal_drms_pusch_cfg_t pusch_cfg;
|
||||
cf_t *signal;
|
||||
uint32_t sf_idx;
|
||||
|
||||
if (nrhs != NOF_INPUTS) {
|
||||
help();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mexutils_read_uint32_struct(UECFG, "NCellID", &cell.id)) {
|
||||
mexErrMsgTxt("Field NCellID not found in UE config\n");
|
||||
return;
|
||||
}
|
||||
cell.nof_prb = 100;
|
||||
cell.cp = CPNORM;
|
||||
cell.nof_ports = 1;
|
||||
|
||||
if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) {
|
||||
mexErrMsgTxt("Field NSubframe not found in UE config\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bzero(&pusch_cfg, sizeof(refsignal_drms_pusch_cfg_t));
|
||||
|
||||
|
||||
char *tmp = mexutils_get_char_struct(UECFG, "Hopping");
|
||||
if (tmp) {
|
||||
if (!strcmp(tmp, "Group")) {
|
||||
pusch_cfg.hopping_method = HOPPING_GROUP;
|
||||
} else if (!strcmp(tmp, "Sequence")) {
|
||||
pusch_cfg.hopping_method = HOPPING_SEQUENCE;
|
||||
} else {
|
||||
pusch_cfg.hopping_method = HOPPING_OFF;
|
||||
}
|
||||
mxFree(tmp);
|
||||
} else {
|
||||
pusch_cfg.hopping_method = HOPPING_OFF;
|
||||
}
|
||||
|
||||
|
||||
if (mexutils_read_uint32_struct(UECFG, "SeqGroup", &pusch_cfg.common.delta_ss)) {
|
||||
pusch_cfg.common.delta_ss = 0;
|
||||
}
|
||||
if (mexutils_read_uint32_struct(UECFG, "CyclicShift", &pusch_cfg.common.cyclic_shift)) {
|
||||
pusch_cfg.common.cyclic_shift = 0;
|
||||
}
|
||||
float *prbset;
|
||||
mxArray *p;
|
||||
p = mxGetField(PUSCHCFG, 0, "PRBSet");
|
||||
if (!p) {
|
||||
mexErrMsgTxt("Error field PRBSet not found in PUSCH config\n");
|
||||
return;
|
||||
}
|
||||
pusch_cfg.nof_prb = mexutils_read_f(p, &prbset);
|
||||
free(prbset);
|
||||
|
||||
if (mexutils_read_uint32_struct(PUSCHCFG, "DynCyclicShift", &pusch_cfg.common.cyclic_shift_for_drms)) {
|
||||
pusch_cfg.common.cyclic_shift_for_drms = 0;
|
||||
pusch_cfg.common.en_drms_2 = false;
|
||||
} else {
|
||||
pusch_cfg.common.en_drms_2 = true;
|
||||
}
|
||||
|
||||
pusch_cfg.beta_pusch = 1.0;
|
||||
|
||||
if (refsignal_ul_init(&refs, cell)) {
|
||||
mexErrMsgTxt("Error initiating refsignal_ul\n");
|
||||
return;
|
||||
}
|
||||
|
||||
mexPrintf("nof_prb: %d, ",pusch_cfg.nof_prb);
|
||||
mexPrintf("cyclic_shift: %d, ",pusch_cfg.common.cyclic_shift);
|
||||
mexPrintf("cyclic_shift_for_drms: %d, ",pusch_cfg.common.cyclic_shift_for_drms);
|
||||
mexPrintf("delta_ss: %d, ",pusch_cfg.common.delta_ss);
|
||||
mexPrintf("hopping_method: %d\n, ",pusch_cfg.hopping_method);
|
||||
|
||||
signal = vec_malloc(2*RE_X_RB*pusch_cfg.nof_prb*sizeof(cf_t));
|
||||
if (!signal) {
|
||||
perror("malloc");
|
||||
return;
|
||||
}
|
||||
for (uint32_t i=0;i<2;i++) {
|
||||
//mexPrintf("Generating DRMS for ns=%d, nof_prb=%d\n", 2*sf_idx+i,pusch_cfg.nof_prb);
|
||||
refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, 2*sf_idx+i, &signal[i*RE_X_RB*pusch_cfg.nof_prb]);
|
||||
}
|
||||
|
||||
if (nlhs >= 1) {
|
||||
mexutils_write_cf(signal, &plhs[0], 2*RE_X_RB*pusch_cfg.nof_prb, 1);
|
||||
}
|
||||
|
||||
refsignal_ul_free(&refs);
|
||||
free(signal);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <complex.h>
|
||||
|
||||
#include "liblte/phy/phy.h"
|
||||
|
||||
lte_cell_t cell = {
|
||||
6, // nof_prb
|
||||
MAX_PORTS, // nof_ports
|
||||
0, // cell_id
|
||||
CPNORM // cyclic prefix
|
||||
};
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [recv]\n", prog);
|
||||
|
||||
printf("\t-r nof_prb [Default %d]\n", cell.nof_prb);
|
||||
printf("\t-e extended cyclic prefix [Default normal]\n");
|
||||
|
||||
printf("\t-c cell_id (1000 tests all). [Default %d]\n", cell.id);
|
||||
|
||||
printf("\t-v increase verbosity\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "recv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'r':
|
||||
cell.nof_prb = atoi(argv[optind]);
|
||||
break;
|
||||
case 'e':
|
||||
cell.cp = CPEXT;
|
||||
break;
|
||||
case 'c':
|
||||
cell.id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lte_hopping_method_t hopping_modes[3]={HOPPING_OFF, HOPPING_GROUP, HOPPING_SEQUENCE};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
refsignal_ul_t refs;
|
||||
refsignal_drms_pusch_cfg_t pusch_cfg;
|
||||
cf_t *signal = NULL;
|
||||
int i, j;
|
||||
int ret = -1;
|
||||
|
||||
parse_args(argc,argv);
|
||||
|
||||
signal = malloc(RE_X_RB * cell.nof_prb * sizeof(cf_t));
|
||||
if (!signal) {
|
||||
perror("malloc");
|
||||
goto do_exit;
|
||||
}
|
||||
|
||||
if (refsignal_ul_init(&refs, cell)) {
|
||||
fprintf(stderr, "Error initializing UL reference signal\n");
|
||||
goto do_exit;
|
||||
}
|
||||
|
||||
printf("Running tests for %d PRB\n", cell.nof_prb);
|
||||
|
||||
for (int n=3;n<cell.nof_prb;n++) {
|
||||
for (int delta_ss=0;delta_ss<NOF_DELTA_SS;delta_ss++) {
|
||||
for (int cshift=0;cshift<NOF_CSHIFT;cshift++) {
|
||||
for (int h=0;h<3;h++) {
|
||||
for (int ns=0;ns<NSLOTS_X_FRAME;ns++) {
|
||||
for (int cshift_drms=5;cshift_drms<NOF_CSHIFT;cshift_drms++) {
|
||||
pusch_cfg.beta_pusch = 1.0;
|
||||
pusch_cfg.nof_prb = n;
|
||||
pusch_cfg.common.cyclic_shift = cshift;
|
||||
pusch_cfg.common.cyclic_shift_for_drms = cshift_drms;
|
||||
pusch_cfg.common.delta_ss = delta_ss;
|
||||
pusch_cfg.hopping_method = hopping_modes[h];
|
||||
pusch_cfg.common.en_drms_2 = true;
|
||||
printf("Beta: %f, ",pusch_cfg.beta_pusch);
|
||||
printf("nof_prb: %d, ",pusch_cfg.nof_prb);
|
||||
printf("cyclic_shift: %d, ",pusch_cfg.common.cyclic_shift);
|
||||
printf("cyclic_shift_for_drms: %d, ",pusch_cfg.common.cyclic_shift_for_drms);
|
||||
printf("delta_ss: %d, ",pusch_cfg.common.delta_ss);
|
||||
printf("hopping_method: %d, ",pusch_cfg.hopping_method);
|
||||
printf("Slot: %d\n", ns);
|
||||
refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, ns, signal);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
do_exit:
|
||||
|
||||
if (signal) {
|
||||
free(signal);
|
||||
}
|
||||
|
||||
refsignal_ul_free(&refs);
|
||||
|
||||
if (!ret) {
|
||||
printf("OK\n");
|
||||
}
|
||||
exit(ret);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
ueConfig=struct('CyclicPrefixUL','Normal','NTxAnts',1);
|
||||
puschConfig=struct('NLayers',1,'OrthCover','Off');
|
||||
|
||||
addpath('../../debug/lte/phy/lib/ch_estimation/test')
|
||||
|
||||
Hopping={'Off','Sequence','Group'};
|
||||
|
||||
k=1;
|
||||
for prb=3:6
|
||||
for ncell=0:2
|
||||
for ns=0:9
|
||||
for h=1:3
|
||||
for sg=0:29
|
||||
for cs=0:7
|
||||
for ds=0:7
|
||||
|
||||
ueConfig.NCellID=ncell;
|
||||
ueConfig.NSubframe=ns;
|
||||
ueConfig.Hopping=Hopping{h};
|
||||
ueConfig.SeqGroup=sg;
|
||||
ueConfig.CyclicShift=cs;
|
||||
|
||||
puschConfig.PRBSet=(0:(prb-1))';
|
||||
puschConfig.DynCyclicShift=ds;
|
||||
|
||||
[mat, info]=ltePUSCHDRS(ueConfig,puschConfig);
|
||||
lib=liblte_refsignal_pusch(ueConfig,puschConfig);
|
||||
|
||||
error(k)=mean(abs(mat-lib));
|
||||
disp(error(k))
|
||||
if (error(k) > 10^-4)
|
||||
k=1;
|
||||
end
|
||||
k=k+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
plot(error);
|
||||
disp(info)
|
||||
disp(length(mat))
|
||||
n=1:length(mat);
|
||||
plot(n,real(mat(n)),n,real(lib(n)))
|
||||
|
|
@ -40,7 +40,6 @@ char *mexutils_get_char_struct(const mxArray *ptr, const char *field_name) {
|
|||
mxArray *p;
|
||||
p = mxGetField(ptr, 0, field_name);
|
||||
if (!p) {
|
||||
mexPrintf("Error field %s not found\n", field_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -56,7 +55,6 @@ int mexutils_read_uint32_struct(const mxArray *ptr, const char *field_name, uint
|
|||
mxArray *p;
|
||||
p = mxGetField(ptr, 0, field_name);
|
||||
if (!p) {
|
||||
mexPrintf("Error field %s not found\n", field_name);
|
||||
return -1;
|
||||
}
|
||||
*value = (uint32_t) mxGetScalar(p);
|
||||
|
|
Loading…
Reference in New Issue