Views with an array layout should be indexable with a slice
whitequark opened this issue · 1 comments
whitequark commented
Currently this breaks (with a nicer message since c649045 / #1375) but there's no reason this can't work; it should return another ArrayLayout
instead:
File "/home/whitequark/Projects/glasgow/software/test.py", line 35, in elaborate
m.d.sync += o_reg.eq(o_reg[1:])
~~~~~^^^^
File "/home/whitequark/Projects/glasgow/software/.venv/lib/python3.12/site-packages/amaranth/lib/data.py", line 796, in __getitem__
raise TypeError(
TypeError: View cannot be indexed with a slice; did you mean to call `.as_value()` first?
whitequark commented
The workaround for the pattern above is fairly annoying too:
m.d.sync += o_reg.eq(o_reg.as_value()[len(o_reg[0]):])
# instead of
m.d.sync += o_reg.eq(o_reg[1:])