From: Luke Kenneth Casson Leighton Date: Sun, 28 Jul 2019 12:32:59 +0000 (+0100) Subject: add code comments X-Git-Tag: ls180-24jan2020~700 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02dbf3a7d73a160f31cd04142f086c125990d2ed;p=ieee754fpu.git add code comments --- diff --git a/src/ieee754/fclass/fclass.py b/src/ieee754/fclass/fclass.py index e1b034e6..f50412c4 100644 --- a/src/ieee754/fclass/fclass.py +++ b/src/ieee754/fclass/fclass.py @@ -54,6 +54,9 @@ class FPClassMod(Elaboratable): m.d.comb += is_sig_nan.eq(a1.exp_128 & (msbzero) & (~a1.m_zero)) subnormal = a1.exp_n127 + # this is hardware-optimal but very hard to understand. + # see unit test test_fclass_pipe.py fclass() for what's + # going on. m.d.comb += self.o.z.eq(Cat( a1.s & a1.is_inf, # | −inf. a1.s & finite_nzero & ~subnormal, # | -normal number. diff --git a/src/ieee754/fclass/test/test_fclass_pipe.py b/src/ieee754/fclass/test/test_fclass_pipe.py index b96d17ff..30fcf4e8 100644 --- a/src/ieee754/fclass/test/test_fclass_pipe.py +++ b/src/ieee754/fclass/test/test_fclass_pipe.py @@ -10,6 +10,10 @@ from sfpy import Float64, Float32, Float16 def fclass(wid, x): """ analyses the FP number and returns a RISC-V "FCLASS" unary bitfield + + this is easy to understand however it has redundant checks (which + don't matter because performance of *testing* is not hardware-critical) + see FPClassMod for a hardware-optimal (hard-to-read) version """ x = x.bits fmt = FPFormat.standard(wid)