def __ne__(self, other): assert self._dtype is other._dtype if areHValues(self, other): return self._ne__val(other) else: return Operator.withRes(AllOps.NE, [self, other], BOOL)
def __eq__(self, other): if areHValues(self, other): if self._dtype == other._dtype: for f in self._dtype.fields: isPadding = f.name is None if not isPadding: sf = getattr(self, f.name) of = getattr(other, f.name) if not (sf == of): return False return True else: return False else: return super(HValue, self).__eq__(other)
def _concat(self, other): """ Concatenate this with other to one wider value/signal """ w = self._dtype.bit_length() try: other._dtype.bit_length except AttributeError: raise TypeError("Can not concat Bits and", other) self = self._vec() if areHValues(self, other): return self._concat__val(other) else: w = self._dtype.bit_length() other_w = other._dtype.bit_length() resWidth = w + other_w Bits = self._dtype.__class__ resT = Bits(resWidth, signed=self._dtype.signed, force_vector=True) # is instance of signal if isinstance(other, InterfaceBase): other = other._sig if other._dtype == BOOL: other = other._auto_cast(BIT) elif isinstance(other._dtype, Bits): if other._dtype.signed is not None: other = other._vec() else: raise TypeError(other._dtype) if self._dtype.signed is not None: self = self._vec() return Operator.withRes(AllOps.CONCAT, [self, other], resT)\ ._auto_cast(Bits(resWidth, signed=self._dtype.signed))