Patch to install rrc ASN headers

master
ismagom 10 years ago
parent f067d98482
commit d56fc6d26d

@ -0,0 +1,81 @@
/*
* Copyright (c) 2012, Ismael Gomez-Miguelez <ismael.gomez@tsc.upc.edu>.
* This file is part of ALOE++ (http://flexnets.upc.edu/)
*
* ALOE++ 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.
*
* ALOE++ 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ALOE++. If not, see <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 INPUT prhs[0]
#define NOF_INPUTS 1
void help()
{
mexErrMsgTxt
("[decoded_bits] = liblte_viterbi(input_llr, type)\n\n");
}
/* the gateway function */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
viterbi_t viterbi;
float *input_llr;
uint8_t *output_data;
int nof_bits;
if (nrhs < NOF_INPUTS) {
help();
return;
}
// Read input symbols
nof_bits = mexutils_read_f(INPUT, &input_llr);
output_data = vec_malloc(nof_bits * sizeof(uint8_t));
uint32_t poly[3] = { 0x6D, 0x4F, 0x57 };
if (viterbi_init(&viterbi, viterbi_37, poly, nof_bits/3, true)) {
return;
}
if (nrhs >= 2) {
float gain_quant = mxGetScalar(prhs[1]);
viterbi_set_gain_quant(&viterbi, gain_quant);
}
viterbi_decode_f(&viterbi, input_llr, output_data, nof_bits/3);
if (nlhs >= 1) {
mexutils_write_uint8(output_data, &plhs[0], nof_bits/3, 1);
}
if (nlhs >= 2) {
mexutils_write_uint8(viterbi.symbols_uc, &plhs[1], nof_bits/3, 1);
}
viterbi_free(&viterbi);
free(input_llr);
free(output_data);
return;
}

@ -0,0 +1,130 @@
/*
* Copyright (c) 2012, Ismael Gomez-Miguelez <ismael.gomez@tsc.upc.edu>.
* This file is part of ALOE++ (http://flexnets.upc.edu/)
*
* ALOE++ 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.
*
* ALOE++ 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ALOE++. If not, see <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 ENBCFG prhs[0]
#define INPUT prhs[1]
#define NOF_INPUTS 2
void help()
{
mexErrMsgTxt
("[decoded_ok, symbols, bits] = liblte_pbch(enbConfig, inputSignal)\n\n");
}
/* the gateway function */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
int i;
lte_cell_t cell;
pbch_t pbch;
chest_dl_t chest;
lte_fft_t fft;
cf_t *input_symbols, *input_fft;
int nof_re;
cf_t *ce[MAX_PORTS], *ce_slot[MAX_PORTS];
if (nrhs != NOF_INPUTS) {
help();
return;
}
if (mexutils_read_cell(ENBCFG, &cell)) {
help();
return;
}
// Read input symbols
mexutils_read_cf(INPUT, &input_symbols);
nof_re = SF_LEN_RE(cell.nof_prb, cell.cp);
// Allocate memory
input_fft = vec_malloc(nof_re * sizeof(cf_t));
for (i=0;i<MAX_PORTS;i++) {
ce[i] = vec_malloc(nof_re * sizeof(cf_t));
}
if (chest_dl_init(&chest, cell)) {
fprintf(stderr, "Error initializing equalizer\n");
return;
}
if (lte_fft_init(&fft, cell.cp, cell.nof_prb)) {
fprintf(stderr, "Error initializing FFT\n");
return;
}
if (pbch_init(&pbch, cell)) {
fprintf(stderr, "Error initiating PBCH\n");
return;
}
lte_fft_run_sf(&fft, input_symbols, input_fft);
chest_dl_estimate(&chest, input_fft, ce, 0);
for (int i=0;i<MAX_PORTS;i++) {
ce_slot[i] = &ce[i][SLOT_LEN_RE(cell.nof_prb, cell.cp)];
}
uint32_t nof_ports;
int n = pbch_decode(&pbch, &input_fft[SLOT_LEN_RE(cell.nof_prb, cell.cp)],
ce_slot, chest_dl_get_noise_estimate(&chest),
NULL, &nof_ports, NULL);
if (nlhs >= 1) {
if (n == 1) {
plhs[0] = mxCreateDoubleScalar(nof_ports);
} else {
plhs[0] = mxCreateDoubleScalar(0);
}
}
if (nlhs >= 2) {
mexutils_write_cf(pbch.pbch_d, &plhs[1], pbch.nof_symbols, 1);
}
if (nlhs >= 3) {
mexutils_write_f(pbch.pbch_llr, &plhs[2], 2*pbch.nof_symbols, 1);
}
if (nlhs >= 4) {
mexutils_write_cf(ce[0], &plhs[3], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14);
}
if (nlhs >= 5) {
mexutils_write_cf(ce[1], &plhs[4], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14);
}
chest_dl_free(&chest);
lte_fft_free(&fft);
pbch_free(&pbch);
for (i=0;i<cell.nof_ports;i++) {
free(ce[i]);
}
free(input_symbols);
free(input_fft);
return;
}

