return lambda state: normalize((arg(state) >> shift) & mask, shape)
def on_Part(self, value):
- raise NotImplementedError
+ shape = value.shape()
+ arg = self(value.value)
+ shift = self(value.offset)
+ mask = (1 << value.width) - 1
+ return lambda state: normalize((arg(state) >> shift(state)) & mask, shape)
def on_Cat(self, value):
shape = value.shape()
return self.value._lhs_signals()
def _rhs_signals(self):
- return self.value._rhs_signals()
+ return self.value._rhs_signals() | self.offset._rhs_signals()
def __repr__(self):
return "(part {} {} {})".format(repr(self.value), repr(self.offset), self.width)
stmt2 = lambda a: a[2:4]
self.assertOperator(stmt2, [C(0b10110100, 8)], C(0b01, 2))
+ def test_part(self):
+ stmt = lambda a, b: a.part(b, 3)
+ self.assertOperator(stmt, [C(0b10110100, 8), C(0)], C(0b100, 3))
+ self.assertOperator(stmt, [C(0b10110100, 8), C(2)], C(0b101, 3))
+ self.assertOperator(stmt, [C(0b10110100, 8), C(3)], C(0b110, 3))
+
def test_cat(self):
self.assertOperator(Cat, [C(0b10, 2), C(0b01, 2)], C(0b0110, 4))