from nmigen.cli import main
from ieee754.part_mul_add.partpoints import PartitionPoints
-from eq_combiner import Twomux
+from ieee754.part_cmp.experiments.eq_combiner import Twomux
+
class PartitionedEq(Elaboratable):
m = Module()
comb = m.d.comb
- # ok first thing to note, before reading this (read the wiki page
- # first), according to boolean algebra, these two are equivalent:
- # (~[~eq0, ~eq1, ~eq2].bool()) is the same as (eq0 AND eq1 AND eq2)
- # where bool() is the *OR* of all bits in the list.
- #
- # given that ~eqN is neN (not equal), we first create a series
- # of != comparisons on the partitions, then chain the relevant
- # ones together depending on partition points, BOOL those together
- # and invert the result.
- #
- # the outer loop is on the partition value. the preparation phase
- # (idx array) is to work out how and when the eqs (ne's) are to be
- # chained together. finally an inner loop - one per bit - grabs
- # each chain, on a per-output-bit basis.
- #
- # the result is that for each partition-point permutation you get
- # a different set of output results for each bit. it's... messy
- # but functional.
-
# make a series of "not-eqs", splitting a and b into partition chunks
nes = Signal(self.mwidth, reset_less=True)
nel = []
start = 0
for i in range(len(keys)):
end = keys[i]
- nel.append(self.a[start:end] != self.b[start:end]) # see bool below
+ nel.append(self.a[start:end] != self.b[start:end])
start = end # for next time round loop
comb += nes.eq(Cat(*nel))
prevresult = nes[-1]
for bit in range(self.mwidth-1, 0, -1): # counts down from mwidth-1 to 1
- m.submodules["mux{}".format(bit)] = mux = Twomux()
+ m.submodules["mux%d" % bit] = mux = Twomux()
comb += mux.ina.eq(prevresult)
comb += mux.inb.eq(0)
comb += mux.sel.eq(~part_points[bit-1])