self.wires = ast.SignalDict()
self.driven = ast.SignalDict()
self.ports = ast.SignalDict()
+ self.anys = ast.ValueDict()
self.expansions = ast.ValueDict()
return "{}'{:0{}b}".format(value.nbits, value_twos_compl, value.nbits)
def on_AnyConst(self, value):
+ if value in self.s.anys:
+ return self.s.anys[value]
+
res_bits, res_sign = value.shape()
res = self.s.rtlil.wire(width=res_bits)
self.s.rtlil.cell("$anyconst", ports={
}, params={
"WIDTH": res_bits,
}, src=src(value.src_loc))
+ self.s.anys[value] = res
return res
def on_AnySeq(self, value):
+ if value in self.s.anys:
+ return self.s.anys[value]
+
res_bits, res_sign = value.shape()
res = self.s.rtlil.wire(width=res_bits)
self.s.rtlil.cell("$anyseq", ports={
}, params={
"WIDTH": res_bits,
}, src=src(value.src_loc))
+ self.s.anys[value] = res
return res
def on_Signal(self, value):
C = Const # shorthand
-class AnyValue(Value):
+class AnyValue(Value, DUID):
def __init__(self, shape):
super().__init__(src_loc_at=0)
if isinstance(shape, int):
def __hash__(self):
if isinstance(self.value, Const):
return hash(self.value.value)
- elif isinstance(self.value, Signal):
+ elif isinstance(self.value, (Signal, AnyValue)):
return hash(self.value.duid)
elif isinstance(self.value, (ClockSignal, ResetSignal)):
return hash(self.value.domain)
if isinstance(self.value, Const):
return self.value.value == other.value.value
- elif isinstance(self.value, Signal):
+ elif isinstance(self.value, (Signal, AnyValue)):
return self.value is other.value
elif isinstance(self.value, (ClockSignal, ResetSignal)):
return self.value.domain == other.value.domain
if isinstance(self.value, Const):
return self.value < other.value
- elif isinstance(self.value, Signal):
+ elif isinstance(self.value, (Signal, AnyValue)):
return self.value.duid < other.value.duid
elif isinstance(self.value, Slice):
return (ValueKey(self.value.value) < ValueKey(other.value.value) and