Skip to content

Commit

Permalink
fhdl: allow use of ResetSignal() on resetless clock domains
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Jul 26, 2015
1 parent 5a535ef commit cc6877d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion migen/fhdl/structure.py
Expand Up @@ -327,10 +327,14 @@ class ResetSignal(Value):
----------
cd : str
Clock domain to obtain a reset signal for. Defaults to `"sys"`.
allow_resetless : bool
If the clock domain is resetless, return 0 instead of reporting an
error.
"""
def __init__(self, cd="sys"):
def __init__(self, cd="sys", allow_resetless=False):
Value.__init__(self)
self.cd = cd
self.allow_resetless = allow_resetless

# statements

Expand Down
10 changes: 9 additions & 1 deletion migen/fhdl/tools.py
Expand Up @@ -191,7 +191,15 @@ def visit_ClockSignal(self, node):
return self.clock_domains[node.cd].clk

def visit_ResetSignal(self, node):
return self.clock_domains[node.cd].rst
rst = self.clock_domains[node.cd].rst
if rst is None:
if node.allow_resetless:
return 0
else:
raise ValueError("Attempted to get reset signal of resetless"
" domain '{}'".format(node.cd))
else:
return rst


class _ComplexSliceLowerer(_Lowerer):
Expand Down

0 comments on commit cc6877d

Please sign in to comment.