mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
gen: add common with reverse_bits/reverse_bytes functions
This commit is contained in:
parent
71fc34d7b6
commit
b796853893
2 changed files with 12 additions and 0 deletions
|
@ -1 +1,2 @@
|
|||
from litex.gen.sim import *
|
||||
from litex.gen.common import *
|
||||
|
|
11
litex/gen/common.py
Normal file
11
litex/gen/common.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from migen import *
|
||||
|
||||
|
||||
def reverse_bits(s):
|
||||
return s[::-1]
|
||||
|
||||
|
||||
def reverse_bytes(s):
|
||||
n = (len(s) + 7)//8
|
||||
return Cat(*[s[i*8:min((i + 1)*8, len(s))]
|
||||
for i in reversed(range(n))])
|
Loading…
Reference in a new issue