Merge branch 'master' into next

Conflicts:
	srslte/lib/CMakeLists.txt
This commit is contained in:
Paul Sutton 2016-06-22 15:32:58 +02:00
commit 3949d2ed46
30 changed files with 196 additions and 117 deletions

21
matlab/common/bin2hex.m Normal file
View File

@ -0,0 +1,21 @@
function [ s ] = bin2hex( in )
%BIN2HEX Summary of this function goes here
% Detailed explanation goes here
a=reshape(in,8,[]);
t=size(a);
s=cell(1,t(2));
nbit=2.^(7:-1:0);
for i=1:t(2)
s{i}=dec2hex(sum(nbit'.*double(a(:,i))));
end
for i=1:t(2)
if (length(s{i})==1)
fprintf('0%s ',s{i})
else
fprintf('%s ',s{i})
end
end
fprintf('\n');
end

View File

@ -6,13 +6,13 @@ clear
plot_noise_estimation_only=false;
SNR_values_db=linspace(0,30,5);
Nrealizations=4;
SNR_values_db=100;%linspace(20,35,8);
Nrealizations=1;
w1=0.1;
w2=0.2;
w2=0.3;
enb.NDLRB = 50; % Number of resource blocks
enb.NDLRB = 25; % Number of resource blocks
enb.CellRefP = 1; % One transmit antenna port
enb.NCellID = 0; % Cell ID
@ -26,7 +26,7 @@ P=K/6;
cfg.Seed = 0; % Random channel seed
cfg.InitTime = 0;
cfg.NRxAnts = 1; % 1 receive antenna
cfg.DelayProfile = 'EVA';
cfg.DelayProfile = 'EPA';
% doppler 5, 70 300
@ -203,7 +203,6 @@ end
%% Plot a single realization
if (length(SNR_values_db) == 1)
subplot(2,1,1)
sym=1;
ref_idx=1:P;
ref_idx_x=[1:6:K];% (292:6:360)-216];% 577:6:648];
@ -212,13 +211,14 @@ if (length(SNR_values_db) == 1)
plot(n,abs(reshape(hest{i}(:,sym),1,[])),colors2{i});
hold on;
end
plot(ref_idx_x,abs(hls(3,ref_idx)),'ro');
plot(n, abs(h(:,sym)),'g-')
% plot(ref_idx_x,real(hls(3,ref_idx)),'ro');
hold off;
tmp=cell(Ntests+1,1);
for i=1:Ntests
tmp{i}=legends{i};
end
tmp{Ntests+1}='LS';
tmp{Ntests+1}='Real';
legend(tmp)
xlabel('SNR (dB)')
@ -228,9 +228,6 @@ if (length(SNR_values_db) == 1)
fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx)))
fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx)))
subplot(2,1,2)
plot(1:P,abs(W3(P/2,:)))
end
end

View File

@ -11,7 +11,7 @@ SNR_values = linspace(2,6,6);
txCFI = 3;
enbConfig.NDLRB = 15; % No of Downlink RBs in total BW
enbConfig.CyclicPrefix = 'Normal'; % CP length
enbConfig.CFI = txCFI; ; % 4 PDCCH symbols as NDLRB <= 10
enbConfig.CFI = txCFI; % 4 PDCCH symbols as NDLRB <= 10
enbConfig.Ng = 'One'; % HICH groups
enbConfig.CellRefP = 1; % 1-antenna ports
enbConfig.NCellID = 0; % Physical layer cell identity
@ -23,7 +23,7 @@ C_RNTI = 1; % 16-bit UE-specific mask
%% Setup Fading channel model
cfg.Seed = 8; % Random channel seed
cfg.NRxAnts = 1; % 1 receive antenna
cfg.DelayProfile = 'EVA'; % EVA delay spread
cfg.DelayProfile = 'EPA'; % EVA delay spread
cfg.DopplerFreq = 5; % 120Hz Doppler frequency
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
cfg.InitTime = 0; % Initialize at time zero
@ -56,7 +56,7 @@ dciConfig.Allocation.RIV = 26; % Resource indication value
if C_RNTI<65535
pdcchConfig.RNTI = C_RNTI; % Radio network temporary identifier
end
pdcchConfig.PDCCHFormat = 0; % PDCCH format
pdcchConfig.PDCCHFormat = 3; % PDCCH format
ueConfig.RNTI = C_RNTI;
candidates = ltePDCCHSpace(enbConfig, pdcchConfig, {'bits', '1based'});
@ -153,7 +153,7 @@ for snr_idx=1:length(SNR_values)
%% Same with srsLTE
[rxCFI_srslte, pcfichRx2, pcfichSymbols2] = srslte_pcfich(enbConfigRx, subframe_rx);
decoded_cfi_srslte(snr_idx) = decoded_cfi_srslte(snr_idx) + (rxCFI_srslte == txCFI);
enbConfigRx.CFI = rxCFI;
enbConfigRx.CFI = txCFI;
[found_srslte, pdcchBits2, pdcchRx2, pdcchSymbols2, hest2] = srslte_pdcch(enbConfigRx, ueConfig.RNTI, subframe_rx, hest, nest);
decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+found_srslte;
end

