From 0824513648d011ead1b5d6729e70b85d261694f7 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 8 Apr 2022 15:41:22 -0700 Subject: [PATCH] clean up CLMulAdd.elaborate --- src/nmigen_gf/hdl/clmul.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nmigen_gf/hdl/clmul.py b/src/nmigen_gf/hdl/clmul.py index 103fc08..ad43173 100644 --- a/src/nmigen_gf/hdl/clmul.py +++ b/src/nmigen_gf/hdl/clmul.py @@ -63,15 +63,15 @@ class CLMulAdd(Elaboratable): def elaborate(self, platform): m = Module() - parts = self.terms + all_terms = self.terms.copy() # create copy to avoid modifying self for shift in range(self.factor_width): part_prod = Signal(self.output.width, name=f"part_prod_{shift}") - # TODO comment (nice ASCII diagram in docstring then refer to it?) + # construct partial product term mask = Repl(self.factor2[shift], self.factor_width) m.d.comb += part_prod.eq((self.factor1 & mask) << shift) - parts.append(part_prod) + all_terms.append(part_prod) - # TODO comment - output = treereduce(parts, operator.xor) + # merge all terms together + output = treereduce(all_terms, operator.xor) m.d.comb += self.output.eq(output) return m -- 2.30.2