From fc282d4e17649d8cff51ce4279dac3cf50fe171f Mon Sep 17 00:00:00 2001 From: morgan Date: Fri, 16 Feb 2024 15:14:01 +0800 Subject: [PATCH] artiq_ddb_template: fix clk_div config remove clk_div default in jsonschema set CLK IN divided by 1 as default when bypassing PLL --- artiq/coredevice/coredevice_generic.schema.json | 3 +-- artiq/frontend/artiq_ddb_template.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/artiq/coredevice/coredevice_generic.schema.json b/artiq/coredevice/coredevice_generic.schema.json index bf79bb976..ce7385ea4 100644 --- a/artiq/coredevice/coredevice_generic.schema.json +++ b/artiq/coredevice/coredevice_generic.schema.json @@ -308,8 +308,7 @@ "clk_div": { "type": "integer", "minimum": 0, - "maximum": 3, - "default": 0 + "maximum": 3 }, "pll_n": { "type": "integer" diff --git a/artiq/frontend/artiq_ddb_template.py b/artiq/frontend/artiq_ddb_template.py index 376467d75..1bb6d8b9c 100755 --- a/artiq/frontend/artiq_ddb_template.py +++ b/artiq/frontend/artiq_ddb_template.py @@ -211,6 +211,11 @@ class PeripheralManager: urukul_name = self.get_name("urukul") synchronization = peripheral["synchronization"] channel = count(0) + pll_en = peripheral["pll_en"] + clk_div = peripheral.get("clk_div") + if clk_div is None: + clk_div = 0 if pll_en else 1 + self.gen(""" device_db["eeprom_{name}"] = {{ "type": "local", @@ -277,7 +282,7 @@ class PeripheralManager: sync_device="\"ttl_{name}_sync\"".format(name=urukul_name) if synchronization else "None", refclk=peripheral.get("refclk", self.primary_description["rtio_frequency"]), clk_sel=peripheral["clk_sel"], - clk_div=peripheral["clk_div"]) + clk_div=clk_div) dds = peripheral["dds"] pll_vco = peripheral.get("pll_vco") for i in range(4): @@ -299,7 +304,7 @@ class PeripheralManager: uchn=i, sw=",\n \"sw_device\": \"ttl_{name}_sw{uchn}\"".format(name=urukul_name, uchn=i) if len(peripheral["ports"]) > 1 else "", pll_vco=",\n \"pll_vco\": {}".format(pll_vco) if pll_vco is not None else "", - pll_n=peripheral.get("pll_n", 32), pll_en=peripheral["pll_en"], + pll_n=peripheral.get("pll_n", 32), pll_en=pll_en, sync_delay_seed=",\n \"sync_delay_seed\": \"eeprom_{}:{}\"".format(urukul_name, 64 + 4*i) if synchronization else "", io_update_delay=",\n \"io_update_delay\": \"eeprom_{}:{}\"".format(urukul_name, 64 + 4*i) if synchronization else "") elif dds == "ad9912": @@ -320,7 +325,7 @@ class PeripheralManager: uchn=i, sw=",\n \"sw_device\": \"ttl_{name}_sw{uchn}\"".format(name=urukul_name, uchn=i) if len(peripheral["ports"]) > 1 else "", pll_vco=",\n \"pll_vco\": {}".format(pll_vco) if pll_vco is not None else "", - pll_n=peripheral.get("pll_n", 8), pll_en=peripheral["pll_en"]) + pll_n=peripheral.get("pll_n", 8), pll_en=pll_en) else: raise ValueError return next(channel)