From 02dbf3a7d73a160f31cd04142f086c125990d2ed Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 28 Jul 2019 13:32:59 +0100 Subject: [PATCH] add code comments --- src/ieee754/fclass/fclass.py | 3 +++ src/ieee754/fclass/test/test_fclass_pipe.py | 4 ++++ 2 files changed, 7 insertions(+) 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) -- 2.30.2