2021-02-07 14:44:09 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
from operator import itemgetter
|
|
|
|
|
|
|
|
from migen import *
|
|
|
|
from migen.build.generic_platform import *
|
|
|
|
from migen.genlib.resetsync import AsyncResetSynchronizer
|
|
|
|
from migen.genlib.cdc import MultiReg
|
|
|
|
from migen_axi.integration.soc_core import SoCCore
|
|
|
|
from migen_axi.platforms import kasli_soc
|
|
|
|
from misoc.interconnect.csr import *
|
2023-08-28 16:08:10 +08:00
|
|
|
from misoc.cores import virtual_leds
|
2021-02-07 14:44:09 +08:00
|
|
|
|
|
|
|
from artiq.coredevice import jsondesc
|
|
|
|
from artiq.gateware import rtio, eem_7series
|
2023-02-17 15:52:43 +08:00
|
|
|
from artiq.gateware.rtio.xilinx_clocking import fix_serdes_timing_path
|
2021-05-30 20:40:53 +08:00
|
|
|
from artiq.gateware.rtio.phy import ttl_simple
|
2023-10-10 10:41:07 +08:00
|
|
|
from artiq.gateware.drtio.transceiver import gtx_7series, eem_serdes
|
2021-10-08 16:12:30 +08:00
|
|
|
from artiq.gateware.drtio.siphaser import SiPhaser7Series
|
|
|
|
from artiq.gateware.drtio.rx_synchronizer import XilinxRXSynchronizer
|
|
|
|
from artiq.gateware.drtio import *
|
2021-02-07 14:44:09 +08:00
|
|
|
|
|
|
|
import dma
|
|
|
|
import analyzer
|
|
|
|
import acpki
|
2021-10-08 16:12:30 +08:00
|
|
|
import drtio_aux_controller
|
2023-02-17 15:52:43 +08:00
|
|
|
import zynq_clocking
|
2023-09-11 11:15:55 +08:00
|
|
|
from config import write_csr_file, write_mem_file, write_rustc_cfg_file
|
2021-02-07 14:44:09 +08:00
|
|
|
|
2021-02-07 22:34:29 +08:00
|
|
|
eem_iostandard_dict = {
|
|
|
|
0: "LVDS_25",
|
|
|
|
1: "LVDS_25",
|
|
|
|
2: "LVDS",
|
|
|
|
3: "LVDS",
|
|
|
|
4: "LVDS",
|
|
|
|
5: "LVDS",
|
|
|
|
6: "LVDS",
|
|
|
|
7: "LVDS",
|
|
|
|
8: "LVDS_25",
|
|
|
|
9: "LVDS_25",
|
|
|
|
10: "LVDS",
|
|
|
|
11: "LVDS",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def eem_iostandard(eem):
|
|
|
|
return IOStandard(eem_iostandard_dict[eem])
|
|
|
|
|
|
|
|
|
2022-03-09 12:43:47 +08:00
|
|
|
class SMAClkinForward(Module):
|
|
|
|
def __init__(self, platform):
|
|
|
|
sma_clkin = platform.request("sma_clkin")
|
|
|
|
sma_clkin_se = Signal()
|
|
|
|
cdr_clk_se = Signal()
|
|
|
|
cdr_clk = platform.request("cdr_clk")
|
|
|
|
self.specials += [
|
|
|
|
Instance("IBUFDS", i_I=sma_clkin.p, i_IB=sma_clkin.n, o_O=sma_clkin_se),
|
|
|
|
Instance("ODDR", i_C=sma_clkin_se, i_CE=1, i_D1=1, i_D2=0, o_Q=cdr_clk_se),
|
|
|
|
Instance("OBUFDS", i_I=cdr_clk_se, o_O=cdr_clk.p, o_OB=cdr_clk.n)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-10-06 15:21:38 +08:00
|
|
|
class GTPBootstrapClock(Module):
|
|
|
|
def __init__(self, platform, freq=125e6):
|
2023-02-17 15:52:43 +08:00
|
|
|
self.clock_domains.cd_bootstrap = ClockDomain(reset_less=True)
|
|
|
|
self.cd_bootstrap.clk.attr.add("keep")
|
|
|
|
|
|
|
|
bootstrap_125 = platform.request("clk125_gtp")
|
|
|
|
bootstrap_se = Signal()
|
2023-10-06 15:21:38 +08:00
|
|
|
clk_out = Signal()
|
2023-02-17 15:52:43 +08:00
|
|
|
platform.add_period_constraint(bootstrap_125.p, 8.0)
|
|
|
|
self.specials += [
|
|
|
|
Instance("IBUFDS_GTE2",
|
|
|
|
i_CEB=0,
|
2023-05-30 12:01:02 +08:00
|
|
|
i_I=bootstrap_125.p, i_IB=bootstrap_125.n,
|
|
|
|
o_O=bootstrap_se,
|
|
|
|
p_CLKCM_CFG="TRUE",
|
|
|
|
p_CLKRCV_TRST="TRUE",
|
|
|
|
p_CLKSWING_CFG=3),
|
2023-10-06 15:21:38 +08:00
|
|
|
Instance("BUFG", i_I=bootstrap_se, o_O=clk_out)
|
2023-02-17 15:52:43 +08:00
|
|
|
]
|
2023-10-06 15:21:38 +08:00
|
|
|
if freq == 125e6:
|
|
|
|
self.comb += self.cd_bootstrap.clk.eq(clk_out)
|
|
|
|
elif freq == 100e6:
|
|
|
|
pll_fb = Signal()
|
|
|
|
pll_out = Signal()
|
|
|
|
self.specials += [
|
|
|
|
Instance("PLLE2_BASE",
|
|
|
|
p_CLKIN1_PERIOD=8.0,
|
|
|
|
i_CLKIN1=clk_out,
|
|
|
|
i_CLKFBIN=pll_fb,
|
|
|
|
o_CLKFBOUT=pll_fb,
|
|
|
|
|
|
|
|
# VCO @ 1GHz
|
|
|
|
p_CLKFBOUT_MULT=8, p_DIVCLK_DIVIDE=1,
|
|
|
|
|
|
|
|
# 100MHz for bootstrap
|
|
|
|
p_CLKOUT1_DIVIDE=10, p_CLKOUT1_PHASE=0.0, o_CLKOUT1=pll_out,
|
|
|
|
),
|
|
|
|
Instance("BUFG", i_I=pll_out, o_O=self.cd_bootstrap.clk)
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
raise ValueError("Bootstrap frequency must be 100 or 125MHz")
|
2023-02-17 15:52:43 +08:00
|
|
|
|
|
|
|
|
2021-02-07 14:44:09 +08:00
|
|
|
class GenericStandalone(SoCCore):
|
|
|
|
def __init__(self, description, acpki=False):
|
|
|
|
self.acpki = acpki
|
2023-08-28 16:08:10 +08:00
|
|
|
|
2021-02-07 14:44:09 +08:00
|
|
|
platform = kasli_soc.Platform()
|
|
|
|
platform.toolchain.bitstream_commands.extend([
|
|
|
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
|
|
|
])
|
2022-06-07 16:21:16 +08:00
|
|
|
ident = description["variant"]
|
2021-02-07 14:44:09 +08:00
|
|
|
if self.acpki:
|
|
|
|
ident = "acpki_" + ident
|
2023-02-17 15:52:43 +08:00
|
|
|
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident, ps_cd_sys=False)
|
2021-02-07 14:44:09 +08:00
|
|
|
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HW_REV"] = description["hw_rev"]
|
2023-10-06 15:21:38 +08:00
|
|
|
|
2023-08-30 14:56:12 +08:00
|
|
|
|
2022-03-09 12:43:47 +08:00
|
|
|
self.submodules += SMAClkinForward(self.platform)
|
|
|
|
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_SI5324"] = None
|
|
|
|
self.config["SI5324_SOFT_RESET"] = None
|
2021-08-04 09:12:38 +08:00
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
clk_synth = platform.request("cdr_clk_clean_fabric")
|
|
|
|
clk_synth_se = Signal()
|
2023-10-11 10:07:06 +08:00
|
|
|
clk_synth_se_buf = Signal()
|
2023-02-17 15:52:43 +08:00
|
|
|
platform.add_period_constraint(clk_synth.p, 8.0)
|
|
|
|
|
2023-10-11 10:07:06 +08:00
|
|
|
self.specials += [
|
|
|
|
Instance("IBUFGDS",
|
2023-02-17 15:52:43 +08:00
|
|
|
p_DIFF_TERM="TRUE", p_IBUF_LOW_PWR="FALSE",
|
2023-10-11 10:07:06 +08:00
|
|
|
i_I=clk_synth.p, i_IB=clk_synth.n, o_O=clk_synth_se
|
|
|
|
),
|
|
|
|
Instance("BUFG", i_I=clk_synth_se, o_O=clk_synth_se_buf),
|
|
|
|
]
|
2023-02-17 15:52:43 +08:00
|
|
|
fix_serdes_timing_path(platform)
|
2023-10-06 15:21:38 +08:00
|
|
|
self.submodules.bootstrap = GTPBootstrapClock(self.platform, description["rtio_frequency"])
|
2023-02-17 15:52:43 +08:00
|
|
|
|
2023-10-11 10:07:06 +08:00
|
|
|
self.submodules.sys_crg = zynq_clocking.SYSCRG(self.platform, self.ps7, clk_synth_se_buf)
|
2023-02-17 15:52:43 +08:00
|
|
|
platform.add_false_path_constraints(
|
|
|
|
self.bootstrap.cd_bootstrap.clk, self.sys_crg.cd_sys.clk)
|
|
|
|
self.csr_devices.append("sys_crg")
|
2021-02-07 14:44:09 +08:00
|
|
|
self.crg = self.ps7 # HACK for eem_7series to find the clock
|
2023-02-17 15:52:43 +08:00
|
|
|
self.crg.cd_sys = self.sys_crg.cd_sys
|
2021-02-07 14:44:09 +08:00
|
|
|
|
|
|
|
self.rtio_channels = []
|
|
|
|
has_grabber = any(peripheral["type"] == "grabber" for peripheral in description["peripherals"])
|
|
|
|
if has_grabber:
|
|
|
|
self.grabber_csr_group = []
|
2021-02-07 22:34:29 +08:00
|
|
|
eem_7series.add_peripherals(self, description["peripherals"], iostandard=eem_iostandard)
|
2021-05-30 20:40:53 +08:00
|
|
|
for i in (0, 1):
|
|
|
|
print("USER LED at RTIO channel 0x{:06x}".format(len(self.rtio_channels)))
|
|
|
|
user_led = self.platform.request("user_led", i)
|
|
|
|
phy = ttl_simple.Output(user_led)
|
|
|
|
self.submodules += phy
|
|
|
|
self.rtio_channels.append(rtio.Channel.from_phy(phy))
|
2021-02-15 19:56:59 +08:00
|
|
|
self.config["RTIO_LOG_CHANNEL"] = len(self.rtio_channels)
|
|
|
|
self.rtio_channels.append(rtio.LogChannel())
|
2021-02-07 14:44:09 +08:00
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
self.submodules.rtio_tsc = rtio.TSC(glbl_fine_ts_width=3)
|
2023-10-04 23:49:09 +08:00
|
|
|
self.submodules.rtio_core = rtio.Core(
|
|
|
|
self.rtio_tsc, self.rtio_channels, lane_count=description["sed_lanes"]
|
|
|
|
)
|
2021-02-07 14:44:09 +08:00
|
|
|
self.csr_devices.append("rtio_core")
|
|
|
|
|
|
|
|
if self.acpki:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["KI_IMPL"] = "acp"
|
2021-02-07 14:44:09 +08:00
|
|
|
self.submodules.rtio = acpki.KernelInitiator(self.rtio_tsc,
|
|
|
|
bus=self.ps7.s_axi_acp,
|
|
|
|
user=self.ps7.s_axi_acp_user,
|
|
|
|
evento=self.ps7.event.o)
|
|
|
|
self.csr_devices.append("rtio")
|
|
|
|
else:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["KI_IMPL"] = "csr"
|
2021-02-07 14:44:09 +08:00
|
|
|
self.submodules.rtio = rtio.KernelInitiator(self.rtio_tsc, now64=True)
|
|
|
|
self.csr_devices.append("rtio")
|
|
|
|
|
|
|
|
self.submodules.rtio_dma = dma.DMA(self.ps7.s_axi_hp0)
|
|
|
|
self.csr_devices.append("rtio_dma")
|
|
|
|
|
|
|
|
self.submodules.cri_con = rtio.CRIInterconnectShared(
|
|
|
|
[self.rtio.cri, self.rtio_dma.cri],
|
|
|
|
[self.rtio_core.cri])
|
|
|
|
self.csr_devices.append("cri_con")
|
|
|
|
|
|
|
|
self.submodules.rtio_moninj = rtio.MonInj(self.rtio_channels)
|
|
|
|
self.csr_devices.append("rtio_moninj")
|
|
|
|
|
|
|
|
self.submodules.rtio_analyzer = analyzer.Analyzer(self.rtio_tsc, self.rtio_core.cri,
|
|
|
|
self.ps7.s_axi_hp1)
|
|
|
|
self.csr_devices.append("rtio_analyzer")
|
|
|
|
|
|
|
|
if has_grabber:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_GRABBER"] = None
|
2021-02-07 14:44:09 +08:00
|
|
|
self.add_csr_group("grabber", self.grabber_csr_group)
|
|
|
|
for grabber in self.grabber_csr_group:
|
|
|
|
self.platform.add_false_path_constraints(
|
2023-02-17 15:52:43 +08:00
|
|
|
self.sys_crg.cd_sys.clk, getattr(self, grabber).deserializer.cd_cl.clk)
|
2021-02-07 14:44:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
class GenericMaster(SoCCore):
|
2021-10-08 16:12:30 +08:00
|
|
|
def __init__(self, description, acpki=False):
|
2023-02-17 15:52:43 +08:00
|
|
|
clk_freq = description["rtio_frequency"]
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-10-10 10:41:07 +08:00
|
|
|
has_drtio_over_eem = any(peripheral["type"] == "shuttler" for peripheral in description["peripherals"])
|
2021-10-08 16:12:30 +08:00
|
|
|
self.acpki = acpki
|
2023-08-28 16:08:10 +08:00
|
|
|
|
2021-10-08 16:12:30 +08:00
|
|
|
platform = kasli_soc.Platform()
|
|
|
|
platform.toolchain.bitstream_commands.extend([
|
|
|
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
|
|
|
])
|
2022-06-07 16:21:16 +08:00
|
|
|
ident = description["variant"]
|
2021-10-08 16:12:30 +08:00
|
|
|
if self.acpki:
|
|
|
|
ident = "acpki_" + ident
|
2023-02-17 15:52:43 +08:00
|
|
|
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident, ps_cd_sys=False)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HW_REV"] = description["hw_rev"]
|
|
|
|
|
2022-03-09 12:43:47 +08:00
|
|
|
self.submodules += SMAClkinForward(self.platform)
|
|
|
|
|
2021-10-08 16:12:30 +08:00
|
|
|
data_pads = [platform.request("sfp", i) for i in range(4)]
|
|
|
|
|
2023-08-28 13:05:40 +08:00
|
|
|
self.submodules.gt_drtio = gtx_7series.GTX(
|
2022-04-25 12:33:21 +08:00
|
|
|
clock_pads=platform.request("clk_gtp"),
|
2021-10-08 16:12:30 +08:00
|
|
|
pads=data_pads,
|
2023-02-17 15:52:43 +08:00
|
|
|
clk_freq=clk_freq)
|
2023-08-28 13:05:40 +08:00
|
|
|
self.csr_devices.append("gt_drtio")
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
txout_buf = Signal()
|
2023-08-28 13:05:40 +08:00
|
|
|
gtx0 = self.gt_drtio.gtxs[0]
|
2023-02-17 15:52:43 +08:00
|
|
|
self.specials += Instance("BUFG", i_I=gtx0.txoutclk, o_O=txout_buf)
|
|
|
|
|
2023-10-06 15:21:38 +08:00
|
|
|
self.submodules.bootstrap = GTPBootstrapClock(self.platform, clk_freq)
|
2023-02-17 15:52:43 +08:00
|
|
|
self.submodules.sys_crg = zynq_clocking.SYSCRG(
|
|
|
|
self.platform,
|
|
|
|
self.ps7,
|
|
|
|
txout_buf,
|
|
|
|
clk_sw=gtx0.tx_init.done)
|
|
|
|
self.csr_devices.append("sys_crg")
|
2021-10-08 16:12:30 +08:00
|
|
|
self.crg = self.ps7 # HACK for eem_7series to find the clock
|
2023-02-17 15:52:43 +08:00
|
|
|
self.crg.cd_sys = self.sys_crg.cd_sys
|
|
|
|
platform.add_false_path_constraints(
|
|
|
|
self.bootstrap.cd_bootstrap.clk, self.sys_crg.cd_sys.clk)
|
|
|
|
fix_serdes_timing_path(platform)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_SI5324"] = None
|
|
|
|
self.config["SI5324_SOFT_RESET"] = None
|
2022-03-04 13:17:53 +08:00
|
|
|
|
2021-10-08 16:12:30 +08:00
|
|
|
self.rtio_channels = []
|
|
|
|
has_grabber = any(peripheral["type"] == "grabber" for peripheral in description["peripherals"])
|
2023-10-10 10:41:07 +08:00
|
|
|
if has_drtio_over_eem:
|
|
|
|
self.eem_drtio_channels = []
|
2021-10-08 16:12:30 +08:00
|
|
|
if has_grabber:
|
|
|
|
self.grabber_csr_group = []
|
|
|
|
eem_7series.add_peripherals(self, description["peripherals"], iostandard=eem_iostandard)
|
|
|
|
for i in (0, 1):
|
|
|
|
print("USER LED at RTIO channel 0x{:06x}".format(len(self.rtio_channels)))
|
|
|
|
user_led = self.platform.request("user_led", i)
|
|
|
|
phy = ttl_simple.Output(user_led)
|
|
|
|
self.submodules += phy
|
|
|
|
self.rtio_channels.append(rtio.Channel.from_phy(phy))
|
|
|
|
self.config["RTIO_LOG_CHANNEL"] = len(self.rtio_channels)
|
|
|
|
self.rtio_channels.append(rtio.LogChannel())
|
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
self.submodules.rtio_tsc = rtio.TSC(glbl_fine_ts_width=3)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-10-10 10:41:07 +08:00
|
|
|
self.drtio_csr_group = []
|
|
|
|
self.drtioaux_csr_group = []
|
|
|
|
self.drtioaux_memory_group = []
|
2021-10-08 16:12:30 +08:00
|
|
|
self.drtio_cri = []
|
2023-08-28 13:05:40 +08:00
|
|
|
for i in range(len(self.gt_drtio.channels)):
|
2021-10-08 16:12:30 +08:00
|
|
|
core_name = "drtio" + str(i)
|
|
|
|
coreaux_name = "drtioaux" + str(i)
|
|
|
|
memory_name = "drtioaux" + str(i) + "_mem"
|
2023-10-10 10:41:07 +08:00
|
|
|
self.drtio_csr_group.append(core_name)
|
|
|
|
self.drtioaux_csr_group.append(coreaux_name)
|
|
|
|
self.drtioaux_memory_group.append(memory_name)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
|
|
|
cdr = ClockDomainsRenamer({"rtio_rx": "rtio_rx" + str(i)})
|
|
|
|
|
2023-08-28 13:05:40 +08:00
|
|
|
core = cdr(DRTIOMaster(self.rtio_tsc, self.gt_drtio.channels[i]))
|
2021-10-08 16:12:30 +08:00
|
|
|
setattr(self.submodules, core_name, core)
|
|
|
|
self.drtio_cri.append(core.cri)
|
|
|
|
self.csr_devices.append(core_name)
|
|
|
|
|
|
|
|
coreaux = cdr(drtio_aux_controller.DRTIOAuxControllerBare(core.link_layer))
|
|
|
|
setattr(self.submodules, coreaux_name, coreaux)
|
|
|
|
self.csr_devices.append(coreaux_name)
|
|
|
|
|
|
|
|
size = coreaux.get_mem_size()
|
|
|
|
memory_address = self.axi2csr.register_port(coreaux.get_tx_port(), size)
|
|
|
|
self.axi2csr.register_port(coreaux.get_rx_port(), size)
|
|
|
|
self.add_memory_region(memory_name, self.mem_map["csr"] + memory_address, size * 2)
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_DRTIO"] = None
|
|
|
|
self.config["HAS_DRTIO_ROUTING"] = None
|
2023-10-10 10:41:07 +08:00
|
|
|
|
|
|
|
if has_drtio_over_eem:
|
|
|
|
self.add_eem_drtio(self.eem_drtio_channels)
|
|
|
|
self.add_drtio_cpuif_groups()
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-10-04 23:49:09 +08:00
|
|
|
self.submodules.rtio_core = rtio.Core(
|
|
|
|
self.rtio_tsc, self.rtio_channels, lane_count=description["sed_lanes"]
|
|
|
|
)
|
2021-10-08 16:12:30 +08:00
|
|
|
self.csr_devices.append("rtio_core")
|
|
|
|
|
|
|
|
if self.acpki:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["KI_IMPL"] = "acp"
|
2021-10-08 16:12:30 +08:00
|
|
|
self.submodules.rtio = acpki.KernelInitiator(self.rtio_tsc,
|
|
|
|
bus=self.ps7.s_axi_acp,
|
|
|
|
user=self.ps7.s_axi_acp_user,
|
|
|
|
evento=self.ps7.event.o)
|
|
|
|
self.csr_devices.append("rtio")
|
|
|
|
else:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["KI_IMPL"] = "csr"
|
2021-10-08 16:12:30 +08:00
|
|
|
self.submodules.rtio = rtio.KernelInitiator(self.rtio_tsc, now64=True)
|
|
|
|
self.csr_devices.append("rtio")
|
|
|
|
|
|
|
|
self.submodules.rtio_dma = dma.DMA(self.ps7.s_axi_hp0)
|
|
|
|
self.csr_devices.append("rtio_dma")
|
|
|
|
|
|
|
|
self.submodules.cri_con = rtio.CRIInterconnectShared(
|
|
|
|
[self.rtio.cri, self.rtio_dma.cri],
|
|
|
|
[self.rtio_core.cri] + self.drtio_cri,
|
|
|
|
enable_routing=True)
|
|
|
|
self.csr_devices.append("cri_con")
|
|
|
|
|
|
|
|
self.submodules.rtio_moninj = rtio.MonInj(self.rtio_channels)
|
|
|
|
self.csr_devices.append("rtio_moninj")
|
|
|
|
|
|
|
|
self.submodules.routing_table = rtio.RoutingTableAccess(self.cri_con)
|
|
|
|
self.csr_devices.append("routing_table")
|
|
|
|
|
|
|
|
self.submodules.rtio_analyzer = analyzer.Analyzer(self.rtio_tsc, self.rtio_core.cri,
|
|
|
|
self.ps7.s_axi_hp1)
|
|
|
|
self.csr_devices.append("rtio_analyzer")
|
|
|
|
|
|
|
|
if has_grabber:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_GRABBER"] = None
|
2021-10-08 16:12:30 +08:00
|
|
|
self.add_csr_group("grabber", self.grabber_csr_group)
|
2023-08-28 16:08:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
self.submodules.virtual_leds = virtual_leds.VirtualLeds()
|
|
|
|
self.csr_devices.append("virtual_leds")
|
|
|
|
|
|
|
|
self.comb += [self.virtual_leds.get(i).eq(channel.rx_ready)
|
|
|
|
for i, channel in enumerate(self.gt_drtio.channels)]
|
|
|
|
|
2023-10-10 10:41:07 +08:00
|
|
|
def add_eem_drtio(self, eem_drtio_channels):
|
|
|
|
# Must be called before invoking add_rtio() to construct the CRI
|
|
|
|
# interconnect properly
|
|
|
|
self.submodules.eem_transceiver = eem_serdes.EEMSerdes(self.platform, eem_drtio_channels)
|
|
|
|
self.csr_devices.append("eem_transceiver")
|
|
|
|
self.config["HAS_DRTIO_EEM"] = None
|
|
|
|
self.config["EEM_DRTIO_COUNT"] = len(eem_drtio_channels)
|
|
|
|
|
|
|
|
cdr = ClockDomainsRenamer({"rtio_rx": "sys"})
|
|
|
|
for i in range(len(self.eem_transceiver.channels)):
|
|
|
|
channel = i + len(self.gt_drtio.channels)
|
|
|
|
core_name = "drtio" + str(channel)
|
|
|
|
coreaux_name = "drtioaux" + str(channel)
|
|
|
|
memory_name = "drtioaux" + str(channel) + "_mem"
|
|
|
|
self.drtio_csr_group.append(core_name)
|
|
|
|
self.drtioaux_csr_group.append(coreaux_name)
|
|
|
|
self.drtioaux_memory_group.append(memory_name)
|
|
|
|
|
|
|
|
core = cdr(DRTIOMaster(self.rtio_tsc, self.eem_transceiver.channels[i]))
|
|
|
|
setattr(self.submodules, core_name, core)
|
|
|
|
self.drtio_cri.append(core.cri)
|
|
|
|
self.csr_devices.append(core_name)
|
|
|
|
|
|
|
|
coreaux = cdr(drtio_aux_controller.DRTIOAuxControllerBare(core.link_layer))
|
|
|
|
setattr(self.submodules, coreaux_name, coreaux)
|
|
|
|
self.csr_devices.append(coreaux_name)
|
|
|
|
|
|
|
|
size = coreaux.get_mem_size()
|
|
|
|
memory_address = self.axi2csr.register_port(coreaux.get_tx_port(), size)
|
|
|
|
self.axi2csr.register_port(coreaux.get_rx_port(), size)
|
|
|
|
self.add_memory_region(memory_name, self.mem_map["csr"] + memory_address, size * 2)
|
|
|
|
|
|
|
|
def add_drtio_cpuif_groups(self):
|
|
|
|
self.add_csr_group("drtio", self.drtio_csr_group)
|
|
|
|
self.add_csr_group("drtioaux", self.drtioaux_csr_group)
|
|
|
|
self.add_memory_group("drtioaux_mem", self.drtioaux_memory_group)
|
2021-02-07 14:44:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
class GenericSatellite(SoCCore):
|
2021-10-08 16:12:30 +08:00
|
|
|
def __init__(self, description, acpki=False):
|
2023-02-17 15:52:43 +08:00
|
|
|
clk_freq = description["rtio_frequency"]
|
2021-10-08 16:12:30 +08:00
|
|
|
|
|
|
|
self.acpki = acpki
|
2023-08-28 16:08:10 +08:00
|
|
|
|
2021-10-08 16:12:30 +08:00
|
|
|
platform = kasli_soc.Platform()
|
|
|
|
platform.toolchain.bitstream_commands.extend([
|
|
|
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
|
|
|
])
|
2022-06-07 16:21:16 +08:00
|
|
|
ident = description["variant"]
|
2021-10-08 16:12:30 +08:00
|
|
|
if self.acpki:
|
|
|
|
ident = "acpki_" + ident
|
2023-02-17 15:52:43 +08:00
|
|
|
SoCCore.__init__(self, platform=platform, csr_data_width=32, ident=ident, ps_cd_sys=False)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HW_REV"] = description["hw_rev"]
|
|
|
|
|
2021-10-08 16:12:30 +08:00
|
|
|
data_pads = [platform.request("sfp", i) for i in range(4)]
|
|
|
|
|
2023-08-28 13:05:40 +08:00
|
|
|
self.submodules.gt_drtio = gtx_7series.GTX(
|
2022-04-25 12:33:21 +08:00
|
|
|
clock_pads=platform.request("clk_gtp"),
|
2021-10-08 16:12:30 +08:00
|
|
|
pads=data_pads,
|
2023-02-17 15:52:43 +08:00
|
|
|
clk_freq=clk_freq)
|
2023-08-28 13:05:40 +08:00
|
|
|
self.csr_devices.append("gt_drtio")
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
txout_buf = Signal()
|
2023-08-28 13:05:40 +08:00
|
|
|
gtx0 = self.gt_drtio.gtxs[0]
|
2023-02-17 15:52:43 +08:00
|
|
|
self.specials += Instance("BUFG", i_I=gtx0.txoutclk, o_O=txout_buf)
|
|
|
|
|
2023-10-06 15:21:38 +08:00
|
|
|
self.submodules.bootstrap = GTPBootstrapClock(self.platform, clk_freq)
|
2023-02-17 15:52:43 +08:00
|
|
|
self.submodules.sys_crg = zynq_clocking.SYSCRG(
|
|
|
|
self.platform,
|
|
|
|
self.ps7,
|
|
|
|
txout_buf,
|
|
|
|
clk_sw=gtx0.tx_init.done)
|
|
|
|
platform.add_false_path_constraints(
|
|
|
|
self.bootstrap.cd_bootstrap.clk, self.sys_crg.cd_sys.clk)
|
|
|
|
self.csr_devices.append("sys_crg")
|
|
|
|
self.crg = self.ps7 # HACK for eem_7series to find the clock
|
|
|
|
self.crg.cd_sys = self.sys_crg.cd_sys
|
|
|
|
|
2023-02-20 13:06:31 +08:00
|
|
|
fix_serdes_timing_path(platform)
|
|
|
|
|
2021-10-08 16:12:30 +08:00
|
|
|
self.rtio_channels = []
|
|
|
|
has_grabber = any(peripheral["type"] == "grabber" for peripheral in description["peripherals"])
|
|
|
|
if has_grabber:
|
|
|
|
self.grabber_csr_group = []
|
|
|
|
eem_7series.add_peripherals(self, description["peripherals"], iostandard=eem_iostandard)
|
|
|
|
for i in (0, 1):
|
|
|
|
print("USER LED at RTIO channel 0x{:06x}".format(len(self.rtio_channels)))
|
|
|
|
user_led = self.platform.request("user_led", i)
|
|
|
|
phy = ttl_simple.Output(user_led)
|
|
|
|
self.submodules += phy
|
|
|
|
self.rtio_channels.append(rtio.Channel.from_phy(phy))
|
|
|
|
self.config["RTIO_LOG_CHANNEL"] = len(self.rtio_channels)
|
|
|
|
self.rtio_channels.append(rtio.LogChannel())
|
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
self.submodules.rtio_tsc = rtio.TSC(glbl_fine_ts_width=3)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
|
|
|
drtioaux_csr_group = []
|
|
|
|
drtioaux_memory_group = []
|
|
|
|
drtiorep_csr_group = []
|
|
|
|
self.drtio_cri = []
|
2023-08-28 13:05:40 +08:00
|
|
|
for i in range(len(self.gt_drtio.channels)):
|
2021-10-08 16:12:30 +08:00
|
|
|
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(
|
2023-08-28 13:05:40 +08:00
|
|
|
self.rtio_tsc, self.gt_drtio.channels[i],
|
2021-10-08 16:12:30 +08:00
|
|
|
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(
|
2023-08-28 13:05:40 +08:00
|
|
|
self.rtio_tsc, self.gt_drtio.channels[i]))
|
2021-10-08 16:12:30 +08:00
|
|
|
setattr(self.submodules, corerep_name, core)
|
|
|
|
self.drtio_cri.append(core.cri)
|
|
|
|
self.csr_devices.append(corerep_name)
|
|
|
|
|
|
|
|
coreaux = cdr(drtio_aux_controller.DRTIOAuxControllerBare(core.link_layer))
|
|
|
|
setattr(self.submodules, coreaux_name, coreaux)
|
|
|
|
self.csr_devices.append(coreaux_name)
|
|
|
|
|
|
|
|
mem_size = coreaux.get_mem_size()
|
|
|
|
tx_port = coreaux.get_tx_port()
|
|
|
|
rx_port = coreaux.get_rx_port()
|
|
|
|
memory_address = self.axi2csr.register_port(tx_port, mem_size)
|
|
|
|
# rcv in upper half of the memory, thus added second
|
|
|
|
self.axi2csr.register_port(rx_port, mem_size)
|
|
|
|
# and registered in PS interface
|
|
|
|
# manually, because software refers to rx/tx by halves of entire memory block, not names
|
|
|
|
self.add_memory_region(memory_name, self.mem_map["csr"] + memory_address, mem_size * 2)
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_DRTIO"] = None
|
|
|
|
self.config["HAS_DRTIO_ROUTING"] = None
|
2021-10-08 16:12:30 +08:00
|
|
|
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)
|
|
|
|
|
|
|
|
if self.acpki:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["KI_IMPL"] = "acp"
|
2021-10-08 16:12:30 +08:00
|
|
|
self.submodules.rtio = acpki.KernelInitiator(self.rtio_tsc,
|
|
|
|
bus=self.ps7.s_axi_acp,
|
|
|
|
user=self.ps7.s_axi_acp_user,
|
|
|
|
evento=self.ps7.event.o)
|
|
|
|
self.csr_devices.append("rtio")
|
|
|
|
else:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["KI_IMPL"] = "csr"
|
2021-10-08 16:12:30 +08:00
|
|
|
self.submodules.rtio = rtio.KernelInitiator(self.rtio_tsc, now64=True)
|
|
|
|
self.csr_devices.append("rtio")
|
|
|
|
|
|
|
|
self.submodules.rtio_dma = dma.DMA(self.ps7.s_axi_hp0)
|
|
|
|
self.csr_devices.append("rtio_dma")
|
|
|
|
|
2023-10-04 23:49:09 +08:00
|
|
|
self.submodules.local_io = SyncRTIO(
|
|
|
|
self.rtio_tsc, self.rtio_channels, lane_count=description["sed_lanes"]
|
|
|
|
)
|
2021-10-08 16:12:30 +08:00
|
|
|
self.comb += self.drtiosat.async_errors.eq(self.local_io.async_errors)
|
|
|
|
|
|
|
|
self.submodules.cri_con = rtio.CRIInterconnectShared(
|
2023-09-05 16:12:03 +08:00
|
|
|
[self.drtiosat.cri, self.rtio_dma.cri, self.rtio.cri],
|
2021-10-08 16:12:30 +08:00
|
|
|
[self.local_io.cri] + self.drtio_cri,
|
2023-02-17 15:52:43 +08:00
|
|
|
enable_routing=True)
|
2021-10-08 16:12:30 +08:00
|
|
|
self.csr_devices.append("cri_con")
|
|
|
|
|
|
|
|
self.submodules.routing_table = rtio.RoutingTableAccess(self.cri_con)
|
|
|
|
self.csr_devices.append("routing_table")
|
|
|
|
|
|
|
|
self.submodules.rtio_moninj = rtio.MonInj(self.rtio_channels)
|
|
|
|
self.csr_devices.append("rtio_moninj")
|
|
|
|
|
2023-05-19 12:58:32 +08:00
|
|
|
self.submodules.rtio_analyzer = analyzer.Analyzer(self.rtio_tsc, self.local_io.cri,
|
|
|
|
self.ps7.s_axi_hp1)
|
|
|
|
self.csr_devices.append("rtio_analyzer")
|
|
|
|
|
2023-02-17 15:52:43 +08:00
|
|
|
rtio_clk_period = 1e9/clk_freq
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["RTIO_FREQUENCY"] = str(clk_freq/1e6)
|
2021-10-08 16:12:30 +08:00
|
|
|
|
|
|
|
self.submodules.siphaser = SiPhaser7Series(
|
|
|
|
si5324_clkin=platform.request("cdr_clk"),
|
|
|
|
rx_synchronizer=self.rx_synchronizer,
|
|
|
|
ultrascale=False,
|
2023-08-28 13:05:40 +08:00
|
|
|
rtio_clk_freq=self.gt_drtio.rtio_clk_freq)
|
2021-10-08 16:12:30 +08:00
|
|
|
self.csr_devices.append("siphaser")
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_SI5324"] = None
|
|
|
|
self.config["SI5324_SOFT_RESET"] = None
|
2021-10-08 16:12:30 +08:00
|
|
|
|
2023-08-28 13:05:40 +08:00
|
|
|
gtx0 = self.gt_drtio.gtxs[0]
|
2021-10-08 16:12:30 +08:00
|
|
|
platform.add_false_path_constraints(
|
|
|
|
gtx0.txoutclk, gtx0.rxoutclk)
|
|
|
|
|
|
|
|
if has_grabber:
|
2023-08-30 14:56:12 +08:00
|
|
|
self.config["HAS_GRABBER"] = None
|
2021-10-08 16:12:30 +08:00
|
|
|
self.add_csr_group("grabber", self.grabber_csr_group)
|
|
|
|
# no RTIO CRG here
|
2023-08-28 16:08:10 +08:00
|
|
|
|
|
|
|
self.submodules.virtual_leds = virtual_leds.VirtualLeds()
|
|
|
|
self.csr_devices.append("virtual_leds")
|
|
|
|
|
|
|
|
self.comb += [self.virtual_leds.get(i).eq(channel.rx_ready)
|
|
|
|
for i, channel in enumerate(self.gt_drtio.channels)]
|
|
|
|
|
2021-02-07 14:44:09 +08:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="ARTIQ device binary builder for generic Kasli-SoC systems")
|
|
|
|
parser.add_argument("-r", default=None,
|
|
|
|
help="build Rust interface into the specified file")
|
|
|
|
parser.add_argument("-c", default=None,
|
|
|
|
help="build Rust compiler configuration into the specified file")
|
2021-10-08 16:12:30 +08:00
|
|
|
parser.add_argument("-m", default=None,
|
|
|
|
help="build Rust memory interface into the specified file")
|
2021-02-07 14:44:09 +08:00
|
|
|
parser.add_argument("-g", default=None,
|
|
|
|
help="build gateware into the specified directory")
|
|
|
|
parser.add_argument("--acpki", default=False, action="store_true",
|
|
|
|
help="enable ACPKI")
|
|
|
|
parser.add_argument("description", metavar="DESCRIPTION",
|
|
|
|
help="JSON system description file")
|
|
|
|
args = parser.parse_args()
|
|
|
|
description = jsondesc.load(args.description)
|
|
|
|
|
|
|
|
if description["target"] != "kasli_soc":
|
|
|
|
raise ValueError("Description is for a different target")
|
|
|
|
|
2023-06-16 17:03:25 +08:00
|
|
|
if description["drtio_role"] == "standalone":
|
2021-02-07 14:44:09 +08:00
|
|
|
cls = GenericStandalone
|
2023-06-16 17:03:25 +08:00
|
|
|
elif description["drtio_role"] == "master":
|
2021-02-07 14:44:09 +08:00
|
|
|
cls = GenericMaster
|
2023-06-16 17:03:25 +08:00
|
|
|
elif description["drtio_role"] == "satellite":
|
2021-02-07 14:44:09 +08:00
|
|
|
cls = GenericSatellite
|
|
|
|
else:
|
2023-06-16 17:03:25 +08:00
|
|
|
raise ValueError("Invalid DRTIO role")
|
2021-02-07 14:44:09 +08:00
|
|
|
|
|
|
|
soc = cls(description, acpki=args.acpki)
|
|
|
|
soc.finalize()
|
|
|
|
|
|
|
|
if args.r is not None:
|
|
|
|
write_csr_file(soc, args.r)
|
2021-10-08 16:12:30 +08:00
|
|
|
if args.m is not None:
|
|
|
|
write_mem_file(soc, args.m)
|
2021-02-07 14:44:09 +08:00
|
|
|
if args.c is not None:
|
|
|
|
write_rustc_cfg_file(soc, args.c)
|
|
|
|
if args.g is not None:
|
|
|
|
soc.build(build_dir=args.g)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|