Merge remote-tracking branch 'origin/develop' into feature-131-new-license
Conflicts: openair1/PHY/INIT/lte_init.c openair1/PHY/LTE_TRANSPORT/dci_tools.c openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c openair1/SCHED/phy_procedures_lte_eNb.c openair1/SCHED/phy_procedures_lte_ue.c openair1/SIMULATION/LTE_PHY/dlsim.c openair1/SIMULATION/RF/adc.c openair2/LAYER2/MAC/lte_transport_init.c targets/RT/USER/lte-softmodem.c targets/RT/USER/sched_dlsch.c targets/RT/USER/sched_rx_pdsch.c targets/RT/USER/sched_ulsch.c targets/SIMU/USER/oaisim.c
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
#include <complex>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
|
||||
#include <time.h>
|
||||
#include "UTIL/LOG/log_extern.h"
|
||||
#include "common_lib.h"
|
||||
#ifdef __SSE4_1__
|
||||
# include <smmintrin.h>
|
||||
@@ -143,23 +144,54 @@ static void trx_usrp_end(openair0_device *device)
|
||||
*/
|
||||
static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags)
|
||||
{
|
||||
static long long int loop=0;
|
||||
static long time_min=0, time_max=0, time_avg=0;
|
||||
struct timespec tp_start, tp_end;
|
||||
long time_diff;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &tp_start);
|
||||
|
||||
int ret=0, ret_i=0;
|
||||
usrp_state_t *s = (usrp_state_t*)device->priv;
|
||||
|
||||
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
|
||||
|
||||
|
||||
if(flags)
|
||||
s->tx_md.has_time_spec = true;
|
||||
else
|
||||
s->tx_md.has_time_spec = false;
|
||||
|
||||
|
||||
if (cc>1) {
|
||||
std::vector<void *> buff_ptrs;
|
||||
for (int i=0;i<cc;i++) buff_ptrs.push_back(buff[i]);
|
||||
s->tx_stream->send(buff_ptrs, nsamps, s->tx_md);
|
||||
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
|
||||
}
|
||||
else
|
||||
s->tx_stream->send(buff[0], nsamps, s->tx_md);
|
||||
ret = (int)s->tx_stream->send(buff[0], nsamps, s->tx_md,1e-3);
|
||||
|
||||
s->tx_md.start_of_burst = false;
|
||||
|
||||
return 0;
|
||||
if (ret != nsamps) {
|
||||
printf("[xmit] tx samples %d != %d\n",ret,nsamps);
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &tp_end);
|
||||
time_diff = (tp_end.tv_sec - tp_start.tv_sec) *1E09 + (tp_end.tv_nsec - tp_start.tv_nsec);
|
||||
if (time_min==0 ||loop==1 || time_min > time_diff)
|
||||
time_min=time_diff;
|
||||
if (time_max==0 ||loop==1 || time_max < time_diff)
|
||||
time_max=time_diff;
|
||||
if (time_avg ==0 ||loop==1)
|
||||
time_avg= time_diff;
|
||||
else
|
||||
time_avg=(time_diff+time_avg) /2.0;
|
||||
|
||||
/* //prints statics of uhd every 10 seconds
|
||||
if ( loop % (10 * ((int)device->openair0_cfg[0].sample_rate /(int)nsamps )) ==0)
|
||||
LOG_I(HW,"usrp_write: min(ns)=%d, max(ns)=%d, avg(ns)=%d\n", (int)time_min, (int)time_max,(int)time_avg);
|
||||
*/
|
||||
loop++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*! \brief Receive samples from hardware.
|
||||
@@ -175,20 +207,25 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
|
||||
*/
|
||||
static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc)
|
||||
{
|
||||
static long long int loop=0;
|
||||
static long time_min=0, time_max=0, time_avg=0;
|
||||
struct timespec tp_start, tp_end;
|
||||
long time_diff;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &tp_start);
|
||||
usrp_state_t *s = (usrp_state_t*)device->priv;
|
||||
int samples_received=0,i,j;
|
||||
int nsamps2; // aligned to upper 32 or 16 byte boundary
|
||||
#if defined(__x86_64) || defined(__i386__)
|
||||
#ifdef __AVX2__
|
||||
__m256i buff_tmp[2][nsamps>>3];
|
||||
nsamps2 = (nsamps+7)>>3;
|
||||
__m256i buff_tmp[2][nsamps2];
|
||||
#else
|
||||
__m128i buff_tmp[2][nsamps>>2];
|
||||
nsamps2 = (nsamps+3)>>2;
|
||||
__m128i buff_tmp[2][nsamps2];
|
||||
#endif
|
||||
#elif defined(__arm__)
|
||||
int16x8_t buff_tmp[2][nsamps>>2];
|
||||
nsamps2 = (nsamps+3)>>2;
|
||||
int16x8_t buff_tmp[2][nsamps2];
|
||||
#endif
|
||||
|
||||
|
||||
@@ -203,7 +240,7 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
|
||||
// receive a single channel (e.g. from connector RF A)
|
||||
samples_received = s->rx_stream->recv(buff_tmp[0], nsamps, s->rx_md);
|
||||
}
|
||||
|
||||
|
||||
// bring RX data into 12 LSBs for softmodem RX
|
||||
for (int i=0;i<cc;i++) {
|
||||
for (int j=0; j<nsamps2; j++) {
|
||||
@@ -219,7 +256,7 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
|
||||
}
|
||||
}
|
||||
} else if (device->type == USRP_X300_DEV) {
|
||||
if (cc>1) {
|
||||
if (cc>1) {
|
||||
// receive multiple channels (e.g. RF A and RF B)
|
||||
std::vector<void *> buff_ptrs;
|
||||
|
||||
@@ -255,6 +292,22 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
|
||||
s->rx_timestamp = s->rx_md.time_spec.to_ticks(s->sample_rate);
|
||||
*ptimestamp = s->rx_timestamp;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &tp_end);
|
||||
time_diff = (tp_end.tv_sec - tp_start.tv_sec) *1E09 + (tp_end.tv_nsec - tp_start.tv_nsec);
|
||||
if (time_min==0 ||loop==1 || time_min > time_diff)
|
||||
time_min=time_diff;
|
||||
if (time_max==0 ||loop==1 || time_max < time_diff)
|
||||
time_max=time_diff;
|
||||
if (time_avg ==0 ||loop==1)
|
||||
time_avg= time_diff;
|
||||
else
|
||||
time_avg=(time_diff+time_avg) /2.0;
|
||||
/*
|
||||
//prints statics of uhd every 10 seconds
|
||||
if ( loop % (10 * ((int)device->openair0_cfg[0].sample_rate /(int)nsamps )) ==0)
|
||||
LOG_I(HW,"usrp_read: min(ns)=%d, max(ns)=%d, avg(ns)=%d\n", (int)time_min, (int)time_max,(int)time_avg);
|
||||
|
||||
loop++;*/
|
||||
return samples_received;
|
||||
}
|
||||
|
||||
@@ -346,7 +399,7 @@ int trx_usrp_set_gains(openair0_device* device,
|
||||
/*! \brief Stop USRP
|
||||
* \param card refers to the hardware index to use
|
||||
*/
|
||||
int trx_usrp_stop(int card) {
|
||||
int trx_usrp_stop(openair0_device* device) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -462,6 +515,7 @@ extern "C" {
|
||||
|
||||
// Initialize USRP device
|
||||
|
||||
device->openair0_cfg = openair0_cfg;
|
||||
|
||||
std::string args = "type=b200";
|
||||
|
||||
@@ -485,6 +539,8 @@ extern "C" {
|
||||
// workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate
|
||||
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
|
||||
|
||||
// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096";
|
||||
|
||||
uhd::device_addrs_t device_adds = uhd::device::find(args);
|
||||
|
||||
if(device_adds.size() == 0)
|
||||
@@ -516,32 +572,28 @@ extern "C" {
|
||||
switch ((int)openair0_cfg[0].sample_rate) {
|
||||
case 30720000:
|
||||
// from usrp_time_offset
|
||||
openair0_cfg[0].samples_per_packet = 2048;
|
||||
//openair0_cfg[0].samples_per_packet = 2048;
|
||||
openair0_cfg[0].tx_sample_advance = 15;
|
||||
openair0_cfg[0].tx_bw = 20e6;
|
||||
openair0_cfg[0].rx_bw = 20e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
case 15360000:
|
||||
openair0_cfg[0].samples_per_packet = 2048;
|
||||
//openair0_cfg[0].samples_per_packet = 2048;
|
||||
openair0_cfg[0].tx_sample_advance = 45;
|
||||
openair0_cfg[0].tx_bw = 10e6;
|
||||
openair0_cfg[0].rx_bw = 10e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
case 7680000:
|
||||
openair0_cfg[0].samples_per_packet = 1024;
|
||||
//openair0_cfg[0].samples_per_packet = 2048;
|
||||
openair0_cfg[0].tx_sample_advance = 50;
|
||||
openair0_cfg[0].tx_bw = 5e6;
|
||||
openair0_cfg[0].rx_bw = 5e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
case 1920000:
|
||||
openair0_cfg[0].samples_per_packet = 256;
|
||||
//openair0_cfg[0].samples_per_packet = 2048;
|
||||
openair0_cfg[0].tx_sample_advance = 50;
|
||||
openair0_cfg[0].tx_bw = 1.25e6;
|
||||
openair0_cfg[0].rx_bw = 1.25e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
default:
|
||||
printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
|
||||
@@ -551,7 +603,7 @@ extern "C" {
|
||||
|
||||
} else {
|
||||
printf("Found USRP B200");
|
||||
args += ",num_recv_frames=256" ;
|
||||
args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096" ;
|
||||
s->usrp = uhd::usrp::multi_usrp::make(args);
|
||||
|
||||
// s->usrp->set_rx_subdev_spec(rx_subdev);
|
||||
@@ -577,43 +629,38 @@ extern "C" {
|
||||
switch ((int)openair0_cfg[0].sample_rate) {
|
||||
case 30720000:
|
||||
s->usrp->set_master_clock_rate(30.72e6);
|
||||
openair0_cfg[0].samples_per_packet = 4096;
|
||||
//openair0_cfg[0].samples_per_packet = 1024;
|
||||
openair0_cfg[0].tx_sample_advance = 115;
|
||||
openair0_cfg[0].tx_bw = 20e6;
|
||||
openair0_cfg[0].rx_bw = 20e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 11*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
case 23040000:
|
||||
s->usrp->set_master_clock_rate(23.04e6); //to be checked
|
||||
openair0_cfg[0].samples_per_packet = 2048;
|
||||
//openair0_cfg[0].samples_per_packet = 1024;
|
||||
openair0_cfg[0].tx_sample_advance = 113;
|
||||
openair0_cfg[0].tx_bw = 20e6;
|
||||
openair0_cfg[0].rx_bw = 20e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
case 15360000:
|
||||
s->usrp->set_master_clock_rate(30.72e06);
|
||||
openair0_cfg[0].samples_per_packet = 2048;
|
||||
//openair0_cfg[0].samples_per_packet = 1024;
|
||||
openair0_cfg[0].tx_sample_advance = 103;
|
||||
openair0_cfg[0].tx_bw = 20e6;
|
||||
openair0_cfg[0].rx_bw = 20e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 10240;
|
||||
break;
|
||||
case 7680000:
|
||||
s->usrp->set_master_clock_rate(30.72e6);
|
||||
openair0_cfg[0].samples_per_packet = 1024;
|
||||
//openair0_cfg[0].samples_per_packet = 1024;
|
||||
openair0_cfg[0].tx_sample_advance = 80;
|
||||
openair0_cfg[0].tx_bw = 20e6;
|
||||
openair0_cfg[0].rx_bw = 20e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
case 1920000:
|
||||
s->usrp->set_master_clock_rate(7.68e6);
|
||||
openair0_cfg[0].samples_per_packet = 256;
|
||||
s->usrp->set_master_clock_rate(30.72e6);
|
||||
//openair0_cfg[0].samples_per_packet = 1024;
|
||||
openair0_cfg[0].tx_sample_advance = 40;
|
||||
openair0_cfg[0].tx_bw = 20e6;
|
||||
openair0_cfg[0].rx_bw = 20e6;
|
||||
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
|
||||
break;
|
||||
default:
|
||||
printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
|
||||
@@ -623,8 +670,8 @@ extern "C" {
|
||||
}
|
||||
|
||||
/* device specific */
|
||||
openair0_cfg[0].txlaunch_wait = 1;//manage when TX processing is triggered
|
||||
openair0_cfg[0].txlaunch_wait_slotcount = 1; //manage when TX processing is triggered
|
||||
//openair0_cfg[0].txlaunch_wait = 1;//manage when TX processing is triggered
|
||||
//openair0_cfg[0].txlaunch_wait_slotcount = 1; //manage when TX processing is triggered
|
||||
openair0_cfg[0].iq_txshift = 4;//shift
|
||||
openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
|
||||
|
||||
@@ -734,7 +781,8 @@ extern "C" {
|
||||
device->trx_stop_func = trx_usrp_stop;
|
||||
device->trx_set_freq_func = trx_usrp_set_freq;
|
||||
device->trx_set_gains_func = trx_usrp_set_gains;
|
||||
|
||||
device->openair0_cfg = openair0_cfg;
|
||||
|
||||
s->sample_rate = openair0_cfg[0].sample_rate;
|
||||
// TODO:
|
||||
// init tx_forward_nsamps based usrp_time_offset ex
|
||||
|
||||
Reference in New Issue
Block a user