from .. import tracer
from .._utils import *
+from .._unused import *
__all__ = [
"Signal", "ClockSignal", "ResetSignal",
"UserValue",
"Sample", "Past", "Stable", "Rose", "Fell", "Initial",
- "Statement", "Assign", "Assert", "Assume", "Cover", "Switch",
- "ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict",
- "SignalSet",
+ "Statement", "Switch",
+ "Property", "Assign", "Assert", "Assume", "Cover",
+ "ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict", "SignalSet",
]
@final
class AnyConst(AnyValue):
def __repr__(self):
- return "(anyconst {}'{})".format(self.nbits, "s" if self.signed else "")
+ return "(anyconst {}'{})".format(self.width, "s" if self.signed else "")
@final
class AnySeq(AnyValue):
def __repr__(self):
- return "(anyseq {}'{})".format(self.nbits, "s" if self.signed else "")
+ return "(anyseq {}'{})".format(self.width, "s" if self.signed else "")
@final
return "(eq {!r} {!r})".format(self.lhs, self.rhs)
-class Property(Statement):
+class UnusedProperty(UnusedMustUse):
+ pass
+
+
+class Property(Statement, MustUse):
+ _MustUse__warning = UnusedProperty
+
def __init__(self, test, *, _check=None, _en=None, src_loc_at=0):
super().__init__(src_loc_at=src_loc_at)
self.test = Value.cast(test)
while len(self._ctrl_stack) > self.domain._depth:
self._pop_ctrl()
- for assign in Statement.cast(assigns):
- if not compat_mode and not isinstance(assign, (Assign, Assert, Assume, Cover)):
+ for stmt in Statement.cast(assigns):
+ if not compat_mode and not isinstance(stmt, (Assign, Assert, Assume, Cover)):
raise SyntaxError(
"Only assignments and property checks may be appended to d.{}"
.format(domain_name(domain)))
- assign = SampleDomainInjector(domain)(assign)
- for signal in assign._lhs_signals():
+ stmt._MustUse__used = True
+ stmt = SampleDomainInjector(domain)(stmt)
+
+ for signal in stmt._lhs_signals():
if signal not in self._driving:
self._driving[signal] = domain
elif self._driving[signal] != domain:
"already driven from d.{}"
.format(signal, domain_name(domain), domain_name(cd_curr)))
- self._statements.append(assign)
+ self._statements.append(stmt)
def _add_submodule(self, submodule, name=None):
if not hasattr(submodule, "elaborate"):
yield from self.domains
def add_statements(self, *stmts):
- self.statements += Statement.cast(stmts)
+ for stmt in Statement.cast(stmts):
+ stmt._MustUse__used = True
+ self.statements.append(stmt)
def add_subfragment(self, subfragment, name=None):
assert isinstance(subfragment, Fragment)
new_stmt.src_loc = stmt.src_loc
if isinstance(new_stmt, Switch) and isinstance(stmt, Switch):
new_stmt.case_src_locs = stmt.case_src_locs
+ if isinstance(new_stmt, Property):
+ new_stmt._MustUse__used = True
return new_stmt
def __call__(self, stmt):