From 78d4b3a7da3c7c14283c6ba37b18df251b1d9e89 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 17 Nov 2018 21:47:32 +0800 Subject: [PATCH] gateware/targets: expose variant lists This allows writing scripts that build all variants. --- artiq/gateware/targets/kasli.py | 14 ++++++++------ artiq/gateware/targets/kc705.py | 13 ++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/artiq/gateware/targets/kasli.py b/artiq/gateware/targets/kasli.py index e232e2296..cee924fdf 100755 --- a/artiq/gateware/targets/kasli.py +++ b/artiq/gateware/targets/kasli.py @@ -1123,24 +1123,26 @@ class VLBAISatellite(_SatelliteBase): self.add_rtio(self.rtio_channels) +VARIANTS = {cls.__name__.lower(): cls for cls in [ + Opticlock, SUServo, PTB, PTB2, HUB, LUH, + SYSU, MITLL, MITLL2, USTC, Tsinghua, Tsinghua2, WIPM, NUDT, + VLBAIMaster, VLBAISatellite, Tester, Master, Satellite]} + + def main(): parser = argparse.ArgumentParser( description="ARTIQ device binary builder for Kasli systems") builder_args(parser) soc_kasli_args(parser) parser.set_defaults(output_dir="artiq_kasli") - variants = {cls.__name__.lower(): cls for cls in [ - Opticlock, SUServo, PTB, PTB2, HUB, LUH, - SYSU, MITLL, MITLL2, USTC, Tsinghua, Tsinghua2, WIPM, NUDT, - VLBAIMaster, VLBAISatellite, Tester, Master, Satellite]} parser.add_argument("-V", "--variant", default="opticlock", help="variant: {} (default: %(default)s)".format( - "/".join(sorted(variants.keys())))) + "/".join(sorted(VARIANTS.keys())))) args = parser.parse_args() variant = args.variant.lower() try: - cls = variants[variant] + cls = VARIANTS[variant] except KeyError: raise SystemExit("Invalid variant (-V/--variant)") diff --git a/artiq/gateware/targets/kc705.py b/artiq/gateware/targets/kc705.py index eb32aedb2..2b9975ec8 100755 --- a/artiq/gateware/targets/kc705.py +++ b/artiq/gateware/targets/kc705.py @@ -400,6 +400,9 @@ class SMA_SPI(_StandaloneBase): self.csr_devices.append("rtio_analyzer") +VARIANTS = {cls.__name__.lower(): cls for cls in [NIST_CLOCK, NIST_QC2, SMA_SPI]} + + def main(): parser = argparse.ArgumentParser( description="KC705 gateware and firmware builder") @@ -413,13 +416,9 @@ def main(): args = parser.parse_args() variant = args.variant.lower() - if variant == "nist_clock": - cls = NIST_CLOCK - elif variant == "nist_qc2": - cls = NIST_QC2 - elif variant == "sma_spi": - cls = SMA_SPI - else: + try: + cls = VARIANTS[variant] + except KeyError: raise SystemExit("Invalid variant (-V/--variant)") soc = cls(**soc_kc705_argdict(args))