csr_eventmanager/EventSourceProcess: Add Rising Edge support and Falling/Rising selection.

This commit is contained in:
Florent Kermarrec 2021-03-09 13:55:43 +01:00
parent ece9005949
commit 0d8b6f8fbb
1 changed files with 10 additions and 8 deletions

View File

@ -78,20 +78,22 @@ class EventSourcePulse(Module, _EventSource):
class EventSourceProcess(Module, _EventSource): class EventSourceProcess(Module, _EventSource):
"""EventSource which triggers on a falling edge. """EventSource which triggers on a Falling or Rising edge.
The purpose of this event source is to monitor the status of processes and The purpose of this event source is to monitor the status of processes and
generate an interrupt on their completion. generate an interrupt on their completion.
""" """
def __init__(self, name=None, description=None): def __init__(self, name=None, description=None, edge="falling"):
assert edge in ["falling", "rising"]
_EventSource.__init__(self, name, description) _EventSource.__init__(self, name, description)
self.comb += self.status.eq(self.trigger) self.comb += self.status.eq(self.trigger)
old_trigger = Signal() trigger_d = Signal()
self.sync += [ self.sync += If(self.clear, self.pending.eq(0))
If(self.clear, self.pending.eq(0)), self.sync += trigger_d.eq(self.trigger)
old_trigger.eq(self.trigger), if edge == "falling":
If(~self.trigger & old_trigger, self.pending.eq(1)) self.sync += If(~self.trigger & trigger_d, self.pending.eq(1))
] if edge == "rising":
self.sync += If(self.trigger & ~trigger_d, self.pending.eq(1))
class EventSourceLevel(Module, _EventSource): class EventSourceLevel(Module, _EventSource):