Skip to content

Commit

Permalink
lib.coding: remove GrayDecoder comb loop for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed Oct 31, 2022
1 parent beb1b38 commit 8170a47
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions amaranth/lib/coding.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def __init__(self, width):

def elaborate(self, platform):
m = Module()
m.d.comb += self.o[-1].eq(self.i[-1])
for i in reversed(range(self.width - 1)):
m.d.comb += self.o[i].eq(self.o[i + 1] ^ self.i[i])
rhs = Const(0)
for i in reversed(range(self.width)):
rhs = rhs ^ self.i[i]
m.d.comb += self.o[i].eq(rhs)
return m

0 comments on commit 8170a47

Please sign in to comment.