View File

@ -7,8 +7,8 @@
recordedSignal=[];
Npackets = 20;
SNR_values = linspace(2,6,10);
Npackets = 1;
SNR_values = 56;%linspace(2,6,10);
Lp=12;
N=256;
@ -35,11 +35,11 @@ w2=reshape(transpose(W2),1,[]);
%% Choose RMC
[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.0',[1;0;0;1]);
[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.5',[1;0;0;1]);
waveform = sum(waveform,2);
if ~isempty(recordedSignal)
rmccFgOut = struct('CellRefP',1,'NDLRB',100,'DuplexMode','FDD','CyclicPrefix','Normal');
rmccFgOut = struct('CellRefP',1,'NDLRB',25,'DuplexMode','FDD','CyclicPrefix','Normal');
rmccFgOut.PDSCH.RNTI = 1234;
rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2);
rmccFgOut.PDSCH.TxScheme = 'Port0';
@ -53,7 +53,7 @@ end
flen=rmccFgOut.SamplingRate/1000;
Nsf = 9;
Nsf = 2;
%% Setup Fading channel model
cfg.Seed = 0; % Random channel seed
@ -71,8 +71,8 @@ cfg.SamplingRate = rmccFgOut.SamplingRate;
% Setup channel equalizer
cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
cec.FreqWindow = 9; % Frequency window size
cec.TimeWindow = 9; % Time window size
cec.FreqWindow = 1; % Frequency window size
cec.TimeWindow = 1; % Time window size
cec.InterpType = 'linear'; % 2D interpolation type
cec.InterpWindow = 'Causal'; % Interpolation window type
cec.InterpWinSize = 1; % Interpolation window size
@ -95,8 +95,9 @@ for snr_idx=1:length(SNR_values)
if isempty(recordedSignal)
%% Fading
%rxWaveform = lteFadingChannel(cfg,waveform);
rxWaveform = waveform;
[rxWaveform, chinfo] = lteFadingChannel(cfg,waveform);
rxWaveform = rxWaveform(chinfo.ChannelFilterDelay+1:end);
%rxWaveform = waveform;
%% Noise Addition
noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise
@ -154,6 +155,7 @@ if (length(SNR_values)>1)
ylabel('BLER')
axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1])
else
scatter(real(symbols{1}),imag(symbols{1}))
fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte);
end

View File

