Skip to content

Commit

Permalink
soc/interconnect/stream: Improve MonitorCounter timings (avoid reset,…
Browse files Browse the repository at this point in the history
… clearer logic).
  • Loading branch information
enjoy-digital committed Jul 5, 2024
1 parent 3c2ddd1 commit 0db650a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions litex/soc/interconnect/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,19 +696,22 @@ def __init__(self, endpoint, count_width=32, clock_domain="sys",
# Generic Monitor Counter ------------------------------------------------------------------
class MonitorCounter(Module):
def __init__(self, reset, latch, enable, count):
_count = Signal.like(count)
_count_latched = Signal.like(count)
_count = Signal(len(count), reset_less=True)
_count_latched = Signal(len(count), reset_less=True)
_sync = getattr(self.sync, clock_domain)
_sync += [
# Count.
If(reset,
_count.eq(0),
_count_latched.eq(0),
).Elif(enable,
If(_count != (2**len(count)-1),
_count.eq(_count + 1)
)
),
If(latch,
# Latch.
If(reset,
_count_latched.eq(0),
).Elif(latch,
_count_latched.eq(_count)
)
]
Expand Down

0 comments on commit 0db650a

Please sign in to comment.