gen/genlib/misc/WaitTimer: Cast t to int and minor cosmetic cleanup.

This commit is contained in:
Florent Kermarrec 2023-07-31 11:27:47 +02:00
parent b8dc1b7757
commit bf79c9032a
1 changed files with 11 additions and 3 deletions

View File

@ -80,12 +80,20 @@ class WaitTimer(Module):
# # #
# Cast t to int.
t = int(t)
count = Signal(bits_for(t), reset=t)
self.comb += self.done.eq(count == 0)
self.sync += \
self.sync += [
If(self.wait,
If(~self.done, count.eq(count - 1))
).Else(count.eq(count.reset))
If(~self.done,
count.eq(count - 1)
)
).Else(
count.eq(count.reset)
)
]
class BitSlip(Module):