From 433c3bb8f972266078aa383281d793f49011a4f7 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 29 Aug 2020 19:17:11 +0800 Subject: [PATCH 1/4] sayma: 1GSPS WIP --- artiq/firmware/libboard_artiq/ad9154.rs | 8 ++--- artiq/firmware/libboard_artiq/hmc830_7043.rs | 32 +++++++++----------- artiq/firmware/runtime/rtio_clocking.rs | 13 -------- artiq/firmware/satman/main.rs | 17 +---------- artiq/gateware/jesd204_tools.py | 24 ++++++--------- artiq/gateware/targets/metlino.py | 2 +- artiq/gateware/targets/sayma_amc.py | 21 ++++++------- artiq/gateware/targets/sayma_rtm.py | 2 +- 8 files changed, 41 insertions(+), 78 deletions(-) diff --git a/artiq/firmware/libboard_artiq/ad9154.rs b/artiq/firmware/libboard_artiq/ad9154.rs index de32ff2e2..f671e2660 100644 --- a/artiq/firmware/libboard_artiq/ad9154.rs +++ b/artiq/firmware/libboard_artiq/ad9154.rs @@ -34,9 +34,9 @@ fn read(addr: u16) -> u8 { } // ad9154 mode 1 -// linerate 5Gbps or 6Gbps -// deviceclock_fpga 125MHz or 150MHz -// deviceclock_dac 500MHz or 600MHz +// linerate 10Gbps +// deviceclock_fpga 125MHz +// deviceclock_dac 1000MHz struct JESDSettings { did: u8, @@ -146,7 +146,7 @@ pub fn setup(dacno: u8, linerate: u64) -> Result<(), &'static str> { write(ad9154_reg::SPI_PAGEINDX, 0x3); // A and B dual - write(ad9154_reg::INTERP_MODE, 0x03); // 4x + write(ad9154_reg::INTERP_MODE, 0x01); // 2x write(ad9154_reg::MIX_MODE, 0); write(ad9154_reg::DATA_FORMAT, 0*ad9154_reg::BINARY_FORMAT); // s16 write(ad9154_reg::DATAPATH_CTRL, diff --git a/artiq/firmware/libboard_artiq/hmc830_7043.rs b/artiq/firmware/libboard_artiq/hmc830_7043.rs index adf753141..d4768aa36 100644 --- a/artiq/firmware/libboard_artiq/hmc830_7043.rs +++ b/artiq/firmware/libboard_artiq/hmc830_7043.rs @@ -149,20 +149,20 @@ pub mod hmc7043 { // enabled, divider, output config, is sysref const OUTPUT_CONFIG: [(bool, u16, u8, bool); 14] = [ - (true, DAC_CLK_DIV, 0x08, false), // 0: DAC1_CLK - (true, SYSREF_DIV, 0x01, true), // 1: DAC1_SYSREF - (true, DAC_CLK_DIV, 0x08, false), // 2: DAC0_CLK - (true, SYSREF_DIV, 0x01, true), // 3: DAC0_SYSREF - (true, SYSREF_DIV, 0x10, true), // 4: AMC_FPGA_SYSREF0 - (false, FPGA_CLK_DIV, 0x10, true), // 5: AMC_FPGA_SYSREF1 - (false, 0, 0x10, false), // 6: unused - (true, FPGA_CLK_DIV, 0x10, true), // 7: RTM_FPGA_SYSREF0 - (true, FPGA_CLK_DIV, 0x08, false), // 8: GTP_CLK0_IN - (false, 0, 0x10, false), // 9: unused - (false, 0, 0x10, false), // 10: unused - (false, 0, 0x08, false), // 11: unused / uFL - (false, 0, 0x10, false), // 12: unused - (false, FPGA_CLK_DIV, 0x10, true), // 13: RTM_FPGA_SYSREF1 + (true, DAC_CLK_DIV, 0x08, false), // 0: DAC1_CLK + (true, SYSREF_DIV, 0x01, true), // 1: DAC1_SYSREF + (true, DAC_CLK_DIV, 0x08, false), // 2: DAC0_CLK + (true, SYSREF_DIV, 0x01, true), // 3: DAC0_SYSREF + (true, SYSREF_DIV, 0x10, true), // 4: AMC_FPGA_SYSREF0 + (false, FPGA_CLK_DIV, 0x10, true), // 5: AMC_FPGA_SYSREF1 + (false, 0, 0x10, false), // 6: unused + (true, FPGA_CLK_DIV, 0x10, true), // 7: RTM_FPGA_SYSREF0 + (true, FPGA_CLK_DIV/2, 0x08, false), // 8: GTP_CLK0_IN + (false, 0, 0x10, false), // 9: unused + (false, 0, 0x10, false), // 10: unused + (false, 0, 0x08, false), // 11: unused / uFL + (false, 0, 0x10, false), // 12: unused + (false, FPGA_CLK_DIV, 0x10, true), // 13: RTM_FPGA_SYSREF1 ]; fn spi_setup() { @@ -393,8 +393,6 @@ pub mod hmc7043 { pub fn init() -> Result<(), &'static str> { #[cfg(all(hmc830_ref = "125", rtio_frequency = "125.0"))] const DIV: (u32, u32, u32, u32) = (2, 32, 0, 1); // 125MHz -> 2.0GHz - #[cfg(all(hmc830_ref = "150", rtio_frequency = "150.0"))] - const DIV: (u32, u32, u32, u32) = (2, 32, 0, 1); // 150MHz -> 2.4GHz /* do not use other SPI devices before HMC830 SPI mode selection */ hmc830::select_spi_mode(); @@ -406,7 +404,7 @@ pub fn init() -> Result<(), &'static str> { hmc830::check_locked()?; if hmc7043::get_id() == hmc7043::CHIP_ID { - error!("HMC7043 detected while in reset (board rework missing?)"); + error!("HMC7043 detected while in reset"); } hmc7043::enable(); hmc7043::detect()?; diff --git a/artiq/firmware/runtime/rtio_clocking.rs b/artiq/firmware/runtime/rtio_clocking.rs index 0a41ab8d0..c5501a755 100644 --- a/artiq/firmware/runtime/rtio_clocking.rs +++ b/artiq/firmware/runtime/rtio_clocking.rs @@ -119,19 +119,6 @@ fn setup_si5324_as_synthesizer() { bwsel : 4, crystal_ref: true }; - // 150MHz output, from crystal - #[cfg(all(rtio_frequency = "150.0", not(si5324_ext_ref)))] - const SI5324_SETTINGS: si5324::FrequencySettings - = si5324::FrequencySettings { - n1_hs : 9, - nc1_ls : 4, - n2_hs : 10, - n2_ls : 33732, - n31 : 9370, - n32 : 7139, - bwsel : 3, - crystal_ref: true - }; // 100MHz output, from crystal. Also used as reference for Sayma HMC830. #[cfg(all(rtio_frequency = "100.0", not(si5324_ext_ref)))] const SI5324_SETTINGS: si5324::FrequencySettings diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index 60f0f4c0a..ac16a116c 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -302,9 +302,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater], #[cfg(has_ad9154)] let (succeeded, retval) = { #[cfg(rtio_frequency = "125.0")] - const LINERATE: u64 = 5_000_000_000; - #[cfg(rtio_frequency = "150.0")] - const LINERATE: u64 = 6_000_000_000; + const LINERATE: u64 = 10_000_000_000; match _reqno { jdac_common::INIT => (board_artiq::ad9154::setup(_dacno, LINERATE).is_ok(), 0), jdac_common::PRINT_STATUS => { board_artiq::ad9154::status(_dacno); (true, 0) }, @@ -419,19 +417,6 @@ fn hardware_tick(ts: &mut u64) { } } -#[cfg(all(has_si5324, rtio_frequency = "150.0"))] -const SI5324_SETTINGS: si5324::FrequencySettings - = si5324::FrequencySettings { - n1_hs : 6, - nc1_ls : 6, - n2_hs : 10, - n2_ls : 270, - n31 : 75, - n32 : 75, - bwsel : 4, - crystal_ref: true -}; - #[cfg(all(has_si5324, rtio_frequency = "125.0"))] const SI5324_SETTINGS: si5324::FrequencySettings = si5324::FrequencySettings { diff --git a/artiq/gateware/jesd204_tools.py b/artiq/gateware/jesd204_tools.py index 27a1ce6cc..8cd8e9872 100644 --- a/artiq/gateware/jesd204_tools.py +++ b/artiq/gateware/jesd204_tools.py @@ -15,30 +15,26 @@ from jesd204b.core import JESD204BCoreTXControl class UltrascaleCRG(Module, AutoCSR): - linerate = int(6e9) - refclk_freq = int(150e6) + linerate = int(10e9) # linerate = 20*data_rate*4/8 = data_rate*10 + refclk_freq = int(250e6) fabric_freq = int(125e6) - def __init__(self, platform, use_rtio_clock=False): + def __init__(self, platform): self.jreset = CSRStorage(reset=1) self.refclk = Signal() self.clock_domains.cd_jesd = ClockDomain() - refclk2 = Signal() refclk_pads = platform.request("dac_refclk", 0) platform.add_period_constraint(refclk_pads.p, 1e9/self.refclk_freq) self.specials += [ - Instance("IBUFDS_GTE3", i_CEB=0, p_REFCLK_HROW_CK_SEL=0b00, + Instance("IBUFDS_GTE3", i_CEB=0, p_REFCLK_HROW_CK_SEL=0b01, i_I=refclk_pads.p, i_IB=refclk_pads.n, - o_O=self.refclk, o_ODIV2=refclk2), - AsyncResetSynchronizer(self.cd_jesd, self.jreset.storage), + o_O=self.refclk), ] - if use_rtio_clock: - self.cd_jesd.clk.attr.add("keep") - self.comb += self.cd_jesd.clk.eq(ClockSignal("rtio")) - else: - self.specials += Instance("BUFG_GT", i_I=refclk2, o_O=self.cd_jesd.clk) + self.cd_jesd.clk.attr.add("keep") + self.comb += self.cd_jesd.clk.eq(ClockSignal("rtio")) + self.specials += AsyncResetSynchronizer(self.cd_jesd, self.jreset.storage) PhyPads = namedtuple("PhyPads", "txp txn") @@ -68,7 +64,7 @@ class UltrascaleTX(Module, AutoCSR): phys.append(phy) self.submodules.core = JESD204BCoreTX( - phys, settings, converter_data_width=64) + phys, settings, converter_data_width=128) self.submodules.control = JESD204BCoreTXControl(self.core) self.core.register_jsync(platform.request("dac_sync", dac)) @@ -92,7 +88,7 @@ class DDMTDEdgeDetector(Module): # See "Digital femtosecond time difference circuit for CERN's timing system" # by P. Moreira and I. Darwazeh class DDMTD(Module, AutoCSR): - def __init__(self, input_pads, rtio_clk_freq=150e6): + def __init__(self, input_pads, rtio_clk_freq=125e6): N = 64 self.reset = CSRStorage(reset=1) self.locked = CSRStatus() diff --git a/artiq/gateware/targets/metlino.py b/artiq/gateware/targets/metlino.py index d1013653c..66afbf0eb 100755 --- a/artiq/gateware/targets/metlino.py +++ b/artiq/gateware/targets/metlino.py @@ -52,7 +52,7 @@ class Master(MiniSoC, AMPSoC): add_identifier(self) platform = self.platform - rtio_clk_freq = 150e6 + rtio_clk_freq = 125e6 self.comb += platform.request("input_clk_sel").eq(1) self.comb += platform.request("filtered_clk_sel").eq(1) diff --git a/artiq/gateware/targets/sayma_amc.py b/artiq/gateware/targets/sayma_amc.py index c2cb435f1..841e28b89 100755 --- a/artiq/gateware/targets/sayma_amc.py +++ b/artiq/gateware/targets/sayma_amc.py @@ -193,7 +193,7 @@ class JDCGSAWG(Module, AutoCSR): self.submodules.jesd = jesd204_tools.UltrascaleTX( platform, sys_crg, jesd_crg, dac) - self.submodules.sawgs = [sawg.Channel(width=16, parallelism=4) for i in range(4)] + self.submodules.sawgs = [sawg.Channel(width=16, parallelism=8) for i in range(4)] for conv, ch in zip(self.jesd.core.sink.flatten(), self.sawgs): assert len(Cat(ch.o)) == len(conv) @@ -210,26 +210,26 @@ class JDCGPattern(Module, AutoCSR): ramp = Signal(4) self.sync.rtio += ramp.eq(ramp + 1) - samples = [[Signal(16) for i in range(4)] for j in range(4)] + samples = [[Signal(16) for i in range(8)] 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): + for i in range(8): 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)] + data = [int(round(cos(i/24*2*pi)*((1 << 15) - 1))) + for i in range(24)] 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)] + i: [samples[1][j].eq(data[i*8 + j]) for j in range(8)] for i in range(3) }) ] @@ -249,7 +249,7 @@ class JDCGSyncDDS(Module, AutoCSR): self.sawgs = [] ftw = round(2**len(self.coarse_ts)*9e6/600e6) - parallelism = 4 + parallelism = 8 mul_1 = Signal.like(self.coarse_ts) mul_2 = Signal.like(self.coarse_ts) @@ -287,9 +287,7 @@ class Satellite(SatelliteBase): DRTIO satellite with local DAC/SAWG channels. """ def __init__(self, jdcg_type, **kwargs): - SatelliteBase.__init__(self, 150e6, - identifier_suffix="." + jdcg_type, - **kwargs) + SatelliteBase.__init__(self, identifier_suffix="." + jdcg_type, **kwargs) platform = self.platform @@ -323,8 +321,7 @@ class Satellite(SatelliteBase): self.submodules += phy rtio_channels.append(rtio.Channel.from_phy(phy)) - self.submodules.jesd_crg = jesd204_tools.UltrascaleCRG( - platform, use_rtio_clock=True) + self.submodules.jesd_crg = jesd204_tools.UltrascaleCRG(platform) cls = { "sawg": JDCGSAWG, "pattern": JDCGPattern, diff --git a/artiq/gateware/targets/sayma_rtm.py b/artiq/gateware/targets/sayma_rtm.py index bdef1fa09..82b09699f 100755 --- a/artiq/gateware/targets/sayma_rtm.py +++ b/artiq/gateware/targets/sayma_rtm.py @@ -297,7 +297,7 @@ def main(): builder_args(parser) soc_sayma_rtm_args(parser) parser.add_argument("--rtio-clk-freq", - default=150, type=int, help="RTIO clock frequency in MHz") + default=125, type=int, help="RTIO clock frequency in MHz") parser.add_argument("--with-wrpll", default=False, action="store_true") parser.set_defaults(output_dir=os.path.join("artiq_sayma", "rtm")) args = parser.parse_args() From b5405dfad6a3f3e375003a63baa90bf3473776ce Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 15 Dec 2020 17:55:48 +0800 Subject: [PATCH 2/4] jdcg: STPL tests now perform after DAC initialization --- artiq/firmware/satman/jdcg.rs | 21 ++++++++++++++++----- artiq/firmware/satman/main.rs | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/artiq/firmware/satman/jdcg.rs b/artiq/firmware/satman/jdcg.rs index c581791a3..c8a34827b 100644 --- a/artiq/firmware/satman/jdcg.rs +++ b/artiq/firmware/satman/jdcg.rs @@ -108,10 +108,6 @@ pub mod jdac { basic_request(dacno, jdac_common::PRBS, 0)?; jesd::prbs(dacno, false); - jesd::stpl(dacno, true); - basic_request(dacno, jdac_common::STPL, 0)?; - jesd::stpl(dacno, false); - basic_request(dacno, jdac_common::INIT, 0)?; clock::spin_us(5000); @@ -120,7 +116,22 @@ pub mod jdac { return Err("JESD core reported bad SYNC"); } - info!(" ...done"); + info!(" ...done initializing"); + } + Ok(()) + } + + pub fn stpl() -> Result<(), &'static str> { + for dacno in 0..csr::JDCG.len() { + let dacno = dacno as u8; + + info!("Running STPL test on DAC-{}...", dacno); + + jesd::stpl(dacno, true); + basic_request(dacno, jdac_common::STPL, 0)?; + jesd::stpl(dacno, false); + + info!(" ...done STPL test"); } Ok(()) } diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index ac16a116c..2abaa2d12 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -594,6 +594,7 @@ pub extern fn main() -> i32 { jdcg::jesd::reset(false); let _ = jdcg::jdac::init(); jdcg::jesd204sync::sysref_auto_align(); + jdcg::jdac::stpl(); unsafe { csr::drtio_transceiver::txenable_write(0xffffffffu32 as _); // unhide } From 400af2c582316b7f94e442ed4eaeb74a95ae1275 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 15 Dec 2020 17:55:59 +0800 Subject: [PATCH 3/4] sayma: use QPLL for 1GSPS JESD204B TX * requires jesd204b changes as in https://github.com/HarryMakes/jesd204b/tree/gth --- artiq/firmware/libboard_artiq/ad9154.rs | 24 +++++- artiq/gateware/jesd204_tools.py | 106 ++++++++++++++++++++---- artiq/gateware/targets/sayma_amc.py | 8 +- 3 files changed, 118 insertions(+), 20 deletions(-) diff --git a/artiq/firmware/libboard_artiq/ad9154.rs b/artiq/firmware/libboard_artiq/ad9154.rs index f671e2660..388c8ac9a 100644 --- a/artiq/firmware/libboard_artiq/ad9154.rs +++ b/artiq/firmware/libboard_artiq/ad9154.rs @@ -87,7 +87,7 @@ const JESD_SETTINGS: JESDSettings = JESDSettings { np: 16, f: 2, s: 2, - k: 16, + k: 32, cs: 0, subclassv: 1, @@ -349,6 +349,28 @@ pub fn setup(dacno: u8, linerate: u64) -> Result<(), &'static str> { write(ad9154_reg::GENERAL_JRX_CTRL_0, 0x1*ad9154_reg::LINK_EN | 0*ad9154_reg::LINK_PAGE | 0*ad9154_reg::LINK_MODE | 0*ad9154_reg::CHECKSUM_MODE); + + // JESD Checks + let jesd_checks = read(ad9154_reg::JESD_CHECKS); + if jesd_checks & ad9154_reg::ERR_DLYOVER == ad9154_reg::ERR_DLYOVER { + error!("LMFC_Delay > JESD_K Parameter") + } + if jesd_checks & ad9154_reg::ERR_WINLIMIT == ad9154_reg::ERR_WINLIMIT { + error!("Unsupported Window Limit") + } + if jesd_checks & ad9154_reg::ERR_JESDBAD == ad9154_reg::ERR_JESDBAD { + error!("Unsupported M/L/S/F Selection") + } + if jesd_checks & ad9154_reg::ERR_KUNSUPP == ad9154_reg::ERR_KUNSUPP { + error!("Unsupported K Values") + } + if jesd_checks & ad9154_reg::ERR_SUBCLASS == ad9154_reg::ERR_SUBCLASS { + error!("Unsupported SUBCLASSV Value") + } + if jesd_checks & ad9154_reg::ERR_INTSUPP == ad9154_reg::ERR_INTSUPP { + error!("Unsupported Interpolation Factor") + } + info!(" ...done"); Ok(()) } diff --git a/artiq/gateware/jesd204_tools.py b/artiq/gateware/jesd204_tools.py index 8cd8e9872..6baa07f15 100644 --- a/artiq/gateware/jesd204_tools.py +++ b/artiq/gateware/jesd204_tools.py @@ -8,7 +8,11 @@ from misoc.interconnect.csr import * from jesd204b.common import (JESD204BTransportSettings, JESD204BPhysicalSettings, JESD204BSettings) -from jesd204b.phy.gth import GTHChannelPLL as JESD204BGTHChannelPLL +from jesd204b.phy.gth import (GTHChannelPLL as JESD204BGTHChannelPLL, + GTHQuadPLL as JESD204BGTHQuadPLL, + GTHTransmitter as JESD204BGTHTransmitter, + GTHInit as JESD204BGTHInit, + GTHTransmitterInterconnect as JESD204BGTHTransmitterInterconnect) from jesd204b.phy import JESD204BPhyTX from jesd204b.core import JESD204BCoreTX from jesd204b.core import JESD204BCoreTXControl @@ -16,6 +20,7 @@ from jesd204b.core import JESD204BCoreTXControl class UltrascaleCRG(Module, AutoCSR): linerate = int(10e9) # linerate = 20*data_rate*4/8 = data_rate*10 + # data_rate = dac_rate/interp_factor refclk_freq = int(250e6) fabric_freq = int(125e6) @@ -41,30 +46,99 @@ PhyPads = namedtuple("PhyPads", "txp txn") class UltrascaleTX(Module, AutoCSR): - def __init__(self, platform, sys_crg, jesd_crg, dac): + def __init__(self, platform, sys_crg, jesd_crg, dac, pll_type="cpll", tx_half=False): + # Note: In general, the choice between channel and quad PLLs can be made based on the "nominal operating ranges", which are (see UG576, Ch.2): + # CPLL: 2.0 - 6.25 GHz + # QPLL0: 9.8 - 16.375 GHz + # QPLL1: 8.0 - 13.0 GHz + # However, the exact frequency and/or linerate range should be checked according to the model and speed grade from their corresponding datasheets. + pll_cls = { + "cpll": JESD204BGTHChannelPLL, + "qpll": JESD204BGTHQuadPLL + }[pll_type] ps = JESD204BPhysicalSettings(l=8, m=4, n=16, np=16) - ts = JESD204BTransportSettings(f=2, s=2, k=16, cs=0) + ts = JESD204BTransportSettings(f=2, s=2, k=32, cs=0) settings = JESD204BSettings(ps, ts, did=0x5a, bid=0x5) jesd_pads = platform.request("dac_jesd", dac) + plls = [] phys = [] for i in range(len(jesd_pads.txp)): - cpll = JESD204BGTHChannelPLL( - jesd_crg.refclk, jesd_crg.refclk_freq, jesd_crg.linerate) - self.submodules += cpll + pll = pll_cls( + jesd_crg.refclk, jesd_crg.refclk_freq, jesd_crg.linerate) + self.submodules += pll + plls.append(pll) + # QPLL quads + if pll_type == "qpll": + gthe3_common_cfgs = [] + for i in range(0, len(plls), 4): + # GTHE3_COMMON common signals + qpll_clk = Signal() + qpll_refclk = Signal() + qpll_reset = Signal() + qpll_lock = Signal() + # GTHE3_COMMON + self.specials += pll_cls.get_gthe3_common( + jesd_crg.refclk, jesd_crg.refclk_freq, jesd_crg.linerate, + qpll_clk, qpll_refclk, qpll_reset, qpll_lock) + gthe3_common_cfgs.append({ + "clk": qpll_clk, + "refclk": qpll_refclk, + "reset": qpll_reset, + "lock": qpll_lock + }) + # Per-channel PLL phys + for i, pll in enumerate(plls): + # PhyTX phy = JESD204BPhyTX( - cpll, PhyPads(jesd_pads.txp[i], jesd_pads.txn[i]), - jesd_crg.fabric_freq, transceiver="gth") - platform.add_period_constraint(phy.transmitter.cd_tx.clk, - 40*1e9/jesd_crg.linerate) - platform.add_false_path_constraints( - sys_crg.cd_sys.clk, - jesd_crg.cd_jesd.clk, - phy.transmitter.cd_tx.clk) + pll, jesd_crg.refclk, PhyPads(jesd_pads.txp[i], jesd_pads.txn[i]), + jesd_crg.fabric_freq, transceiver="gth", tx_half=tx_half) phys.append(phy) + if tx_half: + platform.add_period_constraint(phy.transmitter.cd_tx_half.clk, + 80*1e9/jesd_crg.linerate) + platform.add_false_path_constraints( + sys_crg.cd_sys.clk, + jesd_crg.cd_jesd.clk, + phy.transmitter.cd_tx_half.clk) + else: + platform.add_period_constraint(phy.transmitter.cd_tx.clk, + 40*1e9/jesd_crg.linerate) + platform.add_false_path_constraints( + sys_crg.cd_sys.clk, + jesd_crg.cd_jesd.clk, + phy.transmitter.cd_tx.clk) + # CHANNEL & init interconnects + for i, (pll, phy) in enumerate(zip(plls, phys)): + # CPLLs: 1 init per channel + if pll_type == "cpll": + phy_channel_cfg = {} + # Connect reset/lock to init + pll_reset = pll.reset + pll_lock = pll.lock + self.submodules += JESD204BGTHTransmitterInterconnect( + pll_reset, pll_lock, phy.transmitter, phy.transmitter.init) + # QPLL: 4 inits and 4 channels per quad + elif pll_type == "qpll": + # Connect clk/refclk to CHANNEL + phy_cfg = gthe3_common_cfgs[int(i//4)] + phy_channel_cfg = { + "qpll_clk": phy_cfg["clk"], + "qpll_refclk": phy_cfg["refclk"] + } + # Connect reset/lock to init + pll_reset = phy_cfg["reset"] + pll_lock = phy_cfg["lock"] + if i % 4 == 0: + self.submodules += JESD204BGTHTransmitterInterconnect( + pll_reset, pll_lock, phy.transmitter, + [phys[j].transmitter.init for j in range(i, min(len(phys), i+4))]) + # GTHE3_CHANNEL + self.specials += JESD204BGTHTransmitter.get_gthe3_channel( + pll, phy.transmitter, **phy_channel_cfg) self.submodules.core = JESD204BCoreTX( - phys, settings, converter_data_width=128) + phys, settings, converter_data_width=128, tx_half=tx_half) self.submodules.control = JESD204BCoreTXControl(self.core) self.core.register_jsync(platform.request("dac_sync", dac)) @@ -111,7 +185,7 @@ class DDMTD(Module, AutoCSR): i_RST=self.reset.storage, o_LOCKED=helper_locked, - # VCO at 1200MHz with 150MHz RTIO frequency + # VCO at 1000MHz/1200MHz with 125MHz/150MHz RTIO frequency p_CLKFBOUT_MULT_F=8.0, p_DIVCLK_DIVIDE=1, diff --git a/artiq/gateware/targets/sayma_amc.py b/artiq/gateware/targets/sayma_amc.py index 841e28b89..868c4f1f4 100755 --- a/artiq/gateware/targets/sayma_amc.py +++ b/artiq/gateware/targets/sayma_amc.py @@ -190,8 +190,10 @@ class SatelliteBase(MiniSoC): # JESD204 DAC Channel Group class JDCGSAWG(Module, AutoCSR): def __init__(self, platform, sys_crg, jesd_crg, dac): + # Kintex Ultrascale GTH, speed grade -1C: + # QPLL0 linerate (D=1): 9.8 - 12.5 Gb/s self.submodules.jesd = jesd204_tools.UltrascaleTX( - platform, sys_crg, jesd_crg, dac) + platform, sys_crg, jesd_crg, dac, pll_type="qpll", tx_half=True) self.submodules.sawgs = [sawg.Channel(width=16, parallelism=8) for i in range(4)] @@ -203,7 +205,7 @@ class JDCGSAWG(Module, AutoCSR): class JDCGPattern(Module, AutoCSR): def __init__(self, platform, sys_crg, jesd_crg, dac): self.submodules.jesd = jesd204_tools.UltrascaleTX( - platform, sys_crg, jesd_crg, dac) + platform, sys_crg, jesd_crg, dac, pll_type="qpll", tx_half=True) self.sawgs = [] @@ -243,7 +245,7 @@ class JDCGPattern(Module, AutoCSR): 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) + platform, sys_crg, jesd_crg, dac, pll_type="qpll", tx_half=True) self.coarse_ts = Signal(32) self.sawgs = [] From d74cd24d89261aafaee754cb02776dc31b98d274 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 15 Dec 2020 17:56:05 +0800 Subject: [PATCH 4/4] sayma_amc: fix JDCGPattern data for 1Gsps --- artiq/gateware/targets/sayma_amc.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/artiq/gateware/targets/sayma_amc.py b/artiq/gateware/targets/sayma_amc.py index 868c4f1f4..55c507989 100755 --- a/artiq/gateware/targets/sayma_amc.py +++ b/artiq/gateware/targets/sayma_amc.py @@ -224,15 +224,23 @@ class JDCGPattern(Module, AutoCSR): samples[0][i][:-4].eq(0x7ff if i % 2 else 0x800) ] # ch1: 50 MHz + # - Formulae: + # target cosine wave frequency: f = 50e6 + # DAC sampling frequency: fs = 1000e6 + # number of samples per coarse RTIO period: P = 8 + # number of samples needed per wave period: M = (1/f) / (1/fs)) = 20 + # number of repeating samples needed: N = LCM(P, M) = 40 + # number of RTIO periods needed for repeating: k = N/P = 5 + # discretized value of the wave: y[i] = cos(i/M * 2pi) from math import pi, cos - data = [int(round(cos(i/24*2*pi)*((1 << 15) - 1))) - for i in range(24)] - k = Signal(2) - self.sync.rtio += If(k == 2, k.eq(0)).Else(k.eq(k + 1)) + data = [int(round(cos(i/20*2*pi)*((1 << 15) - 1))) + for i in range(40)] + k = Signal(max=5) + self.sync.rtio += If(k == 4, k.eq(0)).Else(k.eq(k + 1)) self.comb += [ Case(k, { i: [samples[1][j].eq(data[i*8 + j]) for j in range(8)] - for i in range(3) + for i in range(5) }) ] # ch2: ch0, ch3: ch1