Removed recv_frame_size from uhd_open() and set symbol size at runtime depending on master clock to support X300

master
ismagom 9 years ago
parent d57951bf10
commit 8e858831e0

@ -6,28 +6,29 @@
recordedSignal=[]; recordedSignal=[];
Npackets = 3; Npackets = 1;
SNR_values = linspace(12,16,4); SNR_values = 25;
%% Choose RMC %% Choose RMC
[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.9',[1;0;0;1]); [waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.9',[1;0;0;1]);
waveform = sum(waveform,2); waveform = sum(waveform,2);
if ~isempty(recordedSignal) if ~isempty(recordedSignal)
rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',50,'SamplingRate',3.84e6,'Nfft',256,'DuplexMode','FDD','CyclicPrefix','Normal'); rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',100,'DuplexMode','FDD','CyclicPrefix','Normal');
rmccFgOut.PDSCH.RNTI = 1234; rmccFgOut.PDSCH.RNTI = 1234;
rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2); rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2);
rmccFgOut.PDSCH.TxScheme = 'Port0'; rmccFgOut.PDSCH.TxScheme = 'Port0';
rmccFgOut.PDSCH.NLayers = 1; rmccFgOut.PDSCH.NLayers = 1;
rmccFgOut.PDSCH.NTurboDecIts = 5; rmccFgOut.PDSCH.NTurboDecIts = 5;
rmccFgOut.PDSCH.Modulation = {'64QAM'}; rmccFgOut.PDSCH.Modulation = {'64QAM'};
rmccFgOut.PDSCH.TrBlkSizes = [0 5992*ones(1,4) 0 5992*ones(1,4)]; trblklen=75376;
rmccFgOut.PDSCH.TrBlkSizes = trblklen*ones(10,1);
rmccFgOut.PDSCH.RV = 0; rmccFgOut.PDSCH.RV = 0;
end end
flen=rmccFgOut.SamplingRate/1000; flen=rmccFgOut.SamplingRate/1000;
Nsf = 9; Nsf = 10;
%% Setup Fading channel model %% Setup Fading channel model
cfg.Seed = 8; % Random channel seed cfg.Seed = 8; % Random channel seed
@ -78,8 +79,8 @@ for snr_idx=1:length(SNR_values)
%% Demodulate %% Demodulate
frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform); frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform);
for sf_idx=0:Nsf %for sf_idx=0:Nsf-1
%sf_idx=9; sf_idx=9;
subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14); subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14);
rmccFgOut.NSubframe=sf_idx; rmccFgOut.NSubframe=sf_idx;
rmccFgOut.TotSubframes=1; rmccFgOut.TotSubframes=1;
@ -96,9 +97,9 @@ for snr_idx=1:length(SNR_values)
%% Same with srsLTE %% Same with srsLTE
if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0) if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0)
[dec2, data, pdschRx, pdschSymbols2, cws2, cb9, temp] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ... [dec2, data, pdschRx, pdschSymbols2, cws2] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ...
rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ... rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ...
subframe_rx); subframe_rx, hest, nest);
else else
dec2 = 1; dec2 = 1;
end end
@ -106,7 +107,7 @@ for snr_idx=1:length(SNR_values)
fprintf('Error in sf=%d\n',sf_idx); fprintf('Error in sf=%d\n',sf_idx);
end end
decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+dec2; decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+dec2;
end %end
if ~isempty(recordedSignal) if ~isempty(recordedSignal)
recordedSignal = recordedSignal(flen*10+1:end); recordedSignal = recordedSignal(flen*10+1:end);

