soc/interconnect/stream: Improve MonitorCounter timings (avoid reset, clearer logic).

This commit is contained in:
Florent Kermarrec 2024-07-05 13:55:58 +02:00
parent 3c2ddd1655
commit 0db650ac6a
1 changed files with 7 additions and 4 deletions

View File

@ -696,19 +696,22 @@ class Monitor(LiteXModule):
# Generic Monitor Counter ------------------------------------------------------------------ # Generic Monitor Counter ------------------------------------------------------------------
class MonitorCounter(Module): class MonitorCounter(Module):
def __init__(self, reset, latch, enable, count): def __init__(self, reset, latch, enable, count):
_count = Signal.like(count) _count = Signal(len(count), reset_less=True)
_count_latched = Signal.like(count) _count_latched = Signal(len(count), reset_less=True)
_sync = getattr(self.sync, clock_domain) _sync = getattr(self.sync, clock_domain)
_sync += [ _sync += [
# Count.
If(reset, If(reset,
_count.eq(0), _count.eq(0),
_count_latched.eq(0),
).Elif(enable, ).Elif(enable,
If(_count != (2**len(count)-1), If(_count != (2**len(count)-1),
_count.eq(_count + 1) _count.eq(_count + 1)
) )
), ),
If(latch, # Latch.
If(reset,
_count_latched.eq(0),
).Elif(latch,
_count_latched.eq(_count) _count_latched.eq(_count)
) )
] ]