migen/genlib/misc: add reverse_bytes
This commit is contained in:
parent
472665b81d
commit
e96ba1e46f
|
@ -1,3 +1,5 @@
|
||||||
|
import math
|
||||||
|
|
||||||
from migen.fhdl.std import *
|
from migen.fhdl.std import *
|
||||||
from migen.fhdl.structure import _Operator
|
from migen.fhdl.structure import _Operator
|
||||||
|
|
||||||
|
@ -64,6 +66,14 @@ def chooser(signal, shift, output, n=None, reverse=False):
|
||||||
return Case(shift, cases).makedefault()
|
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):
|
def timeline(trigger, events):
|
||||||
lastevent = max([e[0] for e in events])
|
lastevent = max([e[0] for e in events])
|
||||||
counter = Signal(max=lastevent+1)
|
counter = Signal(max=lastevent+1)
|
||||||
|
|
Loading…
Reference in New Issue