projects
/
litex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
472665b
)
migen/genlib/misc: add reverse_bytes
author
Florent Kermarrec
<florent@enjoy-digital.fr>
Mon, 27 Apr 2015 13:08:10 +0000
(15:08 +0200)
committer
Florent Kermarrec
<florent@enjoy-digital.fr>
Mon, 27 Apr 2015 13:08:10 +0000
(15:08 +0200)
migen/genlib/misc.py
patch
|
blob
|
history
diff --git
a/migen/genlib/misc.py
b/migen/genlib/misc.py
index fc7528a6e3cc878288e2f69a25b90429c965fe64..f13b93c3efa429c34e1457687a50500f7bba7ae9 100644
(file)
--- a/
migen/genlib/misc.py
+++ b/
migen/genlib/misc.py
@@
-1,3
+1,5
@@
+import math
+
from migen.fhdl.std import *
from migen.fhdl.structure import _Operator
@@
-64,6
+66,14
@@
def chooser(signal, shift, output, n=None, reverse=False):
return Case(shift, cases).makedefault()
+def reverse_bytes(signal):
+ n = math.ceil(flen(signal)/8)
+ r = []
+ for i in reversed(range(n)):
+ r.append(signal[i*8:min((i+1)*8, flen(signal))])
+ return Cat(iter(r))
+
+
def timeline(trigger, events):
lastevent = max([e[0] for e in events])
counter = Signal(max=lastevent+1)