From 377d0d86e9f542dd752909a6dd276d33f5f65a43 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 8 Apr 2022 09:15:43 +0100 Subject: [PATCH] move NOT into carrysum so that variable name "different" preserves its meaning compared to the reference code --- src/nmigen_gf/hdl/cldivrem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nmigen_gf/hdl/cldivrem.py b/src/nmigen_gf/hdl/cldivrem.py index 01f8c20..77c4b14 100644 --- a/src/nmigen_gf/hdl/cldivrem.py +++ b/src/nmigen_gf/hdl/cldivrem.py @@ -92,12 +92,12 @@ class EqualLeadingZeroCount(Elaboratable): m.d.comb += both_ones.eq(self.a & self.b) # `different` is set if there are a different number of leading # zeros so far - m.d.comb += different.eq(~(self.a ^ self.b)) + m.d.comb += different.eq(self.a ^ self.b) # now [ab]use add: the last bit [carry-out] is the result csum = Signal(self.width + 1) carry_in = 1 # both have no leading zeros so far, so set carry - m.d.comb += csum.eq(both_ones + different + carry_in) + m.d.comb += csum.eq(both_ones + (~different) + carry_in) m.d.comb += self.out.eq(csum[self.width]) # out is carry-out return m -- 2.30.2