From: Luke Kenneth Casson Leighton Date: Wed, 10 Nov 2021 18:33:51 +0000 (+0000) Subject: Merge branch 'display-patch' into libresoc-partsig X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=refs%2Fheads%2Flibresoc-nmigen-fork;p=nmigen.git Merge branch 'display-patch' into libresoc-partsig --- cb87062e0a3a8afe43076b3b45917e83344120dd diff --cc nmigen/hdl/ast.py index 39fb33f,d206675..1e0b5c7 --- a/nmigen/hdl/ast.py +++ b/nmigen/hdl/ast.py @@@ -1546,14 -1472,32 +1545,37 @@@ class Assume(Property) 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) diff --cc nmigen/hdl/dsl.py index bac2686,cf40c66..86e190e --- a/nmigen/hdl/dsl.py +++ b/nmigen/hdl/dsl.py @@@ -493,7 -484,7 +493,7 @@@ class Module(_ModuleBuilderRoot, Elabor 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))) diff --cc nmigen/hdl/xfrm.py index c39e523,4e043f7..94d8fbf --- a/nmigen/hdl/xfrm.py +++ b/nmigen/hdl/xfrm.py @@@ -213,7 -217,9 +217,9 @@@ class StatementVisitor(metaclass=ABCMet new_stmt = self.on_Assume(stmt) elif type(stmt) is Cover: new_stmt = self.on_Cover(stmt) + elif type(stmt) is Display: + new_stmt = self.on_Display(stmt) - elif isinstance(stmt, Switch): + 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):