From 68530fde07aee7f96bf779210f0d7a0d600a89be Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 23 Jun 2018 10:35:25 +0800 Subject: [PATCH] sayma: generate 100MHz from Si5324 on standalone and master targets * Allow switching between DRTIO satellite and standalone without touching the hardware. * Allow operating standalone and master without an additional RF signal generator. --- artiq/firmware/runtime/main.rs | 19 ++++++++++++++++--- artiq/gateware/targets/sayma_amc.py | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs index cfd420e04..a0af6667f 100644 --- a/artiq/firmware/runtime/main.rs +++ b/artiq/firmware/runtime/main.rs @@ -131,7 +131,7 @@ fn startup() { fn setup_si5324_as_synthesizer() { // 125MHz output, from 100MHz CLKIN2 reference, 586 Hz - #[cfg(all(rtio_frequency = "125.0", si5324_ext_ref))] + #[cfg(all(not(si5324_sayma_ref), rtio_frequency = "125.0", si5324_ext_ref))] const SI5324_SETTINGS: board_artiq::si5324::FrequencySettings = board_artiq::si5324::FrequencySettings { n1_hs : 10, @@ -144,7 +144,7 @@ fn setup_si5324_as_synthesizer() crystal_ref: false }; // 125MHz output, from crystal, 7 Hz - #[cfg(all(rtio_frequency = "125.0", not(si5324_ext_ref)))] + #[cfg(all(not(si5324_sayma_ref), rtio_frequency = "125.0", not(si5324_ext_ref)))] const SI5324_SETTINGS: board_artiq::si5324::FrequencySettings = board_artiq::si5324::FrequencySettings { n1_hs : 10, @@ -157,7 +157,7 @@ fn setup_si5324_as_synthesizer() crystal_ref: true }; // 150MHz output, from crystal - #[cfg(all(rtio_frequency = "150.0", not(si5324_ext_ref)))] + #[cfg(all(not(si5324_sayma_ref), rtio_frequency = "150.0", not(si5324_ext_ref)))] const SI5324_SETTINGS: board_artiq::si5324::FrequencySettings = board_artiq::si5324::FrequencySettings { n1_hs : 9, @@ -169,6 +169,19 @@ fn setup_si5324_as_synthesizer() bwsel : 3, crystal_ref: true }; + // 100MHz output, from crystal (reference for HMC830) + #[cfg(si5324_sayma_ref)] + const SI5324_SETTINGS: board_artiq::si5324::FrequencySettings + = board_artiq::si5324::FrequencySettings { + n1_hs : 9, + nc1_ls : 6, + n2_hs : 10, + n2_ls : 33732, + n31 : 9370, + n32 : 7139, + bwsel : 3, + crystal_ref: true + }; board_artiq::si5324::setup(&SI5324_SETTINGS, board_artiq::si5324::Input::Ckin2).expect("cannot initialize Si5324"); } diff --git a/artiq/gateware/targets/sayma_amc.py b/artiq/gateware/targets/sayma_amc.py index 165d09c50..abb614977 100755 --- a/artiq/gateware/targets/sayma_amc.py +++ b/artiq/gateware/targets/sayma_amc.py @@ -139,6 +139,16 @@ class Standalone(MiniSoC, AMPSoC, RTMCommon): platform = self.platform + 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 + self.config["SI5324_AS_SYNTHESIZER"] = None + self.config["SI5324_SAYMA_REF"] = None + # RTIO rtio_channels = [] for i in range(4): @@ -233,6 +243,16 @@ class Master(MiniSoC, AMPSoC, RTMCommon): platform = self.platform rtio_clk_freq = 150e6 + 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 + self.config["SI5324_AS_SYNTHESIZER"] = None + self.config["SI5324_SAYMA_REF"] = None + self.comb += [ platform.request("sfp_tx_disable", i).eq(0) for i in range(2)