From: Luke Kenneth Casson Leighton Date: Tue, 23 Jul 2019 16:44:32 +0000 (+0100) Subject: specialcases: sqrt of -ve zero is -ve zero X-Git-Tag: ls180-24jan2020~745 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=166d85d572afb1a359d0b17ce9c11029280b2b95;p=ieee754fpu.git specialcases: sqrt of -ve zero is -ve zero --- diff --git a/src/ieee754/fpdiv/specialcases.py b/src/ieee754/fpdiv/specialcases.py index 62873026..3b634bf3 100644 --- a/src/ieee754/fpdiv/specialcases.py +++ b/src/ieee754/fpdiv/specialcases.py @@ -104,8 +104,13 @@ class FPDIVSpecialCasesMod(Elaboratable): with m.If(self.i.ctx.op == 1): # SQRT + # if a is zero return zero + with m.If(a1.is_zero): + m.d.comb += self.o.out_do_z.eq(1) + m.d.comb += self.o.z.zero(a1.s) + # -ve number is NaN - with m.If(a1.s): + with m.Elif(a1.s): m.d.comb += self.o.out_do_z.eq(1) m.d.comb += self.o.z.nan(0) @@ -119,11 +124,6 @@ class FPDIVSpecialCasesMod(Elaboratable): m.d.comb += self.o.out_do_z.eq(1) m.d.comb += self.o.z.nan(0) - # if a is zero return zero - with m.Elif(a1.is_zero): - m.d.comb += self.o.out_do_z.eq(1) - m.d.comb += self.o.z.zero(0) - # Denormalised Number checks next, so pass a/b data through with m.Else(): m.d.comb += self.o.out_do_z.eq(0)