From bf79c9032a1e5199c660bdef4871ea8afce49623 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 31 Jul 2023 11:27:47 +0200 Subject: [PATCH] gen/genlib/misc/WaitTimer: Cast t to int and minor cosmetic cleanup. --- litex/gen/genlib/misc.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/litex/gen/genlib/misc.py b/litex/gen/genlib/misc.py index a44ef6d39..b39077860 100644 --- a/litex/gen/genlib/misc.py +++ b/litex/gen/genlib/misc.py @@ -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):