minor fixes in pucch rx

master
Ismael Gomez 8 years ago
parent c732c5c5f0
commit ffd4fb7d93

@ -97,8 +97,15 @@ if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-write-strings -Wno-format-extra-args -Winline -Wno-unused-result -Wno-format -std=c99 -D_GNU_SOURCE -g") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-write-strings -Wno-format-extra-args -Winline -Wno-unused-result -Wno-format -std=c99 -D_GNU_SOURCE -g")
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") find_package(SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
if(HAVE_AVX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE")
elseif(HAVE_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE")
endif(HAVE_AVX)
else(${CMAKE_BUILD_TYPE} STREQUAL "Debug") else(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
find_package(SSE) find_package(SSE)
if(HAVE_AVX) if(HAVE_AVX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE")

@ -1,13 +1,13 @@
%% PRACH Detection Conformance Test %% PRACH Detection Conformance Test
%clear %clear
d=50;%linspace(4,14,6); d=80;%linspace(4,14,6);
pDetection2 = zeros(2,length(d)); pDetection2 = zeros(2,length(d));
for dd=1:length(d) for dd=1:length(d)
detect_factor=d(dd); detect_factor=d(dd);
numSubframes = 1; % Number of subframes frames to simulate at each SNR numSubframes = 1; % Number of subframes frames to simulate at each SNR
SNRdB = 10;%linspace(-14,10,8); % SNR points to simulate SNRdB = 50;%linspace(-14,10,8); % SNR points to simulate
foffset = 0.0; % Frequency offset in Hertz foffset = 0.0; % Frequency offset in Hertz
delay=0; delay=0;
add_fading=false; add_fading=false;
@ -26,7 +26,7 @@ ue.NTxAnts = 1; % Number of transmission antennas
prach.Format = 0; % PRACH format: TS36.104, Table 8.4.2.1-1 prach.Format = 0; % PRACH format: TS36.104, Table 8.4.2.1-1
prach.HighSpeed = 0; % Normal mode: TS36.104, Table 8.4.2.1-1 prach.HighSpeed = 0; % Normal mode: TS36.104, Table 8.4.2.1-1
prach.FreqOffset = 4; % Default frequency location prach.FreqOffset = 2; % Default frequency location
info = ltePRACHInfo(ue, prach); % PRACH information info = ltePRACHInfo(ue, prach); % PRACH information
%% Propagation Channel Configuration %% Propagation Channel Configuration
@ -67,9 +67,10 @@ for nSNR = 1:length(SNRdB)
% Loop for each subframe % Loop for each subframe
for nsf = 1:numSubframes for nsf = 1:numSubframes
prach.SeqIdx = 0;%randi(838,1,1)-1; % Logical sequence index: TS36.141, Table A.6-1 prach.SeqIdx = 41;%randi(838,1,1)-1; % Logical sequence index: TS36.141, Table A.6-1
prach.CyclicShiftIdx = 11;%randi(16,1,1)-1; % Cyclic shift index: TS36.141, Table A.6-1 prach.CyclicShiftIdx = 11;%randi(16,1,1)-1; % Cyclic shift index: TS36.141, Table A.6-1
prach.PreambleIdx = 1;%randi(64,1,1)-1; % Preamble index: TS36.141, Table A.6-1 prach.PreambleIdx = 1;%randi(64,1,1)-1; % Preamble index: TS36.141, Table A.6-1
prach.TimingOffset = 0;
info = ltePRACHInfo(ue, prach); % PRACH information info = ltePRACHInfo(ue, prach); % PRACH information
% PRACH transmission % PRACH transmission
@ -99,7 +100,7 @@ for nSNR = 1:length(SNRdB)
rxwave = rxwave((fadinginfo.ChannelFilterDelay + 1):end, :); rxwave = rxwave((fadinginfo.ChannelFilterDelay + 1):end, :);
end end
rxwave=x; rxwave=lteFrequencyCorrect(ue, x, -20);
% rxwave=[zeros(delay,1); txwave(1:end-delay)]; % rxwave=[zeros(delay,1); txwave(1:end-delay)];
% Apply frequency offset % Apply frequency offset

@ -270,6 +270,10 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t *q, cf_t *input, cf_t *ce,
} }
int n_rs = srslte_refsignal_dmrs_N_rs(format, q->cell.cp); int n_rs = srslte_refsignal_dmrs_N_rs(format, q->cell.cp);
if (!n_rs) {
fprintf(stderr, "Error computing N_rs\n");
return SRSLTE_ERROR;
}
int nrefs_sf = SRSLTE_NRE*n_rs*2; int nrefs_sf = SRSLTE_NRE*n_rs*2;
/* Get references from the input signal */ /* Get references from the input signal */

@ -471,6 +471,9 @@ uint32_t srslte_refsignal_dmrs_N_rs(srslte_pucch_format_t format, srslte_cp_t cp
case SRSLTE_PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2A:
case SRSLTE_PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
return 2; return 2;
default:
fprintf(stderr, "Unsupported format %d\n", format);
return 0;
} }
return 0; return 0;
} }
@ -575,6 +578,9 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, srslte_pucch_forma
case SRSLTE_PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
w=w_arg_pucch_format2_cpnorm; w=w_arg_pucch_format2_cpnorm;
break; break;
default:
fprintf(stderr, "Unsupported format %d\n", format);
return SRSLTE_ERROR;
} }
cf_t z_m = 1.0; cf_t z_m = 1.0;
if (m == 1) { if (m == 1) {

@ -190,7 +190,6 @@ int srslte_enb_ul_cfg_ue(srslte_enb_ul_t *q, uint32_t idx,
q->uci_cfg_en[idx] = false; q->uci_cfg_en[idx] = false;
} }
if (pucch_sched) { if (pucch_sched) {
printf("saving sched for idx=%d, N_pucch_1=%d\n", idx, pucch_sched->N_pucch_1);
memcpy(&q->pucch_sched[idx], pucch_sched, sizeof(srslte_pucch_sched_t)); memcpy(&q->pucch_sched[idx], pucch_sched, sizeof(srslte_pucch_sched_t));
} }
if (srs_cfg) { if (srs_cfg) {
@ -216,12 +215,11 @@ void srslte_enb_ul_fft(srslte_enb_ul_t *q, cf_t *signal_buffer)
srslte_ofdm_rx_sf(&q->fft, signal_buffer, q->sf_symbols); srslte_ofdm_rx_sf(&q->fft, signal_buffer, q->sf_symbols);
} }
int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx, int get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx,
uint32_t pdcch_n_cce, uint32_t sf_rx, uint32_t pdcch_n_cce, uint32_t sf_rx,
srslte_uci_data_t *uci_data) srslte_uci_data_t *uci_data, uint8_t bits[SRSLTE_PUCCH_MAX_BITS])
{ {
float noise_power = srslte_chest_ul_get_noise_estimate(&q->chest);
if (rnti_idx < q->nof_rnti) {
srslte_pucch_format_t format = srslte_pucch_get_format(uci_data, q->cell.cp); srslte_pucch_format_t format = srslte_pucch_get_format(uci_data, q->cell.cp);
@ -232,23 +230,44 @@ int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx,
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
float noise_power = srslte_chest_ul_get_noise_estimate(&q->chest);
uint8_t bits[SRSLTE_PUCCH_MAX_BITS];
int ret_val = srslte_pucch_decode(&q->pucch, format, n_pucch, sf_rx, q->sf_symbols, q->ce, noise_power, bits); int ret_val = srslte_pucch_decode(&q->pucch, format, n_pucch, sf_rx, q->sf_symbols, q->ce, noise_power, bits);
if (ret_val < 0) { if (ret_val < 0) {
fprintf(stderr,"Error decoding PUCCH\n"); fprintf(stderr,"Error decoding PUCCH\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return ret_val;
}
int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx,
uint32_t pdcch_n_cce, uint32_t sf_rx,
srslte_uci_data_t *uci_data)
{
uint8_t bits[SRSLTE_PUCCH_MAX_BITS];
if (rnti_idx < q->nof_rnti) {
int ret_val = get_pucch(q, rnti_idx, pdcch_n_cce, sf_rx, uci_data, bits);
// If we are looking for SR and ACK at the same time and ret=0, means there is no SR.
// try again to decode ACK only
if (uci_data->scheduling_request && uci_data->uci_ack_len && ret_val != 1) {
uci_data->scheduling_request = false;
ret_val = get_pucch(q, rnti_idx, pdcch_n_cce, sf_rx, uci_data, bits);
}
// update schedulign request // update schedulign request
if (uci_data->scheduling_request) { if (uci_data->scheduling_request) {
uci_data->scheduling_request = ret_val; uci_data->scheduling_request = (ret_val==1);
} }
// Save ACK bits // Save ACK bits
if (uci_data->uci_ack_len > 0) { if (uci_data->uci_ack_len > 0) {
if (ret_val > 0) {
uci_data->uci_ack = bits[0]; uci_data->uci_ack = bits[0];
} else {
uci_data->uci_ack = 0;
}
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {

@ -65,7 +65,7 @@ int srslte_dci_msg_to_dl_grant(srslte_dci_msg_t *msg, uint16_t msg_rnti,
srslte_dci_format_t tmp = msg->format; srslte_dci_format_t tmp = msg->format;
ret = srslte_dci_msg_unpack_pdsch(msg, dl_dci, nof_prb, nof_ports, crc_is_crnti); ret = srslte_dci_msg_unpack_pdsch(msg, dl_dci, nof_prb, nof_ports, crc_is_crnti);
if (ret) { if (ret) {
fprintf(stderr, "Can't unpack DCI message %s (%d)\n", srslte_dci_format_string(tmp), tmp); //fprintf(stderr, "Can't unpack DCI message %s (%d)\n", srslte_dci_format_string(tmp), tmp);
return ret; return ret;
} }
@ -754,13 +754,13 @@ int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
while(i<nof_bits && y[1+i] == 1) while(i<nof_bits && y[1+i] == 1)
i++; i++;
if (i == nof_bits) { if (i == nof_bits) {
printf("Warning check me: could this be a RA PDCCH order??\n"); //printf("Warning check me: could this be a RA PDCCH order??\n");
i=1+10+nof_bits; i=1+10+nof_bits;
while(i<msg->nof_bits-1 && y[i] == 0) { while(i<msg->nof_bits-1 && y[i] == 0) {
i++; i++;
} }
if (i == msg->nof_bits-1) { if (i == msg->nof_bits-1) {
printf("Received a Format1A RA PDCCH order. Not implemented!\n"); //printf("Received a Format1A RA PDCCH order. Not implemented!\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }

@ -600,6 +600,7 @@ int srslte_prach_detect_offset(srslte_prach_t *p,
for (int j=0;j<n_wins;j++) { for (int j=0;j<n_wins;j++) {
if(p->peak_values[j] > p->detect_factor*corr_ave) if(p->peak_values[j] > p->detect_factor*corr_ave)
{ {
//printf("saving prach correlation\n");
//memcpy(save_corr, p->corr, p->N_zc*sizeof(float)); //memcpy(save_corr, p->corr, p->N_zc*sizeof(float));
if (indices) { if (indices) {
indices[*n_indices] = (i*n_wins)+j; indices[*n_indices] = (i*n_wins)+j;

@ -101,6 +101,8 @@ uint32_t get_N_sf(srslte_pucch_format_t format, uint32_t slot_idx, bool shortene
case SRSLTE_PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2A:
case SRSLTE_PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
return 5; return 5;
default:
return 0;
} }
return 0; return 0;
} }
@ -128,6 +130,8 @@ uint32_t srslte_pucch_nbits_format(srslte_pucch_format_t format) {
return 21; return 21;
case SRSLTE_PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
return 22; return 22;
default:
return 0;
} }
return 0; return 0;
} }
@ -156,6 +160,8 @@ uint32_t get_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslte_cp_t
} }
} }
break; break;
default:
return 0;
} }
return 0; return 0;
} }
@ -216,6 +222,7 @@ uint32_t srslte_pucch_get_npucch(uint32_t n_cce, srslte_pucch_format_t format, b
} else { } else {
n_pucch = pucch_sched->n_pucch_2; n_pucch = pucch_sched->n_pucch_2;
} }
return n_pucch;
} }
uint32_t srslte_pucch_n_prb(srslte_pucch_cfg_t *cfg, srslte_pucch_format_t format, uint32_t n_pucch, uint32_t srslte_pucch_n_prb(srslte_pucch_cfg_t *cfg, srslte_pucch_format_t format, uint32_t n_pucch,
@ -250,6 +257,9 @@ uint32_t srslte_pucch_m(srslte_pucch_cfg_t *cfg, srslte_pucch_format_t format, u
case SRSLTE_PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
m = n_pucch/SRSLTE_NRE; m = n_pucch/SRSLTE_NRE;
break; break;
default:
m = 0;
break;
} }
return m; return m;
} }
@ -729,6 +739,8 @@ int srslte_pucch_decode(srslte_pucch_t* q, srslte_pucch_format_t format,
if (corr > corr_max && corr >= q->threshold_format1a) { if (corr > corr_max && corr >= q->threshold_format1a) {
corr_max = corr; corr_max = corr;
b_max = b; b_max = b;
}
if (corr_max > q->threshold_format1a) {
ret = 1; ret = 1;
} }
DEBUG("format1a b=%d, corr=%f, nof_re=%d, th=%f\n", b, corr, nof_re, q->threshold_format1a); DEBUG("format1a b=%d, corr=%f, nof_re=%d, th=%f\n", b, corr, nof_re, q->threshold_format1a);
@ -740,7 +752,6 @@ int srslte_pucch_decode(srslte_pucch_t* q, srslte_pucch_format_t format,
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
break; break;
} }
ret = SRSLTE_SUCCESS;
} }
return ret; return ret;

@ -265,6 +265,7 @@ int srslte_ue_ul_pucch_encode(srslte_ue_ul_t *q, srslte_uci_data_t uci_data,
// Choose n_pucch // Choose n_pucch
uint32_t n_pucch = srslte_pucch_get_npucch(pdcch_n_cce, format, uci_data.scheduling_request, &q->pucch_sched); uint32_t n_pucch = srslte_pucch_get_npucch(pdcch_n_cce, format, uci_data.scheduling_request, &q->pucch_sched);
if (srslte_pucch_encode(&q->pucch, format, n_pucch, sf_idx, pucch_bits, q->sf_symbols)) { if (srslte_pucch_encode(&q->pucch, format, n_pucch, sf_idx, pucch_bits, q->sf_symbols)) {
fprintf(stderr, "Error encoding TB\n"); fprintf(stderr, "Error encoding TB\n");
return ret; return ret;

Loading…
Cancel
Save