[libre-riscv-dev] partitioned compare and mux

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sun Feb 9 15:00:43 GMT 2020


hiya michael, saw the carry-in and carry-out, looks really good.  i'll
add a unit test for subtract in test_partsig.py, i'll leave it with
you to add __sub__?

btw i discovered the "implies" operator.  "~x | (x & y)" is the same
as "~x | y" in boolean logic if you do a karnaugh map, and it's less
gates.  once i'd remembered / worked that out (btw do please check
that!  i get logic wrong sometimes), i replaced ~x | y with
x.implies(y) which you can see in nmigen/hdl/ast.py as a simple
"convenience" function.

one thing, do please keep below 80 chars and do a "git diff" before
committing: if your bash shell has colour syntax highlighting switched
on, any erroneously-added whitespace by the (really annoying feature
enabled by default recently in) vim "being helpful" auto-suggest thing
shows up really obviously in red.

l.

--- a/src/ieee754/part_mul_add/adder.py
+++ b/src/ieee754/part_mul_add/adder.py
@@ -193,15 +193,13 @@ class PartitionedAdder(Elaboratable):
             if pi.is_integer() and pi in self.part_pts:
                 # add extra bit set to 0 + 0 for enabled partition points
                 a_bit = Signal()
-                m.d.comb += a_bit.eq(~self.part_pts[pi] |
-                                     (self.part_pts[pi] & \
-                                      self.carry_in[carry_bit]))
+                carry_in = self.carry_in[carry_bit] # convenience
+                m.d.comb += a_bit.eq(self.part_pts[pi].implies(carry_in))
                 # and 1 + 0 for disabled partition points
                 ea.append(expanded_a[expanded_index])
                 al.append(a_bit) # add extra bit in a
                 eb.append(expanded_b[expanded_index])
-                bl.append(self.carry_in[carry_bit] &
-                          self.part_pts[pi]) # yes, add a zero
+                bl.append(carry_in & self.part_pts[pi]) # yes, add a zero
                 co.append(expanded_o[expanded_index])
                 cl.append(self.carry_out[carry_bit-1])
                 expanded_index += 1 # skip the extra point.  NOT in the output



More information about the libre-riscv-dev mailing list