From 166d85d572afb1a359d0b17ce9c11029280b2b95 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 23 Jul 2019 17:44:32 +0100 Subject: [PATCH] specialcases: sqrt of -ve zero is -ve zero --- src/ieee754/fpdiv/specialcases.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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) -- 2.30.2