summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-08 17:07:41 -0700
committerJosh Blum <josh@joshknows.com>2010-06-08 17:07:41 -0700
commit8c7b73ee536357d2f7efc4558b531575fa28ca31 (patch)
treee52fc304d904e5cc10c69c9e0d158f0e3e5c2090
parent185971dd625034366b2d1420b74c3de072a90330 (diff)
downloaduhd-8c7b73ee536357d2f7efc4558b531575fa28ca31.tar.gz
uhd-8c7b73ee536357d2f7efc4558b531575fa28ca31.tar.bz2
uhd-8c7b73ee536357d2f7efc4558b531575fa28ca31.zip
fixed converter logic in convert types
-rwxr-xr-xhost/lib/transport/gen_convert_types.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/host/lib/transport/gen_convert_types.py b/host/lib/transport/gen_convert_types.py
index 1b6b71e00..af2bcc7cb 100755
--- a/host/lib/transport/gen_convert_types.py
+++ b/host/lib/transport/gen_convert_types.py
@@ -56,30 +56,29 @@ static const float floats_per_short = float(1.0/shorts_per_float);
/***********************************************************************
* Single-sample converters
**********************************************************************/
-template<typename outptr_type, typename inptr_type>
-static UHD_INLINE outptr_type conv_ptr(inptr_type inptr){
- return reinterpret_cast<outptr_type>(inptr);
-}
-
static UHD_INLINE item32_t sc16_to_item32(sc16_t num){
- return *conv_ptr<item32_t*>(&num);
+ boost::uint16_t real = boost::int16_t(num.real());
+ boost::uint16_t imag = boost::int16_t(num.imag());
+ return (item32_t(real) << 16) | (item32_t(imag) << 0);
}
static UHD_INLINE sc16_t item32_to_sc16(item32_t item){
- return *conv_ptr<sc16_t*>(&item);
+ return sc16_t(
+ boost::uint16_t(item >> 16),
+ boost::uint16_t(item >> 0)
+ );
}
static UHD_INLINE item32_t fc32_to_item32(fc32_t num){
- return sc16_to_item32(sc16_t(
- boost::int16_t(num.real()*shorts_per_float),
- boost::int16_t(num.imag()*shorts_per_float)
- ));
+ boost::uint16_t real = boost::int16_t(num.real()*shorts_per_float);
+ boost::uint16_t imag = boost::int16_t(num.imag()*shorts_per_float);
+ return (item32_t(real) << 16) | (item32_t(imag) << 0);
}
static UHD_INLINE fc32_t item32_to_fc32(item32_t item){
- sc16_t num = item32_to_sc16(item); return fc32_t(
- float(num.real()*floats_per_short),
- float(num.imag()*floats_per_short)
+ return fc32_t(
+ float(boost::int16_t(item >> 16)*floats_per_short),
+ float(boost::int16_t(item >> 0)*floats_per_short)
);
}
@@ -120,7 +119,7 @@ void transport::convert_io_type_to_otw_type(
size_t num_samps
){
switch(get_pred(io_type, otw_type)){
- #for $pred in range(4)
+ #for $pred in range(2**$ph.nbits)
case $pred:
#set $out_type = $ph.get_dev_type($pred)
#set $in_type = $ph.get_host_type($pred)
@@ -167,6 +166,8 @@ class ph:
sc16_p = 0b00010
fc32_p = 0b00000
+ nbits = 2 #see above
+
@staticmethod
def get_xe_macro(pred):
if (pred & ph.be_p) == ph.be_p: return 'BE_MACRO'