Skip to content

Commit b5b17f3

Browse files
committed
stream.Split supports reverse flag
1 parent ffedbdc commit b5b17f3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

veriloggen/stream/stypes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ def eval(self):
15271527
return Slice(var, msb, lsb)
15281528

15291529

1530-
def Split(data, width=None, point=None, signed=None, num_chunks=None):
1530+
def Split(data, width=None, point=None, signed=None, num_chunks=None, reverse=False):
15311531
"""
15321532
Split the given data into multiple chunks
15331533
@@ -1548,6 +1548,9 @@ def Split(data, width=None, point=None, signed=None, num_chunks=None):
15481548
num_chunks: int
15491549
The number of separated chunks (default: (input data width) / width)
15501550
1551+
reverse: bool
1552+
reverse flag. If true, a reversed list is returned
1553+
15511554
Returns
15521555
-------
15531556
chunks : list
@@ -1556,6 +1559,7 @@ def Split(data, width=None, point=None, signed=None, num_chunks=None):
15561559
For the consistency with Cat operator, the order of chunks is higher-bit first.
15571560
If data is a 32-bit value, and width is 8, returned list of chunks will be
15581561
chunks = [data[31:24], data[23:16], data[15:8], data[7:0]]
1562+
If reverse == True, it returns the reversed list of chunks
15591563
"""
15601564

15611565
data = _to_constant(data)
@@ -1600,7 +1604,9 @@ def Split(data, width=None, point=None, signed=None, num_chunks=None):
16001604

16011605
ret.append(ReinterpretCast(v, width, point, signed))
16021606

1603-
ret.reverse()
1607+
if not reverse:
1608+
ret.reverse()
1609+
16041610
return ret
16051611

16061612

0 commit comments

Comments
 (0)