mirror of https://github.com/m-labs/artiq.git
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
|
from migen import *
|
||
|
|
||
|
from artiq.gateware.rtio import rtlink
|
||
|
from .fastlink import SerDes
|
||
|
|
||
|
|
||
|
class Phaser(Module):
|
||
|
def __init__(self, pins, pins_n):
|
||
|
self.config = rtlink.Interface(
|
||
|
rtlink.OInterface(data_width=8, address_width=8,
|
||
|
enable_replace=False),
|
||
|
rtlink.IInterface(data_width=8))
|
||
|
self.data = rtlink.Interface(
|
||
|
rtlink.OInterface(data_width=32, address_width=8,
|
||
|
enable_replace=True))
|
||
|
|
||
|
self.submodules.serializer = SerDes(
|
||
|
pins, pins_n, t_clk=8, d_clk=0b00001111,
|
||
|
n_frame=10, n_crc=6, poly=0x2f)
|
||
|
|
||
|
header = Record([
|
||
|
("we", 1),
|
||
|
("addr", 7),
|
||
|
("data", 8),
|
||
|
("type", 4)
|
||
|
])
|
||
|
n_channels = 2
|
||
|
n_samples = 8
|
||
|
body = [[(Signal(14), Signal(14)) for i in range(n_channels)]
|
||
|
for j in range(n_samples)]
|
||
|
assert len(Cat(header.raw_bits(), body)) == \
|
||
|
len(self.serializer.payload)
|
||
|
self.comb += self.serializer.payload.eq(Cat(header.raw_bits(), body))
|
||
|
|
||
|
self.sync.rio_phy += [
|
||
|
If(self.serializer.stb,
|
||
|
header.we.eq(0),
|
||
|
),
|
||
|
If(self.config.o.stb,
|
||
|
header.we.eq(~self.config.o.address[-1]),
|
||
|
header.addr.eq(self.config.o.address),
|
||
|
header.data.eq(self.config.o.data),
|
||
|
header.type.eq(0), # reserved
|
||
|
),
|
||
|
]
|
||
|
|
||
|
self.sync.rtio += [
|
||
|
self.config.i.stb.eq(self.config.o.stb &
|
||
|
self.config.o.address[-1]),
|
||
|
self.config.i.data.eq(self.serializer.readback),
|
||
|
]
|