- (+) `Mux` id
- (+) `_Slice` → `Slice`, `stop=`→`end=`, `.stop`→`.end`
- (+) `_Part` → `Part`
- - (+) `Cat` id, `.l`→`.operands`
+ - (+) `Cat` id, `.l`→`.parts`
- (+) `Replicate` → `Repl`, `v=`→`value=`, `n=`→`count=`, `.v`→`.value`, `.n`→`.count`
- (+) `Constant` → `Const`, `bits_sign=`→`shape=`
- (+) `Signal` id, `bits_sign=`→`shape=`, `attr=`→`attrs=`, `name_override=`∼, `related=`, `variable=`∼
shape = value.shape()
parts = []
offset = 0
- for opnd in value.operands:
+ for opnd in value.parts:
parts.append((offset, (1 << len(opnd)) - 1, self(opnd)))
offset += len(opnd)
def eval(state):
def on_Cat(self, value):
parts = []
offset = 0
- for opnd in value.operands:
+ for opnd in value.parts:
parts.append((offset, (1 << len(opnd)) - 1, self(opnd)))
offset += len(opnd)
def eval(state, rhs):
"""
def __init__(self, *args):
super().__init__()
- self.operands = [Value.wrap(v) for v in flatten(args)]
+ self.parts = [Value.wrap(v) for v in flatten(args)]
def shape(self):
- return sum(len(op) for op in self.operands), False
+ return sum(len(op) for op in self.parts), False
def _lhs_signals(self):
- return union(op._lhs_signals() for op in self.operands)
+ return union(op._lhs_signals() for op in self.parts)
def _rhs_signals(self):
- return union(op._rhs_signals() for op in self.operands)
+ return union(op._rhs_signals() for op in self.parts)
def __repr__(self):
- return "(cat {})".format(" ".join(map(repr, self.operands)))
+ return "(cat {})".format(" ".join(map(repr, self.parts)))
class Repl(Value):
return Part(self.on_value(value.value), self.on_value(value.offset), value.width)
def on_Cat(self, value):
- return Cat(self.on_value(o) for o in value.operands)
+ return Cat(self.on_value(o) for o in value.parts)
def on_Repl(self, value):
return Repl(self.on_value(value.value), value.count)
self.assertEqual(s2.end, 2)
s3 = Const(31)[::2]
self.assertIsInstance(s3, Cat)
- self.assertIsInstance(s3.operands[0], Slice)
- self.assertEqual(s3.operands[0].start, 0)
- self.assertEqual(s3.operands[0].end, 1)
- self.assertIsInstance(s3.operands[1], Slice)
- self.assertEqual(s3.operands[1].start, 2)
- self.assertEqual(s3.operands[1].end, 3)
- self.assertIsInstance(s3.operands[2], Slice)
- self.assertEqual(s3.operands[2].start, 4)
- self.assertEqual(s3.operands[2].end, 5)
+ self.assertIsInstance(s3.parts[0], Slice)
+ self.assertEqual(s3.parts[0].start, 0)
+ self.assertEqual(s3.parts[0].end, 1)
+ self.assertIsInstance(s3.parts[1], Slice)
+ self.assertEqual(s3.parts[1].start, 2)
+ self.assertEqual(s3.parts[1].end, 3)
+ self.assertIsInstance(s3.parts[2], Slice)
+ self.assertEqual(s3.parts[2].start, 4)
+ self.assertEqual(s3.parts[2].end, 5)
def test_getitem_wrong(self):
with self.assertRaises(TypeError):