-from .hdl.ast import Value, Const, C, Mux, Cat, Repl, Array, Signal, ClockSignal, ResetSignal, Assert, Assume
+from .hdl.ast import Value, Const, C, AnyConst, AnySeq, Mux, Cat, Repl, Array, Signal, ClockSignal, ResetSignal, Assert, Assume
from .hdl.dsl import Module
from .hdl.cd import ClockDomain
from .hdl.ir import Fragment, Instance
__all__ = [
- "Value", "Const", "C", "Operator", "Mux", "Part", "Slice", "Cat", "Repl",
+ "Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat", "Repl",
"Array", "ArrayProxy",
"Signal", "ClockSignal", "ResetSignal",
"Statement", "Assign", "Assert", "Assume", "Switch", "Delay", "Tick",
C = Const # shorthand
+class AnyValue(Value):
+ def __init__(self, shape):
+ super().__init__(src_loc_at=0)
+ if isinstance(shape, int):
+ shape = shape, False
+ self.nbits, self.signed = shape
+ if not isinstance(self.nbits, int) or self.nbits < 0:
+ raise TypeError("Width must be a non-negative integer, not '{!r}'", self.nbits)
+
+ def shape(self):
+ return self.nbits, self.signed
+
+ def _rhs_signals(self):
+ return ValueSet()
+
+
+class AnyConst(AnyValue):
+ def __repr__(self):
+ return "(anyconst {}'{})".format(self.nbits, "s" if self.signed else "")
+
+
+class AnySeq(AnyValue):
+ def __repr__(self):
+ return "(anyseq {}'{})".format(self.nbits, "s" if self.signed else "")
+
+
class Operator(Value):
def __init__(self, op, operands, src_loc_at=0):
super().__init__(src_loc_at=1 + src_loc_at)