Skip to content

Commit

Permalink
Work around a weird bug in Verilator (or Amaranth?)
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Sep 26, 2024
1 parent 81f3b85 commit 0eced83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions coreblocks/func_blocks/fu/division/long_division.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ def recursive_module(self) -> TModule:
m.d.comb += rec_div.divisor.eq(self.divisor)

# Single step as described in article
quotient_msb = Signal()
with m.If(concat >= self.divisor):
m.d.comb += self.quotient[self.step_count - 1].eq(1)
m.d.comb += quotient_msb.eq(1)
m.d.comb += rec_div.input_remainder.eq(concat - self.divisor)
with m.Else():
m.d.comb += self.quotient[self.step_count - 1].eq(0)
m.d.comb += quotient_msb.eq(0)
m.d.comb += rec_div.input_remainder.eq(concat)

# wiring up rest of result from recursive module
m.d.comb += self.quotient[: (self.step_count - 1)].eq(rec_div.quotient)
m.d.comb += self.quotient.eq(Cat(rec_div.quotient[: (self.step_count - 1)], quotient_msb))
m.d.comb += self.remainder.eq(rec_div.remainder)

# partial remainder
Expand Down

0 comments on commit 0eced83

Please sign in to comment.