2017-08-20 23:47:45 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
2017-08-27 05:48:11 +08:00
|
|
|
import os
|
2018-01-22 18:25:10 +08:00
|
|
|
import warnings
|
2021-02-10 15:32:09 +08:00
|
|
|
from functools import partial
|
2017-08-20 23:47:45 +08:00
|
|
|
|
|
|
|
from migen import *
|
2021-02-10 15:32:09 +08:00
|
|
|
from migen.build.generic_platform import IOStandard
|
2017-08-20 23:47:45 +08:00
|
|
|
|
2018-01-22 18:33:22 +08:00
|
|
|
from misoc.cores import gpio
|
2017-08-20 23:47:45 +08:00
|
|
|
from misoc.integration.builder import builder_args, builder_argdict
|
2017-09-28 00:44:35 +08:00
|
|
|
from misoc.interconnect.csr import *
|
2019-02-25 23:49:45 +08:00
|
|
|
from misoc.targets.sayma_amc import *
|
2017-08-20 23:47:45 +08:00
|
|
|
|
2018-01-22 18:25:10 +08:00
|
|
|
from artiq.gateware.amp import AMPSoC
|
2020-08-31 15:26:39 +08:00
|
|
|
from artiq.gateware import eem
|
2017-08-20 23:47:45 +08:00
|
|
|
from artiq.gateware import rtio
|
2018-06-20 17:42:04 +08:00
|
|
|
from artiq.gateware import jesd204_tools
|
2020-08-31 15:26:39 +08:00
|
|
|
from artiq.gateware import fmcdio_vhdci_eem
|
2019-01-03 20:50:38 +08:00
|
|
|
from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_ultrascale, sawg
|
2018-01-22 18:25:10 +08:00
|
|
|
from artiq.gateware.drtio.transceiver import gth_ultrascale
|
2018-03-07 11:15:44 +08:00
|
|
|
from artiq.gateware.drtio.siphaser import SiPhaser7Series
|
2019-12-08 15:30:00 +08:00
|
|
|
from artiq.gateware.drtio.wrpll import WRPLL, DDMTDSamplerExtFF
|
2018-02-22 15:21:23 +08:00
|
|
|
from artiq.gateware.drtio.rx_synchronizer import XilinxRXSynchronizer
|
2018-09-05 17:56:56 +08:00
|
|
|
from artiq.gateware.drtio import *
|
2018-07-15 17:21:17 +08:00
|
|
|
from artiq.build_soc import *
|
2017-08-20 23:47:45 +08:00
|
|
|
|
|
|
|
|
2019-10-05 10:23:55 +08:00
|
|
|
def workaround_us_lvds_tristate(platform):
|
|
|
|
# Those shoddy Kintex Ultrascale FPGAs take almost a microsecond to change the direction of a
|
|
|
|
# LVDS I/O buffer. The application has to cope with it and this cannot be handled at static
|
|
|
|
# timing analysis. Disable the latter for IOBUFDS.
|
|
|
|
# See:
|
|
|
|
# https://forums.xilinx.com/t5/Timing-Analysis/Delay-890-ns-in-OBUFTDS-in-Kintex-UltraScale/td-p/868364
|
|
|
|
platform.add_platform_command(
|
|
|
|
"set_false_path -through [get_pins -filter {{REF_PIN_NAME == T}} -of [get_cells -filter {{REF_NAME == IOBUFDS}}]]")
|
|
|
|
|
|
|
|
|
|
|
|
class RTMUARTForward(Module):
|
|
|
|
def __init__(self, platform):
|
|
|
|
# forward RTM UART to second FTDI UART channel
|
|
|
|
serial_1 = platform.request("serial", 1)
|
|
|
|
serial_rtm = platform.request("serial_rtm")
|
|
|
|
self.comb += [
|
|
|
|
serial_1.tx.eq(serial_rtm.rx),
|
|
|
|
serial_rtm.tx.eq(serial_1.rx)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-10-30 21:39:00 +08:00
|
|
|
class SatelliteBase(MiniSoC):
|
2019-10-05 10:23:55 +08:00
|
|
|
mem_map = {
|
|
|
|
"drtioaux": 0x14000000,
|
|
|
|
}
|
2019-10-30 21:39:00 +08:00
|
|
|
mem_map.update(MiniSoC.mem_map)
|
2019-10-05 10:23:55 +08:00
|
|
|
|
2020-09-01 23:48:43 +08:00
|
|
|
def __init__(self, rtio_clk_freq=125e6, identifier_suffix="", gateware_identifier_str=None, with_sfp=False, *, with_wrpll, **kwargs):
|
2019-10-30 21:39:00 +08:00
|
|
|
MiniSoC.__init__(self,
|
2021-08-16 15:42:58 +08:00
|
|
|
cpu_type="vexriscv",
|
2019-10-05 10:23:55 +08:00
|
|
|
sdram_controller_type="minicon",
|
|
|
|
l2_size=128*1024,
|
2019-10-30 21:39:00 +08:00
|
|
|
integrated_sram_size=8192,
|
|
|
|
ethmac_nrxslots=4,
|
|
|
|
ethmac_ntxslots=4,
|
2019-10-05 10:23:55 +08:00
|
|
|
**kwargs)
|
2020-09-01 23:48:43 +08:00
|
|
|
add_identifier(self, suffix=identifier_suffix, gateware_identifier_str=gateware_identifier_str)
|
2019-10-08 12:30:47 +08:00
|
|
|
self.rtio_clk_freq = rtio_clk_freq
|
2019-10-05 10:23:55 +08:00
|
|
|
|
|
|
|
platform = self.platform
|
|
|
|
|
2019-11-20 19:16:04 +08:00
|
|
|
if with_wrpll:
|
|
|
|
clock_recout_pads = platform.request("ddmtd_rec_clk")
|
|
|
|
else:
|
|
|
|
clock_recout_pads = None
|
2020-05-29 14:58:49 +08:00
|
|
|
if with_sfp:
|
|
|
|
# Use SFP0 to connect to master (Kasli)
|
|
|
|
self.comb += platform.request("sfp_tx_disable", 0).eq(0)
|
|
|
|
drtio_uplink = platform.request("sfp", 0)
|
|
|
|
else:
|
|
|
|
drtio_uplink = platform.request("fat_pipe", 0)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.submodules.drtio_transceiver = gth_ultrascale.GTH(
|
|
|
|
clock_pads=platform.request("cdr_clk_clean"),
|
2020-05-29 14:58:49 +08:00
|
|
|
data_pads=[drtio_uplink, platform.request("rtm_amc_link")],
|
2019-10-05 10:23:55 +08:00
|
|
|
sys_clk_freq=self.clk_freq,
|
2019-11-20 19:16:04 +08:00
|
|
|
rtio_clk_freq=rtio_clk_freq,
|
|
|
|
clock_recout_pads=clock_recout_pads)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.csr_devices.append("drtio_transceiver")
|
|
|
|
|
|
|
|
self.submodules.rtio_tsc = rtio.TSC("sync", glbl_fine_ts_width=3)
|
|
|
|
|
|
|
|
drtioaux_csr_group = []
|
|
|
|
drtioaux_memory_group = []
|
|
|
|
drtiorep_csr_group = []
|
|
|
|
self.drtio_cri = []
|
|
|
|
for i in range(len(self.drtio_transceiver.channels)):
|
|
|
|
coreaux_name = "drtioaux" + str(i)
|
|
|
|
memory_name = "drtioaux" + str(i) + "_mem"
|
|
|
|
drtioaux_csr_group.append(coreaux_name)
|
|
|
|
drtioaux_memory_group.append(memory_name)
|
|
|
|
|
|
|
|
cdr = ClockDomainsRenamer({"rtio_rx": "rtio_rx" + str(i)})
|
|
|
|
|
|
|
|
if i == 0:
|
|
|
|
self.submodules.rx_synchronizer = cdr(XilinxRXSynchronizer())
|
|
|
|
core = cdr(DRTIOSatellite(
|
|
|
|
self.rtio_tsc, self.drtio_transceiver.channels[i],
|
|
|
|
self.rx_synchronizer))
|
|
|
|
self.submodules.drtiosat = core
|
|
|
|
self.csr_devices.append("drtiosat")
|
|
|
|
else:
|
|
|
|
corerep_name = "drtiorep" + str(i-1)
|
|
|
|
drtiorep_csr_group.append(corerep_name)
|
|
|
|
|
|
|
|
core = cdr(DRTIORepeater(
|
|
|
|
self.rtio_tsc, self.drtio_transceiver.channels[i]))
|
|
|
|
setattr(self.submodules, corerep_name, core)
|
|
|
|
self.drtio_cri.append(core.cri)
|
|
|
|
self.csr_devices.append(corerep_name)
|
|
|
|
|
|
|
|
coreaux = cdr(DRTIOAuxController(core.link_layer))
|
|
|
|
setattr(self.submodules, coreaux_name, coreaux)
|
|
|
|
self.csr_devices.append(coreaux_name)
|
|
|
|
|
|
|
|
memory_address = self.mem_map["drtioaux"] + 0x800*i
|
|
|
|
self.add_wb_slave(memory_address, 0x800,
|
|
|
|
coreaux.bus)
|
|
|
|
self.add_memory_region(memory_name, memory_address | self.shadow_base, 0x800)
|
|
|
|
self.config["HAS_DRTIO"] = None
|
|
|
|
self.config["HAS_DRTIO_ROUTING"] = None
|
|
|
|
self.add_csr_group("drtioaux", drtioaux_csr_group)
|
|
|
|
self.add_memory_group("drtioaux_mem", drtioaux_memory_group)
|
|
|
|
self.add_csr_group("drtiorep", drtiorep_csr_group)
|
|
|
|
|
2019-12-09 12:26:44 +08:00
|
|
|
rtio_clk_period = 1e9/rtio_clk_freq
|
2019-10-05 10:23:55 +08:00
|
|
|
self.config["RTIO_FREQUENCY"] = str(rtio_clk_freq/1e6)
|
2019-11-20 17:37:09 +08:00
|
|
|
if with_wrpll:
|
|
|
|
self.comb += [
|
2019-11-27 21:21:00 +08:00
|
|
|
platform.request("filtered_clk_sel").eq(0),
|
2019-11-20 17:37:09 +08:00
|
|
|
platform.request("ddmtd_main_dcxo_oe").eq(1),
|
|
|
|
platform.request("ddmtd_helper_dcxo_oe").eq(1)
|
|
|
|
]
|
2019-12-08 15:30:00 +08:00
|
|
|
self.submodules.wrpll_sampler = DDMTDSamplerExtFF(
|
|
|
|
platform.request("ddmtd_inputs"))
|
2019-11-20 17:37:09 +08:00
|
|
|
self.submodules.wrpll = WRPLL(
|
2019-11-28 17:40:00 +08:00
|
|
|
helper_clk_pads=platform.request("ddmtd_helper_clk"),
|
2019-11-20 17:37:09 +08:00
|
|
|
main_dcxo_i2c=platform.request("ddmtd_main_dcxo_i2c"),
|
2019-11-28 22:03:50 +08:00
|
|
|
helper_dxco_i2c=platform.request("ddmtd_helper_dcxo_i2c"),
|
2019-12-08 15:30:00 +08:00
|
|
|
ddmtd_inputs=self.wrpll_sampler)
|
2019-11-20 17:37:09 +08:00
|
|
|
self.csr_devices.append("wrpll")
|
2019-12-09 12:26:44 +08:00
|
|
|
platform.add_period_constraint(self.wrpll.cd_helper.clk, rtio_clk_period*0.99)
|
|
|
|
platform.add_false_path_constraints(self.crg.cd_sys.clk, self.wrpll.cd_helper.clk)
|
2019-11-27 21:21:00 +08:00
|
|
|
else:
|
|
|
|
self.comb += platform.request("filtered_clk_sel").eq(1)
|
|
|
|
self.submodules.siphaser = SiPhaser7Series(
|
|
|
|
si5324_clkin=platform.request("si5324_clkin"),
|
|
|
|
rx_synchronizer=self.rx_synchronizer,
|
|
|
|
ultrascale=True,
|
|
|
|
rtio_clk_freq=rtio_clk_freq)
|
|
|
|
platform.add_false_path_constraints(
|
|
|
|
self.crg.cd_sys.clk, self.siphaser.mmcm_freerun_output)
|
|
|
|
self.csr_devices.append("siphaser")
|
|
|
|
self.submodules.si5324_rst_n = gpio.GPIOOut(platform.request("si5324").rst_n)
|
|
|
|
self.csr_devices.append("si5324_rst_n")
|
|
|
|
i2c = self.platform.request("i2c")
|
|
|
|
self.submodules.i2c = gpio.GPIOTristate([i2c.scl, i2c.sda])
|
|
|
|
self.csr_devices.append("i2c")
|
|
|
|
self.config["I2C_BUS_COUNT"] = 1
|
|
|
|
self.config["HAS_SI5324"] = None
|
2019-11-20 17:37:09 +08:00
|
|
|
|
2019-10-05 10:23:55 +08:00
|
|
|
gth = self.drtio_transceiver.gths[0]
|
|
|
|
platform.add_period_constraint(gth.txoutclk, rtio_clk_period/2)
|
|
|
|
platform.add_period_constraint(gth.rxoutclk, rtio_clk_period)
|
|
|
|
platform.add_false_path_constraints(
|
|
|
|
self.crg.cd_sys.clk,
|
|
|
|
gth.txoutclk, gth.rxoutclk)
|
|
|
|
|
|
|
|
def add_rtio(self, rtio_channels):
|
|
|
|
# Only add MonInj core if there is anything to monitor
|
|
|
|
if any([len(c.probes) for c in rtio_channels]):
|
|
|
|
self.submodules.rtio_moninj = rtio.MonInj(rtio_channels)
|
|
|
|
self.csr_devices.append("rtio_moninj")
|
|
|
|
|
|
|
|
self.submodules.local_io = SyncRTIO(self.rtio_tsc, rtio_channels)
|
|
|
|
self.comb += self.drtiosat.async_errors.eq(self.local_io.async_errors)
|
|
|
|
self.submodules.cri_con = rtio.CRIInterconnectShared(
|
|
|
|
[self.drtiosat.cri],
|
|
|
|
[self.local_io.cri] + self.drtio_cri,
|
|
|
|
mode="sync", enable_routing=True)
|
|
|
|
self.csr_devices.append("cri_con")
|
|
|
|
self.submodules.routing_table = rtio.RoutingTableAccess(self.cri_con)
|
|
|
|
self.csr_devices.append("routing_table")
|
|
|
|
|
|
|
|
|
2019-10-06 20:15:09 +08:00
|
|
|
# JESD204 DAC Channel Group
|
2020-04-07 21:17:04 +08:00
|
|
|
class JDCGSAWG(Module, AutoCSR):
|
2017-11-10 17:48:32 +08:00
|
|
|
def __init__(self, platform, sys_crg, jesd_crg, dac):
|
2020-12-15 18:06:02 +08:00
|
|
|
# Kintex Ultrascale GTH, speed grade -1C:
|
|
|
|
# CPLL linerate (D=1): 4.0 - 8.5 Gb/s
|
2018-06-20 17:42:04 +08:00
|
|
|
self.submodules.jesd = jesd204_tools.UltrascaleTX(
|
|
|
|
platform, sys_crg, jesd_crg, dac)
|
2017-09-28 00:44:35 +08:00
|
|
|
|
2020-04-07 21:17:04 +08:00
|
|
|
self.submodules.sawgs = [sawg.Channel(width=16, parallelism=4) for i in range(4)]
|
2017-09-28 00:44:35 +08:00
|
|
|
|
2017-11-19 21:36:20 +08:00
|
|
|
for conv, ch in zip(self.jesd.core.sink.flatten(), self.sawgs):
|
2017-12-30 02:15:40 +08:00
|
|
|
assert len(Cat(ch.o)) == len(conv)
|
2017-11-19 21:36:20 +08:00
|
|
|
self.sync.jesd += conv.eq(Cat(ch.o))
|
2017-09-28 00:44:35 +08:00
|
|
|
|
|
|
|
|
2020-04-07 21:17:04 +08:00
|
|
|
class JDCGPattern(Module, AutoCSR):
|
2017-12-31 19:18:37 +08:00
|
|
|
def __init__(self, platform, sys_crg, jesd_crg, dac):
|
2018-06-20 17:42:04 +08:00
|
|
|
self.submodules.jesd = jesd204_tools.UltrascaleTX(
|
|
|
|
platform, sys_crg, jesd_crg, dac)
|
2017-12-31 19:18:37 +08:00
|
|
|
|
|
|
|
self.sawgs = []
|
|
|
|
|
2018-06-06 16:02:20 +08:00
|
|
|
ramp = Signal(4)
|
|
|
|
self.sync.rtio += ramp.eq(ramp + 1)
|
|
|
|
|
|
|
|
samples = [[Signal(16) for i in range(4)] for j in range(4)]
|
|
|
|
self.comb += [
|
|
|
|
a.eq(Cat(b)) for a, b in zip(
|
|
|
|
self.jesd.core.sink.flatten(), samples)
|
|
|
|
]
|
|
|
|
# ch0: 16-step ramp with big carry toggles
|
|
|
|
for i in range(4):
|
|
|
|
self.comb += [
|
|
|
|
samples[0][i][-4:].eq(ramp),
|
|
|
|
samples[0][i][:-4].eq(0x7ff if i % 2 else 0x800)
|
|
|
|
]
|
|
|
|
# ch1: 50 MHz
|
|
|
|
from math import pi, cos
|
|
|
|
data = [int(round(cos(i/12*2*pi)*((1 << 15) - 1)))
|
|
|
|
for i in range(12)]
|
|
|
|
k = Signal(2)
|
|
|
|
self.sync.rtio += If(k == 2, k.eq(0)).Else(k.eq(k + 1))
|
|
|
|
self.comb += [
|
|
|
|
Case(k, {
|
|
|
|
i: [samples[1][j].eq(data[i*4 + j]) for j in range(4)]
|
|
|
|
for i in range(3)
|
|
|
|
})
|
|
|
|
]
|
|
|
|
# ch2: ch0, ch3: ch1
|
|
|
|
self.comb += [
|
|
|
|
Cat(samples[2]).eq(Cat(samples[0])),
|
|
|
|
Cat(samples[3]).eq(Cat(samples[1]))
|
|
|
|
]
|
2017-12-31 19:18:37 +08:00
|
|
|
|
2019-10-05 09:40:47 +08:00
|
|
|
|
2020-04-07 21:17:04 +08:00
|
|
|
class JDCGSyncDDS(Module, AutoCSR):
|
|
|
|
def __init__(self, platform, sys_crg, jesd_crg, dac):
|
|
|
|
self.submodules.jesd = jesd204_tools.UltrascaleTX(
|
|
|
|
platform, sys_crg, jesd_crg, dac)
|
|
|
|
self.coarse_ts = Signal(32)
|
|
|
|
|
|
|
|
self.sawgs = []
|
|
|
|
|
2020-04-08 15:00:33 +08:00
|
|
|
ftw = round(2**len(self.coarse_ts)*9e6/600e6)
|
2020-04-07 21:17:04 +08:00
|
|
|
parallelism = 4
|
|
|
|
|
|
|
|
mul_1 = Signal.like(self.coarse_ts)
|
|
|
|
mul_2 = Signal.like(self.coarse_ts)
|
|
|
|
mul_3 = Signal.like(self.coarse_ts)
|
|
|
|
self.sync.rtio += [
|
2020-04-08 15:00:33 +08:00
|
|
|
mul_1.eq(self.coarse_ts*ftw*parallelism),
|
2020-04-07 21:17:04 +08:00
|
|
|
mul_2.eq(mul_1),
|
|
|
|
mul_3.eq(mul_2)
|
|
|
|
]
|
|
|
|
|
|
|
|
phases = [Signal.like(self.coarse_ts) for i in range(parallelism)]
|
2020-04-08 15:00:33 +08:00
|
|
|
self.sync.rtio += [phases[i].eq(mul_3 + i*ftw) for i in range(parallelism)]
|
2020-04-07 21:17:04 +08:00
|
|
|
|
|
|
|
resolution = 10
|
|
|
|
steps = 2**resolution
|
|
|
|
from math import pi, cos
|
|
|
|
data = [(2**16 + round(cos(i/steps*2*pi)*((1 << 15) - 1))) & 0xffff
|
|
|
|
for i in range(steps)]
|
|
|
|
samples = [Signal(16) for i in range(4)]
|
|
|
|
for phase, sample in zip(phases, samples):
|
|
|
|
table = Memory(16, steps, init=data)
|
|
|
|
table_port = table.get_port(clock_domain="rtio")
|
|
|
|
self.specials += table, table_port
|
|
|
|
self.comb += [
|
|
|
|
table_port.adr.eq(phase >> (len(self.coarse_ts) - resolution)),
|
|
|
|
sample.eq(table_port.dat_r)
|
|
|
|
]
|
|
|
|
|
|
|
|
self.sync.rtio += [sink.eq(Cat(samples))
|
|
|
|
for sink in self.jesd.core.sink.flatten()]
|
|
|
|
|
|
|
|
|
2019-10-06 18:09:42 +08:00
|
|
|
class Satellite(SatelliteBase):
|
|
|
|
"""
|
2020-08-31 15:26:39 +08:00
|
|
|
DRTIO satellite with local DAC/SAWG channels, as well as TTL channels via FMC and VHDCI carrier.
|
2019-10-06 18:09:42 +08:00
|
|
|
"""
|
2020-04-07 21:17:04 +08:00
|
|
|
def __init__(self, jdcg_type, **kwargs):
|
2019-10-06 18:09:42 +08:00
|
|
|
SatelliteBase.__init__(self, 150e6,
|
2020-04-07 21:17:04 +08:00
|
|
|
identifier_suffix="." + jdcg_type,
|
2019-10-06 18:09:42 +08:00
|
|
|
**kwargs)
|
|
|
|
|
2019-10-05 09:40:47 +08:00
|
|
|
platform = self.platform
|
|
|
|
|
2019-10-06 18:09:42 +08:00
|
|
|
self.submodules += RTMUARTForward(platform)
|
|
|
|
|
2018-01-16 15:28:00 +08:00
|
|
|
# RTM bitstream upload
|
2018-03-01 00:45:55 +08:00
|
|
|
slave_fpga_cfg = self.platform.request("rtm_fpga_cfg")
|
|
|
|
self.submodules.slave_fpga_cfg = gpio.GPIOTristate([
|
|
|
|
slave_fpga_cfg.cclk,
|
|
|
|
slave_fpga_cfg.din,
|
|
|
|
slave_fpga_cfg.done,
|
|
|
|
slave_fpga_cfg.init_b,
|
|
|
|
slave_fpga_cfg.program_b,
|
|
|
|
])
|
2018-06-16 18:47:26 +08:00
|
|
|
self.csr_devices.append("slave_fpga_cfg")
|
2018-05-09 19:47:29 +08:00
|
|
|
self.config["SLAVE_FPGA_GATEWARE"] = 0x200000
|
2018-01-16 15:28:00 +08:00
|
|
|
|
2020-08-31 15:26:39 +08:00
|
|
|
self.rtio_channels = rtio_channels = []
|
2019-10-05 10:23:55 +08:00
|
|
|
for i in range(4):
|
|
|
|
phy = ttl_simple.Output(platform.request("user_led", i))
|
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
2019-10-07 20:31:35 +08:00
|
|
|
mcx_io = platform.request("mcx_io", 0)
|
2019-10-16 18:48:42 +08:00
|
|
|
phy = ttl_serdes_ultrascale.InOut(4, mcx_io.level)
|
|
|
|
self.comb += mcx_io.direction.eq(phy.oe)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
2019-10-07 20:31:35 +08:00
|
|
|
mcx_io = platform.request("mcx_io", 1)
|
|
|
|
phy = ttl_serdes_ultrascale.InOut(4, mcx_io.level)
|
2019-10-16 18:48:42 +08:00
|
|
|
self.comb += mcx_io.direction.eq(phy.oe)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
|
|
|
|
2019-10-06 20:15:09 +08:00
|
|
|
self.submodules.jesd_crg = jesd204_tools.UltrascaleCRG(
|
2019-10-05 10:23:55 +08:00
|
|
|
platform, use_rtio_clock=True)
|
2020-04-07 21:17:04 +08:00
|
|
|
cls = {
|
|
|
|
"sawg": JDCGSAWG,
|
|
|
|
"pattern": JDCGPattern,
|
|
|
|
"syncdds": JDCGSyncDDS
|
|
|
|
}[jdcg_type]
|
2019-10-06 20:15:09 +08:00
|
|
|
self.submodules.jdcg_0 = cls(platform, self.crg, self.jesd_crg, 0)
|
|
|
|
self.submodules.jdcg_1 = cls(platform, self.crg, self.jesd_crg, 1)
|
|
|
|
self.csr_devices.append("jesd_crg")
|
|
|
|
self.csr_devices.append("jdcg_0")
|
|
|
|
self.csr_devices.append("jdcg_1")
|
|
|
|
self.config["HAS_JDCG"] = None
|
|
|
|
self.add_csr_group("jdcg", ["jdcg_0", "jdcg_1"])
|
2019-10-05 10:23:55 +08:00
|
|
|
self.config["RTIO_FIRST_SAWG_CHANNEL"] = len(rtio_channels)
|
|
|
|
rtio_channels.extend(rtio.Channel.from_phy(phy)
|
2019-10-06 20:15:09 +08:00
|
|
|
for sawg in self.jdcg_0.sawgs +
|
|
|
|
self.jdcg_1.sawgs
|
2019-10-05 10:23:55 +08:00
|
|
|
for phy in sawg.phys)
|
|
|
|
|
2020-08-31 15:26:39 +08:00
|
|
|
# FMC-VHDCI-EEM DIOs x 2 (all OUTPUTs)
|
|
|
|
platform.add_connectors(fmcdio_vhdci_eem.connectors)
|
2021-02-10 15:32:09 +08:00
|
|
|
output_4x = partial(ttl_serdes_ultrascale.Output, 4)
|
2020-08-31 15:26:39 +08:00
|
|
|
eem.DIO.add_std(self, 0,
|
2021-02-10 15:32:09 +08:00
|
|
|
output_4x, output_4x,
|
|
|
|
iostandard=lambda eem: IOStandard("LVDS"))
|
2020-08-31 15:26:39 +08:00
|
|
|
eem.DIO.add_std(self, 1,
|
2021-02-10 15:32:09 +08:00
|
|
|
output_4x, output_4x,
|
|
|
|
iostandard=lambda eem: IOStandard("LVDS"))
|
2020-08-31 15:26:39 +08:00
|
|
|
# FMC-DIO-32ch-LVDS-a Direction Control Pins (via shift register) as TTLs x 3
|
|
|
|
platform.add_extension(fmcdio_vhdci_eem.io)
|
|
|
|
print("fmcdio_vhdci_eem.[CLK, SER, LATCH] starting at RTIO channel 0x{:06x}"
|
|
|
|
.format(len(rtio_channels)))
|
|
|
|
fmcdio_dirctl = platform.request("fmcdio_dirctl", 0)
|
|
|
|
fmcdio_dirctl_phys = [
|
|
|
|
ttl_simple.Output(fmcdio_dirctl.clk),
|
|
|
|
ttl_simple.Output(fmcdio_dirctl.ser),
|
|
|
|
ttl_simple.Output(fmcdio_dirctl.latch)
|
|
|
|
]
|
|
|
|
for phy in fmcdio_dirctl_phys:
|
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
|
|
|
workaround_us_lvds_tristate(platform)
|
|
|
|
|
2019-10-05 10:23:55 +08:00
|
|
|
self.add_rtio(rtio_channels)
|
|
|
|
|
|
|
|
self.submodules.sysref_sampler = jesd204_tools.SysrefSampler(
|
2019-10-08 12:30:47 +08:00
|
|
|
platform.request("amc_fpga_sysref", 0), self.rtio_tsc.coarse_ts)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.csr_devices.append("sysref_sampler")
|
2019-10-06 20:15:09 +08:00
|
|
|
self.jdcg_0.jesd.core.register_jref(self.sysref_sampler.jref)
|
|
|
|
self.jdcg_1.jesd.core.register_jref(self.sysref_sampler.jref)
|
2020-04-07 21:17:04 +08:00
|
|
|
if jdcg_type == "syncdds":
|
|
|
|
self.comb += [
|
|
|
|
self.jdcg_0.coarse_ts.eq(self.rtio_tsc.coarse_ts),
|
|
|
|
self.jdcg_1.coarse_ts.eq(self.rtio_tsc.coarse_ts),
|
|
|
|
]
|
2019-10-05 10:23:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
class SimpleSatellite(SatelliteBase):
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
SatelliteBase.__init__(self, **kwargs)
|
|
|
|
|
|
|
|
platform = self.platform
|
|
|
|
|
|
|
|
self.submodules += RTMUARTForward(platform)
|
|
|
|
|
|
|
|
rtio_channels = []
|
|
|
|
for i in range(4):
|
|
|
|
phy = ttl_simple.Output(platform.request("user_led", i))
|
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
2019-10-07 20:31:35 +08:00
|
|
|
mcx_io = platform.request("mcx_io", 0)
|
2019-10-16 18:48:42 +08:00
|
|
|
phy = ttl_serdes_ultrascale.InOut(4, mcx_io.level)
|
|
|
|
self.comb += mcx_io.direction.eq(phy.oe)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
2019-10-07 20:31:35 +08:00
|
|
|
mcx_io = platform.request("mcx_io", 1)
|
|
|
|
phy = ttl_serdes_ultrascale.InOut(4, mcx_io.level)
|
2019-10-16 18:48:42 +08:00
|
|
|
self.comb += mcx_io.direction.eq(phy.oe)
|
2019-10-05 10:23:55 +08:00
|
|
|
self.submodules += phy
|
|
|
|
rtio_channels.append(rtio.Channel.from_phy(phy))
|
|
|
|
|
|
|
|
self.add_rtio(rtio_channels)
|
2019-01-09 13:47:08 +08:00
|
|
|
|
|
|
|
|
2017-08-20 23:47:45 +08:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
2018-01-22 18:25:10 +08:00
|
|
|
description="Sayma AMC gateware and firmware builder")
|
2017-08-20 23:47:45 +08:00
|
|
|
builder_args(parser)
|
2019-02-25 23:49:45 +08:00
|
|
|
soc_sayma_amc_args(parser)
|
2018-01-28 03:53:43 +08:00
|
|
|
parser.set_defaults(output_dir="artiq_sayma")
|
2019-03-23 13:37:55 +08:00
|
|
|
parser.add_argument("-V", "--variant", default="satellite",
|
2020-05-29 14:40:49 +08:00
|
|
|
help="variant: satellite/simplesatellite "
|
2018-01-22 18:25:10 +08:00
|
|
|
"(default: %(default)s)")
|
2020-12-07 18:02:36 +08:00
|
|
|
parser.add_argument("--sfp", default=False, action="store_true",
|
2020-05-29 14:58:49 +08:00
|
|
|
help="use SFP port for DRTIO instead of uTCA backplane")
|
2017-08-27 05:48:11 +08:00
|
|
|
parser.add_argument("--rtm-csr-csv",
|
2018-01-28 22:27:08 +08:00
|
|
|
default=os.path.join("artiq_sayma", "rtm_gateware", "rtm_csr.csv"),
|
2017-08-27 05:48:11 +08:00
|
|
|
help="CSV file listing remote CSRs on RTM (default: %(default)s)")
|
2020-04-07 21:17:04 +08:00
|
|
|
parser.add_argument("--jdcg-type",
|
|
|
|
default="sawg",
|
|
|
|
help="Change type of signal generator. This is used exclusively for "
|
|
|
|
"development and debugging.")
|
2019-11-20 17:37:09 +08:00
|
|
|
parser.add_argument("--with-wrpll", default=False, action="store_true")
|
2020-09-01 23:48:43 +08:00
|
|
|
parser.add_argument("--gateware-identifier-str", default=None,
|
2020-08-28 05:56:57 +08:00
|
|
|
help="Override ROM identifier")
|
2017-08-20 23:47:45 +08:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2018-01-22 18:25:10 +08:00
|
|
|
variant = args.variant.lower()
|
2019-10-05 10:23:55 +08:00
|
|
|
if variant == "satellite":
|
2020-08-28 05:56:57 +08:00
|
|
|
soc = Satellite(
|
|
|
|
with_sfp=args.sfp,
|
|
|
|
jdcg_type=args.jdcg_type,
|
|
|
|
with_wrpll=args.with_wrpll,
|
2020-09-01 23:48:43 +08:00
|
|
|
gateware_identifier_str=args.gateware_identifier_str,
|
2020-08-28 05:56:57 +08:00
|
|
|
**soc_sayma_amc_argdict(args))
|
2019-10-05 10:23:55 +08:00
|
|
|
elif variant == "simplesatellite":
|
2020-08-28 05:56:57 +08:00
|
|
|
soc = SimpleSatellite(
|
|
|
|
with_sfp=args.sfp,
|
|
|
|
with_wrpll=args.with_wrpll,
|
2020-09-01 23:48:43 +08:00
|
|
|
gateware_identifier_str=args.gateware_identifier_str,
|
2020-08-28 05:56:57 +08:00
|
|
|
**soc_sayma_amc_argdict(args))
|
2019-10-05 10:23:55 +08:00
|
|
|
else:
|
|
|
|
raise SystemExit("Invalid variant (-V/--variant)")
|
2017-08-27 05:48:11 +08:00
|
|
|
|
2017-08-20 23:47:45 +08:00
|
|
|
build_artiq_soc(soc, builder_argdict(args))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|