From c8b633207f42b85480635573fd2a271b842c1260 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Fri, 8 Mar 2024 01:11:21 -0600 Subject: platform/wavelet3d: implement int->float conversion --- platform/wavelet3d/main.cpp | 67 ++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 19 deletions(-) (limited to 'platform/wavelet3d/main.cpp') diff --git a/platform/wavelet3d/main.cpp b/platform/wavelet3d/main.cpp index 1bffb68..037aee4 100644 --- a/platform/wavelet3d/main.cpp +++ b/platform/wavelet3d/main.cpp @@ -23,18 +23,41 @@ int main(int argc, char **argv) Py_Initialize(); - float a, b; + float q; + int a, b; + const char *op = "int->fp"; + std::cin >> a >> b; + // int->fp + top.mul_float_m1 = 0; + top.unit_b_m1 = 1; + top.float_a_1 = 0; + top.int_hi_a_1 = 0; + top.int_lo_a_1 = 1; + top.zero_flags_1 = 1; + top.zero_b_1 = 1; + top.copy_flags_2 = 0; + top.int_signed_4 = 1; + top.int_operand_5 = 1; + top.copy_flags_5 = 1; + top.enable_norm_6 = 1; + top.copy_flags_10 = 0; + top.copy_flags_11 = 0; + top.enable_round_11 = 1; + top.encode_special_13 = 1; + // mul int //top.mul_float_m1 = 0; //top.unit_b_m1 = 0; //top.float_a_1 = 0; //top.int_hi_a_1 = 0; //top.int_lo_a_1 = 1; - //top.zero_flags_a_1 = 1; + //top.zero_flags_1 = 1; //top.zero_b_1 = 1; //top.copy_flags_2 = 1; + //top.int_signed_4 = 0; + //top.int_operand_5 = 0; //top.copy_flags_5 = 1; //top.enable_norm_6 = 0; //top.copy_flags_10 = 1; @@ -48,10 +71,12 @@ int main(int argc, char **argv) //top.float_a_1 = 1; //top.int_hi_a_1 = 0; //top.int_lo_a_1 = 0; - //top.zero_flags_a_1 = 0; + //top.zero_flags_1 = 0; //top.zero_b_1 = 1; //top.copy_flags_2 = 1; //top.copy_flags_5 = 1; + //top.int_signed_4 = 0; + //top.int_operand_5 = 0; //top.enable_norm_6 = 1; //top.copy_flags_10 = 1; //top.copy_flags_11 = 1; @@ -59,20 +84,22 @@ int main(int argc, char **argv) //top.encode_special_13 = 1; // suma/resta - top.mul_float_m1 = 0; - top.unit_b_m1 = 1; - top.float_a_1 = 0; - top.int_hi_a_1 = 0; - top.int_lo_a_1 = 1; - top.zero_flags_a_1 = 0; - top.zero_b_1 = 0; - top.copy_flags_2 = 0; - top.copy_flags_5 = 0; - top.enable_norm_6 = 1; - top.copy_flags_10 = 0; - top.copy_flags_11 = 0; - top.enable_round_11 = 1; - top.encode_special_13 = 1; + //top.mul_float_m1 = 0; + //top.unit_b_m1 = 1; + //top.float_a_1 = 0; + //top.int_hi_a_1 = 0; + //top.int_lo_a_1 = 1; + //top.zero_flags_1 = 0; + //top.zero_b_1 = 0; + //top.copy_flags_2 = 0; + //top.copy_flags_5 = 0; + //top.int_signed_4 = 0; + //top.int_operand_5 = 0; + //top.enable_norm_6 = 1; + //top.copy_flags_10 = 0; + //top.copy_flags_11 = 0; + //top.enable_round_11 = 1; + //top.encode_special_13 = 1; top.a = *reinterpret_cast(&a); top.b = *reinterpret_cast(&b); @@ -85,8 +112,10 @@ int main(int argc, char **argv) top.eval(); } - unsigned q = top.q; - std::cout << a << " * " << b << " = " << *reinterpret_cast(&q) << '\n'; + unsigned q_bits = top.q; + q = *reinterpret_cast(&q_bits); + + std::cout << a << ' ' << op << ' ' << b << " = " << q << '\n'; bool failed = Py_FinalizeEx() < 0; -- cgit v1.2.3