aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/convert/gen_convert_general.py
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-03 16:46:00 -0700
committerJosh Blum <josh@joshknows.com>2011-11-03 20:37:10 -0700
commit75b7967fac3ec72fb35c542da23491215d53a8bb (patch)
treefa588c1e71bb7cbc751d2f5738bb37aad5cfec45 /host/lib/convert/gen_convert_general.py
parentc480414fea7948dedd9428f545dfff90f4c8f2c8 (diff)
downloaduhd-75b7967fac3ec72fb35c542da23491215d53a8bb.tar.gz
uhd-75b7967fac3ec72fb35c542da23491215d53a8bb.tar.bz2
uhd-75b7967fac3ec72fb35c542da23491215d53a8bb.zip
convert: reworked convert to use new identification standard
Diffstat (limited to 'host/lib/convert/gen_convert_general.py')
-rw-r--r--host/lib/convert/gen_convert_general.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py
index 8c3138bda..0d68a4dd3 100644
--- a/host/lib/convert/gen_convert_general.py
+++ b/host/lib/convert/gen_convert_general.py
@@ -29,26 +29,26 @@ using namespace uhd::convert;
"""
TMPL_CONV_TO_FROM_ITEM32_1 = """
-DECLARE_CONVERTER(convert_$(cpu_type)_1_to_item32_1_$(swap), PRIORITY_GENERAL){
+DECLARE_CONVERTER($(cpu_type), 1, sc16_item32_$(end), 1, PRIORITY_GENERAL){
const $(cpu_type)_t *input = reinterpret_cast<const $(cpu_type)_t *>(inputs[0]);
item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
for (size_t i = 0; i < nsamps; i++){
- output[i] = $(swap_fcn)($(cpu_type)_to_item32(input[i], float(scale_factor)));
+ output[i] = $(to_wire)($(cpu_type)_to_item32(input[i], float(scale_factor)));
}
}
-DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_1_$(swap), PRIORITY_GENERAL){
+DECLARE_CONVERTER(sc16_item32_$(end), 1, $(cpu_type), 1, PRIORITY_GENERAL){
const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
$(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]);
for (size_t i = 0; i < nsamps; i++){
- output[i] = item32_to_$(cpu_type)($(swap_fcn)(input[i]), float(scale_factor));
+ output[i] = item32_to_$(cpu_type)($(to_host)(input[i]), float(scale_factor));
}
}
"""
TMPL_CONV_TO_FROM_ITEM32_X = """
-DECLARE_CONVERTER(convert_$(cpu_type)_$(width)_to_item32_1_$(swap), PRIORITY_GENERAL){
+DECLARE_CONVERTER($(cpu_type), $(width), sc16_item32_$(end), 1, PRIORITY_GENERAL){
#for $w in range($width)
const $(cpu_type)_t *input$(w) = reinterpret_cast<const $(cpu_type)_t *>(inputs[$(w)]);
#end for
@@ -56,12 +56,12 @@ DECLARE_CONVERTER(convert_$(cpu_type)_$(width)_to_item32_1_$(swap), PRIORITY_GEN
for (size_t i = 0, j = 0; i < nsamps; i++){
#for $w in range($width)
- output[j++] = $(swap_fcn)($(cpu_type)_to_item32(input$(w)[i], float(scale_factor)));
+ output[j++] = $(to_wire)($(cpu_type)_to_item32(input$(w)[i], float(scale_factor)));
#end for
}
}
-DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_$(width)_$(swap), PRIORITY_GENERAL){
+DECLARE_CONVERTER(sc16_item32_$(end), 1, $(cpu_type), $(width), PRIORITY_GENERAL){
const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
#for $w in range($width)
$(cpu_type)_t *output$(w) = reinterpret_cast<$(cpu_type)_t *>(outputs[$(w)]);
@@ -69,7 +69,7 @@ DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_$(width)_$(swap), PRIORITY_GEN
for (size_t i = 0, j = 0; i < nsamps; i++){
#for $w in range($width)
- output$(w)[i] = item32_to_$(cpu_type)($(swap_fcn)(input[j++]), float(scale_factor));
+ output$(w)[i] = item32_to_$(cpu_type)($(to_host)(input[j++]), float(scale_factor));
#end for
}
}
@@ -84,10 +84,13 @@ if __name__ == '__main__':
file = os.path.basename(__file__)
output = parse_tmpl(TMPL_HEADER, file=file)
for width in 1, 2, 3, 4:
- for swap, swap_fcn in (('nswap', ''), ('bswap', 'uhd::byteswap')):
+ for end, to_host, to_wire in (
+ ('be', 'uhd::ntohx', 'uhd::htonx'),
+ ('le', 'uhd::wtohx', 'uhd::htowx'),
+ ):
for cpu_type in 'fc64', 'fc32', 'sc16':
output += parse_tmpl(
TMPL_CONV_TO_FROM_ITEM32_1 if width == 1 else TMPL_CONV_TO_FROM_ITEM32_X,
- width=width, swap=swap, swap_fcn=swap_fcn, cpu_type=cpu_type
+ width=width, end=end, to_host=to_host, to_wire=to_wire, cpu_type=cpu_type
)
open(sys.argv[1], 'w').write(output)