Commit 91f312eb authored by Raymond Knopp's avatar Raymond Knopp

12->16bit rescaling (transmission) for USRP device

parent 0fccd994
......@@ -148,6 +148,35 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
int ret=0;
usrp_state_t *s = (usrp_state_t*)device->priv;
int nsamps2; // aligned to upper 32 or 16 byte boundary
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
__m256i buff_tx[2][nsamps2];
#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[2][nsamps2];
#endif
#elif defined(__arm__)
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[2][nsamps2];
#endif
// bring RX data into 12 LSBs for softmodem RX
for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
buff_tx[i][j] = _mm256_slli_epi16(((__m256i*)buff[i])[j],4);
#else
buff_tx[i][j] = _mm_slli_epi16(((__m128i*)buff128[i])[j],4);
#endif
#elif defined(__arm__)
buff_tx[i][j] = vshlq_n_s16(((int16x8_t*)buff128[i])[j],4);
#endif
}
}
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_md.has_time_spec = flags;
......@@ -174,10 +203,10 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
if (cc>1) {
std::vector<void *> buff_ptrs;
for (int i=0; i<cc; i++)
buff_ptrs.push_back(buff[i]);
buff_ptrs.push_back(buff_tx[i]);
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
} else
ret = (int)s->tx_stream->send(buff[0], nsamps, s->tx_md,1e-3);
ret = (int)s->tx_stream->send(buff_tx[0], nsamps, s->tx_md,1e-3);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment