From 619ed43e11b762d6b13d742ed1832a5b1a7176e7 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Mon, 6 Mar 2017 15:59:17 +0000 Subject: [PATCH 1/2] Removing old test files and references --- CMakeLists.txt | 11 +- cmake/modules/BuildMex.cmake | 63 ---- matlab/common/bin2hex.m | 21 -- matlab/common/read_complex.m | 20 -- matlab/common/read_int16.m | 18 -- matlab/common/read_real.m | 18 -- matlab/common/read_trace_uint.m | 19 -- matlab/common/read_uchar.m | 18 -- matlab/common/write_c_struct_complex.m | 16 -- matlab/common/write_complex.m | 22 -- matlab/common/write_int16.m | 14 - matlab/common/write_real.m | 14 - matlab/common/write_uchar.m | 14 - matlab/rate_algorithm.m | 20 -- matlab/resampler/arb_filter.mat | Bin 1475 -> 0 bytes matlab/resampler/arb_resample_linear.m | 46 --- matlab/resampler/arb_resample_nearest.m | 37 --- matlab/resampler/arb_resample_test.m | 33 --- matlab/sync/addnoise.m | 6 - matlab/sync/cfo_estimate_cp.m | 18 -- matlab/sync/cfo_test.m | 42 --- matlab/sync/check_pss.m | 33 --- matlab/sync/correct_cfo.m | 14 - matlab/sync/cp_corr.m | 9 - matlab/sync/cp_pss_comp.m | 8 - matlab/sync/epsilon.m | 14 - matlab/sync/find_peaks.m | 13 - matlab/sync/find_pss.m | 19 -- matlab/sync/find_pss2.m | 14 - matlab/sync/find_pss_ac.m | 7 - matlab/sync/find_sss.m | 50 ---- matlab/sync/ifo_pss.m | 13 - matlab/sync/ifo_pss_corr.m | 10 - matlab/sync/lte_pss_zc.m | 24 -- matlab/sync/sfo_estimate.m | 18 -- matlab/sync/sym_sync_cp.m | 13 - matlab/tests/diversity_decode_test.m | 46 --- matlab/tests/diversity_test_rate.m | 285 ------------------- matlab/tests/dlsch_test.m | 27 -- matlab/tests/dmrs_equalizer_test.m | 184 ------------ matlab/tests/drms_pusch_test.m | 52 ---- matlab/tests/equalizer_test.m | 277 ------------------ matlab/tests/get_sc.m | 111 -------- matlab/tests/pbch_bler.m | 130 --------- matlab/tests/pdcch_bler.m | 189 ------------ matlab/tests/pdsch_bler.m | 108 ------- matlab/tests/pdsch_decode_signal.m | 76 ----- matlab/tests/pdsch_equal.m | 166 ----------- matlab/tests/pdsch_resalloc.m | 76 ----- matlab/tests/pdsch_test_verify_unrm.m | 39 --- matlab/tests/phich_bler.m | 132 --------- matlab/tests/prach_detect_test.m | 200 ------------- matlab/tests/prach_falsealarm_test.m | 83 ------ matlab/tests/prach_test.m | 51 ---- matlab/tests/print_m.m | 9 - matlab/tests/pucch_bler.m | 133 --------- matlab/tests/pucch_test.m | 79 ----- matlab/tests/pusch_bler.m | 188 ------------ matlab/tests/pusch_decode_signal.m | 20 -- matlab/tests/pusch_encode_test.m | 67 ----- matlab/tests/rm_turbo_rx_test.m | 43 --- matlab/tests/srs_test.m | 47 --- matlab/tests/sss_test.m | 144 ---------- matlab/tests/sync_test.m | 96 ------- matlab/tests/test_ofdma_peakamp.m | 32 --- matlab/tests/test_scfdma.m | 26 -- matlab/tests/test_scfdma_peakamp.m | 32 --- matlab/tests/turbodecoder_bler.m | 51 ---- matlab/tests/ulsch_test.m | 67 ----- matlab/tests/viterbi_bler.m | 49 ---- mex/CMakeLists.txt | 49 ---- mex/include/srslte/mex/mexutils.h | 103 ------- mex/lib/CMakeLists.txt | 63 ---- mex/lib/mexutils.c | 249 ---------------- srslte/lib/ch_estimation/test/CMakeLists.txt | 6 - srslte/lib/fec/test/CMakeLists.txt | 6 - srslte/lib/mimo/test/CMakeLists.txt | 4 - srslte/lib/phch/test/CMakeLists.txt | 25 -- srslte/lib/sync/test/CMakeLists.txt | 7 - 79 files changed, 2 insertions(+), 4554 deletions(-) delete mode 100644 cmake/modules/BuildMex.cmake delete mode 100644 matlab/common/bin2hex.m delete mode 100644 matlab/common/read_complex.m delete mode 100644 matlab/common/read_int16.m delete mode 100644 matlab/common/read_real.m delete mode 100644 matlab/common/read_trace_uint.m delete mode 100644 matlab/common/read_uchar.m delete mode 100644 matlab/common/write_c_struct_complex.m delete mode 100644 matlab/common/write_complex.m delete mode 100644 matlab/common/write_int16.m delete mode 100644 matlab/common/write_real.m delete mode 100644 matlab/common/write_uchar.m delete mode 100644 matlab/rate_algorithm.m delete mode 100644 matlab/resampler/arb_filter.mat delete mode 100644 matlab/resampler/arb_resample_linear.m delete mode 100644 matlab/resampler/arb_resample_nearest.m delete mode 100644 matlab/resampler/arb_resample_test.m delete mode 100644 matlab/sync/addnoise.m delete mode 100644 matlab/sync/cfo_estimate_cp.m delete mode 100644 matlab/sync/cfo_test.m delete mode 100644 matlab/sync/check_pss.m delete mode 100644 matlab/sync/correct_cfo.m delete mode 100644 matlab/sync/cp_corr.m delete mode 100644 matlab/sync/cp_pss_comp.m delete mode 100644 matlab/sync/epsilon.m delete mode 100644 matlab/sync/find_peaks.m delete mode 100644 matlab/sync/find_pss.m delete mode 100644 matlab/sync/find_pss2.m delete mode 100644 matlab/sync/find_pss_ac.m delete mode 100644 matlab/sync/find_sss.m delete mode 100644 matlab/sync/ifo_pss.m delete mode 100644 matlab/sync/ifo_pss_corr.m delete mode 100644 matlab/sync/lte_pss_zc.m delete mode 100644 matlab/sync/sfo_estimate.m delete mode 100644 matlab/sync/sym_sync_cp.m delete mode 100644 matlab/tests/diversity_decode_test.m delete mode 100644 matlab/tests/diversity_test_rate.m delete mode 100644 matlab/tests/dlsch_test.m delete mode 100644 matlab/tests/dmrs_equalizer_test.m delete mode 100644 matlab/tests/drms_pusch_test.m delete mode 100644 matlab/tests/equalizer_test.m delete mode 100644 matlab/tests/get_sc.m delete mode 100644 matlab/tests/pbch_bler.m delete mode 100644 matlab/tests/pdcch_bler.m delete mode 100644 matlab/tests/pdsch_bler.m delete mode 100644 matlab/tests/pdsch_decode_signal.m delete mode 100644 matlab/tests/pdsch_equal.m delete mode 100644 matlab/tests/pdsch_resalloc.m delete mode 100644 matlab/tests/pdsch_test_verify_unrm.m delete mode 100644 matlab/tests/phich_bler.m delete mode 100644 matlab/tests/prach_detect_test.m delete mode 100644 matlab/tests/prach_falsealarm_test.m delete mode 100644 matlab/tests/prach_test.m delete mode 100644 matlab/tests/print_m.m delete mode 100644 matlab/tests/pucch_bler.m delete mode 100644 matlab/tests/pucch_test.m delete mode 100644 matlab/tests/pusch_bler.m delete mode 100644 matlab/tests/pusch_decode_signal.m delete mode 100644 matlab/tests/pusch_encode_test.m delete mode 100644 matlab/tests/rm_turbo_rx_test.m delete mode 100644 matlab/tests/srs_test.m delete mode 100644 matlab/tests/sss_test.m delete mode 100644 matlab/tests/sync_test.m delete mode 100644 matlab/tests/test_ofdma_peakamp.m delete mode 100644 matlab/tests/test_scfdma.m delete mode 100644 matlab/tests/test_scfdma_peakamp.m delete mode 100644 matlab/tests/turbodecoder_bler.m delete mode 100644 matlab/tests/ulsch_test.m delete mode 100644 matlab/tests/viterbi_bler.m delete mode 100644 mex/CMakeLists.txt delete mode 100644 mex/include/srslte/mex/mexutils.h delete mode 100644 mex/lib/CMakeLists.txt delete mode 100644 mex/lib/mexutils.c diff --git a/CMakeLists.txt b/CMakeLists.txt index fec7856b9..4f91dec82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,6 @@ MESSAGE( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} ) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") include(SRSLTEVersion) #sets version information include(SRSLTEPackage) #setup cpack -include(BuildMex) include(CTest) set( CTEST_MEMORYCHECK_COMMAND valgrind ) @@ -51,7 +50,7 @@ configure_file( ######################################################################## # Options ######################################################################## -option(DisableMEX "DisableMEX" ON) + ######################################################################## # Install Dirs @@ -69,7 +68,6 @@ endif() set(RUNTIME_DIR bin) set(LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}) set(INCLUDE_DIR include) -set(MEX_DIR mex) set(DOC_DIR "share/doc/${CPACK_PACKAGE_NAME}") set(DATA_DIR share/${CPACK_PACKAGE_NAME}) @@ -98,7 +96,7 @@ endif(CMAKE_COMPILER_IS_GNUCXX) 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") - + if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") find_package(SSE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0") @@ -141,8 +139,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - - ######################################################################## # Create uninstall targets ######################################################################## @@ -153,7 +149,6 @@ configure_file( add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) - ######################################################################## # Macro to add -fPIC property to static libs @@ -173,10 +168,8 @@ message(STATUS "Building for version: ${VERSION}") ######################################################################## include_directories(${PROJECT_BINARY_DIR}/srslte/include/) include_directories(${PROJECT_SOURCE_DIR}/srslte/include/) -include_directories(${PROJECT_SOURCE_DIR}/mex/include) ######################################################################## # Add the subdirectories ######################################################################## add_subdirectory(srslte) -add_subdirectory(mex) diff --git a/cmake/modules/BuildMex.cmake b/cmake/modules/BuildMex.cmake deleted file mode 100644 index e1bb573eb..000000000 --- a/cmake/modules/BuildMex.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# BuildMex.cmake -# Author: Kent Williams norman-k-williams at uiowa.edu -# Modified by Ismael Gomez, 2014 - -include(CMakeParseArguments) - -if(NOT DisableMEX) - if(NOT MATLAB_FOUND) - find_package(MATLAB) - endif() - - if(NOT OCTAVE_FOUND) - find_package(OCTAVE) - endif() - - # CMake 2.8.12 & earlier apparently don't define the - # Mex script path, so find it. - if(NOT MATLAB_MEX_PATH) - find_program( MATLAB_MEX_PATH mex - HINTS ${MATLAB_ROOT}/bin - PATHS ${MATLAB_ROOT}/bin - DOC "The mex program path" - ) - endif() -endif() - -# -# BuildMex -- arguments -# MEXNAME = root of mex library name -# SOURCE = list of source files -# LIBRARIES = libraries needed to link mex library -FUNCTION(BuildMex) - if(NOT DisableMEX) - set(oneValueArgs MEXNAME) - set(multiValueArgs SOURCES LIBRARIES) - cmake_parse_arguments(BuildMex "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if (MATLAB_FOUND) - add_library(${BuildMex_MEXNAME}-mat SHARED ${BuildMex_SOURCES}) - #target_include_directories(${BuildMex_MEXNAME}-mat PUBLIC ${MATLAB_INCLUDE_DIR}) - set_target_properties(${BuildMex_MEXNAME}-mat PROPERTIES - SUFFIX "${MATLAB_MEX_EXTENSION}" - PREFIX "srslte_" - OUTPUT_NAME "${BuildMex_MEXNAME}" - COMPILE_FLAGS "-fvisibility=default ${MATLAB_MEX_CFLAGS} -DFORCE_STANDARD_RATE -I${MATLAB_INCLUDE_DIR}" - ) - target_link_libraries(${BuildMex_MEXNAME}-mat ${BuildMex_LIBRARIES} ${MATLAB_MEX_LIBRARY}) - install(TARGETS ${BuildMex_MEXNAME}-mat DESTINATION "${MEX_DIR}/srslte/") - endif(MATLAB_FOUND) - if (OCTAVE_FOUND) - add_library(${BuildMex_MEXNAME}-oct SHARED ${BuildMex_SOURCES}) - #target_include_directories(${BuildMex_MEXNAME}-oct PUBLIC ${OCTAVE_INCLUDE_DIR}) - set_target_properties(${BuildMex_MEXNAME}-oct PROPERTIES - SUFFIX ".${OCTAVE_MEXFILE_EXT}" - PREFIX "srslte_" - OUTPUT_NAME "${BuildMex_MEXNAME}" - COMPILE_FLAGS "-fvisibility=default ${OCTAVE_MEX_CFLAGS} -DFORCE_STANDARD_RATE -DUNDEF_BOOL -I${OCTAVE_INCLUDE_DIR}" - ) - target_link_libraries(${BuildMex_MEXNAME}-oct ${BuildMex_LIBRARIES} ${OCTAVE_LIBRARIES}) - install(TARGETS ${BuildMex_MEXNAME}-oct DESTINATION "${MEX_DIR}/srslte/") - endif (OCTAVE_FOUND) - endif (NOT DisableMEX) -ENDFUNCTION(BuildMex) - diff --git a/matlab/common/bin2hex.m b/matlab/common/bin2hex.m deleted file mode 100644 index 45ca9ea4f..000000000 --- a/matlab/common/bin2hex.m +++ /dev/null @@ -1,21 +0,0 @@ -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 - diff --git a/matlab/common/read_complex.m b/matlab/common/read_complex.m deleted file mode 100644 index d9185a7ea..000000000 --- a/matlab/common/read_complex.m +++ /dev/null @@ -1,20 +0,0 @@ -function [ out ] = read_complex( filename, count ) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'r'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - if (nargin==1) - count=inf; - end - - x=fread(tidin,2*count,'single'); - i=1:2:length(x); - out=x(i)+x(i+1)*1i; -end - diff --git a/matlab/common/read_int16.m b/matlab/common/read_int16.m deleted file mode 100644 index 3db6a3179..000000000 --- a/matlab/common/read_int16.m +++ /dev/null @@ -1,18 +0,0 @@ -function [ out ] = read_int16( filename, count ) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'r'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - if (nargin==1) - count=inf; - end - - out=fread(tidin,count,'int16'); -end - diff --git a/matlab/common/read_real.m b/matlab/common/read_real.m deleted file mode 100644 index 2447d11ce..000000000 --- a/matlab/common/read_real.m +++ /dev/null @@ -1,18 +0,0 @@ -function [ out ] = read_real( filename, count ) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'r'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - if (nargin==1) - count=inf; - end - - out=fread(tidin,count,'single'); -end - diff --git a/matlab/common/read_trace_uint.m b/matlab/common/read_trace_uint.m deleted file mode 100644 index b383798e7..000000000 --- a/matlab/common/read_trace_uint.m +++ /dev/null @@ -1,19 +0,0 @@ -function [ values, tti] = read_trace_uint( filename, count ) - - [tidin msg]=fopen(filename,'r'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - if (nargin==1) - count=inf; - end - - x=fread(tidin,2*count,'uint'); - i=1:2:length(x); - tti=x(i); - values=x(i+1); -end - diff --git a/matlab/common/read_uchar.m b/matlab/common/read_uchar.m deleted file mode 100644 index 59ed56430..000000000 --- a/matlab/common/read_uchar.m +++ /dev/null @@ -1,18 +0,0 @@ -function [ out ] = read_uchar( filename, count ) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'r'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - if (nargin==1) - count=inf; - end - - out=fread(tidin,count,'uint8'); -end - diff --git a/matlab/common/write_c_struct_complex.m b/matlab/common/write_c_struct_complex.m deleted file mode 100644 index 41f312b90..000000000 --- a/matlab/common/write_c_struct_complex.m +++ /dev/null @@ -1,16 +0,0 @@ -function [ out ] = write_c_struct_complex( filename, varname, x) - - [tidin msg]=fopen(filename,'wt'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - fprintf(tidin, 'float %s[%d]={%.9g,%.9g',varname,2*length(x),real(x(1)),imag(x(1))); - for i=2:length(x) - fprintf(tidin, ',\n %.9g,%.9g',real(x(i)),imag(x(i))); - end - fprintf(tidin, '};\n'); - fclose(tidin); -end - diff --git a/matlab/common/write_complex.m b/matlab/common/write_complex.m deleted file mode 100644 index a152c8672..000000000 --- a/matlab/common/write_complex.m +++ /dev/null @@ -1,22 +0,0 @@ -function [ out ] = write_complex( filename, x) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'w'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - if (isreal(x)) - y=x; - else - i=1:2:2*length(x); - y(i)=real(x); - y(i+1)=imag(x); - end - - fwrite(tidin,y,'single'); -end - diff --git a/matlab/common/write_int16.m b/matlab/common/write_int16.m deleted file mode 100644 index afd6e0ff4..000000000 --- a/matlab/common/write_int16.m +++ /dev/null @@ -1,14 +0,0 @@ -function [ out ] = write_int16( filename, x) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'w'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - fwrite(tidin,x,'int16'); -end - diff --git a/matlab/common/write_real.m b/matlab/common/write_real.m deleted file mode 100644 index 039906b16..000000000 --- a/matlab/common/write_real.m +++ /dev/null @@ -1,14 +0,0 @@ -function [ out ] = write_complex( filename, x) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'w'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - fwrite(tidin,x,'single'); -end - diff --git a/matlab/common/write_uchar.m b/matlab/common/write_uchar.m deleted file mode 100644 index 7ba41fb46..000000000 --- a/matlab/common/write_uchar.m +++ /dev/null @@ -1,14 +0,0 @@ -function [ out ] = write_uchar( filename, x) -%READ_COMPLEX Summary of this function goes here -% Detailed explanation goes here - - [tidin msg]=fopen(filename,'w'); - if (tidin==-1) - fprintf('error opening %s: %s\n',filename, msg); - out=[]; - return - end - - fwrite(tidin,x,'uint8'); -end - diff --git a/matlab/rate_algorithm.m b/matlab/rate_algorithm.m deleted file mode 100644 index 0edd42697..000000000 --- a/matlab/rate_algorithm.m +++ /dev/null @@ -1,20 +0,0 @@ -F=100000./(1:100); -PQ=(1:50); - -PRB=50; -Mmax=1024; -N=PRB*12; - -Fmin=N*15*1.1; -Fs=F(F>Fmin); - -for i=length(Fs):-1:1 - for p=PQ - for q=PQ - if (mod(p/q*Fs(i),15)==0 && p/q*Fs(i)/15_4ZaN@Tb!8wyaB?6qH6SrIIyE*rH8vnJFflYBARr(hARr(hARr(hARr(hARr(h zARr(hARr(hARr(hARr(hARr(B00000000000ZB~{0000x1pokeoJEy;RLp4@$EP|f zX`}77vGc8X0c5vrIwI%nYJBerVS%H(IyGog~`$dO>Id$-H4i! zE>3H65@TJPbl7EUv39qwoj>M1zq$N=@B2L8=kqZW2m}ts0)gTC_5Jei`p;{`@U@=c zzc)RBfxt6nt6-#H_>19}v}1ySheH78Wk0gLU*yLNUccBGc+8*I6-}R}-4e*_nqvYC zdV+ZVEqQ0y!w^YtivE9bm7rQxk-<-9-_ z`-QuWg4@PIlAY&2O(;d?=S%CHI&<_u&fZB%6tTi^#Imq(yr= zn1sS+&)Hu`(suLB8D~>v)Yb0orms#UlawoVzianU+ehka+r3jrv(IUczw{tYwN%|c z?vqYSvey@?oDY-#{osKz+boKeG=xoiag4OHHuW~Cvq>n)TNN-Zmr~6|ny&SEG(wlS zGBW-IJ)Yd%a6aZFnQhbmLm^g?*wA~vP$B%IOCf| zHG%W&X9*6Gq`msN;gb{!I^UA;Kqe=z@!x^uyuyZnqMZ>vXS)R zuF(2gZrN>iLPd3)Hu$E}D5Z{__bfc*{!<-K)YA{2{Qf%8-tub0{5oEqb0hxn$yyFC zQ5s2FYxtX34`We9HIJ3JTLh>tb9lAEl3O7c*&)e%$zW1BHx@3Gy)sktlY&8;WWz!p zzc|UKuRe!A&(MujL@Bt|nv!hSq>+Bq&{9RyDQeS8muN4l>FpU|wzGK^dC44GTElC} z?#A~+cSbdkYo2$h@^%yXj@!5`KCG3ZgZ#T<2HU9ocz9afIAzE@t;qrvGCYe!sci6 za$juKoxOczIzHKOsz^uTkfFq`3LPo`I=cRiT|bHQ9feKt{iN~LRh|C1pRCu;2ytxx zf5qqc-G~1T-v{@_bMRd31N*{0v2UCM=fXL0ZqxyFL7h-H)Dd+>ol$r60ewNA&^PoE zeMO(qcjN%MKu(Yw#xkk>Bd&~jm0&{}7!5m?(FlU%M%pv9y zbBeje9AmCA=a_qN09*hkzzuK&Tmfgm9dHO-0;j+&a12}n=fFL15L^T&!A)=!Tm@&r zU2qs&2B*Poa2#9*=fQn=0A7G6;0<^LUV&%e9e4;{f~Vjucnn^H=iohf5MKP?$zgB8 dqwp#`3-7|i@G?9NZ^Ps8Iy?{W{|&w3`HXB8)ZG98 diff --git a/matlab/resampler/arb_resample_linear.m b/matlab/resampler/arb_resample_linear.m deleted file mode 100644 index 4bfb4df03..000000000 --- a/matlab/resampler/arb_resample_linear.m +++ /dev/null @@ -1,46 +0,0 @@ -function out = arb_resample_linear(sig, rate) - -N = 32; -M = 8; -step = (1/rate)*N; - -load('arb_filter.mat'); - -figure;plot(Num);title('Filter impulse response'); -[h,w] = freqz(Num, 1); -figure;plot(20*log10(abs(h)));title('Filter freq response'); - -% Create polyphase partition -poly = reshape(Num, N, M); - -% Filter -sig = [zeros(1,(M/2)-1) sig]; -k=0; -acc=0; -index=0; -frac=0; -out = []; -while k < length(sig)-M - sig_reg = fliplr(sig(k+1:k+M)); - filt_reg1 = poly(index+1, :); - filt_reg2 = poly(mod(index+1,N)+1, :); - res1 = sig_reg*filt_reg1'; - res2 = sig_reg*filt_reg2'; - - if index+1 == 32 - res = res1; - else - res = res1 + (res2-res1)*frac; - end - - out = [out res]; - - acc = acc+step; - index = fix(acc); - while index >= N - acc = acc - N; - index = index - N; - k = k+1; - end - frac = abs(acc-index); -end diff --git a/matlab/resampler/arb_resample_nearest.m b/matlab/resampler/arb_resample_nearest.m deleted file mode 100644 index 0601aa169..000000000 --- a/matlab/resampler/arb_resample_nearest.m +++ /dev/null @@ -1,37 +0,0 @@ -function out = arb_resample_nearest(sig, rate) - -N = 32; -M = 8; -step = (1/rate)*N; - -load('arb_filter.mat'); - -figure;plot(Num);title('Filter impulse response'); -[h,w] = freqz(Num, 1); -figure;plot(20*log10(abs(h)));title('Filter frequency response'); - -% Create polyphase partition -poly = reshape(Num, N, M); - -% Filter -sig = [zeros(1,(M/2)-1) sig]; -k=0; -acc=0; -index=0; -frac=0; -out = []; -while k < length(sig)-M - sig_reg = fliplr(sig(k+1:k+M)); - filt_reg1 = poly(index+1, :); - res = sig_reg*filt_reg1'; - - out = [out res]; - - acc = acc+step; - index = round(acc); - while index >= N - acc = acc - N; - index = index - N; - k = k+1; - end -end \ No newline at end of file diff --git a/matlab/resampler/arb_resample_test.m b/matlab/resampler/arb_resample_test.m deleted file mode 100644 index b6d661da4..000000000 --- a/matlab/resampler/arb_resample_test.m +++ /dev/null @@ -1,33 +0,0 @@ -close all -clear all - -up = 24; -down = 25; -d_rate = up/down; -Fs = 100; % Arbitrary sample rate (used for displays) -Fsin = 1; - -% Create a sine wave -t = 0:1/Fs:1-1/Fs; -sig = sin(2*pi*t); - -out = arb_resample_nearest(sig,d_rate); - -% matlab resample for comparison -out2 = resample(sig, up, down); -figure;hold on;title('Ours and matlabs'); -l = min(length(out), length(out2)); -stem(out(1:l)); -stem(out2(1:l), 'r', 'filled'); -diff = out2(1:l)-out(1:l); -figure;plot(diff);title('Difference between ours and matlabs'); - -figure; hold on;title('Original and resampled - no time scaling'); -stem(sig); -stem(out, 'r', 'filled'); - -% Time align and plot -figure;hold on;title('Original and resampled - with time scaling'); -stem((1:75)/Fs,real(sig(1:75))); -stem((1:72)/(Fs*d_rate),real(out(1:72)),'r','filled'); -xlabel('Time (sec)');ylabel('Signal value'); \ No newline at end of file diff --git a/matlab/sync/addnoise.m b/matlab/sync/addnoise.m deleted file mode 100644 index 56f49c4f8..000000000 --- a/matlab/sync/addnoise.m +++ /dev/null @@ -1,6 +0,0 @@ -function [ y ] = addnoise( x, snr_db ) -v = 10^(-snr_db/10); -y=x+sqrt(v)*(randn(size(x))+1i*randn(size(x)))/sqrt(2); -y=y/sqrt(mean(y.*conj(y))); -end - diff --git a/matlab/sync/cfo_estimate_cp.m b/matlab/sync/cfo_estimate_cp.m deleted file mode 100644 index ebc1f0735..000000000 --- a/matlab/sync/cfo_estimate_cp.m +++ /dev/null @@ -1,18 +0,0 @@ -function [cfo, r] = cfo_estimate_cp(input_slot, Nsyms, sym_len, cp0_len, cp_len) - -% Start correlating from the end. Nsyms is the number of symbols to -% correlate starting from the end. - -s=length(input_slot)-sym_len-cp_len; -e=length(input_slot)-sym_len; -for i=1:Nsyms - r(i)=sum(input_slot(s:e).*conj(input_slot(s+sym_len:e+sym_len))); - if (i < 7) - s=s-sym_len-cp_len; - e=e-sym_len-cp_len; - else - s=s-sym_len-cp0_len; - e=e-sym_len-cp0_len; - end -end -cfo=-angle(mean(r))/pi; \ No newline at end of file diff --git a/matlab/sync/cfo_test.m b/matlab/sync/cfo_test.m deleted file mode 100644 index cd957fb5c..000000000 --- a/matlab/sync/cfo_test.m +++ /dev/null @@ -1,42 +0,0 @@ -clear; -sym_len=128; -hflen = (sym_len/128)*1920*5; -samp_rate = (sym_len/128)*1920000; -N_id_2=0; -input=read_complex('../../debug/lte_signal.dat', hflen*240); - -addpath('../../debug/srslte/lib/sync/test') - -off=100; -halfframes=reshape(input(hflen-off+1:end-hflen-off),hflen,[]); -[n m]=size(halfframes); - -fo=linspace(-30000,30000,m); - -nreal=1; - -cfdl=struct('NDLRB',6,'CyclicPrefix','Normal','NCellID',0,'CellRefP',1,'DuplexMode','FDD'); -cfo=zeros(m,3); -toffset=zeros(m,2); -for i=1:m - x = halfframes(:,i); - t = (0:n-1).'/samp_rate; - x = x .* exp(1i*2*pi*fo(i).*t); - cfo_=zeros(nreal,2); - idx_=zeros(nreal,2); - for j=1:nreal - y=awgn(x,5); - cfo_(j,1) = lteFrequencyOffset(cfdl,y)/15000; - [idx_(j,1), cfo_(j,2)] = find_pss(y,N_id_2); - [idx_(j,2), corr] = srslte_cp_synch(cfdl,y); - cfo_(j,3) = -angle(corr(idx_(j,2)+1))/2/pi; - idx_(j,1) = idx_(j,1)-961; - end - cfo(i,:)=mean(cfo_,1); - toffset(i,:)=mean(idx_,1); -end - -error=abs(cfo-repmat(fo',1,3)/15000); -semilogy(fo/15000,error) -%plot(fo/15000,toffset) -legend('Matlab','PSS-based','CP-based') diff --git a/matlab/sync/check_pss.m b/matlab/sync/check_pss.m deleted file mode 100644 index a0a3544f0..000000000 --- a/matlab/sync/check_pss.m +++ /dev/null @@ -1,33 +0,0 @@ -function [ fs ] = check_pss( x, N_id_2, threshold) -%CHECK_PSS Summary of this function goes here -% Detailed explanation goes here -flen=9600; -n=length(x); -nf=floor(n/flen); - -xf=reshape(x(1:nf*flen),flen,[]); - -fs=zeros(nf,1); -cfo=zeros(nf,1); -cfo2=zeros(nf,1); -m_p=zeros(nf,1); -for i=1:nf - [fs(i) cfo(i) m_p(i)]=find_pss(xf(:,i),N_id_2,false, threshold); -end - -fs=fs+960; -[sfo sfo_v]=srslte_sfo_estimate(fs, 5/1000); - -subplot(1,3,1) -plot(1:nf,fs) -subplot(1,3,2) -plot(1:nf, cfo) -if (nf > 0) - axis([0 nf -0.5 0.5]) -end -subplot(1,3,3) -plot(m_p) -fprintf('cfo_mean=%g Hz, cfo_std=%g Hz, m_p=%g sfo=%g Hz\n',15000*nanmean(cfo),15000*nanstd(cfo), nanmean(m_p), sfo) -end - - diff --git a/matlab/sync/correct_cfo.m b/matlab/sync/correct_cfo.m deleted file mode 100644 index effff8dc4..000000000 --- a/matlab/sync/correct_cfo.m +++ /dev/null @@ -1,14 +0,0 @@ -function [ y eps] = correct_cfo( x ) - -xf=reshape(x,9600,[]); -yf=zeros(size(xf)); -[m n]=size(xf); - -for i=1:n - [fs eps(i)]=find_pss(xf(:,i),0,false); - yf(:,i)=xf(:,i).*exp(-1i.*(1:length(xf(:,i)))'.*2*pi*eps(i)/128); -end - -y=reshape(yf,1,[]); - -end \ No newline at end of file diff --git a/matlab/sync/cp_corr.m b/matlab/sync/cp_corr.m deleted file mode 100644 index c97a2f82b..000000000 --- a/matlab/sync/cp_corr.m +++ /dev/null @@ -1,9 +0,0 @@ -function [ lambda ] = cp_corr( x, theta, N, L) - -l0=sum(x(theta:theta+L-1).*conj(x(theta+N:theta+L+N-1))); -l1=0; -for i=theta:theta+L-1 - l1=l1+abs(x(i))^2+abs(x(i+N))^2; -end - -lambda=l1;%2*abs(l0)-rho*l1; diff --git a/matlab/sync/cp_pss_comp.m b/matlab/sync/cp_pss_comp.m deleted file mode 100644 index a589e482a..000000000 --- a/matlab/sync/cp_pss_comp.m +++ /dev/null @@ -1,8 +0,0 @@ -function cp_pss_comp(x,N_id_2) - -[ fs eps p_m w2] = find_pss( x, N_id_2); -lambda=zeros(1,length(x)-138); -for theta=1:length(lambda) - lambda(theta)=cp_corr(x,theta,128,9,0); -end -plot(1:length(w2),abs(w2)/max(abs(w2)),1:length(lambda),abs(lambda)/max(abs(lambda))) \ No newline at end of file diff --git a/matlab/sync/epsilon.m b/matlab/sync/epsilon.m deleted file mode 100644 index 4accfcc3a..000000000 --- a/matlab/sync/epsilon.m +++ /dev/null @@ -1,14 +0,0 @@ -function [ eps fs] = epsilon( x ) - -xf=reshape(x,19200,[]); - -[m n]=size(xf); -eps=zeros(n,1); -fs=zeros(n,1); - -for i=1:n - [fs(i) eps(i)]=find_pss(xf(:,i),0,false); -end - - -end \ No newline at end of file diff --git a/matlab/sync/find_peaks.m b/matlab/sync/find_peaks.m deleted file mode 100644 index 7f9b27bf5..000000000 --- a/matlab/sync/find_peaks.m +++ /dev/null @@ -1,13 +0,0 @@ -function [peaks] = find_peaks(x, N_id_2, fft_size) - -flen=4800*(ceil(fft_size/64)); - -n=floor(length(x)/flen)*flen; -xf=reshape(x(1:n),flen,[]); - -[n m] = size(xf); - -peaks=zeros(m,1); -for i=1:m - [w, peaks(i)]= find_pss2(xf(:,i),N_id_2,fft_size); -end diff --git a/matlab/sync/find_pss.m b/matlab/sync/find_pss.m deleted file mode 100644 index 1dbd4a4fb..000000000 --- a/matlab/sync/find_pss.m +++ /dev/null @@ -1,19 +0,0 @@ -function [ fs, cfo, p_m, w2] = find_pss( x, N_id_2) - - c=lte_pss_zc(N_id_2); - cc=[zeros(33,1); c; zeros(33,1)]; - ccf=[0; cc(65:128); cc(2:64)]; - ccf=sqrt(128)*conj(ifft(ccf)); - w2=conv(x,ccf); - [m, fs]=max(abs(w2)); - - if (fs > 128 && fs < length(x)) - y=ccf.*x(fs-128:fs-1); - y0=y(1:64); - y1=y(65:length(y)); - - cfo=angle(conj(sum(y0))*sum(y1))/pi; - p_m = m/mean(abs(w2)); - end -end - diff --git a/matlab/sync/find_pss2.m b/matlab/sync/find_pss2.m deleted file mode 100644 index 478a47cdb..000000000 --- a/matlab/sync/find_pss2.m +++ /dev/null @@ -1,14 +0,0 @@ -function [w2, m, idx] = find_pss2( x, N_id_2, fft_size) - c=lte_pss_zc(N_id_2); - cc=[zeros(fft_size/2-31,1); c; zeros(fft_size/2-31,1)]; - ccd=[0; cc(fft_size/2+1:fft_size); cc(2:fft_size/2)]; - ccf=sqrt(fft_size)*conj(ifft(ccd)); - - w2=abs(conv(x,ccf/62)).^2/var(x,1)/sqrt(2); - plot(w2) - [m, idx]=max(w2); - - %fprintf('Frame starts at %d, energy=%g, p=%g, p/en=%g dB\n',i, ... - % en, m, m/en); -end - diff --git a/matlab/sync/find_pss_ac.m b/matlab/sync/find_pss_ac.m deleted file mode 100644 index 0bff75866..000000000 --- a/matlab/sync/find_pss_ac.m +++ /dev/null @@ -1,7 +0,0 @@ -function fs = find_pss_ac( x) - - w2=xcorr(x,x); - [m, fs]=max(abs(w2)); - fs=fs-1920; -end - diff --git a/matlab/sync/find_sss.m b/matlab/sync/find_sss.m deleted file mode 100644 index a6fddd9c9..000000000 --- a/matlab/sync/find_sss.m +++ /dev/null @@ -1,50 +0,0 @@ -function [ m1 m2 out Zprod0 Zprod1] = find_sss( y, Nid_2,c0,c1) - - y=y((960-2*137+1):(960-137-9)); - yf=fft(y,128); - y=[yf(98:128) yf(2:32)]; - - - n=length(y); - Y0=y(1:2:n); - Y1=y(2:2:n); - - Z0=Y0.*c0; - nz=length(Z0); - - sm0=zeros(31,31); - sm1=zeros(31,31); - zm0=zeros(31,31); - - for i=1:31 - [sm0(i,:) zm0(i,:)]=compute_m0(i-1); - end - - Zprod0=Z0(2:nz).*conj(Z0(1:(nz-1))); - - sum0=zeros(31,1); - for m=1:31 - for i=2:31 - sum0(m)=sum0(m)+Z0(i)*conj(Z0(i-1))*sm0(m,i)*conj(sm0(m,i-1)); - end - end - - [mi1 i1]=max(abs(sum0)); - - Z1=Y1.*c1.*zm0(i1,:); - - Zprod1=Z1(2:nz).*conj(Z1(1:(nz-1))); - - sum1=zeros(31,1); - for m=1:31 - for i=2:31 - sum1(m)=sum1(m)+Z1(i)*conj(Z1(i-1))*sm0(m,i)*conj(sm0(m,i-1)); - end - end - [mi2 i2]=max(abs(sum1)); - - m1=i1; - m2=i2; - out=[sum0; sum1]; -end - diff --git a/matlab/sync/ifo_pss.m b/matlab/sync/ifo_pss.m deleted file mode 100644 index 739cbe1a7..000000000 --- a/matlab/sync/ifo_pss.m +++ /dev/null @@ -1,13 +0,0 @@ -function [ ifo ] = ifo_pss( r_pss, x_pss) - -k=1; -v=-31:31; -c=zeros(length(v),1); -for i=v - c(k) = ifo_pss_corr(i, r_pss, x_pss); - k=k+1; -end -[m i]=max(c); -ifo=v(i); -plot(v,c); - diff --git a/matlab/sync/ifo_pss_corr.m b/matlab/sync/ifo_pss_corr.m deleted file mode 100644 index c921cba9c..000000000 --- a/matlab/sync/ifo_pss_corr.m +++ /dev/null @@ -1,10 +0,0 @@ -function [ corr ] = ifo_pss_corr( n, r_pss, x_pss) - - x=0; - for i=1:length(x_pss) - x=x+r_pss(1+mod(i+n-1,length(r_pss)))*conj(x_pss(i)); - end - corr=real(exp(1i*2*pi*9*n/128)*x); -% corr=abs(x); -end - diff --git a/matlab/sync/lte_pss_zc.m b/matlab/sync/lte_pss_zc.m deleted file mode 100644 index 1cf94af88..000000000 --- a/matlab/sync/lte_pss_zc.m +++ /dev/null @@ -1,24 +0,0 @@ -function[a]=lte_pss_zc(cell_id) -% Function returns 1 out of 3 possible Zadoff-Chu sequences used in LTE. - -Nzc=62; -u=0; -if cell_id==0 - u=25; -end -if cell_id==1 - u=29; -end -if cell_id==2 - u=34; -end - -a = zeros(Nzc,1); -for n=0:30 - a(n+1)=exp(complex(0,-1)*pi*u*n*(n+1)/63); -end -for n=31:61 - a(n+1)=exp(complex(0,-1)*pi*u*(n+1)*(n+2)/63); -end - -end diff --git a/matlab/sync/sfo_estimate.m b/matlab/sync/sfo_estimate.m deleted file mode 100644 index 16c208712..000000000 --- a/matlab/sync/sfo_estimate.m +++ /dev/null @@ -1,18 +0,0 @@ -function [ sfo sfo_v ] = srslte_sfo_estimate( fs, T ) - - -nanfs=fs(~isnan(fs)); -idx=find(~isnan(fs)); -sfo_v = zeros(length(nanfs)-1,1); -for i=2:length(nanfs) - if (abs(nanfs(i)-nanfs(i-1))<9000) - sfo_v(i-1)=(nanfs(i)-nanfs(i-1))/T/(idx(i)-idx(i-1)); - else - sfo_v(i-1)=sfo_v(i-2); - end -end - -sfo = mean(sfo_v); - - - diff --git a/matlab/sync/sym_sync_cp.m b/matlab/sync/sym_sync_cp.m deleted file mode 100644 index a122ef182..000000000 --- a/matlab/sync/sym_sync_cp.m +++ /dev/null @@ -1,13 +0,0 @@ -function [ fs ] = sym_sync_cp( x, s ) - -lambda=zeros(1,length(x)-138); -for theta=1:length(lambda) - lambda(theta)=cp_corr(x,theta,128,9,s); -end - -subplot(1,2,1) -plot(abs(lambda)) -subplot(1,2,2) -plot(angle(lambda)) -[m i] = max(abs(lambda)) - diff --git a/matlab/tests/diversity_decode_test.m b/matlab/tests/diversity_decode_test.m deleted file mode 100644 index 9f21a971b..000000000 --- a/matlab/tests/diversity_decode_test.m +++ /dev/null @@ -1,46 +0,0 @@ -clear - -addpath('../../build/srslte/lib/mimo/test') - -enb = lteRMCDL('R.10'); - -cec = struct('FreqWindow',9,'TimeWindow',9,'InterpType','cubic'); -cec.PilotAverage = 'UserDefined'; -cec.InterpWinSize = 1; -cec.InterpWindow = 'Causal'; - -cfg.Seed = 1; % Random channel seed -cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'ETU'; % EVA delay spread -cfg.DopplerFreq = 100; % 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 - -[txWaveform, ~, info] = lteRMCDLTool(enb,[1;0;0;1]); -n = length(txWaveform); -cfg.SamplingRate = info.SamplingRate; - -txWaveform = txWaveform+complex(randn(n,2),randn(n,2))*1e-3; - -rxWaveform = lteFadingChannel(cfg,txWaveform); - -rxGrid = lteOFDMDemodulate(enb,sum(rxWaveform,2)); - -[h,n0] = lteDLChannelEstimate(enb,cec,rxGrid); - -signal=rxGrid(:,1); -hest(:,1,1)=reshape(h(:,1,1,1),[],1); -hest(:,1,2)=reshape(h(:,1,1,1),[],1); - -output_mat = lteTransmitDiversityDecode(signal(, hest(1:598,1,:)); -output_srs = srslte_diversitydecode(signal(1:598), hest(1:598,1,:)); - -plot(abs(output_mat-output_srs)) -mean(abs(output_mat-output_srs).^2) - - diff --git a/matlab/tests/diversity_test_rate.m b/matlab/tests/diversity_test_rate.m deleted file mode 100644 index 87e8f2f8d..000000000 --- a/matlab/tests/diversity_test_rate.m +++ /dev/null @@ -1,285 +0,0 @@ -%% PDSCH Transmit Diversity Throughput Conformance Test -% This example demonstrates the throughput performance under conformance -% test conditions as defined in TS36.101[ <#9 1> ]: single codeword, -% transmit diversity 4Tx-2Rx with medium correlation, EPA5 (Extended -% Pedestrian A) channel. The example also introduces the use of Parallel -% Computing Toolbox(TM) to provide improvements in the simulation time. - -% Copyright 2009-2013 The MathWorks, Inc. - -%% Introduction -% In this example, Hybrid Automatic Repeat Request(HARQ) is used in line -% with conformance test requirements. A total of 8 HARQ processes are used -% with a maximum of 4 retransmissions permitted. This example uses the R.12 -% Reference Measurement Channel (RMC). -% -% This example also uses loop instead of the -% loop for SNR calculation. , as part of the Parallel Computing Toolbox, executes the SNR loop -% in parallel to reduce the total simulation time. - -%% Simulation Settings -% The default simulation length is set to 10 frames at a number of |SNR| -% values including 0.2dB (as per TS36.101 (Section 8.2.1.2.2-Test1)[ <#9 -% 1> ]). -NFrames = 50; % Number of frames -SNRdB = [4 5 6]; % SNR range - -% eNodeB Configuration -enb = struct; % eNodeB config structure -enb.TotSubframes = 1; % Total subframes RMC will generate -enb.RC = 'R.10'; % RMC number - -% Channel Configuration -channel = struct; % Channel config structure -channel.Seed = 2; % Random channel seed -channel.NRxAnts = 1; % 2 receive antennas -channel.DelayProfile ='EVA'; % Delay profile -channel.DopplerFreq = 5; % Doppler frequency -channel.MIMOCorrelation = 'Low'; % Multi-antenna correlation -channel.NTerms = 16; % Oscillators used in fading model -channel.ModelType = 'GMEDS'; % Rayleigh fading model type -channel.InitPhase = 'Random'; % Random initial phases -channel.NormalizePathGains = 'On'; % Normalize delay profile power -channel.NormalizeTxAnts = 'On'; % Normalize for transmit antennas - -% Channel Estimator Configuration -cec = struct; % Channel estimation config structure -cec.PilotAverage = 'UserDefined'; % Type of pilot symbol 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 - -% PDSCH Configuration -enb.PDSCH.TxScheme = 'TxDiversity'; % Transmission scheme -enb.PDSCH.RNTI = 1; % 16-bit User Equipment (UE) mask -enb.PDSCH.Rho = 0; % PDSCH RE power adjustment factor -enb.PDSCH.CSI = 'Off'; % No CSI scaling of soft bits - -% Simulation Variables -totalBLKCRC = []; % Define total block CRC vector -bitThroughput = []; % Define total bit throughput vector - -%% System Processing -% Working on a subframe by subframe basis and using the LTE System -% Toolbox(TM) a populated resource grid is generated and OFDM modulated to -% create a transmit waveform. The generated waveform is transmitted through -% a propagation channel and AWGN is added. Channel estimation, equalization -% and the inverse of transmission chain are performed at receiver. The -% throughput performance of the PDSCH is determined using the block CRC -% result. - -% Generate the RMC configuration structure for RMC R.12 -rmc = lteRMCDL(enb); -rvSeq = rmc.PDSCH.RVSeq; - -% Transport block sizes for each subframe in a frame -trBlkSizes = rmc.PDSCH.TrBlkSizes; -codedTrBlkSizes = rmc.PDSCH.CodedTrBlkSizes; - -% Determine resource grid dimensions -dims = lteDLResourceGridSize(rmc); -p = dims(3); - -% Set up channel model sampling rate -ofdmInfo = lteOFDMInfo(rmc); -channel.SamplingRate = ofdmInfo.SamplingRate; - -% Generation HARQ table for 8-HARQ processes -harqTable = hHARQTable(); - -% Initializing state of all HARQ processes -for i=1:9 - harqProcess_init(i) = hTxDiversityNewHARQProcess ... - (trBlkSizes(i),codedTrBlkSizes(i),rvSeq); %#ok -end - -% Display the SNR points being simulated -for s=1:numel(SNRdB) - fprintf('\nSimulating at %gdB SNR for a total %d Frame(s)\n', ... - SNRdB(s),NFrames); -end - -% The temporary variables 'rmc_init' and 'channel_init' are used to create -% the temporary variables 'rmc' and 'channel' within the SNR loop to create -% independent simulation loops for the parfor loop -rmc_init = rmc; -channel_init = channel; - -% 'parfor' will default to the normal 'for' when executed without Parallel -% Computing Toolbox. -parfor index = 1:numel(SNRdB) - - % Set the random number generator seed depending to the loop variable - % to ensure independent random streams - rng(index,'combRecursive'); - - % Set up variables for the SNR loop - offsets = 0; % Initialize overall frame offset value for the SNR - offset = 0; % Initialize frame offset value for the radio frame - rmc = rmc_init; % Initialize RMC configuration - channel = channel_init; % Initialize channel configuration - blkCRC = []; % Define intermediate block CRC vector - bitTput = []; % Intermediate bit throughput vector - - % Initializing state of all HARQ processes - harqProcess = harqProcess_init; - - for subframeNo = 0:(NFrames*10-1) - - % Updating subframe number - rmc.NSubframe = subframeNo; - - % HARQ index table - harqIdx = harqTable(mod(subframeNo,length(harqTable))+1); %#ok - - % Update HARQ process - harqProcess(harqIdx) = hTxDiversityHARQScheduling( ... - harqProcess(harqIdx)); - - % Updating the RV value for correct waveform generation - rmc.PDSCH.RV = harqProcess(harqIdx).rvSeq ... - (harqProcess(harqIdx).rvIdx); - - rmc.PDSCH.RVSeq = harqProcess(harqIdx).rvSeq ... - (harqProcess(harqIdx).rvIdx); - - [txWaveform txGrid] = lteRMCDLTool(rmc, ... - {harqProcess(harqIdx).dlschTransportBlk}); - txWaveform = [txWaveform; zeros(25,p)]; - - % Initialize at time zero - channel.InitTime = subframeNo/1000; - - % Pass data through the fading channel model - rxWaveform = lteFadingChannel(channel,txWaveform); - - % Noise setup including compensation for downlink power allocation - SNR = 10^((SNRdB(index)-rmc.PDSCH.Rho)/20); % Linear SNR - - % Normalize noise power to take account of sampling rate, which is - % a function of the IFFT size used in OFDM modulation, and the - % number of antennas - N0 = 1/(sqrt(2.0*rmc.CellRefP*double(ofdmInfo.Nfft))*SNR); - - % Create additive white Gaussian noise - noise = N0*complex(randn(size(rxWaveform)), ... - randn(size(rxWaveform))); - - % Add AWGN to the received time domain waveform - rxWaveform = rxWaveform + noise; - - % Receiver - % Perform synchronization - % An offset within the range of delays expected from the channel - % modeling(a combination of implementation delay and channel delay - % spread) indicates success - if (mod(subframeNo,10)==0) - [offset] = lteDLFrameOffset(rmc,rxWaveform); - if (offset > 25) - offset = offsets(end); - end - offsets = [offsets offset]; - end - rxWaveform = rxWaveform(1+offset:end,:); - - % Perform OFDM demodulation on the received data to recreate the - % resource grid - rxSubframe = lteOFDMDemodulate(rmc,rxWaveform); - - % Equalization and channel estimation - [estChannelGrid,noiseEst] = lteDLChannelEstimate(rmc,cec, ... - rxSubframe); - - addpath('../../debug/lte/phy/lib/ch_estimation/test') - [est, ~, output] = srslte_chest(rmc.NCellID,rmc.CellRefP,rxSubframe,[0.25 0.5 0.25],[0.1 0.9],mod(rmc.NSubframe,10)); - - %estChannelGrid=reshape(est,size(estChannelGrid)); - - % Perform deprecoding, layer demapping, demodulation and - % descrambling on the received data using the estimate of - % the channel - rxEncodedBits = ltePDSCHDecode2(rmc,rmc.PDSCH,rxSubframe,estChannelGrid,noiseEst); - - % Decode DownLink Shared Channel (DL-SCH) - [decbits,harqProcess(harqIdx).crc,harqProcess(harqIdx).decState] = ... - lteDLSCHDecode(rmc,rmc.PDSCH,harqProcess(harqIdx).trBlkSize, ... - rxEncodedBits{1},harqProcess(harqIdx).decState); - - if(harqProcess(harqIdx).trBlkSize ~= 0) - blkCRC = [blkCRC harqProcess(harqIdx).crc]; - bitTput = [bitTput harqProcess(harqIdx).trBlkSize.*(1- ... - harqProcess(harqIdx).crc)]; - end - end - % Record the block CRC and bit throughput for the total number of - % frames simulated at a particular SNR - totalBLKCRC(index,:) = blkCRC; - bitThroughput(index,:) = bitTput; - -end -%% -% |totalBLKCRC| is a matrix where each row contains the results of decoding -% the block CRC for a defined value of SNR. |bitThroughput| is a matrix -% containing the total number of bits per subframe at the different SNR -% points that have been successfully received and decoded. - -%% Results - -% First graph shows the throughput as total bits per second against the -% range of SNRs -% figure; -% plot(SNRdB,mean(bitThroughput,2),'-*'); -% %axis([-5 3 200 400]) -% title(['Throughput for ', num2str(NFrames) ' frame(s)'] ); -% xlabel('SNRdB'); ylabel('Throughput (kbps)'); -% grid on; -% hold on; -% plot(SNRdB,mean([trBlkSizes(1:5) trBlkSizes(7:10)])*0.7*ones ... -% (1,numel(SNRdB)),'--rs'); -% legend('Simulation Result','70 Percent Throughput','Location','SouthEast'); -% -% % Second graph shows the total throughput as a percentage of CRC passes -% % against SNR range -% figure; -plot(SNRdB,100*(1-mean(totalBLKCRC,2)),'-*'); -%axis([-5 3 50 110]) -title(['Throughput for ', num2str(NFrames) ' frame(s)'] ); -xlabel('SNRdB'); ylabel('Throughput (%)'); -grid on; -hold on; -plot(SNRdB,70*ones(1,numel(SNRdB)),'--rs'); -legend('Simulation Result','70 Percent Throughput','Location','SouthEast'); - - -%% Further Exploration -% -% You can modify parts of this example to experiment with different number -% of |NFrames| and different values of SNR. SNR can be a vector of -% values or a single value. Following scenarios can be simulated. -%% -% * Allows control over the total number of frames to run the demo at an -% SNR of 0.2dB (as per TS 36.101). -% -% * Allows control over the total number of frames to run the demo, as well -% as defining a set of desired SNR values. |SNRIn| can be a single value -% or a vector containing a range of values. -% -% * For simulations of multiple SNR points over a large number of frames, -% the use of Parallel Computing Toolbox provides significant improvement in -% the simulation time. This can be easily verified by changing the |parfor| -% in the SNR loop to |for| and re-running the example. - -%% Appendix -% This example uses the following helper functions: -% -% * -% * -% * - -%% Selected Bibliography -% # 3GPP TS 36.101 - -displayEndOfDemoMessage(mfilename) diff --git a/matlab/tests/dlsch_test.m b/matlab/tests/dlsch_test.m deleted file mode 100644 index c8414c755..000000000 --- a/matlab/tests/dlsch_test.m +++ /dev/null @@ -1,27 +0,0 @@ -clear -enbConfig=struct('NCellID',0,'CyclicPrefix','Normal','CellRefP',1); -pdschConfig=struct('Modulation','64QAM','RV',1,'TxScheme','Port0','NTurboDecIts',10); - -addpath('../../build/srslte/lib/phch/test') - -TBs=18336; -i=1; -e_bits=3450*6; -error=zeros(size(TBs)); -for i=1:length(TBs) - trblkin=randi(2,TBs(i),1)-1; - - [mat, info]=lteDLSCH(enbConfig,pdschConfig,e_bits,trblkin); - lib=srslte_dlsch_encode(enbConfig,pdschConfig,e_bits,trblkin); - error(i)=mean(abs(double(mat)-double(lib))); - -end - - if (length(TBs) == 1) - disp(info) - disp(error) - n=1:length(mat); - plot(abs(double(mat)-double(lib))) - else - plot(error) - end diff --git a/matlab/tests/dmrs_equalizer_test.m b/matlab/tests/dmrs_equalizer_test.m deleted file mode 100644 index 11f14cbff..000000000 --- a/matlab/tests/dmrs_equalizer_test.m +++ /dev/null @@ -1,184 +0,0 @@ -%% LTE Downlink Channel Estimation and Equalization - -%% Cell-Wide Settings - -clear - -plot_noise_estimation_only=false; - -SNR_values_db=100;%linspace(0,30,5); -Nrealizations=1; - -w1=1/3; - -%% UE Configuration -ue = lteRMCUL('A3-5'); -ue.TotSubframes = 2; - -K=ue.NULRB*12; -P=K/6; - -%% Channel Model Configuration -chs.Seed = 1; % Random channel seed -chs.InitTime = 0; -chs.NRxAnts = 1; % 1 receive antenna -chs.DelayProfile = 'EVA'; -chs.DopplerFreq = 300; % 120Hz Doppler frequency -chs.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation -chs.NTerms = 16; % Oscillators used in fading model -chs.ModelType = 'GMEDS'; % Rayleigh fading model type -chs.InitPhase = 'Random'; % Random initial phases -chs.NormalizePathGains = 'On'; % Normalize delay profile power -chs.NormalizeTxAnts = 'On'; % Normalize for transmit antennas - -%% Channel Estimator Configuration -cec = struct; % Channel estimation config structure -cec.PilotAverage = 'UserDefined'; % Type of pilot symbol averaging -cec.FreqWindow = 9; % Frequency window size -cec.TimeWindow = 9; % Time window size -cec.InterpType = 'Linear'; % 2D interpolation type -cec.InterpWindow = 'Causal'; % Interpolation window type -cec.InterpWinSize = 1; % Interpolation window size - - -%% Allocate memory -Ntests=3; -hest=cell(1,Ntests); -for i=1:Ntests - hest{i}=zeros(K,14); -end -MSE=zeros(Ntests,Nrealizations,length(SNR_values_db)); -noiseEst=zeros(Ntests,Nrealizations,length(SNR_values_db)); - -legends={'matlab','ls',num2str(w1)}; -colors={'bo-','rx-','m*-','k+-','c+-'}; -colors2={'b-','r-','m-','k-','c-'}; - -addpath('../../debug/srslte/lib/ch_estimation/test') - -offset = -1; -for nreal=1:Nrealizations - - %% Signal Generation - [txWaveform, txGrid, info] = lteRMCULTool(ue,[1;0;0;1]); - - %% SNR Configuration - for snr_idx=1:length(SNR_values_db) - SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB - SNR = 10^(SNRdB/20); % Linear SNR - - fprintf('SNR=%.1f dB\n',SNRdB) - - %% Fading Channel - - chs.SamplingRate = info.SamplingRate; - [rxWaveform, chinfo] = lteFadingChannel(chs,txWaveform); - - %% Additive Noise - - % Calculate noise gain - N0 = 1/(sqrt(2.0*double(info.Nfft))*SNR); - - % Create additive white Gaussian noise - noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform))); - - % Add noise to the received time domain waveform - rxWaveform = rxWaveform + noise; - - %% Synchronization - - % Time offset estimation is done once because depends on channel - % model only - if (offset==-1) - offset = lteULFrameOffset(ue,ue.PUSCH,rxWaveform); - end - rxWaveform = rxWaveform(1+offset:end); - - %% OFDM Demodulation - rxGrid = lteSCFDMADemodulate(ue,rxWaveform); - rxGrid = rxGrid(:,1:14); - - %% Perfect channel estimate - h=lteULPerfectChannelEstimate(ue,chs,offset); - h=h(:,1:14); - - %% Channel Estimation with Matlab - [hest{1}, noiseEst(1,nreal,snr_idx)] = lteULChannelEstimate(ue,ue.PUSCH,cec,rxGrid); - - %% LS-Linear estimation with srsLTE - [hest{2}, noiseEst(2,nreal,snr_idx)] = srslte_chest_ul(ue,ue.PUSCH,rxGrid); - - %% LS-Linear estimation + averaging with srsLTE - [hest{3}, noiseEst(3,nreal,snr_idx)] = srslte_chest_ul(ue,ue.PUSCH,rxGrid,w1); - - %% Compute MSE - for i=1:Ntests - MSE(i,nreal,snr_idx)=mean(mean(abs(h-hest{i}).^2)); - fprintf('MSE test %d: %f\n',i, 10*log10(MSE(i,nreal,snr_idx))); - end - - %% Plot a single realization - if (length(SNR_values_db) == 1) - subplot(1,1,1) - sym=1; - n=1:(K*length(sym)); - for i=1:Ntests - plot(n,abs(reshape(hest{i}(:,sym),1,[])),colors2{i}); - hold on; - end - plot(n,abs(reshape(h(:,sym),1,[])),'k'); - hold off; - - tmp=cell(Ntests+1,1); - for i=1:Ntests - tmp{i}=legends{i}; - end - tmp{Ntests+1}='Perfect'; - legend(tmp) - - xlabel('SNR (dB)') - ylabel('Channel Gain') - grid on; - - end - - end -end - -%% Compute average MSE and noise estimation -mean_mse=mean(MSE,2); -mean_snr=10*log10(1./mean(noiseEst,2)); - -%disp(mean_snr(3) - -%% Plot average over all SNR values -if (length(SNR_values_db) > 1) - subplot(1,2,1) - for i=1:Ntests - plot(SNR_values_db, 10*log10(mean_mse(i,:)),colors{i}) - hold on; - end - hold off; - legend(legends); - grid on - xlabel('SNR (dB)') - ylabel('MSE (dB)') - - subplot(1,2,2) - plot(SNR_values_db, SNR_values_db,'k:') - hold on; - for i=1:Ntests - plot(SNR_values_db, mean_snr(i,:), colors{i}) - end - hold off - tmp=cell(Ntests+1,1); - tmp{1}='Theory'; - for i=2:Ntests+1 - tmp{i}=legends{i-1}; - end - legend(tmp) - grid on - xlabel('SNR (dB)') - ylabel('Estimated SNR (dB)') -end - diff --git a/matlab/tests/drms_pusch_test.m b/matlab/tests/drms_pusch_test.m deleted file mode 100644 index 271e925d8..000000000 --- a/matlab/tests/drms_pusch_test.m +++ /dev/null @@ -1,52 +0,0 @@ -ueConfig=struct('CyclicPrefixUL','Normal','NTxAnts',1,'NULRB',6); -puschConfig=struct('NLayers',1,'OrthCover','Off'); - -addpath('../../debug/lte/phy/lib/ch_estimation/test') - -Hopping={'Off','Sequence','Group'}; - -k=1; -for prb=4 - for ncell=1 - for ns=8 - for h=1 - for sg=0 - for cs=0 - for ds=0 - - ueConfig.NCellID=ncell; - ueConfig.NSubframe=ns; - ueConfig.Hopping=Hopping{h}; - ueConfig.SeqGroup=sg; - ueConfig.CyclicShift=cs; - - puschConfig.PRBSet=(1:4)'; - puschConfig.DynCyclicShift=ds; - - [mat, info]=ltePUSCHDRS(ueConfig,puschConfig); - ind=ltePUSCHDRSIndices(ueConfig, puschConfig); - subframe_mat = lteULResourceGrid(ueConfig); - subframe_mat(ind)=mat; - - subframe_lib=srslte_refsignal_pusch(ueConfig,puschConfig); - - error(k)=mean(abs(subframe_mat(:)-subframe_lib(:))); - disp(error(k)) - if (error(k) > 10^-3) - k=1; - end - k=k+1; - end - end - end - end - end - end -end - -plot(error); -disp(info) -disp(length(subframe_mat)) -n=1:length(subframe_mat(:)); -%plot(n,real(subframe_mat(:)),n,real(subframe_lib(:))) -plot(abs(subframe_mat(:)-subframe_lib(:))) diff --git a/matlab/tests/equalizer_test.m b/matlab/tests/equalizer_test.m deleted file mode 100644 index 816a29957..000000000 --- a/matlab/tests/equalizer_test.m +++ /dev/null @@ -1,277 +0,0 @@ -%% LTE Downlink Channel Estimation and Equalization - -%% Cell-Wide Settings - -clear - -plot_noise_estimation_only=false; - -SNR_values_db=linspace(0,30,8); -Nrealizations=10; - -w1=0.1; -w2=0.2; - -enb.NDLRB = 6; % Number of resource blocks - -enb.CellRefP = 1; % One transmit antenna port -enb.NCellID = 0; % Cell ID -enb.CyclicPrefix = 'Normal'; % Normal cyclic prefix -enb.DuplexMode = 'FDD'; % FDD - -K=enb.NDLRB*12; -P=K/6; - -%% Channel Model Configuration -cfg.Seed = 0; % Random channel seed -cfg.InitTime = 0; -cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'EVA'; - -% doppler 5, 70 300 - -cfg.DopplerFreq = 5; % 120Hz Doppler frequency -cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation -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 - -%% Channel Estimator Configuration -cec = struct; % Channel estimation config structure -cec.PilotAverage = 'UserDefined'; % Type of pilot symbol averaging -cec.FreqWindow = 9; % Frequency window size -cec.TimeWindow = 9; % Time window size -cec.InterpType = 'Linear'; % 2D interpolation type -cec.InterpWindow = 'Causal'; % Interpolation window type -cec.InterpWinSize = 1; % Interpolation window size - -%% Subframe Resource Grid Size - -gridsize = lteDLResourceGridSize(enb); -Ks = gridsize(1); % Number of subcarriers -L = gridsize(2); % Number of OFDM symbols in one subframe -Ports = gridsize(3); % Number of transmit antenna ports - -%% Allocate memory -Ntests=4; -hest=cell(1,Ntests); -tmpnoise=cell(1,Ntests); -for i=1:Ntests - hest{i}=zeros(K,140); - tmpnoise{i}=zeros(1,10); -end -hls=zeros(4,4*P*10); -MSE=zeros(Ntests,Nrealizations,length(SNR_values_db)); -noiseEst=zeros(Ntests,Nrealizations,length(SNR_values_db)); - -legends={'matlab','ls',num2str(w1),num2str(w2)}; -colors={'bo-','rx-','m*-','k+-','c+-'}; -colors2={'b-','r-','m-','k-','c-'}; - -addpath('../../build/srslte/lib/ch_estimation/test') - -offset=-1; - -for nreal=1:Nrealizations -%% Transmit Resource Grid -txGrid = []; - -%% Payload Data Generation -% Number of bits needed is size of resource grid (K*L*P) * number of bits -% per symbol (2 for QPSK) -numberOfBits = Ks*L*Ports*2; - -% Create random bit stream -inputBits = randi([0 1], numberOfBits, 1); - -% Modulate input bits -inputSym = lteSymbolModulate(inputBits,'QPSK'); - -%% Frame Generation - -% For all subframes within the frame -for sf = 0:10 - - % Set subframe number - enb.NSubframe = mod(sf,10); - - % Generate empty subframe - subframe = lteDLResourceGrid(enb); - - % Map input symbols to grid - subframe(:) = inputSym; - - % Generate synchronizing signals - pssSym = ltePSS(enb); - sssSym = lteSSS(enb); - pssInd = ltePSSIndices(enb); - sssInd = lteSSSIndices(enb); - - % Map synchronizing signals to the grid - subframe(pssInd) = pssSym; - subframe(sssInd) = sssSym; - - % Generate cell specific reference signal symbols and indices - cellRsSym = lteCellRS(enb); - cellRsInd = lteCellRSIndices(enb); - - % Map cell specific reference signal to grid - subframe(cellRsInd) = cellRsSym; - - % Append subframe to grid to be transmitted - txGrid = [txGrid subframe]; %#ok - -end - -txGrid([1:5 68:72],6:7) = ones(10,2); - -%% OFDM Modulation - -[txWaveform,info] = lteOFDMModulate(enb,txGrid); -txGrid = txGrid(:,1:140); - -%% SNR Configuration -for snr_idx=1:length(SNR_values_db) -SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB -SNR = 10^(SNRdB/20); % Linear SNR - -fprintf('SNR=%.1f dB\n',SNRdB) - -%% Fading Channel - -cfg.SamplingRate = info.SamplingRate; -[rxWaveform, chinfo] = lteFadingChannel(cfg,txWaveform); - -%% Additive Noise - -% Calculate noise gain -N0 = 1/(sqrt(2.0*enb.CellRefP*double(info.Nfft))*SNR); - -% Create additive white Gaussian noise -noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform))); - -% Add noise to the received time domain waveform -rxWaveform_nonoise = rxWaveform; -rxWaveform = rxWaveform + noise; - -%% Synchronization - -if (offset==-1) - offset = lteDLFrameOffset(enb,rxWaveform); -end - -rxWaveform = rxWaveform(1+offset:end,:); -rxWaveform_nonoise = rxWaveform_nonoise(1+offset:end,:); - -%% OFDM Demodulation -rxGrid = lteOFDMDemodulate(enb,rxWaveform); -rxGrid = rxGrid(:,1:140); - -rxGrid_nonoise = lteOFDMDemodulate(enb,rxWaveform_nonoise); -rxGrid_nonoise = rxGrid_nonoise(:,1:140); - -% True channel -h=rxGrid_nonoise./(txGrid); - -for i=1:10 - enb.NSubframe=i-1; - - rxGrid_sf = rxGrid(:,(i-1)*14+1:i*14); - - %% Channel Estimation with Matlab - [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i)] = ... - lteDLChannelEstimate(enb,cec,rxGrid_sf); - tmpnoise{1}(i)=tmpnoise{1}(i)*sqrt(2)*enb.CellRefP; - - %% LS-Linear estimation with srsLTE - [hest{2}(:,(1:14)+(i-1)*14), tmpnoise{2}(i)] = srslte_chest_dl(enb,rxGrid_sf); - - %% LS-Linear + averaging with srsLTE - [hest{3}(:,(1:14)+(i-1)*14), tmpnoise{3}(i)] = srslte_chest_dl(enb,rxGrid_sf,w1); - - %% LS-Linear + more averaging with srsLTE - [hest{4}(:,(1:14)+(i-1)*14), tmpnoise{4}(i)] = srslte_chest_dl(enb,rxGrid_sf,w2); - -end - -%% Average noise estimates over all frame -for i=1:Ntests - noiseEst(i,nreal,snr_idx)=mean(tmpnoise{i}); -end - -%% Compute MSE -for i=1:Ntests - MSE(i,nreal,snr_idx)=mean(mean(abs(h-hest{i}).^2)); - fprintf('MSE test %d: %f\n',i, 10*log10(MSE(i,nreal,snr_idx))); -end - -%% Plot a single realization -if (length(SNR_values_db) == 1) - sym=1; - ref_idx=1:P; - ref_idx_x=[1:6:K];% (292:6:360)-216];% 577:6:648]; - n=1:(K*length(sym)); - for i=1:Ntests - plot(n,abs(reshape(hest{i}(:,sym),1,[])),colors2{i}); - hold on; - end - 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}='Real'; - legend(tmp) - - xlabel('SNR (dB)') - ylabel('Channel Gain') - grid on; - - 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))) -end - -end -end - - -%% Compute average MSE and noise estimation -mean_mse=mean(MSE,2); -mean_snr=10*log10(1./mean(noiseEst,2)); - - -%% Plot average over all SNR values -if (length(SNR_values_db) > 1) - subplot(1,2,1) - for i=1:Ntests - plot(SNR_values_db, 10*log10(mean_mse(i,:)),colors{i}) - hold on; - end - hold off; - legend(legends); - grid on - xlabel('SNR (dB)') - ylabel('MSE (dB)') - - subplot(1,2,2) - plot(SNR_values_db, SNR_values_db,'k:') - hold on; - for i=1:Ntests - plot(SNR_values_db, mean_snr(i,:), colors{i}) - end - hold off - tmp=cell(Ntests+1,1); - tmp{1}='Theory'; - for i=2:Ntests+1 - tmp{i}=legends{i-1}; - end - legend(tmp) - grid on - xlabel('SNR (dB)') - ylabel('Estimated SNR (dB)') -end - diff --git a/matlab/tests/get_sc.m b/matlab/tests/get_sc.m deleted file mode 100644 index 2db50dd1f..000000000 --- a/matlab/tests/get_sc.m +++ /dev/null @@ -1,111 +0,0 @@ -function [ s, c0, c1 ] = get_sc( N_id_2 ) - - if (N_id_2 == 0) - - s(1,:)=[1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, ]; - s(2,:)=[1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, ]; - s(3,:)=[1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, ]; - s(4,:)=[1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, ]; - s(5,:)=[-1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, ]; - s(6,:)=[1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, ]; - s(7,:)=[1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, ]; - s(8,:)=[-1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, ]; - s(9,:)=[1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, ]; - s(10,:)=[-1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, ]; - s(11,:)=[-1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, ]; - s(12,:)=[1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, ]; - s(13,:)=[1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, ]; - s(14,:)=[-1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, ]; - s(15,:)=[-1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, ]; - s(16,:)=[-1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, ]; - s(17,:)=[-1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, ]; - s(18,:)=[-1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, ]; - s(19,:)=[1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, ]; - s(20,:)=[1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, ]; - s(21,:)=[1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, ]; - s(22,:)=[-1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, ]; - s(23,:)=[-1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, ]; - s(24,:)=[1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, ]; - s(25,:)=[-1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, ]; - s(26,:)=[-1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, ]; - s(27,:)=[-1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, ]; - s(28,:)=[1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, ]; - s(29,:)=[-1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, ]; - s(30,:)=[1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, ]; - s(31,:)=[-1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, ]; - c0=[1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, ]; - c1=[1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, ]; - elseif (N_id_2 == 1) - s(1,:)=[1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, ]; - s(2,:)=[1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, ]; - s(3,:)=[1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, ]; - s(4,:)=[1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, ]; - s(5,:)=[-1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, ]; - s(6,:)=[1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, ]; - s(7,:)=[1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, ]; - s(8,:)=[-1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, ]; - s(9,:)=[1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, ]; - s(10,:)=[-1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, ]; - s(11,:)=[-1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, ]; - s(12,:)=[1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, ]; - s(13,:)=[1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, ]; - s(14,:)=[-1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, ]; - s(15,:)=[-1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, ]; - s(16,:)=[-1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, ]; - s(17,:)=[-1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, ]; - s(18,:)=[-1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, ]; - s(19,:)=[1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, ]; - s(20,:)=[1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, ]; - s(21,:)=[1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, ]; - s(22,:)=[-1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, ]; - s(23,:)=[-1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, ]; - s(24,:)=[1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, ]; - s(25,:)=[-1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, ]; - s(26,:)=[-1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, ]; - s(27,:)=[-1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, ]; - s(28,:)=[1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, ]; - s(29,:)=[-1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, ]; - s(30,:)=[1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, ]; - s(31,:)=[-1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, ]; - c0=[1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, ]; - c1=[-1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, ]; - - else - s(1,:)=[1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, ]; - s(2,:)=[1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, ]; - s(3,:)=[1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, ]; - s(4,:)=[1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, ]; - s(5,:)=[-1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, ]; - s(6,:)=[1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, ]; - s(7,:)=[1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, ]; - s(8,:)=[-1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, ]; - s(9,:)=[1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, ]; - s(10,:)=[-1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, ]; - s(11,:)=[-1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, ]; - s(12,:)=[1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, ]; - s(13,:)=[1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, ]; - s(14,:)=[-1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, ]; - s(15,:)=[-1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, ]; - s(16,:)=[-1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, ]; - s(17,:)=[-1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, ]; - s(18,:)=[-1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, ]; - s(19,:)=[1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, ]; - s(20,:)=[1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, ]; - s(21,:)=[1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, ]; - s(22,:)=[-1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, ]; - s(23,:)=[-1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, ]; - s(24,:)=[1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, ]; - s(25,:)=[-1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, ]; - s(26,:)=[-1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, ]; - s(27,:)=[-1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, ]; - s(28,:)=[1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, ]; - s(29,:)=[-1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, ]; - s(30,:)=[1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, ]; - s(31,:)=[-1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, ]; - c0=[1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, ]; - c1=[1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, ]; - - end - -end - diff --git a/matlab/tests/pbch_bler.m b/matlab/tests/pbch_bler.m deleted file mode 100644 index ed67da4ff..000000000 --- a/matlab/tests/pbch_bler.m +++ /dev/null @@ -1,130 +0,0 @@ -clear - -Nblock=[3]; -SNR_values_db=100;%linspace(-4,0,6); -Nrealizations=1; -enb = struct('NCellID',62,'NDLRB',50,'CellRefP',2,'CyclicPrefix','Normal','DuplexMode','FDD',... - 'NSubframe',0,'PHICHDuration','Normal','Ng','One','NFrame',101,'TotSubframes',40); - -cfg.Seed = 8; % Random channel seed -cfg.NRxAnts = 1; % 1 receive antenna -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 -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 - -griddims = lteResourceGridSize(enb); % Resource grid dimensions -L = griddims(2); - -% Generate signal -mib = lteMIB(enb); -bchCoded = lteBCH(enb,mib); -mibCRC = lteCRCEncode(mib,'16'); -mibCoded = lteConvolutionalEncode(mibCRC); -pbchSymbolsTx = ltePBCH(enb,bchCoded); -pbchIndtx = ltePBCHIndices(enb); -subframe_tx = lteDLResourceGrid(enb); -rs = lteCellRS(enb); -rsind = lteCellRSIndices(enb); -subframe_tx(rsind)=rs; - -NofPortsTx=enb.CellRefP; - -addpath('../../build/srslte/lib/phch/test') - -txWaveform=cell(length(Nblock)); -rxWaveform=cell(length(Nblock)); -for n=1:length(Nblock) - subframe_tx2=subframe_tx; - subframe_tx2(pbchIndtx)=pbchSymbolsTx(Nblock(n)*240+1:(Nblock(n)+1)*240,:); - [txWaveform{n},info] = lteOFDMModulate(enb, subframe_tx2, 0); - cfg.SamplingRate = info.SamplingRate; -end - -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/10); % Linear SNR - - errorReal = zeros(Nrealizations,2); - for i=1:Nrealizations - - for n=1:length(Nblock) - - %rxWaveform = lteFadingChannel(cfg,sum(txWaveform,2)); - rxWaveform{n} = sum(txWaveform{n},2); - - %% 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{n})),randn(size(rxWaveform{n}))); - - rxWaveform{n} = noise + rxWaveform{n}; - - % Number of OFDM symbols in a subframe - % OFDM demodulate signal - rxgrid = lteOFDMDemodulate(enb, rxWaveform{n}, 0); - - % Perform channel estimation - %enb.CellRefP=2; - [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, nof_ports] = ltePBCHDecode(enb, pbchRx, pbchHest, nest); - - if (nof_ports ~= NofPortsTx) - errorReal(i,1)=1; - end - end - - %enb.CellRefP=NofPortsTx; - [nof_ports2, pbchSymbols2, pbchBits, ce, ce2, pbchRx2, pbchHest2, mod2, codedbits]= ... - srslte_pbch(enb, rxWaveform); - - subplot(2,1,1) - plot(abs((bchCoded(1:960)>0)-(pbchBits(1:960)>0))) - subplot(2,1,2) - codedbits2 = reshape(reshape(codedbits,3,[])',1,[]); - plot(abs((codedbits2'>0)-(mibCoded>0))) - - %decodedData = lteConvolutionalDecode(noisysymbols); - %[decodedData2, quant] = srslte_viterbi(interleavedSymbols); - - if (nof_ports2 ~= NofPortsTx) - errorReal(i,2)=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) - semilogy(SNR_values_db, error/Nrealizations) - grid on - xlabel('SNR (dB)'); - ylabel('BLER') - legend('Matlab','srsLTE') - axis([min(SNR_values_db) max(SNR_values_db) 1/Nrealizations/10 1]) -else - disp(error) - disp(nfmod4) - disp(mod2) -end - diff --git a/matlab/tests/pdcch_bler.m b/matlab/tests/pdcch_bler.m deleted file mode 100644 index d63883b7d..000000000 --- a/matlab/tests/pdcch_bler.m +++ /dev/null @@ -1,189 +0,0 @@ - -%% PDCCH Blind Search and DCI Decoding + PCFICH encoding/decoding - -%% Cell-Wide Settings -% A structure |enbConfig| is used to configure the eNodeB. -clear - -Npackets = 60; -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.Ng = 'One'; % HICH groups -enbConfig.CellRefP = 1; % 1-antenna ports -enbConfig.NCellID = 0; % Physical layer cell identity -enbConfig.NSubframe = 5; % Subframe number 0 -enbConfig.DuplexMode = 'FDD'; % Frame structure -enbConfig.PHICHDuration = 'Normal'; -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 = 'EPA'; % EVA delay spread -cfg.DopplerFreq = 5; % 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 - -% Setup channel equalizer -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 = 'Causal'; % Interpolation window type -cec.InterpWinSize = 1; % Interpolation window size - -%% DCI Message Generation -% Generate a DCI message to be mapped to the PDCCH. - -dciConfig.DCIFormat = 'Format1A'; % DCI message format -dciConfig.Allocation.RIV = 26; % Resource indication value - -% Create DCI message for given configuration -[dciMessage, dciMessageBits] = lteDCI(enbConfig, dciConfig); - -%% DCI Channel Coding - -% Do not include RNTI if Common Search space -if C_RNTI<65535 - pdcchConfig.RNTI = C_RNTI; % Radio network temporary identifier -end -pdcchConfig.PDCCHFormat = 3; % PDCCH format -ueConfig.RNTI = C_RNTI; - -candidates = ltePDCCHSpace(enbConfig, pdcchConfig, {'bits', '1based'}); - -% Include now RNTI in pdcch -pdcchConfig.RNTI = C_RNTI; - -% DCI message bits coding to form coded DCI bits -codedDciBits = lteDCIEncode(pdcchConfig, dciMessageBits); - -%% PDCCH Bits Generation - -pdcchDims = ltePDCCHInfo(enbConfig); - -% Initialize elements with -1 to indicate that all the bits are unused -pdcchBitsTx = -1*ones(pdcchDims.MTot, 1); - - -Ncad=1; - -% Map PDCCH payload on available UE-specific candidate. In this example the -% first available candidate is used to map the coded DCI bits. -pdcchBitsTx ( candidates(Ncad, 1) : candidates(Ncad, 2) ) = codedDciBits; - -%% PDCCH Complex-Valued Modulated Symbol Generation - -pdcchSymbolsTx = ltePDCCH(enbConfig, pdcchBitsTx); -pdcchIndices = ltePDCCHIndices(enbConfig,{'1based'}); -subframe_tx = lteDLResourceGrid(enbConfig); -subframe_tx(pdcchIndices) = pdcchSymbolsTx; - -%% PCFICH -cfiCodeword = lteCFI(enbConfig); -pcfichSymbols = ltePCFICH(enbConfig,cfiCodeword); -pcfichIndices = ltePCFICHIndices(enbConfig,'1based'); -subframe_tx(pcfichIndices) = pcfichSymbols; - -%% Add references -cellRsSym = lteCellRS(enbConfig); -cellRsInd = lteCellRSIndices(enbConfig); -subframe_tx(cellRsInd) = cellRsSym; - -[txWaveform, info] = lteOFDMModulate(enbConfig,subframe_tx); -cfg.SamplingRate = info.SamplingRate; - -addpath('../../build/srslte/lib/phch/test') - -decoded = zeros(size(SNR_values)); -decoded_cfi = zeros(size(SNR_values)); -decoded_srslte = zeros(size(SNR_values)); -decoded_cfi_srslte = zeros(size(SNR_values)); - -for snr_idx=1:length(SNR_values) - SNRdB = SNR_values(snr_idx); - SNR = 10^(SNRdB/10); % Linear SNR - N0 = 1/(sqrt(2.0*enbConfig.CellRefP*double(info.Nfft))*SNR); - for i=1:Npackets - - enbConfigRx=enbConfig; - - rxWaveform = sum(txWaveform,2); - - %% Fading - rxWaveform = lteFadingChannel(cfg,rxWaveform); - - %% Noise Addition - noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise - rxWaveform = rxWaveform + noise; - - %% Demodulate - subframe_rx = lteOFDMDemodulate(enbConfigRx, rxWaveform); - - % Perform channel estimation - [hest, nest] = lteDLChannelEstimate(enbConfigRx, cec, subframe_rx); - - [pcfichSymbolsRx, pcfichSymbolsHest] = lteExtractResources(pcfichIndices(:,1), subframe_rx, hest); - - %% PCFICH decoding - [pcfichBits, pcfichSymbols] = ltePCFICHDecode(enbConfigRx,pcfichSymbolsRx, pcfichSymbolsHest, nest); - rxCFI = lteCFIDecode(pcfichBits); - - decoded_cfi(snr_idx) = decoded_cfi(snr_idx) + (rxCFI == txCFI); - - %% PDCCH Decoding - enbConfigRx.CFI = rxCFI; - pdcchIndicesRx = ltePDCCHIndices(enbConfigRx,{'1based'}); - [pdcchRx, pdcchHest] = lteExtractResources(pdcchIndicesRx(:,1), subframe_rx, hest); - [pdcchBits, pdcchSymbols] = ltePDCCHDecode(enbConfigRx, pdcchRx, pdcchHest, nest); - - %% Blind Decoding using DCI Search - [rxDCI, rxDCIBits] = ltePDCCHSearch(enbConfigRx, ueConfig, pdcchBits); - decoded(snr_idx) = decoded(snr_idx) + (length(rxDCI)>0); - - %% 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 = 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 - fprintf('SNR: %.1f\n',SNRdB) -end - -if (Npackets>1) - semilogy(SNR_values,1-decoded/Npackets,'bo-',... - SNR_values,1-decoded_cfi/Npackets,'bx:',... - SNR_values,1-decoded_srslte/Npackets, 'ro-',... - SNR_values,1-decoded_cfi_srslte/Npackets,'rx:') - grid on - legend('Matlab all','Matlab cfi', 'srsLTE all', 'srsLTE cfi') - xlabel('SNR (dB)') - ylabel('BLER') - axis([min(SNR_values) max(SNR_values) 1/Npackets/10 1]) -else - - n=min(length(pdcchSymbols),length(pdcchSymbols2)); - subplot(2,1,1) - plot(abs(pdcchSymbols(1:n)-pdcchSymbols2(1:n))) - n=min(length(pdcchBits),length(pdcchBits2)); - subplot(2,1,2) - pdcchBitsTx(pdcchBitsTx==-1)=0; - plot(abs((pdcchBitsTx(1:n)>0.1)-(pdcchBits2(1:n)>0.1))) - - subplot(1,1,1) - plot(1:180,real(hest(:,1,1,1)),1:180,real(hest2(1:180))) - - disp(decoded) - disp(decoded_srslte) -end - diff --git a/matlab/tests/pdsch_bler.m b/matlab/tests/pdsch_bler.m deleted file mode 100644 index 4efc17348..000000000 --- a/matlab/tests/pdsch_bler.m +++ /dev/null @@ -1,108 +0,0 @@ -%% Plot PDSCH BLER vs SNR for PDSCH without equalization -clear -transportBlkSize=75376; -modulation='64QAM'; -rvValues=[0 2 3 1]; -SNR=linspace(-2.9,-2.0,8); -Nblocks=30; - -addpath('../../build/srslte/lib/phch/test') - -% Subframe configuration -enbConfig.NCellID = 100; -enbConfig.CyclicPrefix = 'Normal'; -enbConfig.NSubframe = 1; -enbConfig.CellRefP = 1; -enbConfig.NDLRB = 100; -enbConfig.CFI = 1; -enbConfig.DuplexMode='FDD'; - -% Transmission mode configuration for PDSCH -pdschConfig.NLayers = 1; -pdschConfig.TxScheme = 'Port0'; -pdschConfig.Modulation = {modulation}; -pdschConfig.RNTI = 100; -pdschConfig.NTurboDecIts = 5; -pdschConfig.PRBSet = (0:enbConfig.NDLRB-1)'; - -switch (modulation) - case 'QPSK' - bitsPerSym = 2; - case '16QAM' - bitsPerSym = 4; - case '64QAM' - bitsPerSym = 6; -end -noiseVarfactor = sqrt(2*bitsPerSym); -snr = 10.^(SNR/10); - -nErrors_mat = zeros(length(SNR),length(rvValues)); -nErrors_srs = zeros(length(SNR),length(rvValues)); - -for k = 1:length(SNR); - subframe=cell(length(rvValues)); - pdschIdx=ltePDSCHIndices(enbConfig,pdschConfig,pdschConfig.PRBSet); - for i=1:length(rvValues) - subframe{i} = lteDLResourceGrid(enbConfig); - end - blkCounter = 0; - for l = 1:Nblocks; - % DL-SCH data bits - dlschBits = randi([0 1],transportBlkSize,1); - softBuffer = {}; - for rvIndex = 1:length(rvValues) - % DLSCH transport channel - pdschConfig.RV = rvValues(rvIndex); - pdschPayload = lteDLSCH(enbConfig, pdschConfig, length(pdschIdx)*bitsPerSym, dlschBits); - - % PDSCH modulated symbols - pdschSymbols = ltePDSCH(enbConfig, pdschConfig, pdschPayload); - pdschSize = size(pdschSymbols); - - % Addition of noise - noise = (1/noiseVarfactor)*sqrt(1/snr(k))*complex(randn(pdschSize),randn(pdschSize)); - noisySymbols = pdschSymbols + noise; - - subframe{rvIndex}(pdschIdx)=noisySymbols; - - % PDSCH Rx-side - rxCW = ltePDSCHDecode(enbConfig, pdschConfig, noisySymbols); - - % DL-SCH turbo decoding - [rxBits, blkCRCerr, softBuffer] = lteDLSCHDecode(enbConfig, pdschConfig, transportBlkSize, rxCW{1}, softBuffer); - - % Add errors to previous error counts - nErrors_mat(k,rvIndex) = nErrors_mat(k,rvIndex)+blkCRCerr; - end - - % Same with srsLTE - [okSRSLTE, data, pdschRx, pdschSymbols, cws] = srslte_pdsch(enbConfig, pdschConfig, ... - transportBlkSize, subframe, ones(size(subframe{1})), 0); - - nErrors_srs(k,rvIndex) = nErrors_srs(k,rvIndex)+~okSRSLTE; - end - fprintf('SNR=%.1f dB, BLER_mat=%f, BLER_srs=%f\n',SNR(k),nErrors_mat(k,rvIndex)/Nblocks, nErrors_srs(k,rvIndex)/Nblocks); -end - -PDSCHBLER_MAT = nErrors_mat./Nblocks; -PDSCHBLER_MAT(PDSCHBLER_MAT==0)=10^-10; - -PDSCHBLER_SRS = nErrors_srs./Nblocks; -PDSCHBLER_SRS(PDSCHBLER_SRS==0)=10^-10; - -if (Nblocks == 1 && length(SNR) == 1) -else - semilogy(SNR,PDSCHBLER_MAT,SNR,PDSCHBLER_SRS) - grid on - xlabel('Eb/No (dB)') - ylabel('BLER') - leg=[]; - for rvIndex = 1:length(rvValues) - leg=strvcat(leg,sprintf('Matlab rv=%d',rvValues(rvIndex))); - end - for rvIndex = 1:length(rvValues) - leg=strvcat(leg,sprintf('srsLTE rv=%d',rvValues(rvIndex))); - end - legend(leg); - axis([min(SNR) max(SNR) 10^-4 1]) -end diff --git a/matlab/tests/pdsch_decode_signal.m b/matlab/tests/pdsch_decode_signal.m deleted file mode 100644 index 72b733eb5..000000000 --- a/matlab/tests/pdsch_decode_signal.m +++ /dev/null @@ -1,76 +0,0 @@ -enb=struct('NCellID',313,'NDLRB',75,'NSubframe',5,'CFI',1,'CyclicPrefix','Normal','CellRefP',2,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD'); - -RNTI=65535; - -addpath('../../build/srslte/lib/phch/test') - -cec.PilotAverage = 'UserDefined'; % Type of pilot averaging -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,x); -subframe_rx=reshape(x,[],14); -[hest,nest] = lteDLChannelEstimate(enb, cec, subframe_rx); - -% Search PDCCH -pdcchIndices = ltePDCCHIndices(enb); -[pdcchRx, pdcchHest] = lteExtractResources(pdcchIndices, subframe_rx, hest); -[dciBits, pdcchSymbols] = ltePDCCHDecode(enb, pdcchRx, pdcchHest, nest); -pdcch = struct('RNTI', RNTI); -[dci, dcidecBits] = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI - -if ~isempty(dci) - - dci = dci{1}; - disp(dci); - - % Get the PDSCH configuration from the DCI - [pdsch, trblklen] = hPDSCHConfiguration(enb, dci, pdcch.RNTI); - pdsch.NTurboDecIts = 16; - %pdsch.Modulation = {'64QAM'}; - pdsch.RV=0; - fprintf('PDSCH settings after DCI decoding:\n'); - disp(pdsch); - - fprintf('Decoding PDSCH...\n\n'); - % Get PDSCH indices - [pdschIndices,pdschIndicesInfo] = ltePDSCHIndices(enb, pdsch, pdsch.PRBSet); - [pdschRx, pdschHest] = lteExtractResources(pdschIndices, subframe_rx, hest); - % Decode PDSCH - [dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, 0); - [sib1, crc] = lteDLSCHDecode(enb, pdsch, trblklen, dlschBits); - - - [dec2, data, pdschRx2, pdschSymbols2, e_bits, ce] = srslte_pdsch(enb, pdsch, ... - trblklen, ... - subframe_rx); - - - subplot(2,1,1) - scatter(real(pdschSymbols{1}),imag(pdschSymbols{1})) - subplot(2,1,2) - scatter(real(pdschSymbols2),imag(pdschSymbols2)) - - if crc == 0 - fprintf('PDSCH Matlab OK.\n\n'); - else - fprintf('PDSCH Matlab ERROR.\n\n'); - end - - if dec2 == 1 - fprintf('PDSCH srsLTE OK.\n\n'); - else - fprintf('PDSCH srsLTE ERROR.\n\n'); - end - - else - % indicate that DCI decoding failed - fprintf('DCI decoding failed.\n\n'); -end - -%indices=indices+1; -%plot(t,indices(t),t,pdschIndices(t)) - \ No newline at end of file diff --git a/matlab/tests/pdsch_equal.m b/matlab/tests/pdsch_equal.m deleted file mode 100644 index 1ad1d86dc..000000000 --- a/matlab/tests/pdsch_equal.m +++ /dev/null @@ -1,166 +0,0 @@ - -%% PDSCH decoding based on RMC channels - -%% Cell-Wide Settings -% A structure |enbConfig| is used to configure the eNodeB. -%clear12 - -recordedSignal=[]; - -Npackets = 1; -SNR_values = 56;%linspace(2,6,10); - -Lp=12; -N=256; -K=180; -rstart=(N-K)/2; -P=K/6; -Rhphp=zeros(P,P); -Rhhp=zeros(K,P); -Rhh=zeros(K,K); - -t=0:Lp-1; -alfa=log(2*Lp)/Lp; -c_l=exp(-t*alfa); -c_l=c_l/sum(c_l); -C_l=diag(1./c_l); -prows=rstart+(1:6:K); - -F=dftmtx(N); -F_p=F(prows,1:Lp); -F_l=F((rstart+1):(K+rstart),1:Lp); -Wi=(F_p'*F_p+C_l*0.01)^(-1); -W2=F_l*Wi*F_p'; -w2=reshape(transpose(W2),1,[]); - - -%% Choose RMC -[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.5',[1;0;0;1]); -waveform = sum(waveform,2); - -if ~isempty(recordedSignal) - 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'; - rmccFgOut.PDSCH.NLayers = 1; - rmccFgOut.PDSCH.NTurboDecIts = 5; - rmccFgOut.PDSCH.Modulation = {'64QAM'}; - trblklen=75376; - rmccFgOut.PDSCH.TrBlkSizes = trblklen*ones(10,1); - rmccFgOut.PDSCH.RV = 0; -end - -flen=rmccFgOut.SamplingRate/1000; - -Nsf = 2; - -%% Setup Fading channel model -cfg.Seed = 0; % Random channel seed -cfg.NRxAnts = 1; % 1 receive antenna -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 -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 -cfg.SamplingRate = rmccFgOut.SamplingRate; - -% Setup channel equalizer -cec.PilotAverage = 'UserDefined'; % Type of pilot averaging -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 - -addpath('../../build/srslte/lib/phch/test') - -decoded = zeros(size(SNR_values)); -decoded_srslte = zeros(size(SNR_values)); - -for snr_idx=1:length(SNR_values) - SNRdB = SNR_values(snr_idx); - SNR = 10^(SNRdB/10); % Linear SNR - N0 = 1/(sqrt(2.0*rmccFgOut.CellRefP*double(rmccFgOut.Nfft))*SNR); - - Rhphp=zeros(30,30); - Rhhp=zeros(180,30); - - for i=1:Npackets - - if isempty(recordedSignal) - - %% Fading - [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 - rxWaveform = rxWaveform + noise; - else - rxWaveform = recordedSignal; - end - - %% Demodulate - frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform); - - for sf_idx=0:Nsf-1 - % sf_idx=9; - subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14); - rmccFgOut.NSubframe=sf_idx; - rmccFgOut.TotSubframes=1; - - % Perform channel estimation - [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx); - - [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); - [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... - rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1),cws); - - decoded(snr_idx) = decoded(snr_idx) + ~blkcrc; - - - %% Same with srsLTE - if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0) - [dec2, data, pdschRx, pdschSymbols2, cws2, ce] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ... - rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ... - subframe_rx); - else - dec2 = 1; - end - if (~dec2) - fprintf('Error in sf=%d\n',sf_idx); - end - decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+dec2; - end - - if ~isempty(recordedSignal) - recordedSignal = recordedSignal(flen*10+1:end); - end - end - fprintf('SNR: %.1f. Decoded: %d-%d\n',SNRdB, decoded(snr_idx), decoded_srslte(snr_idx)) -end - -if (length(SNR_values)>1) - semilogy(SNR_values,1-decoded/Npackets/(Nsf),'bo-',... - SNR_values,1-decoded_srslte/Npackets/(Nsf), 'ro-') - grid on; - legend('Matlab','srsLTE') - xlabel('SNR (dB)') - ylabel('BLER') - axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1]) -else - subplot(2,1,1) - scatter(real(pdschSymbols2),imag(pdschSymbols2)) - %plot(real(hest)) - subplot(2,1,2) - %plot(1:180,angle(ce(1:180)),1:180,angle(hest(:,1))) - plot(abs(ce-hest(:))) - fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte); -end - diff --git a/matlab/tests/pdsch_resalloc.m b/matlab/tests/pdsch_resalloc.m deleted file mode 100644 index d274c0c99..000000000 --- a/matlab/tests/pdsch_resalloc.m +++ /dev/null @@ -1,76 +0,0 @@ -filename='../../debug/dist_ra.dat'; - -enb.NDLRB = 50; -enb.CyclicPrefix = 'Normal'; -enb.PHICHDuration = 'Normal'; -enb.CFI = 2; -enb.Ng = 'Sixth'; -enb.CellRefP = 1; -enb.NCellID = 196; -enb.NSubframe = 5; -enb.NTotalSubframes=1; -enb.DuplexMode = 'FDD'; - -dci.NDLRB = enb.NDLRB; -dci.DCIFormat = 'SRSLTE_DCI_FORMAT1C'; -dci.AllocationType=1; -%dci.Allocation.Bitmap='01111000011110000'; -%dci.Allocation.Subset=3; -dci.Allocation.RIV = 33; -dci.Allocation.Gap = 0; -dci.ModCoding=6; -dci.RV=0; -dci.DuplexMode = enb.DuplexMode; -dci.NTxAnts = enb.CellRefP; -pdcch.RNTI = 65535; -pdcch.PDCCHFormat = 3; - -pdsch.Modulation='QPSK'; -pdsch.RNTI=pdcch.RNTI; -if (enb.CellRefP == 1) - pdsch.TxScheme='Port0'; -else - pdsch.TxScheme='TxDiversity'; -end -pdsch.NLayers=enb.CellRefP; -pdsch.trblklen=176; -pdsch.RV=dci.RV; - -% Begin frame generation -subframe = lteDLResourceGrid(enb); - -%%% Create Reference Signals -rsAnt = lteCellRS(enb); -indAnt = lteCellRSIndices(enb); -subframe(indAnt) = rsAnt; - -%%% Create PDCCH -[dciMessage,dciMessageBits] = lteDCI(enb,dci); -codedDciBits = lteDCIEncode(pdcch,dciMessageBits); -pdcchInfo = ltePDCCHInfo(enb); -pdcchBits = -1*ones(1,pdcchInfo.MTot); -candidates = ltePDCCHSpace(enb,pdcch,{'bits','1based'}); -pdcchBits (candidates(1,1):candidates(1,2)) = codedDciBits; -pdcchSymbols = ltePDCCH(enb, pdcchBits); -pdcchIndices = ltePDCCHIndices(enb,{'1based'}); -subframe(pdcchIndices) = pdcchSymbols; - -% Create PDSCH -pdsch.prbset = lteDCIResourceAllocation(enb,dci); - -[pdschIndices,pdschInfo] = ltePDSCHIndices(enb,pdsch,pdsch.prbset); - -dlschTransportBlk=randi([0 1],pdsch.trblklen,1); -pdschcodeword = lteDLSCH(enb,pdsch,pdschInfo.G,dlschTransportBlk); -%crced = lteCRCEncode(dlschTransportBlk, '24A'); -%encoded = lteTurboEncode(crced); -%pdschcodeword2 = lteRateMatchTurbo(encoded,pdschInfo.G,pdsch.RV); -pdschSymbols = ltePDSCH(enb,pdsch,pdschcodeword); - -subframe(pdschIndices) = pdschSymbols; - -txwaveform = lteOFDMModulate(enb,subframe); - -write_complex(filename,sum(txwaveform,2)); -fprintf('Written signal to %s\n',filename); - diff --git a/matlab/tests/pdsch_test_verify_unrm.m b/matlab/tests/pdsch_test_verify_unrm.m deleted file mode 100644 index 3f32c7466..000000000 --- a/matlab/tests/pdsch_test_verify_unrm.m +++ /dev/null @@ -1,39 +0,0 @@ -clear - -% Run pdsch_test with -vv to generate files. Then run this script to check -% rate matching and demodulation -% Need to change soft demodulator output to +-10 - -enbConfig=struct('NCellID',0,'CyclicPrefix','Normal','CellRefP',1,'DuplexMode','FDD'); -pdschConfig=struct('Modulation','64QAM','RV',3,'TxScheme','Port0','NTurboDecIts',10,... - 'NSoftbits',0,'DuplexMode','FDD'); - -addpath('../../build/srslte/lib/phch/test') - -cbidx_v=0:12; -e_bits=90000; - -trblkin=read_uchar('../../build/data_in'); -[mat, info]=lteDLSCH(enbConfig,pdschConfig,e_bits,trblkin); -mat(mat==0)=-1; -mat=mat*10; -rec = lteRateRecoverTurbo(mat,length(trblkin),pdschConfig.RV,pdschConfig); - -rec2=cell(size(rec)); -srs=cell(size(rec)); -for cbidx=cbidx_v - rec2{cbidx+1} = reshape(reshape(rec{cbidx+1},[],3)',[],1); - srs{cbidx+1}=read_int16(sprintf('../../build/rmout_%d.dat',cbidx)); -end - - -subplot(2,1,1) -plot(abs(double(reshape(cell2mat(srs),1,[]))-double(reshape(cell2mat(rec2),1,[])))); - -subplot(2,1,2) -llr=read_int16('../../build/llr.dat'); -plot(abs(double(mat)-double(llr))) - -[data, crc,state] = lteDLSCHDecode(enbConfig, pdschConfig, length(trblkin), mat); -disp(crc) - diff --git a/matlab/tests/phich_bler.m b/matlab/tests/phich_bler.m deleted file mode 100644 index 723c8b572..000000000 --- a/matlab/tests/phich_bler.m +++ /dev/null @@ -1,132 +0,0 @@ -clear - -%% PHICH encoding/decoding - -%% Setup simulation -Npackets = 80; -SNR_values = linspace(-6,0,6); -enable_fading=false; -addpath('../../debug/srslte/lib/phch/test') - - -%% Cell-Wide Settings -enbConfig.NDLRB = 50; % No of Downlink RBs in total BW -enbConfig.CyclicPrefix = 'Normal'; % CP length -enbConfig.Ng = 'One'; % HICH groups -enbConfig.CellRefP = 1; % 1-antenna ports -enbConfig.NCellID = 36; % Physical layer cell identity -enbConfig.NSubframe = 5; % Subframe number 0 -enbConfig.DuplexMode = 'FDD'; % Frame structure -enbConfig.PHICHDuration = 'Normal'; - -%% Define HI resource -hi_res = [1 1]; -ack_bit = 1; - -%% Setup Fading channel model -if (enable_fading) - cfg.Seed = 8; % Random channel seed - cfg.NRxAnts = 1; % 1 receive antenna - 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 - 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 -end - -% Setup channel equalizer -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 = 'Causal'; % Interpolation window type -cec.InterpWinSize = 1; % Interpolation window size - -%% Generate TX subframe -subframe_tx = lteDLResourceGrid(enbConfig); - -%% Genearte PHICH signal -hi_sym_tx = ltePHICH(enbConfig, [hi_res ack_bit]); -hi_indices = ltePHICHIndices(enbConfig); -subframe_tx(hi_indices)=hi_sym_tx; - -%% Add references to subframe -cellRsSym = lteCellRS(enbConfig); -cellRsInd = lteCellRSIndices(enbConfig); -subframe_tx(cellRsInd) = cellRsSym; - -%% Modulate signal -[txWaveform, info] = lteOFDMModulate(enbConfig,subframe_tx); -cfg.SamplingRate = info.SamplingRate; - -%% Start simulation -decoded = zeros(size(SNR_values)); -decoded_srslte = zeros(size(SNR_values)); - -for snr_idx=1:length(SNR_values) - SNRdB = SNR_values(snr_idx); - SNR = 10^(SNRdB/10); % Linear SNR - N0 = 1/(sqrt(2.0*enbConfig.CellRefP*double(info.Nfft))*SNR); - for i=1:Npackets - - %% Fading - rxWaveform = sum(txWaveform,2); - if (enable_fading) - rxWaveform = lteFadingChannel(cfg,rxWaveform); - end - - %% Noise Addition - noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); - rxWaveform = rxWaveform + noise; - - %% Demodulate - subframe_rx = lteOFDMDemodulate(enbConfig, rxWaveform); - - %% Channel estimation - if (enable_fading) - [hest, nest] = lteDLChannelEstimate(enbConfig, cec, subframe_rx); - else - hest=ones(size(subframe_rx)); - nest=0; - end - - %% Extract resources - phichSymbolsRx = subframe_rx(hi_indices); - phichSymbolsHest = hest(hi_indices); - - %% PHICH decoding - [hi, hi_symbols] = ltePHICHDecode(enbConfig,hi_res, phichSymbolsRx, phichSymbolsHest, nest); - decoded(snr_idx) = decoded(snr_idx) + (hi == ack_bit); - - %% Same with srsLTE - [hi_srslte, hi_symbols_srslte] = srslte_phich(enbConfig, hi_res, subframe_rx, hest, nest); - decoded_srslte(snr_idx) = decoded_srslte(snr_idx) + (hi_srslte == ack_bit); - end - fprintf('SNR: %.1f\n',SNRdB) -end - -if (Npackets>1) - semilogy(SNR_values,1-decoded/Npackets,'bo-',... - SNR_values,1-decoded_srslte/Npackets, 'ro-') - grid on - legend('Matlab','srsLTE') - xlabel('SNR (dB)') - ylabel('BLER') - axis([min(SNR_values) max(SNR_values) 1/Npackets/10 1]) -else - - scatter(real(hi_symbols),imag(hi_symbols)) - hold on - scatter(real(hi_symbols_srslte),imag(hi_symbols_srslte)) - hold off - grid on; - axis([-2 2 -2 2]) - disp(hi) - disp(hi_srslte) - -end - diff --git a/matlab/tests/prach_detect_test.m b/matlab/tests/prach_detect_test.m deleted file mode 100644 index 51bda6c21..000000000 --- a/matlab/tests/prach_detect_test.m +++ /dev/null @@ -1,200 +0,0 @@ -%% PRACH Detection Conformance Test -%clear - -d=80;%linspace(4,14,6); -pDetection2 = zeros(2,length(d)); -for dd=1:length(d) -detect_factor=d(dd); - -numSubframes = 1; % Number of subframes frames to simulate at each SNR -SNRdB = 50;%linspace(-14,10,8); % SNR points to simulate -foffset = 0.0; % Frequency offset in Hertz -delay=0; -add_fading=false; - -addpath('../../build/srslte/lib/phch/test') - -%% UE Configuration -% User Equipment (UE) settings are specified in the structure |ue|. - -ue.NULRB = 15; % 6 Resource Blocks -ue.DuplexMode = 'FDD'; % Frequency Division Duplexing (FDD) -ue.CyclicPrefixUL = 'Normal'; % Normal cyclic prefix length -ue.NTxAnts = 1; % Number of transmission antennas - -%% PRACH Configuration - -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.FreqOffset = 2; % Default frequency location -info = ltePRACHInfo(ue, prach); % PRACH information - -%% Propagation Channel Configuration -% Configure the propagation channel model using a structure |chcfg| as per -% TS36.104, Table 8.4.2.1-1 [ <#9 1> ]. - -chcfg.NRxAnts = 1; % Number of receive antenna -chcfg.DelayProfile = 'ETU'; % Delay profile -chcfg.DopplerFreq = 70.0; % Doppler frequency -chcfg.MIMOCorrelation = 'Low'; % MIMO correlation -chcfg.Seed = 1; % Channel seed -chcfg.NTerms = 16; % Oscillators used in fading model -chcfg.ModelType = 'GMEDS'; % Rayleigh fading model type -chcfg.InitPhase = 'Random'; % Random initial phases -chcfg.NormalizePathGains = 'On'; % Normalize delay profile power -chcfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas -chcfg.SamplingRate = info.SamplingRate; % Sampling rate - -%% Loop for SNR Values - -% Initialize the random number generator stream -rng('default'); - -% Initialize variables storing probability of detection at each SNR -pDetection = zeros(2,length(SNRdB)); - -for nSNR = 1:length(SNRdB) - - % Scale noise to ensure the desired SNR after SC-FDMA demodulation - ulinfo = lteSCFDMAInfo(ue); - SNR = 10^(SNRdB(nSNR)/20); - N = 1/(SNR*sqrt(double(ulinfo.Nfft)))/sqrt(2.0); - - % Detected preamble count - detectedCount = 0; - detectedCount_srs = 0; - - % Loop for each subframe - for nsf = 1:numSubframes - - 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.PreambleIdx = 1;%randi(64,1,1)-1; % Preamble index: TS36.141, Table A.6-1 - prach.TimingOffset = 0; - info = ltePRACHInfo(ue, prach); % PRACH information - - % PRACH transmission - ue.NSubframe = mod(nsf-1, 10); - ue.NFrame = fix((nsf-1)/10); - - % Set PRACH timing offset in us as per TS36.141, Figure 8.4.1.4.2-2 - %prach.TimingOffset = info.BaseOffset + ue.NSubframe/10.0; - prach.TimingOffset = 0; - - % Generate transmit wave - [txwave,prachinfo] = ltePRACH(ue, prach); - - % Channel modeling - if (add_fading) - chcfg.InitTime = (nsf-1)/1000; - [rxwave, fadinginfo] = lteFadingChannel(chcfg, ... - [txwave; zeros(25, 1)]); - else - rxwave = txwave; - end - % Add noise - %noise = N*complex(randn(size(rxwave)), randn(size(rxwave))); - %rxwave = rxwave + noise; - % Remove the implementation delay of the channel modeling - if (add_fading) - rxwave = rxwave((fadinginfo.ChannelFilterDelay + 1):end, :); - end - - rxwave=lteFrequencyCorrect(ue, x, -20); - % rxwave=[zeros(delay,1); txwave(1:end-delay)]; - - % Apply frequency offset - t = ((0:size(rxwave, 1)-1)/chcfg.SamplingRate).'; - rxwave = rxwave .* repmat(exp(1i*2*pi*foffset*t), ... - 1, size(rxwave, 2)); - - - % PRACH detection for all cell preamble indices - [detected, offsets] = ltePRACHDetect(ue, prach, rxwave, (0:63).'); - - [detected_srs, offsets_srs, corrout] = srslte_prach_detect(ue, prach, rxwave, detect_factor); - - disp(detected) - disp(detected_srs) - disp(offsets_srs*1e6) - - % Test for preamble detection - if (length(detected)==1) - - % Test for correct preamble detection - if (detected==prach.PreambleIdx) - - % Calculate timing estimation error. The true offset is - % PRACH offset plus channel delay - trueOffset = prach.TimingOffset/1e6 + 310e-9; - measuredOffset = offsets(1)/chcfg.SamplingRate; - timingerror = abs(measuredOffset-trueOffset); - - % Test for acceptable timing error - if (timingerror<=2.08e-6) - detectedCount = detectedCount + 1; % Detected preamble - else - disp('Timing error'); - end - else - disp('Detected incorrect preamble'); - end - else - disp('Detected multiple or zero preambles'); - end - - % Test for preamble detection - if (length(detected_srs)==1) - - % Test for correct preamble detection - if (detected_srs==prach.PreambleIdx) - - % Calculate timing estimation error. The true offset is - % PRACH offset plus channel delay - trueOffset = prach.TimingOffset/1e6 + 310e-9; - measuredOffset = offsets_srs(1); - timingerror = abs(measuredOffset-trueOffset); - - % Test for acceptable timing error - if (timingerror<=2.08e-6) - detectedCount_srs = detectedCount_srs + 1; % Detected preamble - else - disp('SRS: Timing error'); - end - else - disp('SRS: Detected incorrect preamble'); - end - else - fprintf('SRS: Detected %d preambles. D=%.1f, Seq=%3d, NCS=%2d, Idx=%2d\n', ... - length(detected_srs),detect_factor, prach.SeqIdx, prach.CyclicShiftIdx, prach.PreambleIdx); - end - - - end % of subframe loop - - % Compute final detection probability for this SNR - pDetection(1,nSNR) = detectedCount/numSubframes; - pDetection(2,nSNR) = detectedCount_srs/numSubframes; - -end % of SNR loop - -pDetection2(1,dd)=pDetection(1,1); -pDetection2(2,dd)=pDetection(2,1); -end -%% Analysis -if (length(SNRdB)>1) - plot(SNRdB, pDetection) - legend('Matlab','srsLTE') - grid on - xlabel('SNR (dB)') - ylabel('Pdet') -else - plot(d,pDetection2) - legend('Matlab','srsLTE') - grid on - xlabel('d') - ylabel('Pdet') - fprintf('Pdet=%.4f%%, Pdet_srs=%.4f%%\n',pDetection(1,nSNR),pDetection(2,nSNR)) -end - -plot(corrout) diff --git a/matlab/tests/prach_falsealarm_test.m b/matlab/tests/prach_falsealarm_test.m deleted file mode 100644 index 48ccc533b..000000000 --- a/matlab/tests/prach_falsealarm_test.m +++ /dev/null @@ -1,83 +0,0 @@ -%% PRACH False Alarm Probability Conformance Test -clear - -detect_factor=5; - -ue.NULRB = 6; % Number of resource blocks -ue.DuplexMode = 'FDD'; % FDD duplexing mode - -%% PRACH Configuration -prach.Format = 0; % Preamble format -prach.SeqIdx = 2; % Logical root sequence index -prach.CyclicShiftIdx = 1; % Cyclic shift configuration index -prach.HighSpeed = 0; % High speed flag -prach.FreqOffset = 0; % Use default frequency resource index -prach.PreambleIdx = []; % Empty since no preamble is transmitted - -%% Establish PRACH Generator Output Length for this Configuration -info = ltePRACHInfo(ue, prach); -nSamples = info.SamplingRate*info.TotSubframes*0.001; - -%% Loop for Detection in Each Subframe -numTrials = 2000; -falseCount = 0; % Initialize false detection counter -falseCount_srs = 0; % Initialize false detection counter -rng('default'); % Random number generator to default state - -runningP=zeros(1, numTrials); -runningP_srs=zeros(1, numTrials); -for nt = 1:numTrials - - % Create noise - noise = complex(randn(nSamples, 1), randn(nSamples, 1)); - - % Attempt detection for all cell preamble indices (0...63) - [detected,offset] = ltePRACHDetect(ue, prach, noise, 0:63); - [detected_srs] = srslte_prach_detect(ue, prach, noise, detect_factor); - - % Record false alarm - if (~isempty(detected)) - falseCount = falseCount+1; - end - - if (~isempty(detected_srs)) - falseCount_srs = falseCount_srs+1; - end - - % Calculate running false alarm probability - runningP(nt) = falseCount/nt*100; - runningP_srs(nt) = falseCount_srs/nt*100; - - % Plot information about false alarm (if applicable) - if (~isempty(detected)) - plot(nt,runningP(nt),'ro','LineWidth',2,'MarkerSize',7); - hold on; - text(nt,runningP(nt), sprintf(['Preamble index = %d' ... - ' \nTiming offset = %0.2f samples '],detected,offset), ... - 'HorizontalAlignment','right'); - end - - if (~isempty(detected_srs)) - plot(nt,runningP(nt),'mx','LineWidth',2,'MarkerSize',7); - hold on; - text(nt,runningP(nt), sprintf(['SRS index = %d' ... - ' \nTiming offset = %0.2f samples '],detected,offset), ... - 'HorizontalAlignment','right'); - end - -end - -%% Compute Final False Alarm Probability - -P = falseCount / numTrials; -P_srs = falseCount_srs / numTrials; -plot(1:numTrials,runningP,'b','LineWidth',2); -plot(1:numTrials,runningP_srs,'k','LineWidth',2); -hold off -axis([0 numTrials+1 -0.1 0.2]); -xlabel('Trials'); -ylabel('Running false alarm probability (%)'); -title('PRACH False Alarm Detection Probability'); - -fprintf('\nFalse alarm probability = %0.4f%% - %.04f%%\n',P*100, P_srs*100); - diff --git a/matlab/tests/prach_test.m b/matlab/tests/prach_test.m deleted file mode 100644 index 049fe1b2e..000000000 --- a/matlab/tests/prach_test.m +++ /dev/null @@ -1,51 +0,0 @@ -clear -ueConfig=struct('NULRB',6,'DuplexMode','FDD','CyclicPrefix','Normal'); -prachConfig=struct('Format',0,'SeqIdx',0,'PreambleIdx',0,'CyclicShiftIdx',0,'HighSpeed',0,'TimingOffset',0,'FreqIdx',0,'FreqOffset',8); - -addpath('../../build/srslte/lib/phch/test') - -NULRB=[100]; - -% FreqIdx, FreqOffset and TimeOffset need to be tested - -for n_rb=1:length(NULRB) - for format=0; - for seqIdx=7:17:237 - for preambleIdx=0:23:63 - for CyclicShift=1:3:15 - fprintf('RB: %d, format %d, seqIdx: %d, Cyc=%d Idx=%d\n',NULRB(n_rb),format,seqIdx, CyclicShift, preambleIdx); - %for hs=0:1 - hs=0; - ueConfig.NULRB=NULRB(n_rb); - prachConfig.Format=format; - prachConfig.SeqIdx=seqIdx; - prachConfig.PreambleIdx=preambleIdx; - prachConfig.CyclicShiftIdx=CyclicShift; - prachConfig.HighSpeed=hs; - prachConfig.FreqIdx=0; - prachConfig.FreqOffset=0; - lib=srslte_prach(ueConfig,prachConfig); - - [mat, info]=ltePRACH(ueConfig,prachConfig); - err=max(abs(mat-lib)); - if (err > 2*10^-3) - disp(err) - a=1:100; - plot(a,real(lib(a)),a,real(mat(a))) - error('Error!'); - end - %end - end - end - end - end -end - -% -% disp(info) - n=1:length(mat); -% plot(abs(double(mat)-double(lib))) -flib=fft(lib(199:end),1536); -fmat=fft(mat(199:end),1536); -n=1:1536; -plot(n,real(flib(n)),n,real(fmat(n))) diff --git a/matlab/tests/print_m.m b/matlab/tests/print_m.m deleted file mode 100644 index 0aa456902..000000000 --- a/matlab/tests/print_m.m +++ /dev/null @@ -1,9 +0,0 @@ -fprintf('static uint8_t M_basis_seq_pucch[20][13]={\n'); -for i=1:20 - fprintf('\t\t{'); - for j=1:12 - fprintf('%d, ',y(i,j)); - end - fprintf('%d},\n',y(i,13)); -end -fprintf('\t\t};\n'); diff --git a/matlab/tests/pucch_bler.m b/matlab/tests/pucch_bler.m deleted file mode 100644 index 4bac59411..000000000 --- a/matlab/tests/pucch_bler.m +++ /dev/null @@ -1,133 +0,0 @@ -clear -ueConfig=struct('NCellID',1,'RNTI',11,'NULRB',25,'NSubframe',0,'CyclicPrefixUL','Normal','NTxAnts',1,'Hopping','Off'); -pucchConfig=struct('NLayers',1,'OrthCover','Off','Shortened',0,'ResourceSize',2); - -format_str={'1','1a'}; - -threshold=[0.5 0]; -formats=[1]; -pucchConfig.ResourceIdx= 0; -pucchConfig.DeltaShift = 1; -pucchConfig.CyclicShifts = 0; -ueConfig.NSubframe=0; - -enable_fading=false; - -SNR_values=-5;%linspace(-8,0,8); -Nreal=50; - -% Setup Fading channel model -cfg.Seed = 8; % Random channel seed -cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'EVA'; % EVA delay spread -cfg.DopplerFreq = 5; % 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 - -% Setup matlab channel equalizer -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 = 'Causal'; % Interpolation window type -cec.InterpWinSize = 1; % Interpolation window size - - -addpath('../../debug/srslte/lib/phch/test') - - -ber=zeros(length(formats),length(SNR_values)); -ber2=zeros(length(formats),length(SNR_values)); -for f=1:length(formats) - nb=formats(f); - for s=1:length(SNR_values) - SNRdB=SNR_values(s); - SNR = 10^(SNRdB/10); % Linear SNR - - errors = 0; - errors2 = 0; - for n=1:Nreal - bits=randi(2,nb-1,1)-1; - - [sym_mat, info]=ltePUCCH1(ueConfig,pucchConfig,bits); - idx=ltePUCCH1Indices(ueConfig,pucchConfig); - [dmrs_mat, info_dmrs]=ltePUCCH1DRS(ueConfig,pucchConfig); - idx_dmrs=ltePUCCH1DRSIndices(ueConfig,pucchConfig); - - % Resource mapping - subframe_tx = lteULResourceGrid(ueConfig); - subframe_tx(idx)=sym_mat; - subframe_tx(idx_dmrs)=dmrs_mat; - - [txWaveform, info] = lteSCFDMAModulate(ueConfig,subframe_tx); - cfg.SamplingRate = info.SamplingRate; - - % Fading - if (enable_fading) - rxWaveform = lteFadingChannel(cfg,txWaveform); - else - rxWaveform = txWaveform; - end - - % Noise Addition - N0 = 1/(sqrt(2.0*double(info.Nfft))*SNR); - noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise - rxWaveform = rxWaveform + noise; - - % Demodulate - subframe_rx = lteSCFDMADemodulate(ueConfig, rxWaveform); - - % Perform channel estimation - [hest, nest] = lteULChannelEstimatePUCCH1(ueConfig, pucchConfig, cec, subframe_rx); - - % Equalize - pucchSymbols = lteEqualizeMMSE(subframe_rx(idx), hest(idx), nest); - - % Decoding - bits_rx = ltePUCCH1Decode(ueConfig, pucchConfig, length(bits), pucchSymbols); - - % Check errors - a=size(bits_rx); - if (a(2) ~= 1) - errors = errors + 1; - elseif (formats(f) == 2) - if (a(1) ~= 1) - errors = errors + 1; - elseif (bits_rx(1) ~= bits(1)) - errors = errors + 1; - end - end - - % Decoding srsLTE - [bits_rx,z,ce]= srslte_pucch(ueConfig, pucchConfig, length(bits), subframe_rx, threshold); - - % Check errors - a=size(bits_rx); - if (a(2) ~= 1) - errors2 = errors2 + 1; - elseif (formats(f) == 2) - if (a(1) ~= 1) - errors2 = errors2 + 1; - elseif (bits_rx(1) ~= bits(1)) - errors2 = errors2 + 1; - end - end - - end - ber(f,s)=errors/Nreal; - ber2(f,s)=errors2/Nreal; - fprintf('Format %s, SNR=%.1f dB, errors=%d, errors2=%d\n', format_str{formats(f)},SNRdB,errors,errors2); - end -end - -semilogy(SNR_values,ber,SNR_values,ber2) -xlabel('SNR (dB)') -ylabel('BER') -grid on -legend(format_str(formats)) - diff --git a/matlab/tests/pucch_test.m b/matlab/tests/pucch_test.m deleted file mode 100644 index a9e2bc4e6..000000000 --- a/matlab/tests/pucch_test.m +++ /dev/null @@ -1,79 +0,0 @@ -clear -ueConfig=struct('NCellID',1,'RNTI',11,'NULRB',25,'NSubframe',0,'CyclicPrefixUL','Normal','NTxAnts',1,'Hopping','Off'); -pucchConfig=struct('NLayers',1,'OrthCover','Off','Shortened',0,'ResourceSize',2); - -addpath('../../build/srslte/lib/phch/test') - -format_str={'1','1a','1b','2','2a','2b'}; - -k=1; -for f=0:5 - for n=0:7:130 - for d=1:3 - for ncs=0:d:7 - for nsf=0:9 - pucchConfig.ResourceIdx= n; - pucchConfig.DeltaShift = d; - pucchConfig.CyclicShifts = ncs; - ueConfig.NSubframe=nsf; - if (f >= 3) - nb=20; - nb_ack=f-3; - else - nb=f; - nb_ack=0; - end - bits=mod(0:nb-1,2); - bits_ack=randi(2,nb_ack,1)-1; - fprintf('Testing PUCCH Format: %s, n_pucch=%d, DeltaShift=%d, CyclicShift=%d, Nsf=%d\n',format_str{f+1},n,d,ncs,nsf); - if (f >= 3) - [sym_mat, info]=ltePUCCH2(ueConfig,pucchConfig,bits); - idx=ltePUCCH2Indices(ueConfig,pucchConfig); - [dmrs_mat, info_dmrs]=ltePUCCH2DRS(ueConfig,pucchConfig,bits_ack); - idx_dmrs=ltePUCCH2DRSIndices(ueConfig,pucchConfig); - else - [sym_mat, info]=ltePUCCH1(ueConfig,pucchConfig,bits); - idx=ltePUCCH1Indices(ueConfig,pucchConfig); - [dmrs_mat, info_dmrs]=ltePUCCH1DRS(ueConfig,pucchConfig); - idx_dmrs=ltePUCCH1DRSIndices(ueConfig,pucchConfig); - end - subframe_mat = lteULResourceGrid(ueConfig); - subframe_mat(idx)=sym_mat; - subframe_mat(idx_dmrs)=dmrs_mat; - - [sym, dmrs, subframe]=srslte_pucch_encode(ueConfig,pucchConfig,[bits; bits_ack]); - - error_sym=max(abs(sym-sym_mat)); - error_dmrs=max(abs(dmrs-dmrs_mat)); - error_sf=max(abs(subframe_mat(:)-subframe)); - k=k+1; - - if (error_sym > 1e-5) - disp(info) - plot(1:length(sym),sym,1:length(sym_mat),sym_mat) - legend('srsLTE','Matlab') - error('Error in symbols'); - end - if (error_dmrs > 1e-5) - disp(info_dmrs) - plot(angle(dmrs)-angle(dmrs_mat)) - error('Error in DMRS'); - end - if (error_sf > 1e-5) - disp(info) - plot(abs(subframe-subframe_mat(:))) - error('Error in subframe'); - end - end - end - end - end -end - -if (k == 2) - disp(info) - disp(error_sym) - disp(error_sf) - n=1:length(sym); - plot(n,real(sym(n)),n,real(sym_mat(n))) -end diff --git a/matlab/tests/pusch_bler.m b/matlab/tests/pusch_bler.m deleted file mode 100644 index 5286434b0..000000000 --- a/matlab/tests/pusch_bler.m +++ /dev/null @@ -1,188 +0,0 @@ -%% Plot PUSCH BLER vs SNR for PUSCH without equalization -clear -transportBlkSize=904; -modulation='64QAM'; -rvValues=0; -SNR=linspace(-5,0.0,8); -Nblocks=30; - -addpath('../../build/srslte/lib/phch/test') - -% Subframe configuration -ueConfig.NCellID = 100; -ueConfig.CyclicPrefixUL = 'Normal'; -ueConfig.NSubframe = 0; -ueConfig.NULRB = 6; -ueConfig.Shortened = 0; -ueConfig.NTxAnts = 1; -ueConfig.RNTI = 1; -ueConfig.DuplexMode='FDD'; -ueConfig.Hopping = 'Off'; -ueConfig.SeqGroup = 0; -ueConfig.CyclicShift = 0; -ueConfig.Shortened = 0; - -% Transmission mode configuration for PUSCH -puschConfig.NLayers = 1; -puschConfig.TxScheme = 'Port0'; -puschConfig.Modulation = modulation; -puschConfig.NTurboDecIts = 5; -puschConfig.PRBSet = (0:ueConfig.NULRB-1)'; -puschConfig.NBundled = 0; - -% Configure control channels -puschConfig.OCQI = 0; -puschConfig.ORI = 0; -puschConfig.OACK = 0; - -puschConfig.BetaCQI = 2; -puschConfig.BetaRI = 3; -puschConfig.BetaACK = 1; - -info=lteULSCHInfo(ueConfig,puschConfig,transportBlkSize,puschConfig.OCQI,puschConfig.ORI,puschConfig.OACK); -puschConfig.QdACK=info.QdACK; -puschConfig.QdRI=info.QdRI; -puschConfig.QdCQI=info.QdCQI; - -switch (modulation) - case 'QPSK' - bitsPerSym = 2; - case '16QAM' - bitsPerSym = 4; - case '64QAM' - bitsPerSym = 6; -end - -noiseVarfactor = sqrt(2*bitsPerSym); -snr = 10.^(SNR/10); - -nErrors_mat = zeros(length(SNR),length(rvValues)); -nErrorsCtrl_mat = zeros(length(SNR),3); -nErrors_srs = zeros(length(SNR),length(rvValues)); -nErrorsCtrl_srs = zeros(length(SNR),3); - -for k = 1:length(SNR); - subframe=cell(length(rvValues)); - puschIdx=ltePUSCHIndices(ueConfig,puschConfig); - for i=1:length(rvValues) - subframe{i} = lteULResourceGrid(ueConfig); - end - blkCounter = 0; - for l = 1:Nblocks; - % UL-SCH data bits - ulschBits = randi([0 1],transportBlkSize,1); - softBuffer = {}; - - % Control bits - cqi = randi([0 1], puschConfig.OCQI,1); - ri = randi([0 1], puschConfig.ORI,1); - ack = randi([0 1], puschConfig.OACK,1); - - for rvIndex = 1:length(rvValues) - % ULSCH transport channel - puschConfig.RV = rvValues(rvIndex); - puschPayload = lteULSCH(ueConfig, puschConfig, ulschBits, cqi, ri, ack); - - % PUSCH modulated symbols - puschSymbols = ltePUSCH(ueConfig, puschConfig, puschPayload); - puschSize = size(puschSymbols); - - % Addition of noise - noise = (1/noiseVarfactor)*sqrt(1/snr(k))*complex(randn(puschSize),randn(puschSize)); - noisySymbols = puschSymbols + noise; - - subframe{rvIndex}(puschIdx)=noisySymbols; - - % PUSCH Rx-side - [rxCW, puschSymbolsRx] = ltePUSCHDecode(ueConfig, puschConfig, noisySymbols); - if (iscell(rxCW)) - rxCW_=rxCW{1}; - else - rxCW_=rxCW; - end - - % UL-SCH turbo decoding - [rxBits, blkCRCerr, softBuffer,ccqi,cri,cack] = lteULSCHDecode2(ueConfig, puschConfig, ... - transportBlkSize, rxCW_, softBuffer); - - % Add errors to previous error counts - nErrors_mat(k,rvIndex) = nErrors_mat(k,rvIndex)+blkCRCerr; - - if (rvIndex==1) - ack_rx=lteACKDecode(puschConfig,cack); - ri_rx=lteRIDecode(puschConfig,cri); - cqi_rx=lteCQIDecode(puschConfig,ccqi); - - nErrorsCtrl_mat(k,1) = nErrorsCtrl_mat(k,1)+(sum(ack_rx~=ack)>0); - nErrorsCtrl_mat(k,2) = nErrorsCtrl_mat(k,2)+(sum(ri_rx~=ri)>0); - nErrorsCtrl_mat(k,3) = nErrorsCtrl_mat(k,3)+(sum(cqi_rx~=cqi)>0); - end - end - - % Same with srsLTE - [okSRSLTE, cqi_rx_srs, ri_rx_srs, ack_rx_srs] = srslte_puscht(ueConfig, puschConfig, ... - transportBlkSize, subframe, ones(size(subframe{1})), 0); - - nErrors_srs(k,rvIndex) = nErrors_srs(k,rvIndex)+~okSRSLTE; - - if (rvIndex==1) - nErrorsCtrl_srs(k,1) = nErrorsCtrl_srs(k,1)+(sum(ack_rx_srs~=ack)>0); - nErrorsCtrl_srs(k,2) = nErrorsCtrl_srs(k,2)+(sum(ri_rx_srs~=ri)>0); - nErrorsCtrl_srs(k,3) = nErrorsCtrl_srs(k,3)+(sum(cqi_rx_srs~=cqi)>0); - end - end - fprintf('SNR=%.1f dB, BLER_mat=%.2f, BLER_srs=%.2f, BLER_ack=%.2f/%.2f, BLER_ri=%.2f/%.2f, BLER_cqi=%.2f/%.2f\n',... - SNR(k),nErrors_mat(k,rvIndex)/Nblocks, nErrors_srs(k,rvIndex)/Nblocks, ... - nErrorsCtrl_mat(k,1)/Nblocks, nErrorsCtrl_srs(k,1)/Nblocks, ... - nErrorsCtrl_mat(k,3)/Nblocks, nErrorsCtrl_srs(k,2)/Nblocks, ... - nErrorsCtrl_mat(k,2)/Nblocks, nErrorsCtrl_srs(k,3)/Nblocks); -end - -puschBLER_mat = nErrors_mat./Nblocks; -puschBLER_mat(puschBLER_mat==0)=10^-10; - -puschBLER_srs = nErrors_srs./Nblocks; -puschBLER_srs(puschBLER_srs==0)=10^-10; - - -puschCtrlBLER_mat = nErrorsCtrl_mat./Nblocks; -puschCtrlBLER_mat(puschCtrlBLER_mat==0)=10^-10; - -puschCtrlBLER_srs = nErrorsCtrl_srs./Nblocks; -puschCtrlBLER_srs(puschCtrlBLER_srs==0)=10^-10; - -if (Nblocks == 1 && length(SNR) == 1) -else - - ctrlplot=1; - if (puschConfig.OCQI+puschConfig.ORI+puschConfig.OACK>0) - ctrlplot=2; - end - - subplot(ctrlplot,1,1) - semilogy(SNR,puschBLER_mat,SNR,puschBLER_srs); - grid on - xlabel('Eb/No (dB)') - ylabel('BLER') - leg=[]; - for rvIndex = 1:length(rvValues) - leg=strvcat(leg,sprintf('Matlab rv=%d',rvValues(rvIndex))); - end - for rvIndex = 1:length(rvValues) - leg=strvcat(leg,sprintf('srsLTE rv=%d',rvValues(rvIndex))); - end - axis([min(SNR) max(SNR) 10^-4 1]) - - if (ctrlplot==2) - subplot(2,1,2) - semilogy(SNR,puschCtrlBLER_mat,SNR,puschCtrlBLER_srs) - grid on - xlabel('Eb/No (dB)') - ylabel('BLER') - leg=[]; - leg=strvcat(leg,'Matlab ACK','Matlab RI', 'Matlab CQI'); - leg=strvcat(leg,'srsLTE ACK','srsLTE RI', 'srsLTE CQI'); - legend(leg); - axis([min(SNR) max(SNR) 10^-4 1]) - end -end diff --git a/matlab/tests/pusch_decode_signal.m b/matlab/tests/pusch_decode_signal.m deleted file mode 100644 index 4973e3aee..000000000 --- a/matlab/tests/pusch_decode_signal.m +++ /dev/null @@ -1,20 +0,0 @@ -ueConfig=struct('NCellID',1,'NULRB',15,'NSubframe',0,'RNTI',30,'CyclicPrefixUL','Normal','NTxAnts',1,'Shortened',0); -puschConfig=struct('NTurboDecIts',5,'NLayers',1,'OrthCover','Off','PRBSet',(0:14)','Modulation','QPSK','RV',0); - -TBS=392; -cfo=0; -t0=1; -x=[rx(t0:end); zeros(t0-1,1)]; - -x=lteFrequencyCorrect(ueConfig,x,cfo); -subframe_rx=lteSCFDMADemodulate(ueConfig,x); -idx=ltePUSCHIndices(ueConfig,puschConfig); -pusch_rx=subframe_rx(idx); -dmrs_rx=subframe_rx(ltePUSCHDRSIndices(ueConfig,puschConfig)); -[hest, noiseest] = lteULChannelEstimate(ueConfig,puschConfig,subframe_rx); -ce=hest(idx); -[cws,symbols] = ltePUSCHDecode(ueConfig,puschConfig,pusch_rx,ce,noiseest); -[trblkout,blkcrc,stateout] = lteULSCHDecode(ueConfig,puschConfig,TBS,cws); -disp(blkcrc) -scatter(real(symbols),imag(symbols)) -%plot(angle(hest(:,1))) \ No newline at end of file diff --git a/matlab/tests/pusch_encode_test.m b/matlab/tests/pusch_encode_test.m deleted file mode 100644 index 5d09e88f5..000000000 --- a/matlab/tests/pusch_encode_test.m +++ /dev/null @@ -1,67 +0,0 @@ -ueConfig=struct('NCellID',1,'NULRB',6,'CyclicPrefixUL','Normal','NTxAnts',1,'RNTI',64); -puschConfig=struct('NLayers',1,'OrthCover','Off','Shortened',0,'NBundled',0); - -addpath('../../build//srslte/lib/phch/test') - -cqilen=0;%[0 4 20]; -mods={'64QAM'}; -rvs=0; -betas=0;%[0 5.0, 20.0]; -for p=1 - for i=0:26 - for m=1:length(mods) - for r=1:length(rvs) - for bri=1:length(betas) - for back=1:length(betas) - for c=1:length(cqilen) - for s=0:9 - ueConfig.NSubframe=s; - puschConfig.PRBSet=(0:p-1)'; - - TBs=lteTBS(length(puschConfig.PRBSet),i); - %TBs=256; - %trblkin=randi(2,TBs,1)-1; - trblkin=ones(1,TBs); - - puschConfig.Modulation = mods{m}; - puschConfig.RV = rvs(r); - puschConfig.BetaCQI = 5; - puschConfig.BetaRI = betas(bri); - puschConfig.BetaACK = betas(back); - - if (betas(bri)>0) - ri_bit=randi(2,1,1)-1; - else - ri_bit=[]; - end - if (betas(back)>0) - ack_bit=randi(2,1,1)-1; - else - ack_bit=[]; - end - - if (cqilen(c)>0 || TBs>0) - [enc, info]=lteULSCH(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); - cw_mat=ltePUSCH(ueConfig,puschConfig,enc); - %[drs, infodrs]=ltePUSCHDRS(ueConfig,puschConfig); - idx=ltePUSCHIndices(ueConfig,puschConfig); - %drs_idx=ltePUSCHDRSIndices(ueConfig,puschConfig); - subframe_mat = lteULResourceGrid(ueConfig); - subframe_mat(idx)=cw_mat; - - [~, subframe_lib, cwlib, bits]=srslte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); - err=max(abs(subframe_mat(:)-subframe_lib)); - if (err > 10^-5) - plot(abs(subframe_mat(:)-subframe_lib)) - error('Error!'); - end - end - end - end - end - end - end - end - end -end - diff --git a/matlab/tests/rm_turbo_rx_test.m b/matlab/tests/rm_turbo_rx_test.m deleted file mode 100644 index a6139f251..000000000 --- a/matlab/tests/rm_turbo_rx_test.m +++ /dev/null @@ -1,43 +0,0 @@ -clear - -enbConfig=struct('NCellID',1,'CyclicPrefix','Normal','CellRefP',1); -pdschConfig=struct('Modulation','QPSK','RV',0,'TxScheme','Port0'); - -addpath('../../build/srslte/lib/fec/test') - - -codewordLen = 12000; -trBlkLenVec = 6201; -error=zeros(size(trBlkLenVec)); -for i=1:length(trBlkLenVec) - trBlkLen=trBlkLenVec(i); - in=randi(2,trBlkLen,1)-1; - - RV = 0; - trblockwithcrc = lteCRCEncode(in,'24A'); - codeblocks = lteCodeBlockSegment(trblockwithcrc); - turbocodedblocks = lteTurboEncode(codeblocks); - codeword = lteRateMatchTurbo(turbocodedblocks,codewordLen,RV); - - info = lteDLSCHInfo(trBlkLen); - - mat = lteRateRecoverTurbo(codeword,trBlkLen,RV); - mat2 = reshape(reshape(mat{1},[],3)',[],1); - out = lteTurboDecode(mat{1}); - - lib=srslte_rm_turbo_rx(double(codeword),trBlkLen,RV); - [outLib] = srslte_turbodecoder(lib); - - if (length(trBlkLenVec) == 1) -% fprintf('Err mat: %d. Err lib: %d\n',sum(out(1+info.F:trBlkLen+info.F)~=in),sum(outLib(1+info.F:trBlkLen+info.F)~=in)); - end - error(i)=mean(abs(double(mat2)-double(lib))); -end - -if (length(trBlkLenVec) == 1) - n=1:length(mat{1}); - plot(abs(double(mat2)-double(lib))) - %plot(n,mat{1},n,lib) -else - plot(error) -end diff --git a/matlab/tests/srs_test.m b/matlab/tests/srs_test.m deleted file mode 100644 index 48c615e78..000000000 --- a/matlab/tests/srs_test.m +++ /dev/null @@ -1,47 +0,0 @@ -clear -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 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, subframe]=srslte_refsignal_srs(ueConfig,srsConfig); - - error_sym=max(abs(sym-sym_mat)); - error_sf=max(abs(subframe_mat(:)-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 \ No newline at end of file diff --git a/matlab/tests/sss_test.m b/matlab/tests/sss_test.m deleted file mode 100644 index f9d4beb83..000000000 --- a/matlab/tests/sss_test.m +++ /dev/null @@ -1,144 +0,0 @@ - -SNR_values = linspace(-6,4,10); -Npackets = 200; -CFO=4/15; -m0=7; -m1=10; -%m0=26; -%m1=21; - -recordedWaveform = x; -if (~isempty(recordedWaveform)) - Npackets = floor(length(recordedWaveform)/19200)-1; - SNR_values = 0; -end - -error = zeros(6,length(SNR_values)); - -enb = struct('NCellID',2,'NSubframe',0,'NDLRB',6,'CellRefP',1,'CyclicPrefix','Normal','DuplexMode','FDD'); -sss=lteSSS(enb); - -cfg.Seed = 2; % Random channel seed -cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'ETU'; % EVA delay spread -cfg.DopplerFreq = 144; % 120Hz Doppler frequency -cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation -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 % Initialize at time zero - -[s, c0, c1] = get_sc(mod(enb.NCellID,3)); - -subframe = lteDLResourceGrid(enb); -sssSym = lteSSS(enb); -sssInd = lteSSSIndices(enb); -subframe(sssInd) = sssSym; -N_id_1 = floor(enb.NCellID/3); - -[txWaveform,info] = lteOFDMModulate(enb,subframe); -cfg.SamplingRate = info.SamplingRate; -fftSize = info.Nfft; - - -addpath('../../debug/lte/phy/lib/sync/test') - -for snr_idx=1:length(SNR_values) - SNRdB = SNR_values(snr_idx); - for i=1:Npackets - %% Noise Addition - SNR = 10^(SNRdB/10); % Linear SNR - - if (isempty(recordedWaveform)) - cfg.InitTime = i*(10^-3); - [rxWaveform, info]= lteFadingChannel(cfg,txWaveform); - rxWaveform = txWaveform; - - % Add CFO - freq = CFO/double(fftSize); - rxWaveform = rxWaveform.*exp(1i*2*pi*freq*(1:length(txWaveform))'); - - N0 = 1/(sqrt(2.0*enb.CellRefP*double(fftSize))*SNR); - noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise - - rxWaveform = rxWaveform + noise; - else - rxWaveform = recordedWaveform(i*19200+1:(i+1)*19200); - end - - offset = lteDLFrameOffset(enb,rxWaveform); - offsetVec(i)=offset; - rxWaveform = [rxWaveform(1+offset:end,:); zeros(offset,1)]; - - subframe_rx = lteOFDMDemodulate(enb,rxWaveform,1); - - sss_rx = subframe_rx(lteSSSIndices(enb)); - sss0=sss_rx(1:2:end); - sss1=sss_rx(2:2:end); - - beta0=sss0.*c0'; - beta1=sss1.*c1'; - - corr0=zeros(31,1); - for m=1:31 - corr0(m)=sum(beta0.*s(m,:)'); - end - corr0=abs(corr0).^2; - [m, idx]=max(corr0); - - error(1,snr_idx) = error(1,snr_idx) + ((idx ~= m0 && idx ~= m1)); - - M=2; - Nm=10; - - corr2=zeros(31,1); - for m=1:31 - for j=0:M - idx=1+j*Nm:(j+1)*Nm; - corr2(m)=corr2(m)+abs(sum(beta0(idx).*s(m,idx)')).^2; - end - end - [m, idx]=max(corr2); - - error(2,snr_idx) = error(2,snr_idx) + ((idx ~= m0 && idx ~= m1)); - - corr3=zeros(31,1); - for m=1:31 - corr3(m)=abs(sum(beta0(2:end).*conj(beta0(1:end-1)).*transpose(s(m,2:end).*conj(s(m,1:end-1))))).^2; - end - [m, idx]=max(corr3); - - error(3,snr_idx) = error(3,snr_idx) + ((idx ~= m0 && idx ~= m1)); - - % srsLTE results - [n,sf_idx,lt_corr0]=srslte_sss(enb,rxWaveform,'full'); - [m, idx]=max(lt_corr0); - error(4,snr_idx) = error(4,snr_idx) + ((idx ~= m0 && idx ~= m1)); - - [n,sf_idx,lt_corr2]=srslte_sss(enb,rxWaveform,'partial'); - [m, idx]=max(lt_corr2); - error(5,snr_idx) = error(5,snr_idx) + ((idx ~= m0 && idx ~= m1)); - - [n,sf_idx,lt_corr3]=srslte_sss(enb,rxWaveform,'diff'); - [m, idx]=max(lt_corr3); - error(6,snr_idx) = error(6,snr_idx) + ((idx ~= m0 && idx ~= m1)); - - end -end - -if (length(SNR_values) > 1) - plot(SNR_values,1-error/Npackets) - legend('Full','Partial','Differential','Full-lt','Partial-lt','Differential-lt') - grid on -else - e=error/Npackets; - fprintf('Full (mt/lt): \t%f/%f\n',e(1),e(4)); - fprintf('Partial (mt/lt):%f/%f\n',e(2),e(5)); - fprintf('Diff (mt/lt): \t%f/%f\n',e(3),e(6)); -end - - - - - diff --git a/matlab/tests/sync_test.m b/matlab/tests/sync_test.m deleted file mode 100644 index c71437aee..000000000 --- a/matlab/tests/sync_test.m +++ /dev/null @@ -1,96 +0,0 @@ -clear -enb = lteTestModel('1.1','1.4MHz'); -Ntrials = 1; -SNR_values = 100;%linspace(-8,0,6); -flen=1920; -fft_size=128; -fading_enabled = true; - -tx_offset = 10;%randi(50,1,Ntrials); - -tx_signal = lteTestModelTool(enb); -pss_idx = flen/2-fft_size+1:flen/2; -pss_signal=tx_signal(pss_idx); -tx_power = mean(pss_signal.*conj(pss_signal)); - -corrcfg.PSS='On'; -corrcfg.SSS='On'; -corrcfg.CellRS='Off'; - -cfg.Seed = 0; % Random channel seed -cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'ETU'; % 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 -cfg.SamplingRate = flen*1000; - -addpath('../../build/srslte/lib/sync/test') -addpath('../sync/') - -t = (0:length(tx_signal)-1).'/fft_size; - -L=fft_size; -M=4; -diff=zeros(length(SNR_values),M); -for snr_idx=1:length(SNR_values) - fprintf('SNR=%.1f dB\n', SNR_values(snr_idx)); - SNRdB = SNR_values(snr_idx); - rx_offset = zeros(M,length(tx_offset)); - for i=1:Ntrials - if fading_enabled - [rx_signal, chinfo] = lteFadingChannel(cfg,tx_signal); - else - rx_signal = tx_signal; - end - SNR = 10^(SNRdB/10); % Linear SNR - rx = [zeros(tx_offset(i),1); rx_signal]; - N0 = tx_power/(sqrt(2.0)*SNR); - noise = N0*complex(randn(size(rx)), randn(size(rx))); % Generate noise - rx=noise+rx; - [rx_offset(1,i),corr_res] = lteDLFrameOffset(enb,rx(1:flen),corrcfg); - - % srsLTE in find mode - [rx_offset(2,i),corr_lt] = srslte_pss(enb,rx(1:flen)); - rx_offset(2,i) = rx_offset(2,i) - flen/2; - - % srsLTE in tracking mode - track_offset=2+rx_offset(2,i)+flen/2-fft_size-L/2; - [rx_offset(3,i),corr_lt_track] = srslte_pss(enb,rx(track_offset:end),L); - rx_offset(3,i) = rx_offset(2,i) + (rx_offset(3,i) - L/2) + 1; - - % CP based - [rx_offset(4,i), corr_lt_cp] = srslte_cp_synch(enb, rx); - - end - if fading_enabled - ch_delay = chinfo.ChannelFilterDelay; - else - ch_delay = 0; - end - diff(snr_idx,:)=mean(abs(rx_offset-repmat(tx_offset,M,1) - ch_delay),2); -end - -if (Ntrials == 1) - disp(rx_offset) - disp(diff) - %plot(1:flen,abs(corr_res(1:flen)),1:flen,abs(corr_lt(1:flen))); - t=1:L; - plot(t,abs(corr_lt_track(t))); - %plot(lambda) - %plot(1:L,abs(corr_lt_track),[L/2, L/2], [0 max(abs(corr_lt_track))]) - grid on - -else - plot(SNR_values,diff); - legend('Matlab','srs find','srs tracking','srs cp') - grid on - xlabel('SNR (dB)') - ylabel('Avg time offset') -end - diff --git a/matlab/tests/test_ofdma_peakamp.m b/matlab/tests/test_ofdma_peakamp.m deleted file mode 100644 index 81f21be10..000000000 --- a/matlab/tests/test_ofdma_peakamp.m +++ /dev/null @@ -1,32 +0,0 @@ -clear -enbConfig=struct('NCellID',0,'DuplexMode','TDD','CyclicPrefix','Normal','CellRefP',1,'CFI',2,'NDLRB',25,'NSubframe',4,'CyclicPrefixUL','Normal','NTxAnts',1); -pdschConfig=struct('NLayers',1,'TxScheme','Port0','OrthCover','Off','PRBSet',0,'RNTI',82,'Modulation','QPSK','RV',0,'Shortened',0); - -addpath('../../debug/lte/phy/lib/phch/test') - -NDLRB=[6 15 25 50 100]; - -Peak=[]; -k=1; -for r=1:length(NDLRB) - fprintf('NDLRB: %d\n',NDLRB(r)); - for l=1:NDLRB(r) - trblkin=randi(2,l*5,1)-1; - - enbConfig.NDLRB=NDLRB(r); - pdschConfig.PRBSet=(0:(l-1))'; - - idx=ltePDSCHIndices(enbConfig,pdschConfig,pdschConfig.PRBSet); - [cw, info]=lteDLSCH(enbConfig,pdschConfig,2*length(idx),trblkin); - cw_mat=ltePDSCH(enbConfig,pdschConfig,cw); - subframe_mat = lteDLResourceGrid(enbConfig); - subframe_mat(idx)=cw_mat; - waveform = lteOFDMModulate(enbConfig,subframe_mat,0); - waveform = waveform*sqrt(512)/sqrt(l)*NDLRB(r)/15; - Peak(k)=max(max(abs(real(waveform))),max(abs(imag(waveform)))); - k=k+1; - end -end - -plot(Peak(:)') - diff --git a/matlab/tests/test_scfdma.m b/matlab/tests/test_scfdma.m deleted file mode 100644 index 70edcb9f3..000000000 --- a/matlab/tests/test_scfdma.m +++ /dev/null @@ -1,26 +0,0 @@ -clear -ue = struct('NULRB',6,'NDLRB',6); -d = lteULResourceGridSize(ue); -rgrid = complex(rand(d)-0.5,rand(d)-0.5); -waveform = lteSCFDMAModulate(ue,rgrid,0); - -wave = []; -freq_correct=[]; -for i=1:14 - symbol = ifft(ifftshift([zeros(28,1); rgrid(:,i); zeros(28,1)]),128); - if (i==1 || i==8) - cp_len=10; - else - cp_len=9; - end - symbol_cp=[symbol((128-cp_len+1):128); symbol(1:128)]; - freq_correct=[freq_correct; exp(1i*pi*(-cp_len:127)'/128)]; - wave = [wave; symbol_cp]; -end - -wave=wave.*freq_correct; - -%wave=transpose(wave); -%plot(1:138,fftshift(fft(waveform(1:138))),1:138,fftshift(fft(wave(1:138)))) -plot(abs(wave(1:138)-waveform(1:138))) -mean(abs(wave-waveform)) diff --git a/matlab/tests/test_scfdma_peakamp.m b/matlab/tests/test_scfdma_peakamp.m deleted file mode 100644 index 211d0e45b..000000000 --- a/matlab/tests/test_scfdma_peakamp.m +++ /dev/null @@ -1,32 +0,0 @@ -clear -ueConfig=struct('NCellID',0,'NULRB',25,'NSubframe',4,'RNTI',82,'CyclicPrefixUL','Normal','NTxAnts',1); -puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',0,'Modulation','QPSK','RV',0,'Shortened',0); - -addpath('../../debug/lte/phy/lib/phch/test') - -NULRB=[6 15 25 50 100]; - -Peak=[]; -k=1; -for r=1:length(NULRB) - fprintf('NULRB: %d\n',NULRB(r)); - for l=1:NULRB(r) - trblkin=randi(2,l*5,1)-1; - - ueConfig.NULRB=NULRB(r); - puschConfig.PRBSet=(0:(l-1))'; - - [cw, info]=lteULSCH(ueConfig,puschConfig,trblkin); - cw_mat=ltePUSCH(ueConfig,puschConfig,cw); - idx=ltePUSCHIndices(ueConfig,puschConfig); - subframe_mat = lteULResourceGrid(ueConfig); - subframe_mat(idx)=cw_mat; - waveform = lteSCFDMAModulate(ueConfig,subframe_mat,0); - waveform = waveform*sqrt(512)/sqrt(l)*NULRB(r)/10; - Peak(k)=max(max(abs(real(waveform))),max(abs(imag(waveform)))); - k=k+1; - end -end - -plot(Peak(:)') - diff --git a/matlab/tests/turbodecoder_bler.m b/matlab/tests/turbodecoder_bler.m deleted file mode 100644 index 754d1c9de..000000000 --- a/matlab/tests/turbodecoder_bler.m +++ /dev/null @@ -1,51 +0,0 @@ - -clear -blen=5184; -SNR_values_db=linspace(-1.3,-0.7,6); -Nrealizations=600; - -addpath('../../build/srslte/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 = lteTurboEncode(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 = lteTurboDecode(noisysymbols); - interleavedSymbols = reshape(reshape(noisysymbols,[],3)',1,[]); - [decodedData2] = srslte_turbodecoder(interleavedSymbols); - - errors1(snr_idx) = errors1(snr_idx) + any(decodedData ~= Data); - errors2(snr_idx) = errors2(snr_idx) + any(decodedData2 ~= Data); - end - - fprintf('SNR: %.2f BLER: %f-%f\n', SNR_values_db(snr_idx), ... - errors1(snr_idx)/Nrealizations, errors2(snr_idx)/Nrealizations); -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','srsLTE'); -else - disp(errors1); - disp(errors2); -end \ No newline at end of file diff --git a/matlab/tests/ulsch_test.m b/matlab/tests/ulsch_test.m deleted file mode 100644 index 013ebca1d..000000000 --- a/matlab/tests/ulsch_test.m +++ /dev/null @@ -1,67 +0,0 @@ -clear -ueConfig=struct('NCellID',1,'CyclicPrefixUL','Normal','NTxAnts',1); -puschConfig=struct('NLayers',1,'OrthCover','Off','Shortened',0); - -addpath('/home/ismael/work/srsLTE/debug/srslte/lib/phch/test') - -cqilen=[0 20]; -mods={'QPSK','16QAM', '64QAM'}; -rvs=0; -betas=[0 2.0 2.5 5.0, 20.0]; -for p=1:100 - for i=0:26 - for m=1:length(mods) - for r=1:length(rvs) - for bri=1:length(betas) - for back=1:length(betas) - for c=1:length(cqilen) - puschConfig.PRBSet=(0:p-1)'; - - TBs=lteTBS(length(puschConfig.PRBSet),i); - %TBs=256; - %trblkin=randi(2,TBs,1)-1; - trblkin=ones(1,TBs); - - puschConfig.Modulation = mods{m}; - puschConfig.RV = rvs(r); - puschConfig.BetaCQI = 5; - puschConfig.BetaRI = betas(bri); - puschConfig.BetaACK = betas(back); - - if (betas(bri)>0) - ri_bit=randi(2,1,1)-1; - else - ri_bit=[]; - end - if (betas(back)>0) - ack_bit=randi(2,1,1)-1; - else - ack_bit=[]; - end - - if (cqilen(c)>0 || TBs>0) - [lib]=srslte_ulsch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); - [mat, info]=lteULSCH(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit,[]); - mat(mat==-2)=0; - mat(mat==-1)=0; - err=sum(abs(double(mat)-double(lib))); - if (err > 0) - disp(err) - plot(abs(double(mat)-double(lib))) - error('Error!'); - end - end - end - end - end - end - end - end -end - -if (length(TBs) == 1) - %disp(info) - n=1:length(mat); - %plot(abs(double(mat)-double(lib))) - plot(n,lib(n),n,mat(n)) -end diff --git a/matlab/tests/viterbi_bler.m b/matlab/tests/viterbi_bler.m deleted file mode 100644 index d0fc61d04..000000000 --- a/matlab/tests/viterbi_bler.m +++ /dev/null @@ -1,49 +0,0 @@ - -clear -blen=40; -SNR_values_db=linspace(-3,4,8); -Nrealizations=50000; - -addpath('../../build/srslte/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] = srslte_viterbi(interleavedSymbols, 32); - - 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','srsLTE'); -else - disp(errors1); - disp(errors2); - disp(errors3); -end \ No newline at end of file diff --git a/mex/CMakeLists.txt b/mex/CMakeLists.txt deleted file mode 100644 index 51df7daea..000000000 --- a/mex/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright 2013-2015 Software Radio Systems Limited -# -# This file is part of the srsLTE library. -# -# srsLTE is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# srsLTE 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 Affero General Public License for more details. -# -# A copy of the GNU Affero General Public License can be found in -# the LICENSE file in the top-level directory of this distribution -# and at http://www.gnu.org/licenses/. -# - -if(NOT DisableMEX) - ######################################################################## - # Install headers - ######################################################################## - INSTALL(DIRECTORY include/ - 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_mex_headers SOURCES ${HEADERS_ALL}) - - ######################################################################## - # Add the subdirectories - ######################################################################## - add_subdirectory(lib) -endif() diff --git a/mex/include/srslte/mex/mexutils.h b/mex/include/srslte/mex/mexutils.h deleted file mode 100644 index b808c14da..000000000 --- a/mex/include/srslte/mex/mexutils.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2015 Software Radio Systems Limited - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE 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 Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - - -#ifndef MEXUTILS_ -#define MEXUTILS_ - -#ifdef UNDEF_BOOL -#undef bool -#endif - -#include "mex.h" - -#include - -#include "srslte/config.h" -#include "srslte/common/phy_common.h" - - - -SRSLTE_API bool mexutils_isScalar(const mxArray *ptr); - -SRSLTE_API bool mexutils_isCell(const mxArray *ptr); - -SRSLTE_API int mexutils_getLength(const mxArray *ptr); - -SRSLTE_API mxArray* mexutils_getCellArray(const mxArray *ptr, int idx); - -SRSLTE_API int mexutils_read_cell(const mxArray *ptr, - srslte_cell_t *cell); - -SRSLTE_API char *mexutils_get_char_struct(const mxArray *ptr, - const char *field_name); - -SRSLTE_API int mexutils_read_uint32_struct(const mxArray *ptr, - const char *field_name, - uint32_t *value); - -SRSLTE_API int mexutils_read_float_struct(const mxArray *ptr, - const char *field_name, - float *value); - -SRSLTE_API int mexutils_write_f(float *buffer, - mxArray **ptr, - uint32_t nr, - uint32_t nc); - -SRSLTE_API int mexutils_write_s(short *buffer, - mxArray **ptr, - uint32_t nr, - uint32_t nc); - -SRSLTE_API int mexutils_write_cf(cf_t *buffer, - mxArray **ptr, - uint32_t nr, - uint32_t nc); - -SRSLTE_API int mexutils_write_uint8(uint8_t *buffer, - mxArray **ptr, - uint32_t nr, - uint32_t nc); - -SRSLTE_API int mexutils_write_int(int *buffer, - mxArray **ptr, - uint32_t nr, - uint32_t nc); - -SRSLTE_API int mexutils_read_uint8(const mxArray *ptr, - uint8_t **buffer); - -SRSLTE_API int mexutils_read_uint64(const mxArray *ptr, - uint64_t **buffer); - -SRSLTE_API int mexutils_read_f(const mxArray *ptr, - float **buffer); - -SRSLTE_API int mexutils_read_cf(const mxArray *ptr, - cf_t **buffer); - -#endif diff --git a/mex/lib/CMakeLists.txt b/mex/lib/CMakeLists.txt deleted file mode 100644 index ec571681a..000000000 --- a/mex/lib/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright 2013-2015 Software Radio Systems Limited -# -# This file is part of the srsLTE library. -# -# srsLTE is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# srsLTE 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 Affero General Public License for more details. -# -# A copy of the GNU Affero General Public License can be found in -# the LICENSE file in the top-level directory of this distribution -# and at http://www.gnu.org/licenses/. -# - -if(NOT MATLAB_FOUND) - find_package(MATLAB) -endif() - -if(NOT OCTAVE_FOUND) - find_package(OCTAVE) -endif() - -# CMake 2.8.12 & earlier apparently don't define the -# Mex script path, so find it. -if(NOT MATLAB_MEX_PATH) - find_program( MATLAB_MEX_PATH mex - HINTS ${MATLAB_ROOT}/bin - PATHS ${MATLAB_ROOT}/bin - DOC "The mex program path" - ) -endif() - -if(MATLAB_FOUND) - message(STATUS "Found MATLAB in ${MATLAB_ROOT}") - add_library(srslte_mex SHARED mexutils.c) - install(TARGETS srslte_mex DESTINATION ${LIBRARY_DIR}) - SRSLTE_SET_PIC(srslte_mex) - include_directories(${MATLAB_INCLUDE_DIR}) -endif(MATLAB_FOUND) - -if(OCTAVE_FOUND) - message(STATUS "Found OCTAVE in ${OCTAVE_INCLUDE_PATHS}") - if (NOT MATLAB_FOUND) - add_library(srslte_mex SHARED mexutils.c) - install(TARGETS srslte_mex DESTINATION ${LIBRARY_DIR}) - SRSLTE_SET_PIC(srslte_mex) - endif (NOT MATLAB_FOUND) - include_directories(${OCTAVE_INCLUDE_DIR}) -endif(OCTAVE_FOUND) - -if(NOT MATLAB_FOUND) - if(NOT OCTAVE_FOUND) - message(STATUS "Could NOT find OCTAVE or MATLAB. MEX files won't be compiled") - endif(NOT OCTAVE_FOUND) -endif(NOT MATLAB_FOUND) - - diff --git a/mex/lib/mexutils.c b/mex/lib/mexutils.c deleted file mode 100644 index dc6a66729..000000000 --- a/mex/lib/mexutils.c +++ /dev/null @@ -1,249 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2015 Software Radio Systems Limited - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE 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 Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#include -#include -#include "srslte/mex/mexutils.h" -#include "srslte/utils/vector.h" -#include "srslte/common/phy_common.h" - - -bool mexutils_isScalar(const mxArray *ptr) { - return mxGetM(ptr) == 1 && mxGetN(ptr) == 1; -} - -bool mexutils_isCell(const mxArray *ptr) { - return mxIsCell(ptr); -} - -int mexutils_getLength(const mxArray *ptr) { - const mwSize *dims; - dims = mxGetDimensions(ptr); - return dims[0]; -} - -mxArray* mexutils_getCellArray(const mxArray *ptr, int idx) { - return mxGetCell(ptr, idx); -} - -char *mexutils_get_char_struct(const mxArray *ptr, const char *field_name) { - mxArray *p; - p = mxGetField(ptr, 0, field_name); - if (!p) { - return ""; - } - - if (mxIsCell(p)) { - return mxArrayToString(mxGetCell(p,0)); - } else { - return mxArrayToString(p); - } -} - -int mexutils_read_uint32_struct(const mxArray *ptr, const char *field_name, uint32_t *value) -{ - mxArray *p; - p = mxGetField(ptr, 0, field_name); - if (!p) { - return -1; - } - *value = (uint32_t) mxGetScalar(p); - return 0; -} - -int mexutils_read_float_struct(const mxArray *ptr, const char *field_name, float *value) -{ - mxArray *p; - p = mxGetField(ptr, 0, field_name); - if (!p) { - return -1; - } - *value = (float) mxGetScalar(p); - return 0; -} - -int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) { - if (mexutils_read_uint32_struct(ptr, "NCellID", &cell->id)) { - return -1; - } - if (mexutils_read_uint32_struct(ptr, "CellRefP", &cell->nof_ports)) { - return -1; - } - if (mexutils_read_uint32_struct(ptr, "NDLRB", &cell->nof_prb)) { - return -1; - } - if (!strcmp(mexutils_get_char_struct(ptr, "CyclicPrefix"), "Extended")) { - cell->cp = SRSLTE_CP_EXT; - } else { - cell->cp = SRSLTE_CP_NORM; - } - if (!strcmp(mexutils_get_char_struct(ptr, "PHICHDuration"), "Extended")) { - cell->phich_length = SRSLTE_PHICH_EXT; - } else { - cell->phich_length = SRSLTE_PHICH_NORM; - } - if (!strcmp(mexutils_get_char_struct(ptr, "Ng"), "Sixth")) { - cell->phich_resources = SRSLTE_PHICH_R_1_6; - } else if (!strcmp(mexutils_get_char_struct(ptr, "Ng"), "Half")) { - cell->phich_resources = SRSLTE_PHICH_R_1_2; - } else if (!strcmp(mexutils_get_char_struct(ptr, "Ng"), "Two")) { - cell->phich_resources = SRSLTE_PHICH_R_2; - } else { - cell->phich_resources = SRSLTE_PHICH_R_1; - } - - return 0; -} - -int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) { - int numelems = mxGetNumberOfElements(ptr); - cf_t *tmp = srslte_vec_malloc(numelems * sizeof(cf_t)); - if (tmp) { - double *inr=mxGetPr(ptr); - double *ini=mxGetPi(ptr); - for (int i=0;i Date: Mon, 6 Mar 2017 16:02:08 +0000 Subject: [PATCH 2/2] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 5df567913..0423f3dc2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Current Features: * All UL channels/signals are supported for UE side: PRACH, PUSCH, PUCCH, SRS * Frequency-based ZF and MMSE equalizer * Highly optimized Turbo Decoder available in Intel SSE4.1/AVX (+100 Mbps) and standard C (+25 Mbps) - * MATLAB and OCTAVE MEX library generation for many components * UE receiver tested and verified with Amarisoft LTE 100 eNodeB and commercial LTE networks (Telefonica Spain, Three.ie and Eircom in Ireland) Missing Features: @@ -44,8 +43,7 @@ Download & Install Instructions * libfftw * Optional requirements: * srsgui: for real-time plotting. Download it here: https://github.com/srslte/srsgui - * VOLK: if the VOLK library and headers are detected, they will be used for accelerating some signal processing functions. - * Matlab/Octave: if found by CMake, MEX files will also be generated and installed. If you find any compilation issue with MEX and you don't need them, pass -DDisableMEX=ON to cmake to disable them. + * VOLK: if the VOLK library and headers are detected, they will be used for accelerating some signal processing functions. Download and build srsLTE: ```