From dfd21d3c2dc095c87509964749c142dc72a454ed Mon Sep 17 00:00:00 2001 From: dragonmux Date: Thu, 19 Oct 2023 23:30:39 +0100 Subject: [PATCH] gateware/platform: Implemented a nextpnr seed specification CLI option --- gateware/dragonBoot/__init__.py | 6 +++++- gateware/dragonBoot/platform.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gateware/dragonBoot/__init__.py b/gateware/dragonBoot/__init__.py index d41e431..ececc7f 100644 --- a/gateware/dragonBoot/__init__.py +++ b/gateware/dragonBoot/__init__.py @@ -27,6 +27,10 @@ def cli(): platforms = listPlatforms() buildAction.add_argument('--target', action = 'store', required = True, choices = platforms.keys()) + # Allow the user to pick a seed if their toolchain is not giving good nextpnr runs + buildAction.add_argument('--seed', action = 'store', type = int, default = 0, + help = 'The nextpnr seed to use for the gateware build (default 0)') + # Parse the command line and, if `-v` is specified, bump the logging level args = parser.parse_args() if args.verbose: @@ -46,5 +50,5 @@ def cli(): return 0 elif args.action == 'build': platform = platforms[args.target]() - platform.build(DragonBoot(), name = 'dragonBoot') + platform.build(DragonBoot(), name = 'dragonBoot', pnrSeed = args.seed) return 0 diff --git a/gateware/dragonBoot/platform.py b/gateware/dragonBoot/platform.py index 83ef8ba..bf495a1 100644 --- a/gateware/dragonBoot/platform.py +++ b/gateware/dragonBoot/platform.py @@ -150,7 +150,7 @@ def __init__(self, toolchain = 'IceStorm'): self.flash.platform(self) def build(self, elaboratable, name = "top", build_dir = "build", do_build = True, - program_opts = None, do_program = False, **kwargs + program_opts = None, do_program = False, pnrSeed = 0, **kwargs ) -> Union[BuildPlan, BuildProducts, None]: """ This is called automatically by the bootloader CLI. @@ -169,7 +169,7 @@ def build(self, elaboratable, name = "top", build_dir = "build", do_build = True """ products : LocalBuildProducts = super().build( elaboratable, name, build_dir, do_build, do_program = False, - synth_opts = '-abc9', nextpnr_opts = '--tmg-ripup --seed=0', + synth_opts = '-abc9', nextpnr_opts = ['--tmg-ripup', f'--seed={pnrSeed}'], **kwargs )