@ -19,6 +19,36 @@
# and at http://www.gnu.org/licenses/.
#
########################################################################
# Install headers
########################################################################
INSTALL(DIRECTORY include/
DESTINATION "${INCLUDE_DIR}"
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
INSTALL(DIRECTORY asn/
DESTINATION "${INCLUDE_DIR}"
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
########################################################################
# Add headers to cmake project (useful for IDEs)
########################################################################
SET(HEADERS_ALL "")
FILE(GLOB headers *)
FOREACH (_header ${headers})
IF(IS_DIRECTORY ${_header})
FILE(GLOB_RECURSE tmp "${_header}/*.h")
LIST(APPEND HEADERS_ALL ${tmp})
ENDIF(IS_DIRECTORY ${_header})
ENDFOREACH()
ADD_CUSTOM_TARGET (add_lte_rrc_headers SOURCES ${HEADERS_ALL})
########################################################################
# Add subdirectories
########################################################################
add_subdirectory(asn)
add_subdirectory(lib)

@ -19,10 +19,9 @@
# and at http://www.gnu.org/licenses/.
#
FILE(GLOB RRC_ASN_SOURCES *.c)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../include/liblte/rrc/asn/")
ADD_LIBRARY(rrc_asn SHARED ${RRC_ASN_SOURCES})
SET(CMAKE_C_FLAGS "-std=c99 -D_GNU_SOURCE -w")
INSTALL(TARGETS rrc_asn DESTINATION ${LIBRARY_DIR})
LIBLTE_SET_PIC(rrc_asn)
LIBLTE_SET_PIC(rrc_asn)

@ -0,0 +1,104 @@
%clear
rmc = lteRMCDL('R.10');
NofPortsTx=2;
SNR_values_db=1;%linspace(-6,5,8);
Nrealizations=1;
cfg.Seed = 8; % Random channel seed
cfg.NRxAnts = 1; % 1 receive antenna
cfg.DelayProfile = 'EVA'; % EVA delay spread
cfg.DopplerFreq = 120; % 120Hz Doppler frequency
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
cfg.InitTime = 0; % Initialize at time zero
cfg.NTerms = 16; % Oscillators used in fading model
cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
cfg.InitPhase = 'Random'; % Random initial phases
cfg.NormalizePathGains = 'On'; % Normalize delay profile power
cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
cec.FreqWindow = 9; % Frequency window size
cec.TimeWindow = 9; % Time window size
cec.InterpType = 'linear'; % 2D interpolation type
cec.InterpWindow = 'Centered'; % Interpolation window type
cec.InterpWinSize = 1; % Interpolation window size
rmc.PDSCH.Modulation = '16QAM';
[waveform,rgrid,info] = lteRMCDLTool(rmc,[1;0;0;1]);
cfg.SamplingRate = info.SamplingRate;
addpath('../../debug/lte/phy/lib/phch/test')
error=zeros(length(SNR_values_db),2);
for snr_idx=1:length(SNR_values_db)
SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB
SNR = 10^(SNRdB/20); % Linear SNR
errorReal = zeros(Nrealizations,2);
for i=1:Nrealizations
enb = struct('NCellID',311,'NDLRB',6,'CellRefP',NofPortsTx,'CyclicPrefix','Normal','DuplexMode','FDD','NSubframe',0);
griddims = lteResourceGridSize(enb); % Resource grid dimensions
L = griddims(2);
%rxWaveform = lteFadingChannel(cfg,waveform(:,1));
%rxWaveform = waveform(:,1);
%% Additive Noise
%N0 = 1/(sqrt(2.0*double(enb.CellRefP)*double(info.Nfft))*SNR);
% Create additive white Gaussian noise
%noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform)));
%rxWaveform = noise + rxWaveform;
rxWaveform = downsampled;
% Number of OFDM symbols in a subframe
% OFDM demodulate signal
rxgrid = lteOFDMDemodulate(enb, rxWaveform);
% Perform channel estimation
[hest, nest] = lteDLChannelEstimate(enb, cec, rxgrid(:,1:L,:));
pbchIndices = ltePBCHIndices(enb);
[pbchRx, pbchHest] = lteExtractResources( ...
pbchIndices, rxgrid(:,1:L,:), hest(:,1:L,:,:));
% Decode PBCH
[bchBits, pbchSymbols, nfmod4, mib, enb.CellRefP] = ltePBCHDecode( ...
enb, pbchRx, pbchHest, nest);
% Parse MIB bits
enb = lteMIB(mib, enb);
if (enb.CellRefP ~= NofPortsTx)
errorReal(i,1)=1;
end
enb = struct('NCellID',311,'NDLRB',6,'CellRefP',NofPortsTx,'CyclicPrefix','Normal','DuplexMode','FDD','NSubframe',0);
[nof_ports, pbchSymbols2, pbchBits, ce, ce2]=liblte_pbch(enb, rxWaveform);
if (nof_ports ~= NofPortsTx)
errorReal(i,2)=1;
end
% if (errorReal(i,1) ~= errorReal(i,2))
% i=1;
% end
end
error(snr_idx,:) = sum(errorReal);
fprintf('SNR: %.2f dB\n', SNR_values_db(snr_idx));
end
if (length(SNR_values_db) > 1)
plot(SNR_values_db, 1-error/Nrealizations)
grid on
xlabel('SNR (dB)');
ylabel('Pdet')
legend('Matlab','libLTE')
else
disp(error)
end

