diff --git a/matlab/tests/srs_test.m b/matlab/tests/srs_test.m index e9133e4f4..48c615e78 100644 --- a/matlab/tests/srs_test.m +++ b/matlab/tests/srs_test.m @@ -1,44 +1,47 @@ clear -ueConfig=struct('NCellID',1,'NULRB',25,'DuplexMode','FDD','NSubframe',0,'NFrame',0,'CyclicPrefixUL','Normal','NTxAnts',1); -srsConfig=struct('NTxAnts',1,'ConfigIdx',0,'SeqGroup',1,'SeqIdx',0,'TxComb',0); +ueConfig=struct('NCellID',1,'NULRB',100,'DuplexMode','FDD','NSubframe',0,'CyclicPrefixUL','Normal','NTxAnts',1); +srsConfig=struct('NTxAnts',1,'ConfigIdx',317,'SeqGroup',1,'SeqIdx',0,'TxComb',0); addpath('../../build/srslte/lib/ch_estimation/test') -for csbw=2:7 - for uebw=0:3 - for hop=0:3 - for ncs=0:7 - for n_rrc=0:23 - srsConfig.BWConfig = csbw; - srsConfig.BW = uebw; - srsConfig.CyclicShift = ncs; - srsConfig.HoppingBW = hop; - srsConfig.FreqPosition = n_rrc; - fprintf('Testing SRS: CSBW=%d, UEBW=%d, b_hop=%d n_rrc=%d, CyclicShift=%d\n',csbw, uebw, hop, n_rrc, ncs); +for k=0:50 + for csbw=0:7 + for uebw=0:3 + for hop=0:3 + for ncs=0 + for n_rrc=1:5:20 + ueConfig.NFrame=mod(32*k,1024); + srsConfig.BWConfig = csbw; + srsConfig.BW = uebw; + srsConfig.CyclicShift = ncs; + srsConfig.HoppingBW = hop; + srsConfig.FreqPosition = n_rrc; + fprintf('Testing SRS: Nframe=%d, CSBW=%d, UEBW=%d, b_hop=%d n_rrc=%d\n',ueConfig.NFrame, csbw, uebw, hop, n_rrc); - [sym_mat, info]=lteSRS(ueConfig,srsConfig); - [idx, info2]=lteSRSIndices(ueConfig,srsConfig); - subframe_mat = lteULResourceGrid(ueConfig); - subframe_mat(idx)=sym_mat; + [sym_mat, info]=lteSRS(ueConfig,srsConfig); + [idx, info2]=lteSRSIndices(ueConfig,srsConfig); + subframe_mat = lteULResourceGrid(ueConfig); + subframe_mat(idx)=sym_mat; - [sym, subframe]=srslte_refsignal_srs(ueConfig,srsConfig); + [sym, subframe]=srslte_refsignal_srs(ueConfig,srsConfig); - error_sym=max(abs(sym-sym_mat)); - error_sf=max(abs(subframe_mat(:)-subframe)); + error_sym=max(abs(sym-sym_mat)); + error_sf=max(abs(subframe_mat(:)-subframe)); - if (error_sym > 1e-3) - disp(info) - plot(1:length(sym),sym,1:length(sym_mat),sym_mat) - legend('srsLTE','Matlab') - error('Error in symbols'); - end - if (error_sf > 1e-3) - disp(info2) - plot(abs(subframe-subframe_mat(:))) - error('Error in subframe'); + if (error_sym > 3.5e-3) + disp(info) + plot(abs(sym-sym_mat)) + legend('srsLTE','Matlab') + error('Error in symbols'); + end + if (error_sf > 3.5e-3) + disp(info2) + plot(abs(subframe-subframe_mat(:))) + error('Error in subframe'); + end end end end end end -end +end \ No newline at end of file diff --git a/srsapps/ue/mac/src/mac.cc b/srsapps/ue/mac/src/mac.cc index 918c5da2b..1e10fcd84 100644 --- a/srsapps/ue/mac/src/mac.cc +++ b/srsapps/ue/mac/src/mac.cc @@ -263,7 +263,6 @@ void mac::main_radio_loop() { ul_buffer->generate_cqi_report(); } - // The UL buffer is released when successfully transmitted. if (ul_buffer->is_released()) { ul_buffer->ready(); diff --git a/srsapps/ue/phy/src/phy.cc b/srsapps/ue/phy/src/phy.cc index fc76e0a47..df94005f1 100644 --- a/srsapps/ue/phy/src/phy.cc +++ b/srsapps/ue/phy/src/phy.cc @@ -358,6 +358,7 @@ bool phy::init_prach() { ul_buffer* phy::get_ul_buffer(uint32_t tti) { + tti=tti%10240; if (tti + 1 < get_current_tti() && tti > NOF_ULDL_QUEUES) { Warning("Warning access to PHY UL buffer too late. Requested TTI=%d while PHY is in %d\n", tti, get_current_tti()); } @@ -371,6 +372,7 @@ ul_buffer* phy::get_ul_buffer_adv(uint32_t tti) dl_buffer* phy::get_dl_buffer(uint32_t tti) { + tti=tti%10240; if (tti + 4 < get_current_tti()) { Warning("Warning access to PHY DL buffer too late. Requested TTI=%d while PHY is in %d\n", tti, get_current_tti()); // return NULL; diff --git a/srslte/lib/ch_estimation/src/refsignal_ul.c b/srslte/lib/ch_estimation/src/refsignal_ul.c index 49f93a834..09c496f83 100644 --- a/srslte/lib/ch_estimation/src/refsignal_ul.c +++ b/srslte/lib/ch_estimation/src/refsignal_ul.c @@ -79,7 +79,7 @@ uint32_t m_srs_b[4][4][8] = {{ /* m_srs for 40tmp_arg, u); } else if (nof_prb == 2) { @@ -340,7 +339,7 @@ void compute_r(srslte_refsignal_ul_t *q, uint32_t nof_prb, uint32_t ns, uint32_t f_gh = q->f_gh[ns]; } uint32_t u = (f_gh + (q->cell.id%30)+delta_ss)%30; - + // Get sequence hopping number v uint32_t v = 0; if (nof_prb >= 6 && q->sequence_hopping_en) { @@ -348,7 +347,7 @@ void compute_r(srslte_refsignal_ul_t *q, uint32_t nof_prb, uint32_t ns, uint32_t } // Compute signal argument - compute_r_uv_arg(q, &q->pusch_cfg, nof_prb, u, v); + compute_r_uv_arg(q, nof_prb, u, v); } @@ -688,19 +687,23 @@ uint32_t srslte_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb) { return 0; } -uint32_t srs_Fb(srslte_refsignal_srs_cfg_t *cfg, uint32_t nof_prb, uint32_t tti) { +uint32_t srs_Fb(srslte_refsignal_srs_cfg_t *cfg, uint32_t b, uint32_t nof_prb, uint32_t tti) { uint32_t n_srs = tti/T_srs_table(cfg->I_srs); - uint32_t N_b = Nb[srsbwtable_idx(nof_prb)][cfg->B][cfg->bw_cfg]; + uint32_t N_b = Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; + uint32_t prod_1=1; - for (uint32_t b=cfg->b_hop;bB-1;b++) { - prod_1 *= Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; + for (uint32_t bp=cfg->b_hop+1;bpbw_cfg]; } - uint32_t prod_2 = prod_1*Nb[srsbwtable_idx(nof_prb)][cfg->B][cfg->bw_cfg]; - if (N_b%2) { - return N_b/2*((n_srs%prod_2)/prod_1)+((n_srs%prod_2)/prod_1/2); + uint32_t prod_2 = prod_1*Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; + uint32_t Fb; + if ((N_b%2) == 0) { + Fb = (N_b/2)*((n_srs%prod_2)/prod_1)+((n_srs%prod_2)/prod_1/2); } else { - return N_b/2*(n_srs/prod_1); + Fb = (N_b/2)*(n_srs/prod_1); } + + return Fb; } /* Returns k0: frequency-domain starting position for ue-specific SRS */ @@ -716,9 +719,11 @@ uint32_t srs_k0_ue(srslte_refsignal_srs_cfg_t *cfg, uint32_t nof_prb, uint32_t t if (b <= cfg->b_hop) { nb = (4*cfg->n_rrc/m_srs)%Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; } else { - nb = ((4*cfg->n_rrc/m_srs)+srs_Fb(cfg, nof_prb, tti))%Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; + uint32_t Fb=srs_Fb(cfg, b, nof_prb, tti); + nb = ((4*cfg->n_rrc/m_srs)+Fb)%Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; } - k0 += 2*m_sc*nb; + k0 += 2*m_sc*nb; + } return k0; } @@ -741,6 +746,7 @@ int srslte_refsignal_srs_gen(srslte_refsignal_ul_t *q, uint32_t sf_idx, cf_t *r_ compute_r(q, M_sc/SRSLTE_NRE, ns, 0); float alpha = 2*M_PI*q->srs_cfg.n_srs/8; + // Do complex exponential and adjust amplitude for (int i=0;isrs_cfg.beta_srs * cexpf(I*(q->tmp_arg[i] + alpha*i));