aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/convert/gen_convert_pred.py
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/convert/gen_convert_pred.py')
-rw-r--r--host/lib/convert/gen_convert_pred.py91
1 files changed, 56 insertions, 35 deletions
diff --git a/host/lib/convert/gen_convert_pred.py b/host/lib/convert/gen_convert_pred.py
index 1d573bf1a..d2f90bf41 100644
--- a/host/lib/convert/gen_convert_pred.py
+++ b/host/lib/convert/gen_convert_pred.py
@@ -21,8 +21,6 @@ TMPL_TEXT = """
/***********************************************************************
* This file was generated by $file on $time.strftime("%c")
**********************************************************************/
-typedef size_t pred_type;
-
\#include <boost/tokenizer.hpp>
\#include <boost/lexical_cast.hpp>
\#include <boost/detail/endian.hpp>
@@ -31,6 +29,9 @@ typedef size_t pred_type;
\#include <string>
\#include <vector>
+typedef size_t pred_type;
+typedef std::vector<pred_type> pred_vector_type;
+
enum dir_type{
DIR_OTW_TO_CPU = 0,
DIR_CPU_TO_OTW = 1
@@ -69,8 +70,10 @@ pred_type make_pred(const std::string &markup, dir_type &dir){
dir = DIR_OTW_TO_CPU;
}
- if (cpu_type == "fc32") pred |= $ph.fc32_p;
+ if (cpu_type == "fc64") pred |= $ph.fc64_p;
+ else if (cpu_type == "fc32") pred |= $ph.fc32_p;
else if (cpu_type == "sc16") pred |= $ph.sc16_p;
+ else if (cpu_type == "sc8") pred |= $ph.sc8_p;
else throw pred_error("unhandled io type " + cpu_type);
if (otw_type == "item32") pred |= $ph.item32_p;
@@ -99,44 +102,60 @@ pred_type make_pred(const std::string &markup, dir_type &dir){
return pred;
}
+#define pred_table_wildcard pred_type(~0)
+#define pred_table_max_size size_t(128)
+#define pred_table_index(e) (pred_type(e) & 0x7f)
+
+static pred_vector_type get_pred_byte_order_table(void){
+ pred_vector_type table(pred_table_max_size, pred_table_wildcard);
+ \#ifdef BOOST_BIG_ENDIAN
+ table[pred_table_index(otw_type_t::BO_BIG_ENDIAN)] = $ph.nswap_p;
+ table[pred_table_index(otw_type_t::BO_LITTLE_ENDIAN)] = $ph.bswap_p;
+ \#else
+ table[pred_table_index(otw_type_t::BO_BIG_ENDIAN)] = $ph.bswap_p;
+ table[pred_table_index(otw_type_t::BO_LITTLE_ENDIAN)] = $ph.nswap_p;
+ \#endif
+ table[pred_table_index(otw_type_t::BO_NATIVE)] = $ph.nswap_p;
+ return table;
+}
+
+static pred_vector_type get_pred_io_type_table(void){
+ pred_vector_type table(pred_table_max_size, pred_table_wildcard);
+ table[pred_table_index(io_type_t::COMPLEX_FLOAT64)] = $ph.fc64_p;
+ table[pred_table_index(io_type_t::COMPLEX_FLOAT32)] = $ph.fc32_p;
+ table[pred_table_index(io_type_t::COMPLEX_INT16)] = $ph.sc16_p;
+ return table;
+}
+
+static pred_vector_type get_pred_num_io_table(void){
+ pred_vector_type table(pred_table_max_size, pred_table_wildcard);
+ table[1] = $ph.chan1_p;
+ table[2] = $ph.chan2_p;
+ table[3] = $ph.chan3_p;
+ table[4] = $ph.chan4_p;
+ return table;
+}
+
UHD_INLINE pred_type make_pred(
const io_type_t &io_type,
const otw_type_t &otw_type,
size_t num_inputs,
size_t num_outputs
){
- pred_type pred = 0;
+ pred_type pred = $ph.item32_p; //only item32 supported as of now
- switch(otw_type.byteorder){
- \#ifdef BOOST_BIG_ENDIAN
- case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.nswap_p; break;
- case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.bswap_p; break;
- \#else
- case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.bswap_p; break;
- case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.nswap_p; break;
- \#endif
- case otw_type_t::BO_NATIVE: pred |= $ph.nswap_p; break;
- default: throw pred_error("unhandled otw byteorder type");
- }
+ static const pred_vector_type pred_byte_order_table(get_pred_byte_order_table());
+ pred |= pred_byte_order_table[pred_table_index(otw_type.byteorder)];
- switch(otw_type.get_sample_size()){
- case sizeof(boost::uint32_t): pred |= $ph.item32_p; break;
- default: throw pred_error("unhandled otw sample size");
- }
+ static const pred_vector_type pred_io_type_table(get_pred_io_type_table());
+ pred |= pred_io_type_table[pred_table_index(io_type.tid)];
- switch(io_type.tid){
- case io_type_t::COMPLEX_FLOAT32: pred |= $ph.fc32_p; break;
- case io_type_t::COMPLEX_INT16: pred |= $ph.sc16_p; break;
- default: throw pred_error("unhandled io type id");
- }
+ static const pred_vector_type pred_num_io_table(get_pred_num_io_table());
+ pred |= pred_num_io_table[pred_table_index(num_inputs*num_outputs)];
- switch(num_inputs*num_outputs){ //FIXME treated as one value
- case 1: pred |= $ph.chan1_p; break;
- case 2: pred |= $ph.chan2_p; break;
- case 3: pred |= $ph.chan3_p; break;
- case 4: pred |= $ph.chan4_p; break;
- default: throw pred_error("unhandled number of channels");
- }
+ if (pred == pred_table_wildcard) throw pred_error(
+ "unhanded input combination for make_pred()"
+ );
return pred;
}
@@ -150,12 +169,14 @@ class ph:
bswap_p = 0b00001
nswap_p = 0b00000
item32_p = 0b00000
+ sc8_p = 0b00000
sc16_p = 0b00010
- fc32_p = 0b00000
+ fc32_p = 0b00100
+ fc64_p = 0b00110
chan1_p = 0b00000
- chan2_p = 0b00100
- chan3_p = 0b01000
- chan4_p = 0b01100
+ chan2_p = 0b01000
+ chan3_p = 0b10000
+ chan4_p = 0b11000
if __name__ == '__main__':
import sys, os