@ -0,0 +1,49 @@
clear
blen=40;
SNR_values_db=linspace(-6,4,8);
Nrealizations=5000;
addpath('../../debug/lte/phy/lib/fec/test')
errors1=zeros(1,length(SNR_values_db));
errors2=zeros(1,length(SNR_values_db));
for snr_idx=1:length(SNR_values_db)
SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB
SNR = 10^(SNRdB/20); % Linear SNR
for i=1:Nrealizations
Data = randi(2,blen,1)==1;
codedData = lteConvolutionalEncode(Data);
codedsymbols = 2*double(codedData)-1;
%% Additive Noise
N0 = 1/SNR;
% Create additive white Gaussian noise
noise = N0*randn(size(codedsymbols));
noisysymbols = noise + codedsymbols;
decodedData = lteConvolutionalDecode(noisysymbols);
interleavedSymbols = reshape(reshape(noisysymbols,[],3)',1,[]);
[decodedData2, quant] = liblte_viterbi(interleavedSymbols);
errors1(snr_idx) = errors1(snr_idx) + any(decodedData ~= Data);
errors2(snr_idx) = errors2(snr_idx) + any(decodedData2 ~= Data);
end
end
if (length(SNR_values_db) > 1)
semilogy(SNR_values_db, errors1/Nrealizations, ...
SNR_values_db, errors2/Nrealizations)
grid on
xlabel('SNR (dB)')
ylabel('BLER')
legend('Matlab','libLTE');
else
disp(errors1);
disp(errors2);
disp(errors3);
end
Loading…
Cancel
Save