migen/genlib/misc: replace Timeout with WaitTimer from artiq
This commit is contained in:
parent
fe6eef7069
commit
88a406ebec
|
@ -118,12 +118,16 @@ class Counter(Module):
|
|||
self.sync += self.value.eq(self.value+increment)
|
||||
|
||||
|
||||
@ResetInserter()
|
||||
@CEInserter()
|
||||
class Timeout(Module):
|
||||
def __init__(self, length):
|
||||
self.reached = Signal()
|
||||
###
|
||||
value = Signal(max=length)
|
||||
self.sync += If(~self.reached, value.eq(value+1))
|
||||
self.comb += self.reached.eq(value == (length-1))
|
||||
class WaitTimer(Module):
|
||||
def __init__(self, t):
|
||||
self.wait = Signal()
|
||||
self.done = Signal()
|
||||
|
||||
# # #
|
||||
|
||||
count = Signal(bits_for(t), reset=t)
|
||||
self.comb += self.done.eq(count == 0)
|
||||
self.sync += \
|
||||
If(self.wait,
|
||||
If(~self.done, count.eq(count - 1))
|
||||
).Else(count.eq(count.reset))
|
||||
|
|
Loading…
Reference in New Issue