@ -1,18 +1,18 @@
enb=struct('NCellID',1,'NDLRB',50,'NSubframe',2,'CFI',2,'CyclicPrefix','Normal','CellRefP',1,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD');
enb=struct('NCellID',1,'NDLRB',25,'NSubframe',5,'CFI',2,'CyclicPrefix','Normal','CellRefP',1,'Ng','Sixth','PHICHDuration','Normal','DuplexMode','FDD');
RNTI=65535;
addpath('../../build/srslte/lib/phch/test')
cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
cec.FreqWindow = 9; % Frequency window size
cec.TimeWindow = 9; % Time window size
cec.FreqWindow = 1; % Frequency window size
cec.TimeWindow = 1; % Time window size
cec.InterpType = 'linear'; % 2D interpolation type
cec.InterpWindow = 'Causal'; % Interpolation window type
cec.InterpWinSize = 1; % Interpolation window size
subframe_rx=lteOFDMDemodulate(enb,y);
%subframe_rx=reshape(input,[],14);
%subframe_rx=lteOFDMDemodulate(enb,x);
subframe_rx=reshape(x,[],14);
[hest,nest] = lteDLChannelEstimate(enb, cec, subframe_rx);
% Search PDCCH
@ -20,7 +20,7 @@ pdcchIndices = ltePDCCHIndices(enb);
[pdcchRx, pdcchHest] = lteExtractResources(pdcchIndices, subframe_rx, hest);
[dciBits, pdcchSymbols] = ltePDCCHDecode(enb, pdcchRx, pdcchHest, nest);
pdcch = struct('RNTI', RNTI);
dci = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI
[dci, dcidecBits] = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI
if ~isempty(dci)
@ -30,9 +30,8 @@ if ~isempty(dci)
% Get the PDSCH configuration from the DCI
[pdsch, trblklen] = hPDSCHConfiguration(enb, dci, pdcch.RNTI);
pdsch.NTurboDecIts = 10;
pdsch.Modulation = {'QPSK'};
%pdsch.Modulation = {'64QAM'};
pdsch.RV=0;
%trblklen=75376;
fprintf('PDSCH settings after DCI decoding:\n');
disp(pdsch);
@ -41,12 +40,13 @@ if ~isempty(dci)
[pdschIndices,pdschIndicesInfo] = ltePDSCHIndices(enb, pdsch, pdsch.PRBSet);
[pdschRx, pdschHest] = lteExtractResources(pdschIndices, subframe_rx, hest);
% Decode PDSCH
[dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, nest);
[dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, 0);
[sib1, crc] = lteDLSCHDecode(enb, pdsch, trblklen, dlschBits);
%[dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ...
% trblklen, ...
% subframe_rx, hest, nest);
[dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ...
trblklen, ...
subframe_rx, hest, 0);
scatter(real(pdschSymbols{1}),imag(pdschSymbols{1}))

View File

@ -66,7 +66,7 @@ srslte_cell_t cell = {
int net_port = -1; // -1 generates random dataThat means there is some problem sending samples to the device
uint32_t cfi=2;
uint32_t cfi=3;
uint32_t mcs_idx = 1, last_mcs_idx = 1;
int nof_frames = -1;
@ -597,7 +597,12 @@ int main(int argc, char **argv) {
for (i=0;i<pdsch_cfg.grant.mcs.tbs/8;i++) {
data[i] = rand()%256;
}
send_data = true;
/* Uncomment this to transmit on sf 0 and 5 only */
if (sf_idx != 0 && sf_idx != 5) {
send_data = true;
} else {
send_data = false;
}
}
if (send_data) {

View File

@ -550,8 +550,8 @@ int main(int argc, char **argv) {
nof_trials++;
rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.1);
rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.1);
noise = SRSLTE_VEC_EMA(srslte_chest_dl_get_noise_estimate(&ue_dl.chest), noise, 0.1);
rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.05);
noise = SRSLTE_VEC_EMA(srslte_chest_dl_get_noise_estimate(&ue_dl.chest), noise, 0.05);
nframes++;
if (isnan(rsrq)) {
rsrq = 0;
@ -585,6 +585,11 @@ int main(int argc, char **argv) {
sfn++;
if (sfn == 1024) {
sfn = 0;
printf("\n");
ue_dl.pkt_errors = 0;
ue_dl.pkts_total = 0;
ue_dl.nof_detected = 0;
nof_trials = 0;
}
}

View File

@ -52,6 +52,12 @@
#define SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN 65
typedef enum {
SRSLTE_NOISE_ALG_REFS,
SRSLTE_NOISE_ALG_PSS,
SRSLTE_NOISE_ALG_EMPTY,
} srslte_chest_dl_noise_alg_t;
typedef struct {
srslte_cell_t cell;
srslte_refsignal_cs_t csr_signal;
@ -78,6 +84,9 @@ typedef struct {
cf_t pss_signal[SRSLTE_PSS_LEN];
cf_t tmp_pss[SRSLTE_PSS_LEN];
cf_t tmp_pss_noisy[SRSLTE_PSS_LEN];
srslte_chest_dl_noise_alg_t noise_alg;
} srslte_chest_dl_t;
@ -93,6 +102,9 @@ SRSLTE_API void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q,
SRSLTE_API void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q,
float w);
SRSLTE_API void srslte_chest_dl_set_noise_alg(srslte_chest_dl_t *q,
srslte_chest_dl_noise_alg_t noise_estimation_alg);
SRSLTE_API int srslte_chest_dl_estimate(srslte_chest_dl_t *q,
cf_t *input,
cf_t *ce[SRSLTE_MAX_PORTS],

View File

@ -61,10 +61,10 @@
typedef enum {SRSLTE_CP_NORM, SRSLTE_CP_EXT} srslte_cp_t;
#define SRSLTE_CRNTI_START 0x003D
#define SRSLTE_CRNTI_START 0x000B
#define SRSLTE_CRNTI_END 0xFFF3
#define SRSLTE_RARNTI_START 0x0001
#define SRSLTE_RARNTI_END 0x003C
#define SRSLTE_RARNTI_END 0x000A
#define SRSLTE_SIRNTI 0xFFFF
#define SRSLTE_PRNTI 0xFFFE
#define SRSLTE_MRNTI 0xFFFD

View File

@ -43,7 +43,7 @@
typedef struct SRSLTE_API {
uint32_t R;
uint32_t K;
uint32_t poly[3];
int poly[3];
bool tail_biting;
}srslte_convcoder_t;

View File

@ -55,7 +55,6 @@ typedef struct SRSLTE_API{
uint32_t framebits;
bool tail_biting;
float gain_quant;
uint32_t poly[3];
int (*decode) (void*, uint8_t*, uint8_t*, uint32_t);
int (*decode_f) (void*, float*, uint8_t*, uint32_t);
void (*free) (void*);
@ -65,7 +64,7 @@ typedef struct SRSLTE_API{
SRSLTE_API int srslte_viterbi_init(srslte_viterbi_t *q,
srslte_viterbi_type_t type,
uint32_t poly[3],
int poly[3],
uint32_t max_frame_length,
bool tail_bitting);
@ -88,7 +87,7 @@ SRSLTE_API int srslte_viterbi_decode_uc(srslte_viterbi_t *q,
SRSLTE_API int srslte_viterbi_init_sse(srslte_viterbi_t *q,
srslte_viterbi_type_t type,
uint32_t poly[3],
int poly[3],
uint32_t max_frame_length,
bool tail_bitting);

View File

@ -124,7 +124,7 @@ typedef struct SRSLTE_API {
uint32_t mcs_idx;
uint32_t harq_process;
uint32_t rv_idx;
int rv_idx;
bool ndi;
} srslte_ra_dl_dci_t;

View File

@ -98,6 +98,9 @@ endif(RF_FOUND)
if(VOLK_FOUND)
target_link_libraries(srslte ${VOLK_LIBRARIES})
if(NOT DisableMEX)
target_link_libraries(srslte_static ${VOLK_LIBRARIES})
endif(NOT DisableMEX)
endif(VOLK_FOUND)
INSTALL(TARGETS srslte DESTINATION ${LIBRARY_DIR})

View File

@ -39,8 +39,6 @@
#include "srslte/utils/vector.h"
#include "srslte/utils/convolution.h"
#define ESTIMATE_NOISE_LS_PSS
//#define DEFAULT_FILTER_LEN 3
#ifdef DEFAULT_FILTER_LEN
@ -125,6 +123,8 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
goto clean_exit;
}
q->noise_alg = SRSLTE_NOISE_ALG_REFS;
q->smooth_filter_len = 3;
srslte_chest_dl_set_smooth_filter3_coeff(q, 0.1);
@ -178,12 +178,17 @@ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id)
srslte_vec_fprint_f(stdout, q->snr_vector, nref);
#endif
/* Compute average power */
float power = (1/q->smooth_filter[0])*q->cell.nof_ports*srslte_vec_avg_power_cf(q->tmp_noise, nref);
/* Compute average power. Normalized for filter len 3 using matlab */
float norm = 1;
if (q->smooth_filter_len == 3) {
float a = q->smooth_filter[0];
float norm3 = 6.143*a*a+0.04859*a-0.002774;
norm /= norm3;
}
float power = norm*q->cell.nof_ports*srslte_vec_avg_power_cf(q->tmp_noise, nref);
return power;
}
#ifdef ESTIMATE_NOISE_LS_PSS
static float estimate_noise_pss(srslte_chest_dl_t *q, cf_t *input, cf_t *ce)
{
/* Get PSS from received signal */
@ -199,13 +204,10 @@ static float estimate_noise_pss(srslte_chest_dl_t *q, cf_t *input, cf_t *ce)
srslte_vec_sub_ccc(q->tmp_pss_noisy, q->tmp_pss, q->tmp_pss_noisy, SRSLTE_PSS_LEN);
/* Compute average power */
float power = q->cell.nof_ports*srslte_vec_avg_power_cf(q->tmp_pss_noisy, SRSLTE_PSS_LEN);
float power = q->cell.nof_ports*srslte_vec_avg_power_cf(q->tmp_pss_noisy, SRSLTE_PSS_LEN)/sqrt(2);
return power;
}
#else
/* Uses the 5 empty transmitted SC before and after the SSS and PSS sequences for noise estimation */
static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) {
int k_sss = (SRSLTE_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31;
@ -218,8 +220,6 @@ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) {
return noise_power;
}
#endif
#define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.nof_prb,i,0)]
@ -277,6 +277,10 @@ void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, float *filter, uint
}
}
void srslte_chest_dl_set_noise_alg(srslte_chest_dl_t *q, srslte_chest_dl_noise_alg_t noise_estimation_alg) {
q->noise_alg = noise_estimation_alg;
}
void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w)
{
q->smooth_filter_len = 3;
@ -315,26 +319,28 @@ int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q, cf_t *input, cf_t *ce, u
srslte_vec_prod_conj_ccc(q->pilot_recv_signal, q->csr_signal.pilots[port_id/2][sf_idx],
q->pilot_estimates, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
if (ce != NULL) {
if (q->smooth_filter_len > 0) {
/* Smooth estimates (if applicable) and interpolate */
if (q->smooth_filter_len == 0 || (q->smooth_filter_len == 3 && q->smooth_filter[0] == 0)) {
interpolate_pilots(q, q->pilot_estimates, ce, port_id);
} else {
average_pilots(q, q->pilot_estimates, q->pilot_estimates_average, port_id);
interpolate_pilots(q, q->pilot_estimates_average, ce, port_id);
}
/* If averaging, compute noise from difference between received and averaged estimates */
/* Estimate noise power */
if (q->noise_alg == SRSLTE_NOISE_ALG_REFS && q->smooth_filter_len > 0) {
q->noise_estimate[port_id] = estimate_noise_pilots(q, port_id);
} else if (q->noise_alg == SRSLTE_NOISE_ALG_PSS) {
if (sf_idx == 0 || sf_idx == 5) {
q->noise_estimate[port_id] = estimate_noise_pilots(q, port_id);
q->noise_estimate[port_id] = estimate_noise_pss(q, input, ce);
}
} else {
interpolate_pilots(q, q->pilot_estimates, ce, port_id);
/* If not averaging, compute noise from empty subcarriers */
if (sf_idx == 0 || sf_idx == 5) {
#ifdef ESTIMATE_NOISE_LS_PSS
q->noise_estimate[port_id] = estimate_noise_pss(q, input, ce);
#else
q->noise_estimate[port_id] = estimate_noise_empty_sc(q, input);
#endif
}
}
}
/* Compute RSRP for the channel estimates in this port */

View File

@ -60,7 +60,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
output_data = srslte_vec_malloc(nof_bits * sizeof(uint8_t));
uint32_t poly[3] = { 0x6D, 0x4F, 0x57 };
int poly[3] = { 0x6D, 0x4F, 0x57 };
if (srslte_viterbi_init(&viterbi, SRSLTE_VITERBI_37, poly, nof_bits/3, true)) {
return;
}

View File

@ -40,6 +40,8 @@
#define TB_ITER 3
#define DEFAULT_GAIN 16
//#undef LV_HAVE_SSE
int decode37(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length) {
@ -128,11 +130,11 @@ void free37(void *o) {
delete_viterbi37_port(q->ptr);
}
int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting) {
int init37(srslte_viterbi_t *q, int poly[3], uint32_t framebits, bool tail_biting) {
q->K = 7;
q->R = 3;
q->framebits = framebits;
q->gain_quant = 32;
q->gain_quant = DEFAULT_GAIN;
q->tail_biting = tail_biting;
q->decode = decode37;
q->free = free37;
@ -164,11 +166,11 @@ int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_
}
#ifdef LV_HAVE_SSE
int init37_sse(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting) {
int init37_sse(srslte_viterbi_t *q, int poly[3], uint32_t framebits, bool tail_biting) {
q->K = 7;
q->R = 3;
q->framebits = framebits;
q->gain_quant = 20;
q->gain_quant = DEFAULT_GAIN;
q->tail_biting = tail_biting;
q->decode = decode37_sse;
q->free = free37_sse;
@ -203,7 +205,7 @@ void srslte_viterbi_set_gain_quant(srslte_viterbi_t *q, float gain_quant) {
q->gain_quant = gain_quant;
}
int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_t poly[3], uint32_t max_frame_length, bool tail_bitting)
int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting)
{
switch (type) {
case SRSLTE_VITERBI_37:
@ -219,7 +221,7 @@ int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_
}
#ifdef LV_HAVE_SSE
int srslte_viterbi_init_sse(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_t poly[3], uint32_t max_frame_length, bool tail_bitting)
int srslte_viterbi_init_sse(srslte_viterbi_t *q, srslte_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting)
{
return init37_sse(q, poly, max_frame_length, tail_bitting);
}

View File

@ -26,7 +26,7 @@
#include <stdbool.h>
void *create_viterbi37_port(uint32_t polys[3],
void *create_viterbi37_port(int polys[3],
uint32_t len);
int init_viterbi37_port(void *p,
@ -45,7 +45,7 @@ int update_viterbi37_blk_port(void *p,
uint32_t *best_state);
void *create_viterbi37_sse(uint32_t polys[3],
void *create_viterbi37_sse(int polys[3],
uint32_t len);
int init_viterbi37_sse(void *p,

View File

@ -54,8 +54,8 @@ int init_viterbi37_port(void *p, int starting_state) {
return 0;
}
void set_viterbi37_polynomial_port(uint32_t polys[3]) {
uint32_t state;
void set_viterbi37_polynomial_port(int polys[3]) {
int state;
for (state = 0; state < 32; state++) {
Branchtab37[0].c[state] =
@ -68,7 +68,7 @@ void set_viterbi37_polynomial_port(uint32_t polys[3]) {
}
/* Create a new instance of a Viterbi decoder */
void *create_viterbi37_port(uint32_t polys[3], uint32_t len) {
void *create_viterbi37_port(int polys[3], uint32_t len) {
struct v37 *vp;
set_viterbi37_polynomial_port(polys);

View File

@ -44,7 +44,7 @@ struct v37 {
decision_t *decisions; /* Beginning of decisions for block */
};
void set_viterbi37_polynomial_sse(uint32_t polys[3]) {
void set_viterbi37_polynomial_sse(int polys[3]) {
int state;
for(state=0;state < 32;state++){
@ -73,7 +73,7 @@ int init_viterbi37_sse(void *p, int starting_state) {
}
/* Create a new instance of a Viterbi decoder */
void *create_viterbi37_sse(uint32_t polys[3], uint32_t len) {
void *create_viterbi37_sse(int polys[3], uint32_t len) {
void *p;
struct v37 *vp;

View File

@ -71,7 +71,7 @@ int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t b
uint8_t *body_ptr = buff;
srslte_bit_unpack(msg->subband_cqi, &body_ptr, 4);
srslte_bit_unpack(msg->subband_label, &body_ptr, msg->subband_label_2_bits?2:1);
return 4+msg->subband_label_2_bits?2:1;
return 4+(msg->subband_label_2_bits)?2:1;
}
int srslte_cqi_value_pack(srslte_cqi_value_t *value, uint8_t buff[SRSLTE_CQI_MAX_BITS])
@ -141,8 +141,12 @@ bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti) {
/* SNR-to-CQI conversion, got from "Downlink SNR to CQI Mapping for Different Multiple Antenna Techniques in LTE"
* Table III.
*/
// From paper
static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29};
// From experimental measurements @ 5 MHz
//static float cqi_to_snr_table[15] = { 1, 1.75, 3, 4, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5};
uint8_t srslte_cqi_from_snr(float snr)
{
for (int cqi=14;cqi>=0;cqi--) {

View File

@ -806,6 +806,7 @@ int dci_format1Cs_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
data->mcs_idx = srslte_bit_pack(&y, 5);
data->dci_format = SRSLTE_RA_DCI_FORMAT1C;
data->rv_idx = -1; // For SI-RNTI, get RV from TTI
msg->nof_bits = (y - msg->data);

View File

@ -158,7 +158,7 @@ int srslte_pbch_init(srslte_pbch_t *q, srslte_cell_t cell) {
goto clean;
}
uint32_t poly[3] = { 0x6D, 0x4F, 0x57 };
int poly[3] = { 0x6D, 0x4F, 0x57 };
if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, 40, true)) {
goto clean;
}

View File

@ -117,14 +117,16 @@ float srslte_pcfich_cfi_decode(srslte_pcfich_t *q, uint32_t *cfi) {
int i;
int index = 0;
float max_corr = 0;
float corr[3];
for (i = 0; i < 3; i++) {
float corr = fabsf(srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN));
if (corr > max_corr) {
max_corr = corr;
corr[i] = srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN);
if (corr[i] > max_corr) {
max_corr = corr[i];
index = i;
}
}
if (cfi) {
*cfi = index + 1;
}
@ -134,7 +136,7 @@ float srslte_pcfich_cfi_decode(srslte_pcfich_t *q, uint32_t *cfi) {
/** Encodes the CFI producing a vector of 32 bits.
* 36.211 10.3 section 5.3.4
*/
int srslte_pcfich_cfi_encode(int cfi, uint8_t bits[PCFICH_CFI_LEN]) {
int srslte_pcfich_cfi_encode(uint32_t cfi, uint8_t bits[PCFICH_CFI_LEN]) {
if (cfi < 1 || cfi > 3) {
return SRSLTE_ERROR_INVALID_INPUTS;
} else{
@ -220,7 +222,7 @@ int srslte_pcfich_encode(srslte_pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SR
int i;
if (q != NULL &&
cfi < 3 &&
cfi <= 3 &&
slot_symbols != NULL &&
subframe < SRSLTE_NSUBFRAMES_X_FRAME)
{

View File

@ -88,7 +88,7 @@ int srslte_pdcch_init(srslte_pdcch_t *q, srslte_regs_t *regs, srslte_cell_t cell
}
}
uint32_t poly[3] = { 0x6D, 0x4F, 0x57 };
int poly[3] = { 0x6D, 0x4F, 0x57 };
if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, SRSLTE_DCI_MAX_BITS + 16, true)) {
goto clean;
}
@ -192,7 +192,7 @@ uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t *q, srslte_dci_location_t *c,
k = 0;
// All aggregation levels from 8 to 1
for (l = 0; l < 3; l++) {
for (l = 3; l >= 0; l--) {
L = (1 << l);
// For all possible ncce offset
for (i = 0; i < SRSLTE_MIN(q->nof_cce / L, S[l]/PDCCH_FORMAT_NOF_CCE(l)); i++) {
@ -273,8 +273,10 @@ static int dci_decode(srslte_pdcch_t *q, float *e, uint8_t *data, uint32_t E, ui
{
bzero(q->rm_f, sizeof(float)*3 * (SRSLTE_DCI_MAX_BITS + 16));
uint32_t coded_len = 3 * (nof_bits + 16);
/* unrate matching */
srslte_rm_conv_rx(e, E, q->rm_f, 3 * (nof_bits + 16));
srslte_rm_conv_rx(e, E, q->rm_f, coded_len);
/* viterbi decoder */
srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16);
@ -286,6 +288,7 @@ static int dci_decode(srslte_pdcch_t *q, float *e, uint8_t *data, uint32_t E, ui
if (crc) {
*crc = p_bits ^ crc_res;
}
return SRSLTE_SUCCESS;
} else {
fprintf(stderr, "Invalid parameters: E: %d, max_bits: %d, nof_bits: %d\n", E, q->max_bits, nof_bits);
@ -399,7 +402,7 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLT
/* in control channels, only diversity is supported */
if (q->cell.nof_ports == 1) {
/* no need for layer demapping */
srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, nof_symbols, noise_estimate);
srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, nof_symbols, noise_estimate/2);
} else {
srslte_predecoding_diversity(q->symbols[0], q->ce, x, q->cell.nof_ports, nof_symbols);
srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, nof_symbols / q->cell.nof_ports);

View File

@ -411,6 +411,13 @@ int srslte_pdsch_decode_rnti(srslte_pdsch_t *q,
}
if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE subframe.dat: received subframe symbols\n",0);
srslte_vec_save_file("subframe.dat", sf_symbols, SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t));
DEBUG("SAVED FILE hest0.dat and hest1.dat: channel estimates for port 0 and port 1\n",0);
srslte_vec_save_file("hest0.dat", ce[0], SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t));
if (q->cell.nof_ports > 1) {
srslte_vec_save_file("hest1.dat", ce[1], SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t));
}
DEBUG("SAVED FILE pdsch_symbols.dat: symbols after equalization\n",0);
srslte_vec_save_file("pdsch_symbols.dat", q->d, cfg->nbits.nof_re*sizeof(cf_t));
}

View File

@ -232,7 +232,7 @@ int srslte_prach_gen_seqs(srslte_prach_t *p)
uint32_t d_u = 0;
uint32_t d_start = 0;
uint32_t N_shift = 0;
uint32_t N_neg_shift = 0;
int N_neg_shift = 0;
uint32_t N_group = 0;
uint32_t C_v = 0;
cf_t root[839];

View File

@ -403,6 +403,7 @@ static int dl_dci_to_grant_mcs(srslte_ra_dl_dci_t *dci, srslte_ra_dl_grant_t *gr
if (dci->dci_format == SRSLTE_RA_DCI_FORMAT1A) {
n_prb = dci->type2_alloc.n_prb1a == SRSLTE_RA_TYPE2_NPRB1A_2 ? 2 : 3;
i_tbs = dci->mcs_idx;
tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb);
} else {
if (dci->mcs_idx < 32) {
tbs = tbs_format1c_table[dci->mcs_idx];
@ -410,6 +411,7 @@ static int dl_dci_to_grant_mcs(srslte_ra_dl_dci_t *dci, srslte_ra_dl_grant_t *gr
}
grant->mcs.mod = SRSLTE_MOD_QPSK;
} else {
tbs = -1;
n_prb = grant->nof_prb;
if (dci->mcs_idx < 10) {
grant->mcs.mod = SRSLTE_MOD_QPSK;
@ -433,8 +435,10 @@ static int dl_dci_to_grant_mcs(srslte_ra_dl_dci_t *dci, srslte_ra_dl_grant_t *gr
tbs = 0;
i_tbs = 0;
}
if (tbs == -1) {
tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb);
}
}
tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb);
if (tbs < 0) {
return SRSLTE_ERROR;

View File

@ -48,6 +48,8 @@ typedef struct {
size_t tx_nof_samples;
double tx_rate;
bool dynamic_rate;
bool has_rssi;
uhd_sensor_value_handle rssi_value;
} rf_uhd_handler_t;
void suppress_handler(const char *x)
@ -193,6 +195,11 @@ void rf_uhd_flush_buffer(void *h)
}
bool rf_uhd_has_rssi(void *h) {
rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h;
return handler->has_rssi;
}
bool get_has_rssi(void *h) {
rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h;
uhd_string_vector_handle rx_sensors;
uhd_string_vector_make(&rx_sensors);
@ -203,14 +210,11 @@ bool rf_uhd_has_rssi(void *h) {
}
float rf_uhd_get_rssi(void *h) {
if (rf_uhd_has_rssi(h)) {
rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h;
uhd_sensor_value_handle value;
uhd_sensor_value_make_from_realnum(&value, "rssi", 0, "dBm", "%f");
uhd_usrp_get_rx_sensor(handler->usrp, "rssi", 0, &value);
rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h;
if (handler->has_rssi) {
double val_out;
uhd_sensor_value_to_realnum(value, &val_out);
uhd_sensor_value_free(&value);
uhd_usrp_get_rx_sensor(handler->usrp, "rssi", 0, &handler->rssi_value);
uhd_sensor_value_to_realnum(handler->rssi_value, &val_out);
return val_out;
} else {
return 0.0;
@ -267,6 +271,11 @@ int rf_uhd_open(char *args, void **h)
.n_channels = 1
};
handler->has_rssi = get_has_rssi(handler);
if (handler->has_rssi) {
uhd_sensor_value_make_from_realnum(&handler->rssi_value, "rssi", 0, "dBm", "%f");
}
/* Initialize rx and tx stremers */
uhd_rx_streamer_make(&handler->rx_stream);
error = uhd_usrp_get_rx_stream(handler->usrp, &stream_args, handler->rx_stream);

View File

@ -139,7 +139,7 @@ uint32_t srslte_sss_synch_subframe(uint32_t m0, uint32_t m1) {
/** Returns the N_id_1 value based on the m0 and m1 values */
int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q, uint32_t m0, uint32_t m1) {
if (m0==m1 || m0 > 29 || m1 > 29) {
if (m0==m1 || m0 > 30 || m1 > 30) {
return SRSLTE_ERROR;
}
int N_id_1;

View File

@ -194,16 +194,12 @@ int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t *q, cf_t *input, uint32_t sf
/* Correct SFO multiplying by complex exponential in the time domain */
if (q->sample_offset) {
struct timeval t[3];
gettimeofday(&t[1], NULL);
for (int i=0;i<2*SRSLTE_CP_NSYMB(q->cell.cp);i++) {
srslte_cfo_correct(&q->sfo_correct,
&q->sf_symbols[i*q->cell.nof_prb*SRSLTE_NRE],
&q->sf_symbols[i*q->cell.nof_prb*SRSLTE_NRE],
q->sample_offset / q->fft.symbol_sz);
}
gettimeofday(&t[2], NULL);
get_time_interval(t);
}
return srslte_ue_dl_decode_estimate(q, sf_idx, cfi);
@ -221,7 +217,8 @@ int srslte_ue_dl_decode_estimate(srslte_ue_dl_t *q, uint32_t sf_idx, uint32_t *c
/* First decode PCFICH and obtain CFI */
if (srslte_pcfich_decode(&q->pcfich, q->sf_symbols, q->ce,
srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, cfi, &cfi_corr)<0) {
srslte_chest_dl_get_noise_estimate(&q->chest),
sf_idx, cfi, &cfi_corr)<0) {
fprintf(stderr, "Error decoding PCFICH\n");
return SRSLTE_ERROR;
}
@ -405,7 +402,7 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u
return ret;
}
if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, 0, sf_idx, q->cfi)) {
if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, q->cfi)) {
fprintf(stderr, "Error extracting LLRs\n");
return SRSLTE_ERROR;
}