fhdl.ast.Signal: implement reset_less signals.
This commit is contained in:
parent
1d46ffb591
commit
263d577323
|
@ -492,6 +492,10 @@ class Signal(Value, DUID):
|
||||||
domain is reset, the ``Signal`` assumes the given value. When this ``Signal`` is unassigned
|
domain is reset, the ``Signal`` assumes the given value. When this ``Signal`` is unassigned
|
||||||
in combinatorial context (due to conditional assignments not being taken), the ``Signal``
|
in combinatorial context (due to conditional assignments not being taken), the ``Signal``
|
||||||
assumes its ``reset`` value. Defaults to 0.
|
assumes its ``reset`` value. Defaults to 0.
|
||||||
|
reset_less : bool
|
||||||
|
If ``True``, do not generate reset logic for this ``Signal`` in synchronous statements.
|
||||||
|
The ``reset`` value is only used as a combinatorial default or as the initial value.
|
||||||
|
Defaults to ``False``.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
|
@ -501,7 +505,7 @@ class Signal(Value, DUID):
|
||||||
reset : int
|
reset : int
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, bits_sign=1, reset=0, name=None):
|
def __init__(self, bits_sign=1, name=None, reset=0, reset_less=False):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
if name is None:
|
if name is None:
|
||||||
|
@ -517,6 +521,7 @@ class Signal(Value, DUID):
|
||||||
if not isinstance(self.nbits, int) or self.nbits < 0:
|
if not isinstance(self.nbits, int) or self.nbits < 0:
|
||||||
raise TypeError("Width must be a positive integer")
|
raise TypeError("Width must be a positive integer")
|
||||||
self.reset = reset
|
self.reset = reset
|
||||||
|
self.reset_less = reset_less
|
||||||
|
|
||||||
def bits_sign(self):
|
def bits_sign(self):
|
||||||
return self.nbits, self.signed
|
return self.nbits, self.signed
|
||||||
|
|
|
@ -114,7 +114,7 @@ class _ControlInserter:
|
||||||
|
|
||||||
class ResetInserter(_ControlInserter):
|
class ResetInserter(_ControlInserter):
|
||||||
def _wrap_control(self, fragment, cd_name, signals):
|
def _wrap_control(self, fragment, cd_name, signals):
|
||||||
stmts = [s.eq(Const(s.reset, s.nbits)) for s in signals]
|
stmts = [s.eq(Const(s.reset, s.nbits)) for s in signals if not s.reset_less]
|
||||||
fragment.add_statements(Switch(self.controls[cd_name], {1: stmts}))
|
fragment.add_statements(Switch(self.controls[cd_name], {1: stmts}))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue