Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/migen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9194fe43a172
Choose a base ref
...
head repository: m-labs/migen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b0f159421c79
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on May 12, 2015

  1. Copy the full SHA
    88a406e View commit details
  2. Copy the full SHA
    b0f1594 View commit details
Showing with 13 additions and 9 deletions.
  1. +13 −9 migen/genlib/misc.py
22 changes: 13 additions & 9 deletions migen/genlib/misc.py
Original file line number Diff line number Diff line change
@@ -118,12 +118,16 @@ def __init__(self, *args, increment=1, **kwargs):
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))