From e348b52c78384fb6a8a44ff75b651b062c1805df Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 19 Jul 2019 12:15:09 +0100 Subject: [PATCH] add i32 to f64 conversion test --- src/ieee754/fcvt/test/test_fcvt_int_pipe.py | 26 +++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/ieee754/fcvt/test/test_fcvt_int_pipe.py b/src/ieee754/fcvt/test/test_fcvt_int_pipe.py index ed48d17a..4f72f83a 100644 --- a/src/ieee754/fcvt/test/test_fcvt_int_pipe.py +++ b/src/ieee754/fcvt/test/test_fcvt_int_pipe.py @@ -15,6 +15,14 @@ def to_int16(x): return x-0x10000 return x +def to_int32(x): + """ input: an unsigned int in the range 0..2^32-1 + output: a signed int in the range -2^31..2^31-1 + """ + if x > ((1<<31)-1): + return x-(1<<32) + return x + def to_uint16(x): return x @@ -28,9 +36,13 @@ def fcvt_64(x): return sfpy.float.ui32_to_f64(x) def fcvt_i16_f32(x): - print ("fcvt i16_f32", x) + print ("fcvt i16_f32", hex(x)) return sfpy.float.i32_to_f32(x) # XXX no i16_to_f32, it's ok though +def fcvt_i32_f64(x): + print ("fcvt i32_f64", hex(x)) + return sfpy.float.i32_to_f64(x) + def fcvt_32(x): return sfpy.float.ui32_to_f32(x) @@ -51,6 +63,11 @@ def test_int_pipe_i16_f32(): runfp(dut, 16, "test_fcvt_int_pipe_i16_f32", to_int16, fcvt_i16_f32, True, n_vals=100, opcode=0x1) +def test_int_pipe_i32_f64(): + dut = FPCVTIntMuxInOut(32, 64, 4, op_wid=1) + runfp(dut, 32, "test_fcvt_int_pipe_i32_f64", to_int32, fcvt_i32_f64, True, + n_vals=100, opcode=0x1) + ###################### # unsigned int to fp ###################### @@ -97,10 +114,11 @@ def test_int_pipe_ui32_f16(): n_vals=100) if __name__ == '__main__': - test_int_pipe_i16_f32() - test_int_pipe_ui16_f32() - exit() for i in range(200): + test_int_pipe_i32_f64() + continue + test_int_pipe_i16_f32() + test_int_pipe_ui16_f32() test_int_pipe_ui64_f32() test_int_pipe_ui32_f16() test_int_pipe_ui64_f16() -- 2.30.2