@ -142,7 +142,7 @@ int mexutils_read_uint64(const mxArray *ptr, uint64_t **buffer) {
int numelems = mxGetNumberOfElements(ptr); int numelems = mxGetNumberOfElements(ptr);
uint64_t *tmp = srslte_vec_malloc(numelems * sizeof(uint64_t)); uint64_t *tmp = srslte_vec_malloc(numelems * sizeof(uint64_t));
if (tmp) { if (tmp) {
uint64_t *inr=mxGetPr(ptr); uint64_t *inr=(uint64_t*) mxGetPr(ptr);
for (int i=0;i<numelems;i++) { for (int i=0;i<numelems;i++) {
tmp[i] = (uint64_t) inr[i]; tmp[i] = (uint64_t) inr[i];
} }

@ -216,6 +216,8 @@ SRSLTE_API int srslte_nof_prb(uint32_t symbol_sz);
SRSLTE_API int srslte_sampling_freq_hz(uint32_t nof_prb); SRSLTE_API int srslte_sampling_freq_hz(uint32_t nof_prb);
SRSLTE_API void srslte_use_standard_symbol_size(bool enabled);
SRSLTE_API uint32_t srslte_re_x_prb(uint32_t ns, SRSLTE_API uint32_t srslte_re_x_prb(uint32_t ns,
uint32_t symbol, uint32_t symbol,
uint32_t nof_ports, uint32_t nof_ports,

@ -63,6 +63,8 @@ SRSLTE_API bool cuhd_rx_wait_lo_locked(void *h);
SRSLTE_API void cuhd_set_master_clock_rate(void *h, SRSLTE_API void cuhd_set_master_clock_rate(void *h,
double rate); double rate);
SRSLTE_API bool cuhd_is_master_clock_dynamic(void *h);
SRSLTE_API double cuhd_set_rx_srate(void *h, SRSLTE_API double cuhd_set_rx_srate(void *h,
double freq); double freq);

@ -34,8 +34,10 @@
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/common/sequence.h" #include "srslte/common/sequence.h"
#ifndef FORCE_STANDARD_RATE #ifdef FORCE_STANDARD_RATE
#define USE_REDUCED_SAMPLING_RATES static bool use_standard_rates = true;
#else
static bool use_standard_rates = false;
#endif #endif
/* Returns true if the structure pointed by cell has valid parameters /* Returns true if the structure pointed by cell has valid parameters
@ -186,6 +188,10 @@ uint32_t srslte_N_ta_new_rar(uint32_t ta) {
} }
void srslte_use_standard_symbol_size(bool enabled) {
use_standard_rates = enabled;
}
int srslte_sampling_freq_hz(uint32_t nof_prb) { int srslte_sampling_freq_hz(uint32_t nof_prb) {
int n = srslte_symbol_sz(nof_prb); int n = srslte_symbol_sz(nof_prb);
if (n == -1) { if (n == -1) {
@ -217,7 +223,7 @@ int srslte_symbol_sz(uint32_t nof_prb) {
if (nof_prb<=0) { if (nof_prb<=0) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
#ifdef USE_REDUCED_SAMPLING_RATES if (!use_standard_rates) {
if (nof_prb<=6) { if (nof_prb<=6) {
return 128; return 128;
} else if (nof_prb<=15) { } else if (nof_prb<=15) {
@ -233,14 +239,14 @@ int srslte_symbol_sz(uint32_t nof_prb) {
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
#else } else {
return srslte_symbol_sz_power2(nof_prb); return srslte_symbol_sz_power2(nof_prb);
#endif }
} }
int srslte_nof_prb(uint32_t symbol_sz) int srslte_nof_prb(uint32_t symbol_sz)
{ {
#ifdef USE_REDUCED_SAMPLING_RATES if (!use_standard_rates) {
switch(symbol_sz) { switch(symbol_sz) {
case 128: case 128:
return 6; return 6;
@ -255,7 +261,7 @@ int srslte_nof_prb(uint32_t symbol_sz)
case 1536: case 1536:
return 100; return 100;
} }
#else } else {
switch(symbol_sz) { switch(symbol_sz) {
case 128: case 128:
return 6; return 6;
@ -270,12 +276,12 @@ int srslte_nof_prb(uint32_t symbol_sz)
case 2048: case 2048:
return 100; return 100;
} }
#endif }
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) { bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) {
#ifdef USE_REDUCED_SAMPLING_RATES if (!use_standard_rates) {
if (symbol_sz == 128 || if (symbol_sz == 128 ||
symbol_sz == 256 || symbol_sz == 256 ||
symbol_sz == 384 || symbol_sz == 384 ||
@ -286,7 +292,7 @@ bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) {
} else { } else {
return false; return false;
} }
#else } else {
if (symbol_sz == 128 || if (symbol_sz == 128 ||
symbol_sz == 256 || symbol_sz == 256 ||
symbol_sz == 512 || symbol_sz == 512 ||
@ -297,8 +303,7 @@ bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) {
} else { } else {
return false; return false;
} }
#endif }
} }
uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) { uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) {

@ -51,4 +51,5 @@ public:
size_t rx_nof_samples; size_t rx_nof_samples;
size_t tx_nof_samples; size_t tx_nof_samples;
double tx_rate; double tx_rate;
bool dynamic_rate;
}; };

@ -34,11 +34,10 @@
#include "cuhd_handler.hpp" #include "cuhd_handler.hpp"
#include "srslte/cuhd/cuhd.h" #include "srslte/cuhd/cuhd.h"
#include "srslte/srslte.h"
//#define METADATA_VERBOSE //#define METADATA_VERBOSE
//#define HIDE_MESSAGES
cuhd_msg_handler_t msg_handler; cuhd_msg_handler_t msg_handler;
void suppress_handler(uhd::msg::type_t type, const std::string & msg) void suppress_handler(uhd::msg::type_t type, const std::string & msg)
@ -218,13 +217,19 @@ void cuhd_register_msg_handler(cuhd_msg_handler_t h)
int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_rx) int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_rx)
{ {
*h = NULL;
/* Set priority to UHD threads */
uhd::set_thread_priority_safe(); uhd::set_thread_priority_safe();
/* Get multiusrp handler */
cuhd_handler *handler = new cuhd_handler(); cuhd_handler *handler = new cuhd_handler();
// Buffer sizes optimized for reduced clock rates (see common/phy_common.c)
std::string _args = std::string(args); std::string _args = std::string(args);
handler->usrp = uhd::usrp::multi_usrp::make(_args + ", recv_frame_size=9232,num_recv_frames=64,send_frame_size=9232,num_send_frames=64"); handler->usrp = uhd::usrp::multi_usrp::make(_args);// + ", recv_frame_size=9232,num_recv_frames=64,send_frame_size=9232,num_send_frames=64");
handler->usrp->set_clock_source("internal");
/* Initialize rx and tx stremers */
std::string otw, cpu; std::string otw, cpu;
otw = "sc16"; otw = "sc16";
cpu = "fc32"; cpu = "fc32";
@ -240,9 +245,7 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
handler->rx_gain_range = handler->usrp->get_rx_gain_range(); handler->rx_gain_range = handler->usrp->get_rx_gain_range();
handler->tx_gain_range = handler->usrp->get_tx_gain_range(); handler->tx_gain_range = handler->usrp->get_tx_gain_range();
/* Create auxiliary thread and mutexes for AGC */
*h = handler;
if (create_thread_gain) { if (create_thread_gain) {
if (pthread_mutex_init(&handler->mutex, NULL)) { if (pthread_mutex_init(&handler->mutex, NULL)) {
return -1; return -1;
@ -257,6 +260,26 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
} }
} }
/* Find out if the master clock rate is configurable */
double cur_clock = handler->usrp->get_master_clock_rate();
handler->usrp->set_master_clock_rate(cur_clock/2);
if (handler->usrp->get_master_clock_rate() == cur_clock) {
handler->dynamic_rate = false;
/* Master clock rate is not configurable. Check if it is compatible with LTE */
int cur_clock_i = (int) cur_clock;
if (cur_clock_i % 1920000) {
fprintf(stderr, "Error: LTE sampling rates are not supported. Master clock rate is %.1f MHz\n", cur_clock/1e6);
return -1;
} else {
printf("Master clock rate is not configurable. Using default LTE sampling rates.\n");
srslte_use_standard_symbol_size(true);
}
} else {
handler->dynamic_rate = true;
}
*h = handler;
return 0; return 0;
} }
@ -278,7 +301,14 @@ int cuhd_close(void *h)
void cuhd_set_master_clock_rate(void *h, double rate) { void cuhd_set_master_clock_rate(void *h, double rate) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); cuhd_handler *handler = static_cast < cuhd_handler * >(h);
if (handler->dynamic_rate) {
handler->usrp->set_master_clock_rate(rate); handler->usrp->set_master_clock_rate(rate);
}
}
bool cuhd_is_master_clock_dynamic(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
return handler->dynamic_rate;
} }
double cuhd_set_rx_srate(void *h, double freq) double cuhd_set_rx_srate(void *h, double freq)

@ -195,5 +195,5 @@ BuildMex(MEXNAME prach SOURCES prach_test_mex.c LIBRARIES srslte srslte_mex)
IF(UHD_FOUND) IF(UHD_FOUND)
ADD_EXECUTABLE(prach_test_usrp prach_test_usrp.c) ADD_EXECUTABLE(prach_test_usrp prach_test_usrp.c)
TARGET_LINK_LIBRARIES(prach_test_usrp srslte srslte_uhd) TARGET_LINK_LIBRARIES(prach_test_usrp srslte_uhd srslte)
ENDIF(UHD_FOUND) ENDIF(UHD_FOUND)

@ -211,7 +211,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!data_bytes) { if (!data_bytes) {
return; return;
} }
srslte_softbuffer_rx_reset(&softbuffer);
int r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, data_bytes); int r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, data_bytes);
free(data_bytes); free(data_bytes);
@ -234,9 +234,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (nlhs >= 5) { if (nlhs >= 5) {
mexutils_write_s(pdsch.e, &plhs[4], cfg.nbits.nof_bits, 1); mexutils_write_s(pdsch.e, &plhs[4], cfg.nbits.nof_bits, 1);
} }
if (nlhs >= 6) {
mexutils_write_int(indices, &plhs[5], cfg.nbits.nof_re, 1);
}
srslte_chest_dl_free(&chest); srslte_chest_dl_free(&chest);
srslte_pdsch_free(&pdsch); srslte_pdsch_free(&pdsch);

Loading…
Cancel
Save