mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
gen/genlib/misc: Add CE option to WaitTimer
This commit is contained in:
parent
36ce71d59b
commit
91ec2d5e3b
1 changed files with 11 additions and 4 deletions
|
@ -74,9 +74,10 @@ def timeline(trigger, events):
|
|||
|
||||
|
||||
class WaitTimer(Module):
|
||||
def __init__(self, t):
|
||||
self.wait = Signal()
|
||||
self.done = Signal()
|
||||
def __init__(self, t, has_ce=False):
|
||||
self.wait = Signal() # i
|
||||
self.ce = Signal() # i
|
||||
self.done = Signal() # o
|
||||
|
||||
# # #
|
||||
|
||||
|
@ -84,10 +85,16 @@ class WaitTimer(Module):
|
|||
t = int(t)
|
||||
count = Signal(bits_for(t), reset=t)
|
||||
|
||||
tick = Signal()
|
||||
if has_ce:
|
||||
self.comb += tick.eq(~self.done & self.ce)
|
||||
else:
|
||||
self.comb += tick.eq(~self.done)
|
||||
|
||||
self.comb += self.done.eq(count == 0)
|
||||
self.sync += [
|
||||
If(self.wait,
|
||||
If(~self.done,
|
||||
If(tick,
|
||||
count.eq(count - 1)
|
||||
)
|
||||
).Else(
|
||||
|
|
Loading…
Reference in a new issue