Changed CP detection algorithm

master
ismagom 11 years ago
parent dbc3195830
commit 3844d19916

@ -65,12 +65,12 @@ typedef enum {CPNORM, CPEXT} lte_cp_t;
#define SYMBOL_SZ_MAX 2048
#define CPNORM_NSYMB 7
#define CPNORM_SF_NSYMB 2*CPNORM_NSYMB
#define CPNORM_SF_NSYMB (2*CPNORM_NSYMB)
#define CPNORM_0_LEN 160
#define CPNORM_LEN 144
#define CPEXT_NSYMB 6
#define CPEXT_SF_NSYMB 2*CPEXT_NSYMB
#define CPEXT_SF_NSYMB (2*CPEXT_NSYMB)
#define CPEXT_LEN 512
#define CPEXT_7_5_LEN 1024
@ -78,13 +78,13 @@ typedef enum {CPNORM, CPEXT} lte_cp_t;
#define CP_ISEXT(cp) (cp==CPEXT)
#define CP_NSYMB(cp) (CP_ISNORM(cp)?CPNORM_NSYMB:CPEXT_NSYMB)
#define CP(symbol_sz, c) (c*symbol_sz/2048)
#define CP_NORM(symbol, symbol_sz) (symbol==0)?CP(symbol_sz,CPNORM_0_LEN):CP(symbol_sz,CPNORM_LEN)
#define CP_EXT(symbol_sz) CP(symbol_sz,CPEXT_LEN)
#define CP(symbol_sz, c) ((c*symbol_sz)/2048)
#define CP_NORM(symbol, symbol_sz) ((symbol==0)?CP((symbol_sz),CPNORM_0_LEN):CP((symbol_sz),CPNORM_LEN))
#define CP_EXT(symbol_sz) (CP((symbol_sz),CPEXT_LEN))
#define SLOT_LEN(symbol_sz) (480*((symbol_sz)/64))
#define SF_LEN(symbol_sz) (2*SLOT_LEN(symbol_sz))
#define SF_LEN_MAX SF_LEN(SYMBOL_SZ_MAX)
#define SF_LEN_MAX (SF_LEN(SYMBOL_SZ_MAX))
#define SLOT_LEN_RE(nof_prb, cp) (nof_prb*RE_X_RB*CP_NSYMB(cp))
#define SF_LEN_RE(nof_prb, cp) (2*SLOT_LEN_RE(nof_prb, cp))

@ -143,9 +143,41 @@ lte_cp_t sync_get_cp(sync_t *q) {
return q->cp;
}
static lte_cp_t detect_cp(cf_t *input, uint32_t peak_pos)
/* CP detection algorithm taken from:
* "SSS Detection Method for Initial Cell Search in 3GPP LTE FDD/TDD Dual Mode Receiver"
* by Jung-In Kim et al.
*/
static lte_cp_t detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos)
{
float R_norm, R_ext, C_norm, C_ext;
float M_norm, M_ext;
R_norm = crealf(vec_dot_prod_conj_ccc(&input[peak_pos-q->fft_size-CP_NORM(7, q->fft_size)],
&input[peak_pos-CP_NORM(7, q->fft_size)],
CP_NORM(7, q->fft_size)));
C_norm = cabsf(vec_dot_prod_conj_ccc(&input[peak_pos-q->fft_size-CP_NORM(7, q->fft_size)],
&input[peak_pos-q->fft_size-CP_NORM(7, q->fft_size)],
CP_NORM(7, q->fft_size)));
R_ext = crealf(vec_dot_prod_conj_ccc(&input[peak_pos-q->fft_size-CP_EXT(q->fft_size)],
&input[peak_pos-CP_EXT(q->fft_size)],
CP_EXT(q->fft_size)));
C_ext = cabsf(vec_dot_prod_conj_ccc(&input[peak_pos-q->fft_size-CP_EXT(q->fft_size)],
&input[peak_pos-q->fft_size-CP_EXT(q->fft_size)],
CP_EXT(q->fft_size)));
M_norm = R_norm/C_norm;
M_ext = R_ext/C_ext;
if (M_norm > M_ext) {
return CPNORM;
} else if (M_norm < M_ext) {
return CPEXT;
} else {
if (R_norm > R_ext) {
return CPNORM;
} else {
return CPEXT;
}
}
}
int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos) {
@ -156,7 +188,7 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos) {
sss_synch_set_N_id_2(&q->sss, q->N_id_2);
if (q->detect_cp) {
q->cp = detect_cp(input, peak_pos);
q->cp = detect_cp(q, input, peak_pos);
}
/* Make sure we have enough room to find SSS sequence */
@ -184,7 +216,8 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos) {
return 1;
}
int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_position) {
int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_position)
{
int ret = LIBLTE_ERROR_INVALID_INPUTS;

@ -211,7 +211,7 @@ int ue_celldetect_scan(ue_celldetect_t * q,
for (uint32_t nf=0;nf<nof_input_frames;nf++) {
sync_set_N_id_2(&q->sfind, q->current_N_id_2);
DEBUG("[%3d/%3d]: Searching cells with N_id_2=%d. %d frames\n",
printf("[%3d/%3d]: Searching cells with N_id_2=%d. %d frames\n",
q->current_nof_detected, q->current_nof_total, q->current_N_id_2, nof_input_frames);
/* Find peak and cell id */

Loading…
Cancel
Save