class Cover(Property):
_kind = "cover"
+ @final
+ class Display(Statement):
+ _MustUse__warning = UnusedProperty
+
+ def __init__(self, text, *args):
+ super().__init__(src_loc_at=0)
+ self.text = text
+ self.args = args
+ self.test = Signal()
+ self._check = Signal(reset_less=True)
+ self._check.src_loc = self.src_loc
+ self._en = Signal(reset_less=True)
+ self._en.src_loc = self.src_loc
+
+ def _lhs_signals(self):
+ return SignalSet((self._en, self._check))
+
+ def _rhs_signals(self):
+ return self.test._rhs_signals()
+
+ def __repr__(self):
+ return "(display {!r})".format(self.text)
+
# @final
-class Switch(Statement):
+def Switch(test, cases, *, src_loc=None, src_loc_at=0, case_src_locs={}):
+ return test.__Switch__(cases, src_loc=src_loc, src_loc_at=src_loc_at,
+ case_src_locs=case_src_locs)
+
+
+class _InternalSwitch(Statement):
def __init__(self, test, cases, *, src_loc=None, src_loc_at=0, case_src_locs={}):
if src_loc is None:
super().__init__(src_loc_at=src_loc_at)
self._pop_ctrl()
for stmt in Statement.cast(assigns):
- if not compat_mode and not isinstance(stmt, (_InternalAssign, Assert, Assume, Cover)):
- if not compat_mode and not isinstance(stmt, (Assign, Assert, Assume, Cover, Display)):
++ if not compat_mode and not isinstance(stmt, (_InternalAssign, Assert, Assume, Cover, Display)):
raise SyntaxError(
"Only assignments and property checks may be appended to d.{}"
.format(domain_name(domain)))
new_stmt = self.on_Assume(stmt)
elif type(stmt) is Cover:
new_stmt = self.on_Cover(stmt)
- elif isinstance(stmt, Switch):
+ elif type(stmt) is Display:
+ new_stmt = self.on_Display(stmt)
+ elif isinstance(stmt, _InternalSwitch):
# Uses `isinstance()` and not `type() is` because nmigen.compat requires it.
new_stmt = self.on_Switch(stmt)
elif isinstance(stmt, Iterable):