Merge branch 'next' of github.com:softwareradiosystems/srsLTE into next

master
Ismael Gomez 7 years ago
commit d3ae456db3

@ -38,10 +38,13 @@
#define RESAMPLE_ARB_ #define RESAMPLE_ARB_
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#include <complex.h> #include <complex.h>
#include "srslte/config.h" #include "srslte/config.h"
#define SRSLTE_RESAMPLE_ARB_N_35 35
#define SRSLTE_RESAMPLE_ARB_N 32 // Polyphase filter rows #define SRSLTE_RESAMPLE_ARB_N 32 // Polyphase filter rows
#define SRSLTE_RESAMPLE_ARB_M 8 // Polyphase filter columns #define SRSLTE_RESAMPLE_ARB_M 8 // Polyphase filter columns
@ -49,11 +52,13 @@ typedef struct SRSLTE_API {
float rate; // Resample rate float rate; // Resample rate
float step; // Step increment through filter float step; // Step increment through filter
float acc; // Index into filter float acc; // Index into filter
bool interpolate;
cf_t reg[SRSLTE_RESAMPLE_ARB_M]; // Our window of samples cf_t reg[SRSLTE_RESAMPLE_ARB_M]; // Our window of samples
} srslte_resample_arb_t; } srslte_resample_arb_t;
SRSLTE_API void srslte_resample_arb_init(srslte_resample_arb_t *q, SRSLTE_API void srslte_resample_arb_init(srslte_resample_arb_t *q,
float rate); float rate, bool interpolate);
SRSLTE_API int srslte_resample_arb_compute(srslte_resample_arb_t *q, SRSLTE_API int srslte_resample_arb_compute(srslte_resample_arb_t *q,
cf_t *input, cf_t *input,

@ -28,64 +28,104 @@
#include <string.h> #include <string.h>
#include "srslte/phy/resampling/resample_arb.h" #include "srslte/phy/resampling/resample_arb.h"
#include "srslte/phy/utils/debug.h" #include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
float srslte_resample_arb_polyfilt[SRSLTE_RESAMPLE_ARB_N][SRSLTE_RESAMPLE_ARB_M] =
{{0,0.002400347599485495,-0.006922416132556366,0.0179104136912176,0.99453086623794,-0.008521087756729117,0.0008598969867484128,0.0004992625165376107},
{-0.001903604727400391,0.004479591950094871,-0.01525319260830623,0.04647449496926549,0.9910477342662829,-0.03275243420114668,0.008048813755373533,-0.001216900416836847}, float srslte_resample_arb_polyfilt[SRSLTE_RESAMPLE_ARB_N][SRSLTE_RESAMPLE_ARB_M] __attribute__((aligned(256))) =
{-0.001750442300940216,0.006728826416921727,-0.02407540632178267,0.07708575473589654,0.9841056525667189,-0.05473739187922162,0.01460652754040275,-0.002745266140572769}, {{0.000499262532685, 0.000859897001646, -0.008521087467670, 0.994530856609344, 0.017910413444042, -0.006922415923327, 0.002400347497314, 0.000000000000000 },
{-0.001807302702047332,0.009130494591071001,-0.03332524241797466,0.1096377743266821,0.9737536341125557,-0.07444712408657775,0.0205085154280773,-0.004077596041064956}, {-0.001216900418513, 0.008048813790083, -0.032752435654402, 0.991047739982605, 0.046474494040012, -0.015253192745149, 0.004479591734707, -0.001903604716063 },
{-0.002005048395707184,0.01166717081713966,-0.04292591596219218,0.1440068251440274,0.9600641782991848,-0.09187282739868929,0.02573649090563353,-0.005218582609802016}, {-0.002745266072452, 0.014606527984142, -0.054737392812967, 0.984105646610260, 0.077085755765438, -0.024075405672193, 0.006728826556355, -0.001750442315824 },
{-0.002303606593778858,0.01431549924598744,-0.05279365431190471,0.1800496557331084,0.9431333663677619,-0.107022659158021,0.03028295984887362,-0.006178495199082676}, {-0.004077596124262, 0.020508514717221, -0.074447125196457, 0.973753631114960, 0.109637774527073, -0.033325243741274, 0.009130494669080, -0.001807302702218 },
{-0.002673824939871474,0.01705308556587308,-0.06283262272105428,0.2176066284621515,0.9230793648715676,-0.1199244901666642,0.03414559686566755,-0.006951034565279722}, {-0.005218582693487, 0.025736490264535, -0.091872826218605, 0.960064172744751, 0.144006818532944, -0.042925916612148, 0.011667170561850, -0.002005048329011 },
{-0.003099294850834212,0.01985022208215894,-0.07294100481214681,0.2564996326404178,0.9000412628278351,-0.1306207218667012,0.03733448898243594,-0.007554128492547957}, {-0.006178495008498, 0.030282959342003, -0.107022657990456, 0.943133354187012, 0.180049657821655, -0.052793655544519, 0.014315498992801, -0.002303606597707 },
{-0.003564415127592977,0.02267702927238637,-0.08300660359189582,0.2965368855416621,0.874178327911914,-0.1391710078036285,0.03986356581130199,-0.007992692892036229}, {-0.006951034534723, 0.034145597368479, -0.119924493134022, 0.923079371452332, 0.217606633901596, -0.062832623720169, 0.017053086310625, -0.002673825016245 },
{-0.004060222849803048,0.02549633298710617,-0.09291211362877161,0.3375102453232687,0.8456688916962831,-0.1456479420005528,0.04175429631970297,-0.00827816851803391}, {-0.007554128300399, 0.037334490567446, -0.130620718002319, 0.900041282176971, 0.256499618291855, -0.072941005229950, 0.019850222393870, -0.003099294845015 },
{-0.004574770330592958,0.02827133859849648,-0.1025308044303699,0.379200979038518,0.8147072909915275,-0.1501397816831265,0.04303284689167361,-0.008423951215857236}, {-0.007992693223059, 0.039863564074039, -0.139171004295349, 0.874178349971771, 0.296536892652512, -0.083006605505943, 0.022677028551698, -0.003564415033907 },
{-0.005100453570725489,0.0309593063669097,-0.1117325201826136,0.4213772298764557,0.7815036335229155,-0.1527444636485677,0.0437349357738538,-0.008441129184587313}, {-0.008278168737888, 0.041754297912121, -0.145647943019867, 0.845668911933899, 0.337510257959366, -0.092912115156651, 0.025496333837509, -0.004060222767293 },
{-0.005625340687997995,0.03351877124912608,-0.1203802123857154,0.463798444519773,0.7462810500374923,-0.1535722712206338,0.04389261707032224,-0.008345136869130621}, {-0.008423951454461, 0.043032847344875, -0.150139778852463, 0.814707279205322, 0.379200965166092, -0.102530807256699, 0.028271337971091, -0.004574770107865 },
{-0.006140888413286479,0.03590276234084221,-0.1283350405000867,0.5062161107254219,0.7092744343987509,-0.152741400055636,0.04355110899623683,-0.008147838953503964}, {-0.008441128768027, 0.043734934180975, -0.152744457125664, 0.781503617763519, 0.421377241611481, -0.111732520163059, 0.030959306284785, -0.005100453738123 },
{-0.006634012711933725,0.03806645580467819,-0.1354549138065051,0.5483763739419955,0.6707272107491931,-0.1503798528838644,0.0427502160096194,-0.007865132034489236}, {-0.008345136418939, 0.043892618268728, -0.153572276234627, 0.746281027793884, 0.463798433542252, -0.120380215346813, 0.033518772572279, -0.005625340621918 },
{-0.007094909626785393,0.03996043743797257,-0.1415969539549883,0.5900207719663111,0.6308907308946271,-0.1466186670140106,0.04153829696698895,-0.007508971112586246}, {-0.008147838525474, 0.043551109731197, -0.152741402387619, 0.709274411201477, 0.506216108798981, -0.128335043787956, 0.035902760922909, -0.006140888202935 },
{-0.007508971112586246,0.04153829696698895,-0.1466186670140106,0.6308907308946271,0.5900207719663111,-0.1415969539549883,0.03996043743797257,-0.007094909626785393}, {-0.007865131832659, 0.042750217020512, -0.150379851460457, 0.670727193355560, 0.548376381397247, -0.135454908013344, 0.038066454231739, -0.006634012795985 },
{-0.007865132034489236,0.0427502160096194,-0.1503798528838644,0.6707272107491931,0.5483763739419955,-0.1354549138065051,0.03806645580467819,-0.006634012711933725}, {-0.007508971262723, 0.041538298130035, -0.146618664264679, 0.630890727043152, 0.590020775794983, -0.141596958041191, 0.039960436522961, -0.007094909437001 },
{-0.008147838953503964,0.04355110899623683,-0.152741400055636,0.7092744343987509,0.5062161107254219,-0.1283350405000867,0.03590276234084221,-0.006140888413286479}, {-0.007094909437001, 0.039960436522961, -0.141596958041191, 0.590020775794983, 0.630890727043152, -0.146618664264679, 0.041538298130035, -0.007508971262723 },
{-0.008345136869130621,0.04389261707032224,-0.1535722712206338,0.7462810500374923,0.463798444519773,-0.1203802123857154,0.03351877124912608,-0.005625340687997995}, {-0.006634012795985, 0.038066454231739, -0.135454908013344, 0.548376381397247, 0.670727193355560, -0.150379851460457, 0.042750217020512, -0.007865131832659 },
{-0.008441129184587313,0.0437349357738538,-0.1527444636485677,0.7815036335229155,0.4213772298764557,-0.1117325201826136,0.0309593063669097,-0.005100453570725489}, {-0.006140888202935, 0.035902760922909, -0.128335043787956, 0.506216108798981, 0.709274411201477, -0.152741402387619, 0.043551109731197, -0.008147838525474 },
{-0.008423951215857236,0.04303284689167361,-0.1501397816831265,0.8147072909915275,0.379200979038518,-0.1025308044303699,0.02827133859849648,-0.004574770330592958}, {-0.005625340621918, 0.033518772572279, -0.120380215346813, 0.463798433542252, 0.746281027793884, -0.153572276234627, 0.043892618268728, -0.008345136418939 },
{-0.00827816851803391,0.04175429631970297,-0.1456479420005528,0.8456688916962831,0.3375102453232687,-0.09291211362877161,0.02549633298710617,-0.004060222849803048}, {-0.005100453738123, 0.030959306284785, -0.111732520163059, 0.421377241611481, 0.781503617763519, -0.152744457125664, 0.043734934180975, -0.008441128768027 },
{-0.007992692892036229,0.03986356581130199,-0.1391710078036285,0.874178327911914,0.2965368855416621,-0.08300660359189582,0.02267702927238637,-0.003564415127592977}, {-0.004574770107865, 0.028271337971091, -0.102530807256699, 0.379200965166092, 0.814707279205322, -0.150139778852463, 0.043032847344875, -0.008423951454461 },
{-0.007554128492547957,0.03733448898243594,-0.1306207218667012,0.9000412628278351,0.2564996326404178,-0.07294100481214681,0.01985022208215894,-0.003099294850834212}, {-0.004060222767293, 0.025496333837509, -0.092912115156651, 0.337510257959366, 0.845668911933899, -0.145647943019867, 0.041754297912121, -0.008278168737888 },
{-0.006951034565279722,0.03414559686566755,-0.1199244901666642,0.9230793648715676,0.2176066284621515,-0.06283262272105428,0.01705308556587308,-0.002673824939871474}, {-0.003564415033907, 0.022677028551698, -0.083006605505943, 0.296536892652512, 0.874178349971771, -0.139171004295349, 0.039863564074039, -0.007992693223059 },
{-0.006178495199082676,0.03028295984887362,-0.107022659158021,0.9431333663677619,0.1800496557331084,-0.05279365431190471,0.01431549924598744,-0.002303606593778858}, {-0.003099294845015, 0.019850222393870, -0.072941005229950, 0.256499618291855, 0.900041282176971, -0.130620718002319, 0.037334490567446, -0.007554128300399 },
{-0.005218582609802016,0.02573649090563353,-0.09187282739868929,0.9600641782991848,0.1440068251440274,-0.04292591596219218,0.01166717081713966,-0.002005048395707184}, {-0.002673825016245, 0.017053086310625, -0.062832623720169, 0.217606633901596, 0.923079371452332, -0.119924493134022, 0.034145597368479, -0.006951034534723 },
{-0.004077596041064956,0.0205085154280773,-0.07444712408657775,0.9737536341125557,0.1096377743266821,-0.03332524241797466,0.009130494591071001,-0.001807302702047332}, {-0.002303606597707, 0.014315498992801, -0.052793655544519, 0.180049657821655, 0.943133354187012, -0.107022657990456, 0.030282959342003, -0.006178495008498 },
{-0.002745266140572769,0.01460652754040275,-0.05473739187922162,0.9841056525667189,0.07708575473589654,-0.02407540632178267,0.006728826416921727,-0.001750442300940216}, {-0.002005048329011, 0.011667170561850, -0.042925916612148, 0.144006818532944, 0.960064172744751, -0.091872826218605, 0.025736490264535, -0.005218582693487 },
{-0.001216900416836847,0.008048813755373533,-0.03275243420114668,0.9910477342662829,0.04647449496926549,-0.01525319260830623,0.004479591950094871,-0.001903604727400391}, {-0.001807302702218, 0.009130494669080, -0.033325243741274, 0.109637774527073, 0.973753631114960, -0.074447125196457, 0.020508514717221, -0.004077596124262 },
{0.0004992625165376107,0.0008598969867484128,-0.008521087756729117,0.99453086623794,0.0179104136912176,-0.006922416132556366,0.002400347599485495,0}}; {-0.001750442315824, 0.006728826556355, -0.024075405672193, 0.077085755765438, 0.984105646610260, -0.054737392812967, 0.014606527984142, -0.002745266072452 },
{-0.001903604716063, 0.004479591734707, -0.015253192745149, 0.046474494040012, 0.991047739982605, -0.032752435654402, 0.008048813790083, -0.001216900418513 },
{0.000000000000000, 0.002400347497314, -0.006922415923327, 0.017910413444042, 0.994530856609344, -0.008521087467670, 0.000859897001646, 0.000499262532685 }};
// TODO: use lte/utils/vector.h and Volk
cf_t srslte_resample_arb_dot_prod(cf_t* x, float *y, int len)
{
cf_t res = 0+0*I;
for(int i=0;i<len;i++){ float srslte_resample_arb_polyfilt_35[SRSLTE_RESAMPLE_ARB_N_35][SRSLTE_RESAMPLE_ARB_M] __attribute__((aligned(256))) =
res += x[i]*y[i]; {{0.000002955485215, 0.000657994314549, -0.033395686652146, 0.188481383863832, 0.704261032406613, 0.171322660416961, -0.032053439082436, 0.000722236729272},
} {0.000003596427925, 0.000568080243211, -0.034615802155152, 0.206204344739138, 0.702921418438421, 0.154765509342932, -0.030612377229395, 0.000764085430796},
return res; {0.000005121937258, 0.000449039680445, -0.035689076986744, 0.224449928603191, 0.700248311996698, 0.138842912406449, -0.029094366813032, 0.000786624971348},
{0.000007718609465, 0.000297261794949, -0.036589488825594, 0.243172347408947, 0.696253915778072, 0.123583456372980, -0.027519775698206, 0.000792734165095},
{0.000011575047600, 0.000109005258838, -0.037289794881918, 0.262321777662990, 0.690956433427623, 0.109011322456059, -0.025907443019580, 0.000785077624893},
{0.000016882508098, -0.000119571475197, -0.037761641428480, 0.281844530653151, 0.684379949985066, 0.095146306185631, -0.024274662580170, 0.000766100891437},
{0.000023834849457, -0.000392374989948, -0.037975689603840, 0.301683254255907, 0.676554274013489, 0.082003866618022, -0.022637179782782, 0.000738028846774},
{0.000032627688404, -0.000713336731203, -0.037901757319987, 0.321777165554580, 0.667514742706306, 0.069595203590358, -0.021009201268519, 0.000702867092175},
{0.000043456678971, -0.001086367817537, -0.037508976943232, 0.342062313218325, 0.657301991568526, 0.057927361522269, -0.019403416364306, 0.000662405963124},
{0.000056514841640, -0.001515308860252, -0.036765968249551, 0.362471868314761, 0.645961690553484, 0.047003358086968, -0.017831029382043, 0.000618226851332},
{0.000071988882997, -0.002003874882511, -0.035641025985104, 0.382936441958648, 0.633544248803284, 0.036822335913581, -0.016301801765629, 0.000571710504985},
{0.000090054461223, -0.002555595491550, -0.034102321191048, 0.403384427938144, 0.620104490387788, 0.027379735343965, -0.014824103048525, 0.000524046983526},
{0.000110870369116, -0.003173750525766, -0.032118115280935, 0.423742368211529, 0.605701303660781, 0.018667486151043, -0.013404969563367, 0.000476246951838},
{0.000134571624077, -0.003861301468941, -0.029656985690720, 0.443935338933583, 0.590397267050922, 0.010674216032341, -0.012050169836157, 0.000429154010367},
{0.000161261473605, -0.004620818996097, -0.026688061757620, 0.463887354454611, 0.574258254277514, 0.003385473622292, -0.010764275599988, 0.000383457772129},
{0.000191002345063, -0.005454407088752, -0.023181269326746, 0.483521786538780, 0.557353022125450, -0.003216036280022, -0.009550737376604, 0.000339707414324},
{0.000223805789820, -0.006363624230896, -0.019107582435436, 0.502761795874207, 0.539752784028766, -0.009150207594916, -0.008411963597610, 0.000298325451050},
{0.000259621494011, -0.007349402269867, -0.014439280286493, 0.521530772797177, 0.521530772797177, -0.014439280286493, -0.007349402269867, 0.000259621494011},
{0.000298325451050, -0.008411963597610, -0.009150207594916, 0.539752784028765, 0.502761795874207, -0.019107582435436, -0.006363624230896, 0.000223805789820},
{0.000339707414324, -0.009550737376604, -0.003216036280022, 0.557353022125450, 0.483521786538780, -0.023181269326746, -0.005454407088752, 0.000191002345063},
{0.000383457772129, -0.010764275599988, 0.003385473622292, 0.574258254277514, 0.463887354454611, -0.026688061757620, -0.004620818996097, 0.000161261473605},
{0.000429154010367, -0.012050169836157, 0.010674216032341, 0.590397267050922, 0.443935338933583, -0.029656985690720, -0.003861301468941, 0.000134571624077},
{0.000476246951838, -0.013404969563367, 0.018667486151043, 0.605701303660781, 0.423742368211529, -0.032118115280935, -0.003173750525766, 0.000110870369116},
{0.000524046983526, -0.014824103048525, 0.027379735343965, 0.620104490387787, 0.403384427938144, -0.034102321191048, -0.002555595491550, 0.000090054461223},
{0.000571710504985, -0.016301801765629, 0.036822335913581, 0.633544248803283, 0.382936441958648, -0.035641025985104, -0.002003874882511, 0.000071988882997},
{0.000618226851332, -0.017831029382043, 0.047003358086968, 0.645961690553484, 0.362471868314761, -0.036765968249551, -0.001515308860252, 0.000056514841640},
{0.000662405963124, -0.019403416364306, 0.057927361522269, 0.657301991568526, 0.342062313218325, -0.037508976943232, -0.001086367817537, 0.000043456678971},
{0.000702867092175, -0.021009201268519, 0.069595203590358, 0.667514742706306, 0.321777165554580, -0.037901757319987, -0.000713336731203, 0.000032627688404},
{0.000738028846774, -0.022637179782782, 0.082003866618022, 0.676554274013489, 0.301683254255907, -0.037975689603840, -0.000392374989948, 0.000023834849457},
{0.000766100891437, -0.024274662580170, 0.095146306185631, 0.684379949985066, 0.281844530653151, -0.037761641428480, -0.000119571475197, 0.000016882508098},
{0.000785077624893, -0.025907443019580, 0.109011322456059, 0.690956433427623, 0.262321777662990, -0.037289794881918, 0.000109005258838, 0.000011575047600},
{0.000792734165095, -0.027519775698206, 0.123583456372980, 0.696253915778072, 0.243172347408947, -0.036589488825594, 0.000297261794949, 0.000007718609465},
{0.000786624971348, -0.029094366813032, 0.138842912406449, 0.700248311996698, 0.224449928603191, -0.035689076986744, 0.000449039680445, 0.000005121937258},
{0.000764085430796, -0.030612377229395, 0.154765509342932, 0.702921418438421, 0.206204344739138, -0.034615802155152, 0.000568080243211, 0.000003596427925},
{0.000722236729272, -0.032053439082436, 0.171322660416961, 0.704261032406613, 0.188481383863832, -0.033395686652146, 0.000657994314549 , 0.000002955485215}};
static inline cf_t srslte_resample_arb_dot_prod(cf_t* x, float *y, int len){
cf_t res1 = srslte_vec_dot_prod_cfc(x,y,len);
return res1;
} }
// Right-shift our window of samples // Right-shift our window of samples
void srslte_resample_arb_push(srslte_resample_arb_t *q, cf_t x) void srslte_resample_arb_push(srslte_resample_arb_t *q, cf_t x){
{
memmove(&q->reg[1], &q->reg[0], (SRSLTE_RESAMPLE_ARB_M-1)*sizeof(cf_t)); memmove(&q->reg[1], &q->reg[0], (SRSLTE_RESAMPLE_ARB_M-1)*sizeof(cf_t));
q->reg[0] = x; q->reg[0] = x;
} }
// Initialize our struct // Initialize our struct
void srslte_resample_arb_init(srslte_resample_arb_t *q, float rate){ void srslte_resample_arb_init(srslte_resample_arb_t *q, float rate, bool interpolate){
memset(q->reg, 0, SRSLTE_RESAMPLE_ARB_M*sizeof(cf_t)); memset(q->reg, 0, SRSLTE_RESAMPLE_ARB_M*sizeof(cf_t));
q->acc = 0.0; q->acc = 0.0;
q->rate = rate; q->rate = rate;
q->interpolate = interpolate;
q->step = (1/rate)*SRSLTE_RESAMPLE_ARB_N; q->step = (1/rate)*SRSLTE_RESAMPLE_ARB_N;
} }
@ -94,19 +134,48 @@ int srslte_resample_arb_compute(srslte_resample_arb_t *q, cf_t *input, cf_t *out
int cnt = 0; int cnt = 0;
int n_out = 0; int n_out = 0;
int idx = 0; int idx = 0;
cf_t res1,res2;
cf_t *filter_input;
float frac = 0;
memset(q->reg, 0, SRSLTE_RESAMPLE_ARB_M*sizeof(cf_t));
while (cnt < n_in) {
if(cnt<SRSLTE_RESAMPLE_ARB_M){
memcpy(&q->reg[SRSLTE_RESAMPLE_ARB_M - cnt], input, (cnt)*sizeof(cf_t));
filter_input = q->reg;
} else{
filter_input = &input[cnt-SRSLTE_RESAMPLE_ARB_M];
}
res1 = srslte_resample_arb_dot_prod(filter_input, srslte_resample_arb_polyfilt[idx], SRSLTE_RESAMPLE_ARB_M);
if(q->interpolate){
res2 = srslte_resample_arb_dot_prod(filter_input, srslte_resample_arb_polyfilt[(idx%SRSLTE_RESAMPLE_ARB_N)+1], SRSLTE_RESAMPLE_ARB_M);
}
if(idx == SRSLTE_RESAMPLE_ARB_N){
*output = res1;
}else {
*output = (q->interpolate)?(res1 + (res2-res1)*frac):res1;
}
while(cnt < n_in)
{
*output = srslte_resample_arb_dot_prod(q->reg, srslte_resample_arb_polyfilt[idx], SRSLTE_RESAMPLE_ARB_M);
output++; output++;
n_out++; n_out++;
q->acc += q->step; q->acc += q->step;
idx = (int)roundf(q->acc); idx = (int)(q->acc);
while(idx >= SRSLTE_RESAMPLE_ARB_N){ while(idx >= SRSLTE_RESAMPLE_ARB_N){
q->acc -= SRSLTE_RESAMPLE_ARB_N; q->acc -= SRSLTE_RESAMPLE_ARB_N;
idx -= SRSLTE_RESAMPLE_ARB_N; idx -= SRSLTE_RESAMPLE_ARB_N;
if(cnt < n_in) if(cnt < n_in){
srslte_resample_arb_push(q, input[cnt++]); cnt++;
}
}
if(q->interpolate){
frac = q->acc - idx;
if(frac < 0)
frac = frac*(-1);
} }
} }
return n_out; return n_out;

@ -35,9 +35,9 @@
#include "srslte/phy/resampling/resample_arb.h" #include "srslte/phy/resampling/resample_arb.h"
#define ITERATIONS 10000
int main(int argc, char **argv) { int main(int argc, char **argv) {
int N=10000000; int N=9000;
float rate = 24.0/25.0; float rate = 24.0/25.0;
cf_t *in = malloc(N*sizeof(cf_t)); cf_t *in = malloc(N*sizeof(cf_t));
cf_t *out = malloc(N*sizeof(cf_t)); cf_t *out = malloc(N*sizeof(cf_t));
@ -46,12 +46,15 @@ int main(int argc, char **argv) {
in[i] = sin(i*2*M_PI/100); in[i] = sin(i*2*M_PI/100);
srslte_resample_arb_t r; srslte_resample_arb_t r;
srslte_resample_arb_init(&r, rate); srslte_resample_arb_init(&r, rate, 0);
clock_t start = clock(), diff; clock_t start = clock(), diff;
//int n_out = srslte_resample_arb_compute(&r, in, out, N); for(int xx = 0; xx<ITERATIONS;xx++){
int n_out = srslte_resample_arb_compute(&r, in, out, N);
}
diff = clock() - start; diff = clock() - start;
diff = diff/ITERATIONS;
int msec = diff * 1000 / CLOCKS_PER_SEC; int msec = diff * 1000 / CLOCKS_PER_SEC;
float thru = (CLOCKS_PER_SEC/(float)diff)*(N/1e6); float thru = (CLOCKS_PER_SEC/(float)diff)*(N/1e6);
printf("Time taken %d seconds %d milliseconds\n", msec/1000, msec%1000); printf("Time taken %d seconds %d milliseconds\n", msec/1000, msec%1000);

@ -35,12 +35,14 @@
#include "srslte/phy/resampling/resample_arb.h" #include "srslte/phy/resampling/resample_arb.h"
int main(int argc, char **argv) { int main(int argc, char **argv) {
int N = 100; // Number of sinwave samples int N = 100; // Number of sinwave samples
int delay = 5; // Delay of our resampling filter int delay = 5; // Delay of our resampling filter
float down = 25.0; // Downsampling rate float down = 25.0; // Downsampling rate
for(int up=1;up<down;up++) for(int up=1;up<down;up++)
{ {
float rate = up/down; float rate = up/down;
@ -62,7 +64,7 @@ int main(int argc, char **argv) {
// Resample // Resample
srslte_resample_arb_t r; srslte_resample_arb_t r;
srslte_resample_arb_init(&r, rate); srslte_resample_arb_init(&r, rate, 0);
int n_out = srslte_resample_arb_compute(&r, in, out, N); int n_out = srslte_resample_arb_compute(&r, in, out, N);
// Check interp values // Check interp values
@ -74,12 +76,11 @@ int main(int argc, char **argv) {
float diff = fabs(creal(in[pre])-creal(in[post])); float diff = fabs(creal(in[pre])-creal(in[post]));
float diff2 = fabs(creal(out[i])-creal(in[round])); float diff2 = fabs(creal(out[i])-creal(in[round]));
if(diff2 > diff && pre != post){ if(diff2 > diff && pre != post){
printf("Interpolation failed at index %f", idx); printf("Interpolation failed at index %f\n", idx);
exit(-1); exit(-1);
} }
} }
free(in); free(in);
free(out); free(out);
} }

@ -38,6 +38,7 @@
#include <SoapySDR/Formats.h> #include <SoapySDR/Formats.h>
typedef struct { typedef struct {
char *devname;
SoapySDRKwargs args; SoapySDRKwargs args;
SoapySDRDevice *device; SoapySDRDevice *device;
SoapySDRRange *ranges; SoapySDRRange *ranges;
@ -51,7 +52,6 @@ typedef struct {
cf_t zero_mem[64*1024]; cf_t zero_mem[64*1024];
int soapy_error(void *h) int soapy_error(void *h)
{ {
return 0; return 0;
@ -90,7 +90,8 @@ void rf_soapy_register_error_handler(void *notused, srslte_rf_error_handler_t ne
char* rf_soapy_devname(void* h) char* rf_soapy_devname(void* h)
{ {
return "soapy"; rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h;
return handler->devname;
} }
@ -196,11 +197,15 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas)
printf("No Soapy devices found.\n"); printf("No Soapy devices found.\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
char* devname;
for (size_t i = 0; i < length; i++) { for (size_t i = 0; i < length; i++) {
printf("Soapy has Found device #%d: ", (int)i); printf("Soapy has Found device #%d: ", (int)i);
for (size_t j = 0; j < soapy_args[i].size; j++) { for (size_t j = 0; j < soapy_args[i].size; j++) {
printf("%s=%s, ", soapy_args[i].keys[j], soapy_args[i].vals[j]); printf("%s=%s, ", soapy_args[i].keys[j], soapy_args[i].vals[j]);
if(!strcmp(soapy_args[i].keys[j],"name") && !strcmp(soapy_args[i].vals[j], "LimeSDR-USB")){
devname = DEVNAME_LIME;
}
} }
printf("\n"); printf("\n");
} }
@ -218,7 +223,7 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas)
handler->device = sdr; handler->device = sdr;
handler->tx_stream_active = false; handler->tx_stream_active = false;
handler->rx_stream_active = false; handler->rx_stream_active = false;
handler->devname = devname;
if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_RX) > 0){ if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_RX) > 0){
printf("setting up RX stream\n"); printf("setting up RX stream\n");
if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) {
@ -234,6 +239,14 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas)
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
size_t sensor_length;
char** sensors;
sensors = SoapySDRDevice_listSensors(handler->device, &sensor_length);
for(int i = 0; i < sensor_length;i++)
{
printf("available sensors are : \n");
puts(sensors[i]);
}
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -267,7 +280,7 @@ int rf_soapy_close(void *h)
void rf_soapy_set_master_clock_rate(void *h, double rate) void rf_soapy_set_master_clock_rate(void *h, double rate)
{ {
// Allow the soapy to automatically set the appropriate clock rate // Allow the soapy to automatically set the appropriate clock rate
// TODO: implement this function
} }
@ -285,7 +298,6 @@ double rf_soapy_set_rx_srate(void *h, double rate)
printf("setSampleRate Rx fail: %s\n", SoapySDRDevice_lastError()); printf("setSampleRate Rx fail: %s\n", SoapySDRDevice_lastError());
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0); return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0);
} }
@ -296,7 +308,6 @@ double rf_soapy_set_tx_srate(void *h, double rate)
printf("setSampleRate Tx fail: %s\n", SoapySDRDevice_lastError()); printf("setSampleRate Tx fail: %s\n", SoapySDRDevice_lastError());
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0);
} }

@ -28,7 +28,7 @@
#include <stdint.h> #include <stdint.h>
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/phy/rf/rf.h" #include "srslte/phy/rf/rf.h"
#define DEVNAME_LIME "lime"
SRSLTE_API int rf_soapy_open(char *args, SRSLTE_API int rf_soapy_open(char *args,
void **handler); void **handler);

@ -59,6 +59,7 @@ bool radio::init(char *args, char *devname)
} else if (strstr(srslte_rf_name(&rf_device), "bladerf")) { } else if (strstr(srslte_rf_name(&rf_device), "bladerf")) {
burst_preamble_sec = blade_default_burst_preamble_sec; burst_preamble_sec = blade_default_burst_preamble_sec;
} else { } else {
burst_preamble_sec = 0;
printf("\nWarning burst preamble is not calibrated for device %s. Set a value manually\n\n", srslte_rf_name(&rf_device)); printf("\nWarning burst preamble is not calibrated for device %s. Set a value manually\n\n", srslte_rf_name(&rf_device));
} }
@ -329,7 +330,6 @@ void radio::set_tx_srate(double srate)
} }
burst_preamble_time_rounded = (double) burst_preamble_samples/cur_tx_srate; burst_preamble_time_rounded = (double) burst_preamble_samples/cur_tx_srate;
int nsamples=0; int nsamples=0;
/* Set time advance for each known device if in auto mode */ /* Set time advance for each known device if in auto mode */
if (tx_adv_auto) { if (tx_adv_auto) {
@ -356,6 +356,47 @@ void radio::set_tx_srate(double srate)
printf("\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); printf("\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate);
nsamples = cur_tx_srate*(uhd_default_tx_adv_samples * (1/cur_tx_srate) + uhd_default_tx_adv_offset_sec); nsamples = cur_tx_srate*(uhd_default_tx_adv_samples * (1/cur_tx_srate) + uhd_default_tx_adv_offset_sec);
} }
}else if(!strcmp(srslte_rf_name(&rf_device), "uhd_usrp2")) {
double srate_khz = round(cur_tx_srate/1e3);
if (srate_khz == 1.92e3) {
nsamples = 14;// estimated
} else if (srate_khz == 3.84e3) {
nsamples = 32;
} else if (srate_khz == 5.76e3) {
nsamples = 43;
} else if (srate_khz == 11.52e3) {
nsamples = 54;
} else if (srate_khz == 15.36e3) {
nsamples = 65;// to calc
} else if (srate_khz == 23.04e3) {
nsamples = 80; // to calc
} else {
/* Interpolate from known values */
printf("\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate);
nsamples = cur_tx_srate*(uhd_default_tx_adv_samples * (1/cur_tx_srate) + uhd_default_tx_adv_offset_sec);
}
} else if(!strcmp(srslte_rf_name(&rf_device), "lime")) {
double srate_khz = round(cur_tx_srate/1e3);
if (srate_khz == 1.92e3) {
nsamples = 70;// estimated
} else if (srate_khz == 3.84e3) {
nsamples = 76;//estimated
} else if (srate_khz == 5.76e3) {
nsamples = 76;
} else if (srate_khz == 11.52e3) {
nsamples = 76;
} else if (srate_khz == 15.36e3) {
nsamples = 73;
} else if (srate_khz == 23.04e3) {
nsamples = 87;
} else {
/* Interpolate from known values */
printf("\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate);
nsamples = cur_tx_srate*(uhd_default_tx_adv_samples * (1/cur_tx_srate) + uhd_default_tx_adv_offset_sec);
}
} else if (!strcmp(srslte_rf_name(&rf_device), "uhd_x300")) { } else if (!strcmp(srslte_rf_name(&rf_device), "uhd_x300")) {
// In X300 TX/RX offset is independent of sampling rate // In X300 TX/RX offset is independent of sampling rate

Loading…
Cancel
Save