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=[];
Npackets = 3;
SNR_values = linspace(12,16,4);
Npackets = 1;
SNR_values = 25;
%% Choose RMC
[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.9',[1;0;0;1]);
waveform = sum(waveform,2);
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.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'};
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;
end
flen=rmccFgOut.SamplingRate/1000;
Nsf = 9;
Nsf = 10;
%% Setup Fading channel model
cfg.Seed = 8; % Random channel seed
@ -78,8 +79,8 @@ for snr_idx=1:length(SNR_values)
%% Demodulate
frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform);
for sf_idx=0:Nsf
%sf_idx=9;
%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;
@ -96,9 +97,9 @@ for snr_idx=1:length(SNR_values)
%% Same with srsLTE
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), ...
subframe_rx);
subframe_rx, hest, nest);
else
dec2 = 1;
end
@ -106,7 +107,7 @@ for snr_idx=1:length(SNR_values)
fprintf('Error in sf=%d\n',sf_idx);
end
decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+dec2;
end
%end
if ~isempty(recordedSignal)
recordedSignal = recordedSignal(flen*10+1:end);

@ -142,7 +142,7 @@ int mexutils_read_uint64(const mxArray *ptr, uint64_t **buffer) {
int numelems = mxGetNumberOfElements(ptr);
uint64_t *tmp = srslte_vec_malloc(numelems * sizeof(uint64_t));
if (tmp) {
uint64_t *inr=mxGetPr(ptr);
uint64_t *inr=(uint64_t*) mxGetPr(ptr);
for (int i=0;i<numelems;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 void srslte_use_standard_symbol_size(bool enabled);
SRSLTE_API uint32_t srslte_re_x_prb(uint32_t ns,
uint32_t symbol,
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,
double rate);
SRSLTE_API bool cuhd_is_master_clock_dynamic(void *h);
SRSLTE_API double cuhd_set_rx_srate(void *h,
double freq);

@ -34,8 +34,10 @@
#include "srslte/common/phy_common.h"
#include "srslte/common/sequence.h"
#ifndef FORCE_STANDARD_RATE
#define USE_REDUCED_SAMPLING_RATES
#ifdef FORCE_STANDARD_RATE
static bool use_standard_rates = true;
#else
static bool use_standard_rates = false;
#endif
/* 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 n = srslte_symbol_sz(nof_prb);
if (n == -1) {
@ -217,7 +223,7 @@ int srslte_symbol_sz(uint32_t nof_prb) {
if (nof_prb<=0) {
return SRSLTE_ERROR;
}
#ifdef USE_REDUCED_SAMPLING_RATES
if (!use_standard_rates) {
if (nof_prb<=6) {
return 128;
} else if (nof_prb<=15) {
@ -233,14 +239,14 @@ int srslte_symbol_sz(uint32_t nof_prb) {
} else {
return SRSLTE_ERROR;
}
#else
} else {
return srslte_symbol_sz_power2(nof_prb);
#endif
}
}
int srslte_nof_prb(uint32_t symbol_sz)
{
#ifdef USE_REDUCED_SAMPLING_RATES
if (!use_standard_rates) {
switch(symbol_sz) {
case 128:
return 6;
@ -255,7 +261,7 @@ int srslte_nof_prb(uint32_t symbol_sz)
case 1536:
return 100;
}
#else
} else {
switch(symbol_sz) {
case 128:
return 6;
@ -270,12 +276,12 @@ int srslte_nof_prb(uint32_t symbol_sz)
case 2048:
return 100;
}
#endif
}
return SRSLTE_ERROR;
}
bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) {
#ifdef USE_REDUCED_SAMPLING_RATES
if (!use_standard_rates) {
if (symbol_sz == 128 ||
symbol_sz == 256 ||
symbol_sz == 384 ||
@ -286,7 +292,7 @@ bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) {
} else {
return false;
}
#else
} else {
if (symbol_sz == 128 ||
symbol_sz == 256 ||
symbol_sz == 512 ||
@ -297,8 +303,7 @@ bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) {
} else {
return false;
}
#endif
}
}
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 tx_nof_samples;
double tx_rate;
bool dynamic_rate;
};

@ -34,11 +34,10 @@
#include "cuhd_handler.hpp"
#include "srslte/cuhd/cuhd.h"
#include "srslte/srslte.h"
//#define METADATA_VERBOSE
//#define HIDE_MESSAGES
cuhd_msg_handler_t msg_handler;
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)
{
*h = NULL;
/* Set priority to UHD threads */
uhd::set_thread_priority_safe();
/* Get multiusrp 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);
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");
handler->usrp = uhd::usrp::multi_usrp::make(_args);// + ", recv_frame_size=9232,num_recv_frames=64,send_frame_size=9232,num_send_frames=64");
/* Initialize rx and tx stremers */
std::string otw, cpu;
otw = "sc16";
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->tx_gain_range = handler->usrp->get_tx_gain_range();
*h = handler;
/* Create auxiliary thread and mutexes for AGC */
if (create_thread_gain) {
if (pthread_mutex_init(&handler->mutex, NULL)) {
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;
}
@ -278,8 +301,15 @@ int cuhd_close(void *h)
void cuhd_set_master_clock_rate(void *h, double rate) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
if (handler->dynamic_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)
{

@ -195,5 +195,5 @@ BuildMex(MEXNAME prach SOURCES prach_test_mex.c LIBRARIES srslte srslte_mex)
IF(UHD_FOUND)
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)

@ -211,7 +211,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!data_bytes) {
return;
}
srslte_softbuffer_rx_reset(&softbuffer);
int r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, data_bytes);
free(data_bytes);
@ -234,9 +234,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (nlhs >= 5) {
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_pdsch_free(&pdsch);

Loading…
Cancel
Save