Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions migen/fhdl/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ def __getitem__(self, key):
raise IndexError
if key < 0:
key += n
if key == 0 and n == 1:
return self
return _Slice(self, key, key+1)
elif isinstance(key, slice):
start, stop, step = key.indices(n)
if step != 1:
return Cat(self[i] for i in range(start, stop, step))
if start == 0 and stop == n:
return self
return _Slice(self, start, stop)
else:
raise TypeError("Cannot use type {} ({}) as key".format(
Expand Down