m.d.comb += msb.m_in.eq(Cat(0, 0, 0, mantissa)) # g/r/s + input
m.d.comb += msb.e_in.eq(me) # exp = int width
- if ms < 0:
- # larger int to smaller FP (uint32/64 -> fp16 most likely)
+ # to do with FP16... not yet resolved why
+ alternative = ms < 0
+
+ if alternative:
m.d.comb += z1.e.eq(msb.e_out-1)
- m.d.comb += z1.m[ms-1:].eq(msb.m_out[-mz-1:])
+ if mz == 16:
+ # larger int to smaller FP (uint32/64 -> fp16 most likely)
+ m.d.comb += z1.m[ms-1:].eq(msb.m_out[-mz-1:])
+ else: # 32? XXX weirdness...
+ m.d.comb += z1.m.eq(msb.m_out[-mz-1:])
else:
# smaller int to larger FP
m.d.comb += z1.e.eq(msb.e_out)
# is even necessary. it probably isn't
# initialise rounding (but only activate if needed)
- if ms < 0:
+ if alternative:
# larger int to smaller FP (uint32/64 -> fp16 most likely)
m.d.comb += self.o.of.guard.eq(msb.m_out[-mz-2])
m.d.comb += self.o.of.round_bit.eq(msb.m_out[-mz-3])
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_f32(x):
+ print ("fcvt i32_f32", hex(x))
+ return sfpy.float.i32_to_f32(x)
+
def fcvt_i32_f64(x):
print ("fcvt i32_f64", hex(x))
return sfpy.float.i32_to_f64(x)
runfp(dut, 32, "test_fcvt_int_pipe_i32_f64", to_int32, fcvt_i32_f64, True,
n_vals=100, opcode=0x1)
+def test_int_pipe_i32_f32():
+ dut = FPCVTIntMuxInOut(32, 32, 4, op_wid=1)
+ runfp(dut, 32, "test_fcvt_int_pipe_i32_f32", to_int32, fcvt_i32_f32, True,
+ n_vals=100, opcode=0x1)
+
######################
# unsigned int to fp
######################
runfp(dut, 16, "test_fcvt_int_pipe_ui16_f64", to_uint16, fcvt_64, True,
n_vals=100)
+def test_int_pipe_ui32_f32():
+ dut = FPCVTIntMuxInOut(32, 32, 4, op_wid=1)
+ runfp(dut, 32, "test_fcvt_int_pipe_ui32_32", to_uint32, fcvt_32, True,
+ n_vals=100)
+
def test_int_pipe_ui32_f64():
dut = FPCVTIntMuxInOut(32, 64, 4, op_wid=1)
runfp(dut, 32, "test_fcvt_int_pipe_ui32_64", to_uint32, fcvt_64, True,
if __name__ == '__main__':
for i in range(200):
- test_int_pipe_i32_f64()
+ test_int_pipe_ui32_f32()
+ test_int_pipe_i32_f32()
continue
test_int_pipe_i16_f32()
+ test_int_pipe_i32_f64()
+ continue
test_int_pipe_ui16_f32()
test_int_pipe_ui64_f32()
test_int_pipe_ui32_f16()