summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorNick Foster <nick@ettus.com>2011-05-23 21:49:28 -0700
committerJosh Blum <josh@joshknows.com>2011-06-14 17:27:46 -0700
commit3dca19a3e7f56c64423789ee025f16150b1a2cdb (patch)
tree6d168b13e0a73c9606dc168752879ee8bbb86498 /host
parent75d0a41c3a7a2c7cd62a6c6b27e648d5617d488e (diff)
downloaduhd-3dca19a3e7f56c64423789ee025f16150b1a2cdb.tar.gz
uhd-3dca19a3e7f56c64423789ee025f16150b1a2cdb.tar.bz2
uhd-3dca19a3e7f56c64423789ee025f16150b1a2cdb.zip
UHD: Fixed convert_test (scalars backwards), fixed Orc conversions (endianness backwards).
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/convert.hpp2
-rw-r--r--host/lib/convert/convert_orc.orc13
-rw-r--r--host/lib/convert/convert_with_orc.cpp5
-rw-r--r--host/tests/convert_test.cpp10
4 files changed, 24 insertions, 6 deletions
diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp
index 99f1860ae..c30484384 100644
--- a/host/include/uhd/convert.hpp
+++ b/host/include/uhd/convert.hpp
@@ -40,7 +40,7 @@ namespace uhd{ namespace convert{
*/
enum priority_type{
PRIORITY_GENERAL = 0,
- PRIORITY_LIBORC = 1,
+ PRIORITY_LIBORC = 4,
PRIORITY_CUSTOM = 2,
PRIORITY_EMPTY = -1,
};
diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc
index c1c3d3c24..83e63f22c 100644
--- a/host/lib/convert/convert_orc.orc
+++ b/host/lib/convert/convert_orc.orc
@@ -11,3 +11,16 @@ x2 convfl converted, scaled
x2 convlw short, converted
swapl short, short
x2 swapw dst, short
+
+.function _convert_fc32_1_to_item32_1_bswap_orc
+.source 8 src
+.dest 4 dst
+.floatparam 4 scalar
+.temp 8 scaled
+.temp 8 converted
+.temp 4 short
+
+x2 mulf scaled, src, scalar
+x2 convfl converted, scaled
+x2 convlw short, converted
+x2 swapw dst, short
diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp
index dded22b9d..2d50351e4 100644
--- a/host/lib/convert/convert_with_orc.cpp
+++ b/host/lib/convert/convert_with_orc.cpp
@@ -23,8 +23,13 @@ using namespace uhd::convert;
extern "C" {
extern void _convert_fc32_1_to_item32_1_nswap_orc(void *, const void *, float, int);
+extern void _convert_fc32_1_to_item32_1_bswap_orc(void *, const void *, float, int);
}
DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_LIBORC){
_convert_fc32_1_to_item32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps);
}
+
+DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_LIBORC){
+ _convert_fc32_1_to_item32_1_bswap_orc(outputs[0], inputs[0], scale_factor, nsamps);
+}
diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp
index ff37d4a0a..d828ed64a 100644
--- a/host/tests/convert_test.cpp
+++ b/host/tests/convert_test.cpp
@@ -31,7 +31,7 @@ typedef std::complex<boost::int16_t> sc16_t;
typedef std::complex<float> fc32_t;
typedef std::complex<double> fc64_t;
-#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f) and std::abs(b) > (f))) \
+#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f))) \
BOOST_CHECK_CLOSE_FRACTION(a, b, f)
/***********************************************************************
@@ -55,12 +55,12 @@ template <typename Range> static void loopback(
//convert to intermediate type
convert::get_converter_cpu_to_otw(
io_type, otw_type, input0.size(), output0.size()
- )(input0, output0, nsamps, 1/32767.);
+ )(input0, output0, nsamps, 32767.);
//convert back to host type
convert::get_converter_otw_to_cpu(
io_type, otw_type, input1.size(), output1.size()
- )(input1, output1, nsamps, 32767.);
+ )(input1, output1, nsamps, 1/32767.);
}
/***********************************************************************
@@ -207,12 +207,12 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){
//convert float to intermediate
convert::get_converter_cpu_to_otw(
io_type_in, otw_type, input0.size(), output0.size()
- )(input0, output0, nsamps, 1/32767.);
+ )(input0, output0, nsamps, 32767.);
//convert intermediate to short
convert::get_converter_otw_to_cpu(
io_type_out, otw_type, input1.size(), output1.size()
- )(input1, output1, nsamps, 32767.);
+ )(input1, output1, nsamps, 1/32767.);
//test that the inputs and outputs match
for (size_t i = 0; i < nsamps; i++){