2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

json: use schema defaults when applicable

This commit is contained in:
Sebastien Bourdeauducq 2023-06-16 16:59:08 +08:00
parent a792bc5456
commit 77293d53e3
4 changed files with 28 additions and 18 deletions

View File

@ -19,7 +19,8 @@
},
"min_artiq_version": {
"type": "string",
"description": "Minimum required ARTIQ version"
"description": "Minimum required ARTIQ version",
"default": "0"
},
"hw_rev": {
"type": "string",
@ -211,7 +212,8 @@
"type": "object",
"properties": {
"name": {
"type": "string"
"type": "string",
"default": "dio_spi"
},
"clk": {
"type": "integer",
@ -247,7 +249,8 @@
"type": "object",
"properties": {
"name": {
"type": "string"
"type": "string",
"default": "ttl"
},
"pin": {
"type": "integer",
@ -264,7 +267,8 @@
}
},
"required": ["pin", "direction"]
}
},
"default": []
}
},
"required": ["ports", "spi"]
@ -391,7 +395,8 @@
},
"sampler_hw_rev": {
"type": "string",
"pattern": "^v[0-9]+\\.[0-9]+"
"pattern": "^v[0-9]+\\.[0-9]+",
"default": "v2.2"
},
"urukul0_ports": {
"type": "array",
@ -573,6 +578,11 @@
},
"minItems": 1,
"maxItems": 1
},
"mode": {
"type": "string",
"enum": ["base", "miqro"],
"default": "base"
}
},
"required": ["ports"]

View File

@ -115,7 +115,7 @@ class PeripheralManager:
name=name[i],
class_name=classes[i // 4],
channel=rtio_offset + next(channel))
if peripheral.get("edge_counter", False):
if peripheral["edge_counter"]:
for i in range(num_channels):
class_name = classes[i // 4]
if class_name == "TTLInOut":
@ -140,14 +140,14 @@ class PeripheralManager:
"class": "SPIMaster",
"arguments": {{"channel": 0x{channel:06x}}}
}}""",
name=self.get_name(spi.get("name", "dio_spi")),
name=self.get_name(spi["name"]),
channel=rtio_offset + next(channel))
for ttl in peripheral.get("ttl", []):
for ttl in peripheral["ttl"]:
ttl_class_names = {
"input": "TTLInOut",
"output": "TTLOut"
}
name = self.get_name(ttl.get("name", "ttl"))
name = self.get_name(ttl["name"])
self.gen("""
device_db["{name}"] = {{
"type": "local",
@ -158,7 +158,7 @@ class PeripheralManager:
name=name,
class_name=ttl_class_names[ttl["direction"]],
channel=rtio_offset + next(channel))
if ttl.get("edge_counter", False):
if ttl["edge_counter"]:
self.gen("""
device_db["{name}_counter"] = {{
"type": "local",
@ -260,7 +260,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.get("pll_en", 1),
pll_n=peripheral.get("pll_n", 32), pll_en=peripheral["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":
@ -281,7 +281,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.get("pll_en", 1))
pll_n=peripheral.get("pll_n", 8), pll_en=peripheral["pll_en"])
else:
raise ValueError
return next(channel)
@ -469,7 +469,7 @@ class PeripheralManager:
}}""",
suservo_name=suservo_name,
sampler_name=sampler_name,
sampler_hw_rev=peripheral.get("sampler_hw_rev", "v2.2"),
sampler_hw_rev=peripheral["sampler_hw_rev"],
cpld_names_list=[urukul_name + "_cpld" for urukul_name in urukul_names],
dds_names_list=[urukul_name + "_dds" for urukul_name in urukul_names],
suservo_channel=rtio_offset+next(channel))
@ -517,7 +517,7 @@ class PeripheralManager:
refclk=peripheral.get("refclk", self.primary_description["rtio_frequency"]),
clk_sel=peripheral["clk_sel"],
pll_vco=",\n \"pll_vco\": {}".format(pll_vco) if pll_vco is not None else "",
pll_n=peripheral["pll_n"], pll_en=peripheral.get("pll_en", 1))
pll_n=peripheral["pll_n"], pll_en=peripheral["pll_en"])
return next(channel)
def process_zotino(self, rtio_offset, peripheral):
@ -582,7 +582,7 @@ class PeripheralManager:
return 1
def process_phaser(self, rtio_offset, peripheral):
mode = peripheral.get("mode", "base")
mode = peripheral["mode"]
if mode == "miqro":
dac = f', "dac": {{"pll_m": 16, "pll_n": 3, "interpolation": 2}}, "gw_rev": {PHASER_GW_MIQRO}'
n_channels = 3

View File

@ -31,7 +31,7 @@ def peripheral_dio_spi(module, peripheral, **kwargs):
for s in peripheral["spi"]]
ttl = [(t["pin"], ttl_classes[t["direction"]],
edge_counter.SimpleEdgeCounter if t.get("edge_counter") else None)
for t in peripheral.get("ttl", [])]
for t in peripheral["ttl"]]
eem.DIO_SPI.add_std(module, peripheral["ports"][0], spi, ttl, **kwargs)
@ -124,7 +124,7 @@ def peripheral_phaser(module, peripheral, **kwargs):
if len(peripheral["ports"]) != 1:
raise ValueError("wrong number of ports")
eem.Phaser.add_std(module, peripheral["ports"][0],
peripheral.get("mode", "base"), **kwargs)
peripheral["base"], **kwargs)
def peripheral_hvamp(module, peripheral, **kwargs):

View File

@ -151,7 +151,7 @@ def main():
args = parser.parse_args()
description = jsondesc.load(args.description)
min_artiq_version = description.get("min_artiq_version", "0")
min_artiq_version = description["min_artiq_version"]
if Version(artiq_version) < Version(min_artiq_version):
logger.warning("ARTIQ version mismatch: current %s < %s minimum",
artiq_version, min_artiq_version)