m.d.comb += finite_nzero.eq(~a1.is_nan & ~a1.is_inf & ~a1.is_zero)
subnormal = a1.exp_lt_n126
- m.d.comb += self.o.z.eqCat(
+ m.d.comb += self.o.z.eq(Cat(
a1.s & a1.is_inf, # | −inf.
a1.s & finite_nzero & ~subnormal, # | -normal number.
a1.s & finite_nzero & subnormal, # | -subnormal number.
~a1.s & finite_nzero & ~subnormal, # | +normal number.
~a1.s & a1.is_inf, # | +inf.
a1.is_denormalised, # | a signaling NaN.
- a1.is_nan & ~a1.is_denormalised) # | a quiet NaN
+ a1.is_nan & ~a1.is_denormalised)) # | a quiet NaN
m.d.comb += self.o.ctx.eq(self.i.ctx)
--- /dev/null
+""" test of FPClassMuxInOut
+"""
+
+from ieee754.fclass.pipeline import (FPClassMuxInOut,)
+from ieee754.fpcommon.test.fpmux import runfp
+from ieee754.fpcommon.fpbase import FPFormat
+
+import sfpy
+from sfpy import Float64, Float32, Float16
+
+def fclass(wid, x):
+ x = x.bits
+ fmt = FPFormat.standard(wid)
+ if fmt.is_inf(x):
+ if fmt.get_sign(x):
+ return 1<<0
+ else:
+ return 1<<7
+ if fmt.is_zero(x):
+ if fmt.get_sign(x):
+ return 1<<3
+ else:
+ return 1<<4
+ if fmt.get_exponent(x) == fmt.emax:
+ if fmt.is_nan_signalling(x):
+ return 1<<8
+ else:
+ return 1<<9
+ if fmt.is_subnormal(x) and fmt.get_mantissa(x) != 0:
+ if fmt.get_sign(x):
+ return 1<<2
+ else:
+ return 1<<5
+ if fmt.get_sign(x):
+ return 1<<1
+ else:
+ return 1<<6
+
+
+def fclass_16(x):
+ return fclass(16, x)
+
+
+def test_class_pipe_f16():
+ dut = FPClassMuxInOut(16, 16, 4, op_wid=1)
+ runfp(dut, 16, "test_fcvt_class_pipe_f16", Float16, fclass_16,
+ True, n_vals=100)
+
+
+if __name__ == '__main__':
+ for i in range(200):
+ test_class_pipe_f16()
""" returns true if x is subnormal (exp at minimum
"""
e_sub = self.exponent_denormal_zero - self.exponent_bias
- print ("e_sub", e_sub)
return self.get_exponent(x) == e_sub and self.get_mantissa(x) == 0
def is_subnormal(self, x):
""" returns true if x is subnormal (exp at minimum
"""
e_sub = self.exponent_denormal_zero - self.exponent_bias
- print ("e_sub", e_sub)
return self.get_exponent(x) == e_sub and self.get_mantissa(x) != 0
def is_inf(self, x):