aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/radioInterface.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-08-20 20:54:54 -0400
committerThomas Tsou <tom@tsou.cc>2013-10-18 13:10:17 -0400
commit03e6ecf9771ea029e69fd4cdc2f2e289e93d3978 (patch)
tree9bd4abdc74ba979a051386b1d730378ae254bdab /Transceiver52M/radioInterface.cpp
parent3eaae80c90752abe3173c43a5dae5cdf17493764 (diff)
Transceiver52M: Replace resampler with SSE enabled implementation
Replace the polyphase filter and resampler with a separate implementation using SSE enabled convolution. The USRP2 (including derived devices N200, N210) are the only supported devices that require sample rate conversion, so set the default resampling parameters for the 100 MHz FPGA clock. This changes the previous resampling ratios. 270.833 kHz -> 400 kHz (65 / 96) 270.833 kHz -> 390.625 kHz (52 / 75) The new resampling factor uses a USRP resampling factor of 256 instead of 250. On the device, this allows two halfband filters to be used rather than one. The end result is reduced distortial and aliasing effecits from CIC filter rolloff. B100 and USRP1 will no be supported at 400 ksps with these changes. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/radioInterface.cpp')
-rw-r--r--Transceiver52M/radioInterface.cpp72
1 files changed, 51 insertions, 21 deletions
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp
index e3fa2a4..1e25b5d 100644
--- a/Transceiver52M/radioInterface.cpp
+++ b/Transceiver52M/radioInterface.cpp
@@ -53,18 +53,47 @@ RadioInterface::RadioInterface(RadioDevice *wRadio,
int wReceiveOffset,
int wSPS,
GSM::Time wStartTime)
- : underrun(false), sendCursor(0), rcvCursor(0), mOn(false),
+ : underrun(false), sendCursor(0), recvCursor(0), mOn(false),
mRadio(wRadio), receiveOffset(wReceiveOffset),
sps(wSPS), powerScaling(1.0),
- loadTest(false)
+ loadTest(false), sendBuffer(NULL), recvBuffer(NULL),
+ convertRecvBuffer(NULL), convertSendBuffer(NULL)
{
mClock.set(wStartTime);
}
+RadioInterface::~RadioInterface(void)
+{
+ close();
+}
+
+bool RadioInterface::init()
+{
+ close();
+
+ sendBuffer = new signalVector(OUTCHUNK * 20);
+ recvBuffer = new signalVector(INCHUNK * 20);
+
+ convertSendBuffer = new short[OUTCHUNK * 2 * 20];
+ convertRecvBuffer = new short[OUTCHUNK * 2 * 2];
+
+ sendCursor = 0;
+ recvCursor = 0;
-RadioInterface::~RadioInterface(void) {
- if (rcvBuffer!=NULL) delete rcvBuffer;
- //mReceiveFIFO.clear();
+ return true;
+}
+
+void RadioInterface::close()
+{
+ delete sendBuffer;
+ delete recvBuffer;
+ delete convertSendBuffer;
+ delete convertRecvBuffer;
+
+ sendBuffer = NULL;
+ recvBuffer = NULL;
+ convertRecvBuffer = NULL;
+ convertSendBuffer = NULL;
}
double RadioInterface::fullScaleInputValue(void) {
@@ -150,9 +179,6 @@ void RadioInterface::start()
mRadio->updateAlignment(writeTimestamp-10000);
mRadio->updateAlignment(writeTimestamp-10000);
- sendBuffer = new float[2*2*INCHUNK*sps];
- rcvBuffer = new float[2*2*OUTCHUNK*sps];
-
mOn = true;
}
@@ -173,11 +199,14 @@ void RadioInterface::alignRadio() {
}
#endif
-void RadioInterface::driveTransmitRadio(signalVector &radioBurst, bool zeroBurst) {
-
- if (!mOn) return;
+void RadioInterface::driveTransmitRadio(signalVector &radioBurst, bool zeroBurst)
+{
+ if (!mOn)
+ return;
- radioifyVector(radioBurst, sendBuffer + 2 * sendCursor, powerScaling, zeroBurst);
+ radioifyVector(radioBurst,
+ (float *) (sendBuffer->begin() + sendCursor),
+ powerScaling, zeroBurst);
sendCursor += radioBurst.size();
@@ -195,7 +224,7 @@ void RadioInterface::driveReceiveRadio() {
GSM::Time rcvClock = mClock.get();
rcvClock.decTN(receiveOffset);
unsigned tN = rcvClock.TN();
- int rcvSz = rcvCursor;
+ int rcvSz = recvCursor;
int readSz = 0;
const int symbolsPerSlot = gSlotLen + 8;
@@ -204,7 +233,7 @@ void RadioInterface::driveReceiveRadio() {
// Using the 157-156-156-156 symbols per timeslot format.
while (rcvSz > (symbolsPerSlot + (tN % 4 == 0)) * sps) {
signalVector rxVector((symbolsPerSlot + (tN % 4 == 0)) * sps);
- unRadioifyVector(rcvBuffer+readSz*2,rxVector);
+ unRadioifyVector((float *) (recvBuffer->begin() + readSz), rxVector);
GSM::Time tmpTime = rcvClock;
if (rcvClock.FN() >= 0) {
//LOG(DEBUG) << "FN: " << rcvClock.FN();
@@ -221,8 +250,6 @@ void RadioInterface::driveReceiveRadio() {
}
mClock.incTN();
rcvClock.incTN();
- //if (mReceiveFIFO.size() >= 16) mReceiveFIFO.wait(8);
- //LOG(DEBUG) << "receiveFIFO: wrote radio vector at time: " << mClock.get() << ", new size: " << mReceiveFIFO.size() ;
readSz += (symbolsPerSlot+(tN % 4 == 0)) * sps;
rcvSz -= (symbolsPerSlot+(tN % 4 == 0)) * sps;
@@ -230,8 +257,11 @@ void RadioInterface::driveReceiveRadio() {
}
if (readSz > 0) {
- rcvCursor -= readSz;
- memmove(rcvBuffer,rcvBuffer+2*readSz,sizeof(float) * 2 * rcvCursor);
+ memmove(recvBuffer->begin(),
+ recvBuffer->begin() + readSz,
+ (recvCursor - readSz) * 2 * sizeof(float));
+
+ recvCursor -= readSz;
}
}
@@ -274,8 +304,8 @@ void RadioInterface::pullBuffer()
underrun |= local_underrun;
readTimestamp += (TIMESTAMP) num_rd;
- shortToFloat(rcvBuffer + 2 * rcvCursor, rx_buf, num_rd);
- rcvCursor += num_rd;
+ shortToFloat((float *) recvBuffer->begin() + recvCursor, rx_buf, num_rd);
+ recvCursor += num_rd;
}
/* Send timestamped chunk to the device with arbitrary size */
@@ -284,7 +314,7 @@ void RadioInterface::pushBuffer()
if (sendCursor < INCHUNK)
return;
- floatToShort(tx_buf, sendBuffer, sendCursor);
+ floatToShort(tx_buf, (float *) sendBuffer->begin(), sendCursor);
/* Write samples. Fail if we don't get what we want. */
int num_smpls = mRadio->writeSamples(tx_buf,