diff --git a/src/gateware/kasli_soc.py b/src/gateware/kasli_soc.py index 716501e..ffa7aaf 100755 --- a/src/gateware/kasli_soc.py +++ b/src/gateware/kasli_soc.py @@ -26,6 +26,7 @@ import analyzer import acpki import drtio_aux_controller import zynq_clocking +import wrpll from config import write_csr_file, write_mem_file, write_rustc_cfg_file eem_iostandard_dict = { @@ -118,7 +119,7 @@ class GTPBootstrapClock(Module): class GenericStandalone(SoCCore): - def __init__(self, description, acpki=False): + def __init__(self, description, acpki=False, with_wrpll=False): self.acpki = acpki clk_freq = description["rtio_frequency"] @@ -148,6 +149,23 @@ class GenericStandalone(SoCCore): self.crg = self.ps7 # HACK for eem_7series to find the clock self.crg.cd_sys = self.sys_crg.cd_sys + if with_wrpll: + self.submodules.wrpll_refclk = wrpll.SMAFrequencyMultiplier(platform.request("sma_clkin")) + self.submodules.wrpll = wrpll.WRPLL( + platform=self.platform, + cd_ref=self.wrpll_refclk.cd_ref, + main_clk_se=self.clk_synth.se) + self.csr_devices.append("wrpll_refclk") + self.csr_devices.append("wrpll") + self.comb += self.ps7.core.core0.nfiq.eq(self.wrpll.ev.irq) + self.config["HAS_SI549"] = None + self.config["WRPLL_REF_CLK"] = "SMA_CLKIN" + else: + self.submodules += SMAClkinForward(self.platform) + self.config["HAS_SI5324"] = None + self.config["SI5324_SOFT_RESET"] = None + + self.rtio_channels = [] has_grabber = any(peripheral["type"] == "grabber" for peripheral in description["peripherals"]) if has_grabber: @@ -204,7 +222,7 @@ class GenericStandalone(SoCCore): class GenericMaster(SoCCore): - def __init__(self, description, acpki=False): + def __init__(self, description, acpki=False, with_wrpll=False): clk_freq = description["rtio_frequency"] has_drtio_over_eem = any(peripheral["type"] == "shuttler" for peripheral in description["peripherals"]) @@ -221,8 +239,6 @@ class GenericMaster(SoCCore): self.config["HW_REV"] = description["hw_rev"] - self.submodules += SMAClkinForward(self.platform) - data_pads = [platform.request("sfp", i) for i in range(4)] self.submodules.gt_drtio = gtx_7series.GTX( @@ -256,8 +272,22 @@ class GenericMaster(SoCCore): self.comb += ext_async_rst.eq(self.sys_crg.clk_sw_fsm.o_clk_sw & ~gtx0.tx_init.done) self.specials += MultiReg(self.sys_crg.clk_sw_fsm.o_clk_sw & self.sys_crg.mmcm_locked, self.gt_drtio.clk_path_ready, odomain="bootstrap") - self.config["HAS_SI5324"] = None - self.config["SI5324_SOFT_RESET"] = None + if with_wrpll: + self.submodules.clk_synth = ClockSynthesis(self.platform) + self.submodules.wrpll_refclk = wrpll.SMAFrequencyMultiplier(platform.request("sma_clkin")) + self.submodules.wrpll = wrpll.WRPLL( + platform=self.platform, + cd_ref=self.wrpll_refclk.cd_ref, + main_clk_se=self.clk_synth.se) + self.csr_devices.append("wrpll_refclk") + self.csr_devices.append("wrpll") + self.comb += self.ps7.core.core0.nfiq.eq(self.wrpll.ev.irq) + self.config["HAS_SI549"] = None + self.config["WRPLL_REF_CLK"] = "SMA_CLKIN" + else: + self.submodules += SMAClkinForward(self.platform) + self.config["HAS_SI5324"] = None + self.config["SI5324_SOFT_RESET"] = None self.rtio_channels = [] has_grabber = any(peripheral["type"] == "grabber" for peripheral in description["peripherals"]) @@ -397,7 +427,7 @@ class GenericMaster(SoCCore): class GenericSatellite(SoCCore): - def __init__(self, description, acpki=False): + def __init__(self, description, acpki=False, with_wrpll=False): clk_freq = description["rtio_frequency"] self.acpki = acpki @@ -550,14 +580,25 @@ class GenericSatellite(SoCCore): self.config["RTIO_FREQUENCY"] = str(clk_freq/1e6) self.config["CLOCK_FREQUENCY"] = int(clk_freq) - self.submodules.siphaser = SiPhaser7Series( - si5324_clkin=platform.request("cdr_clk"), - rx_synchronizer=self.rx_synchronizer, - ultrascale=False, - rtio_clk_freq=self.gt_drtio.rtio_clk_freq) - self.csr_devices.append("siphaser") - self.config["HAS_SI5324"] = None - self.config["SI5324_SOFT_RESET"] = None + if with_wrpll: + self.submodules.clk_synth = ClockSynthesis(self.platform) + self.submodules.wrpll = wrpll.WRPLL( + platform=self.platform, + cd_ref=self.gt_drtio.cd_rtio_rx0, + main_clk_se=self.clk_synth.se) + self.csr_devices.append("wrpll") + self.comb += self.ps7.core.core0.nfiq.eq(self.wrpll.ev.irq) + self.config["HAS_SI549"] = None + self.config["WRPLL_REF_CLK"] = "GTX_CDR" + else: + self.submodules.siphaser = SiPhaser7Series( + si5324_clkin=platform.request("cdr_clk"), + rx_synchronizer=self.rx_synchronizer, + ultrascale=False, + rtio_clk_freq=self.gt_drtio.rtio_clk_freq) + self.csr_devices.append("siphaser") + self.config["HAS_SI5324"] = None + self.config["SI5324_SOFT_RESET"] = None gtx0 = self.gt_drtio.gtxs[0] platform.add_false_path_constraints( @@ -587,6 +628,8 @@ def main(): help="build gateware into the specified directory") parser.add_argument("--acpki", default=False, action="store_true", help="enable ACPKI") + parser.add_argument("--with-wrpll", default=False, action="store_true", + help="enable WRPLL") parser.add_argument("description", metavar="DESCRIPTION", help="JSON system description file") args = parser.parse_args() @@ -604,7 +647,7 @@ def main(): else: raise ValueError("Invalid DRTIO role") - soc = cls(description, acpki=args.acpki) + soc = cls(description, acpki=args.acpki, with_wrpll=args.with_wrpll) soc.finalize() if args.r is not None: