forked from M-Labs/artiq
json: use schema defaults when applicable
This commit is contained in:
parent
a792bc5456
commit
77293d53e3
|
@ -19,7 +19,8 @@
|
||||||
},
|
},
|
||||||
"min_artiq_version": {
|
"min_artiq_version": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Minimum required ARTIQ version"
|
"description": "Minimum required ARTIQ version",
|
||||||
|
"default": "0"
|
||||||
},
|
},
|
||||||
"hw_rev": {
|
"hw_rev": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -211,7 +212,8 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"default": "dio_spi"
|
||||||
},
|
},
|
||||||
"clk": {
|
"clk": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -247,7 +249,8 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"default": "ttl"
|
||||||
},
|
},
|
||||||
"pin": {
|
"pin": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -264,7 +267,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["pin", "direction"]
|
"required": ["pin", "direction"]
|
||||||
}
|
},
|
||||||
|
"default": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["ports", "spi"]
|
"required": ["ports", "spi"]
|
||||||
|
@ -391,7 +395,8 @@
|
||||||
},
|
},
|
||||||
"sampler_hw_rev": {
|
"sampler_hw_rev": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^v[0-9]+\\.[0-9]+"
|
"pattern": "^v[0-9]+\\.[0-9]+",
|
||||||
|
"default": "v2.2"
|
||||||
},
|
},
|
||||||
"urukul0_ports": {
|
"urukul0_ports": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -573,6 +578,11 @@
|
||||||
},
|
},
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
"maxItems": 1
|
"maxItems": 1
|
||||||
|
},
|
||||||
|
"mode": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["base", "miqro"],
|
||||||
|
"default": "base"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["ports"]
|
"required": ["ports"]
|
||||||
|
|
|
@ -115,7 +115,7 @@ class PeripheralManager:
|
||||||
name=name[i],
|
name=name[i],
|
||||||
class_name=classes[i // 4],
|
class_name=classes[i // 4],
|
||||||
channel=rtio_offset + next(channel))
|
channel=rtio_offset + next(channel))
|
||||||
if peripheral.get("edge_counter", False):
|
if peripheral["edge_counter"]:
|
||||||
for i in range(num_channels):
|
for i in range(num_channels):
|
||||||
class_name = classes[i // 4]
|
class_name = classes[i // 4]
|
||||||
if class_name == "TTLInOut":
|
if class_name == "TTLInOut":
|
||||||
|
@ -140,14 +140,14 @@ class PeripheralManager:
|
||||||
"class": "SPIMaster",
|
"class": "SPIMaster",
|
||||||
"arguments": {{"channel": 0x{channel:06x}}}
|
"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))
|
channel=rtio_offset + next(channel))
|
||||||
for ttl in peripheral.get("ttl", []):
|
for ttl in peripheral["ttl"]:
|
||||||
ttl_class_names = {
|
ttl_class_names = {
|
||||||
"input": "TTLInOut",
|
"input": "TTLInOut",
|
||||||
"output": "TTLOut"
|
"output": "TTLOut"
|
||||||
}
|
}
|
||||||
name = self.get_name(ttl.get("name", "ttl"))
|
name = self.get_name(ttl["name"])
|
||||||
self.gen("""
|
self.gen("""
|
||||||
device_db["{name}"] = {{
|
device_db["{name}"] = {{
|
||||||
"type": "local",
|
"type": "local",
|
||||||
|
@ -158,7 +158,7 @@ class PeripheralManager:
|
||||||
name=name,
|
name=name,
|
||||||
class_name=ttl_class_names[ttl["direction"]],
|
class_name=ttl_class_names[ttl["direction"]],
|
||||||
channel=rtio_offset + next(channel))
|
channel=rtio_offset + next(channel))
|
||||||
if ttl.get("edge_counter", False):
|
if ttl["edge_counter"]:
|
||||||
self.gen("""
|
self.gen("""
|
||||||
device_db["{name}_counter"] = {{
|
device_db["{name}_counter"] = {{
|
||||||
"type": "local",
|
"type": "local",
|
||||||
|
@ -260,7 +260,7 @@ class PeripheralManager:
|
||||||
uchn=i,
|
uchn=i,
|
||||||
sw=",\n \"sw_device\": \"ttl_{name}_sw{uchn}\"".format(name=urukul_name, uchn=i) if len(peripheral["ports"]) > 1 else "",
|
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_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 "",
|
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 "")
|
io_update_delay=",\n \"io_update_delay\": \"eeprom_{}:{}\"".format(urukul_name, 64 + 4*i) if synchronization else "")
|
||||||
elif dds == "ad9912":
|
elif dds == "ad9912":
|
||||||
|
@ -281,7 +281,7 @@ class PeripheralManager:
|
||||||
uchn=i,
|
uchn=i,
|
||||||
sw=",\n \"sw_device\": \"ttl_{name}_sw{uchn}\"".format(name=urukul_name, uchn=i) if len(peripheral["ports"]) > 1 else "",
|
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_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:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return next(channel)
|
return next(channel)
|
||||||
|
@ -469,7 +469,7 @@ class PeripheralManager:
|
||||||
}}""",
|
}}""",
|
||||||
suservo_name=suservo_name,
|
suservo_name=suservo_name,
|
||||||
sampler_name=sampler_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],
|
cpld_names_list=[urukul_name + "_cpld" for urukul_name in urukul_names],
|
||||||
dds_names_list=[urukul_name + "_dds" for urukul_name in urukul_names],
|
dds_names_list=[urukul_name + "_dds" for urukul_name in urukul_names],
|
||||||
suservo_channel=rtio_offset+next(channel))
|
suservo_channel=rtio_offset+next(channel))
|
||||||
|
@ -517,7 +517,7 @@ class PeripheralManager:
|
||||||
refclk=peripheral.get("refclk", self.primary_description["rtio_frequency"]),
|
refclk=peripheral.get("refclk", self.primary_description["rtio_frequency"]),
|
||||||
clk_sel=peripheral["clk_sel"],
|
clk_sel=peripheral["clk_sel"],
|
||||||
pll_vco=",\n \"pll_vco\": {}".format(pll_vco) if pll_vco is not None else "",
|
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)
|
return next(channel)
|
||||||
|
|
||||||
def process_zotino(self, rtio_offset, peripheral):
|
def process_zotino(self, rtio_offset, peripheral):
|
||||||
|
@ -582,7 +582,7 @@ class PeripheralManager:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def process_phaser(self, rtio_offset, peripheral):
|
def process_phaser(self, rtio_offset, peripheral):
|
||||||
mode = peripheral.get("mode", "base")
|
mode = peripheral["mode"]
|
||||||
if mode == "miqro":
|
if mode == "miqro":
|
||||||
dac = f', "dac": {{"pll_m": 16, "pll_n": 3, "interpolation": 2}}, "gw_rev": {PHASER_GW_MIQRO}'
|
dac = f', "dac": {{"pll_m": 16, "pll_n": 3, "interpolation": 2}}, "gw_rev": {PHASER_GW_MIQRO}'
|
||||||
n_channels = 3
|
n_channels = 3
|
||||||
|
|
|
@ -31,7 +31,7 @@ def peripheral_dio_spi(module, peripheral, **kwargs):
|
||||||
for s in peripheral["spi"]]
|
for s in peripheral["spi"]]
|
||||||
ttl = [(t["pin"], ttl_classes[t["direction"]],
|
ttl = [(t["pin"], ttl_classes[t["direction"]],
|
||||||
edge_counter.SimpleEdgeCounter if t.get("edge_counter") else None)
|
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)
|
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:
|
if len(peripheral["ports"]) != 1:
|
||||||
raise ValueError("wrong number of ports")
|
raise ValueError("wrong number of ports")
|
||||||
eem.Phaser.add_std(module, peripheral["ports"][0],
|
eem.Phaser.add_std(module, peripheral["ports"][0],
|
||||||
peripheral.get("mode", "base"), **kwargs)
|
peripheral["base"], **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def peripheral_hvamp(module, peripheral, **kwargs):
|
def peripheral_hvamp(module, peripheral, **kwargs):
|
||||||
|
|
|
@ -151,7 +151,7 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
description = jsondesc.load(args.description)
|
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):
|
if Version(artiq_version) < Version(min_artiq_version):
|
||||||
logger.warning("ARTIQ version mismatch: current %s < %s minimum",
|
logger.warning("ARTIQ version mismatch: current %s < %s minimum",
|
||||||
artiq_version, min_artiq_version)
|
artiq_version, min_artiq_version)
|
||||||
|
|
Loading…
Reference in New Issue