mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-19 08:26:30 +08:00
gateware: reverse bytes of SDRAM word, not bits.
This commit is contained in:
parent
6b63322106
commit
4de336fbe9
@ -7,8 +7,8 @@ from misoc.interconnect import stream, wishbone
|
|||||||
from artiq.gateware.rtio import cri
|
from artiq.gateware.rtio import cri
|
||||||
|
|
||||||
|
|
||||||
def _reverse_signal(s):
|
def _reverse_bytes(s, g):
|
||||||
return Cat(s[i] for i in reversed(range(len(s))))
|
return Cat(reversed(list(s[i*g:(i+1)*g] for i in range(len(s)//g))))
|
||||||
|
|
||||||
|
|
||||||
class WishboneReader(Module):
|
class WishboneReader(Module):
|
||||||
@ -39,7 +39,7 @@ class WishboneReader(Module):
|
|||||||
If(self.source.ack, data_reg_loaded.eq(0)),
|
If(self.source.ack, data_reg_loaded.eq(0)),
|
||||||
If(bus.ack,
|
If(bus.ack,
|
||||||
data_reg_loaded.eq(1),
|
data_reg_loaded.eq(1),
|
||||||
self.source.data.eq(_reverse_signal(bus.dat_r)),
|
self.source.data.eq(bus.dat_r),
|
||||||
self.source.eop.eq(self.sink.eop)
|
self.source.eop.eq(self.sink.eop)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -96,7 +96,7 @@ class RawSlicer(Module):
|
|||||||
# <data being shifted out> <new incoming word>
|
# <data being shifted out> <new incoming word>
|
||||||
buf_size = out_size - 1 + in_size
|
buf_size = out_size - 1 + in_size
|
||||||
buf = Signal(buf_size*g)
|
buf = Signal(buf_size*g)
|
||||||
self.comb += self.source.eq(buf[:out_size*8])
|
self.comb += self.source.eq(buf[:out_size*g])
|
||||||
|
|
||||||
level = Signal(max=buf_size+1)
|
level = Signal(max=buf_size+1)
|
||||||
next_level = Signal(max=buf_size+1)
|
next_level = Signal(max=buf_size+1)
|
||||||
@ -108,7 +108,7 @@ class RawSlicer(Module):
|
|||||||
|
|
||||||
self.sync += [
|
self.sync += [
|
||||||
If(load_buf, Case(level,
|
If(load_buf, Case(level,
|
||||||
{i: buf[i*g:(i+in_size)*g].eq(self.sink.data)
|
{i: buf[i*g:(i+in_size)*g].eq(_reverse_bytes(self.sink.data, g))
|
||||||
for i in range(out_size)})),
|
for i in range(out_size)})),
|
||||||
If(shift_buf, Case(self.source_consume,
|
If(shift_buf, Case(self.source_consume,
|
||||||
{i: buf.eq(buf[i*g:])
|
{i: buf.eq(buf[i*g:])
|
||||||
|
@ -31,14 +31,14 @@ def pack(x, size):
|
|||||||
r = []
|
r = []
|
||||||
for i in range((len(x)+size-1)//size):
|
for i in range((len(x)+size-1)//size):
|
||||||
n = 0
|
n = 0
|
||||||
for j, w in enumerate(x[i*size:(i+1)*size]):
|
for j in range(i*size, (i+1)*size):
|
||||||
n |= w << j*8
|
n <<= 8
|
||||||
nr = 0
|
try:
|
||||||
for i in range(size*8):
|
n |= x[j]
|
||||||
if (n >> i) & 1: nr |= 1 << (size*8 - 1 - i)
|
except IndexError:
|
||||||
# print("{:064x}".format(n))
|
pass
|
||||||
# print("{:064x}".format(nr))
|
# print("{:0128x}".format(n))
|
||||||
r.append(nr)
|
r.append(n)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user