Merge pull request #588 from oskirby/trellis-spimode

trellis: Add option to select SPI mode.
This commit is contained in:
enjoy-digital 2020-07-11 21:26:55 +02:00 committed by GitHub
commit 7c381dadc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -118,10 +118,10 @@ _build_template = [
"yosys -l {build_name}.rpt {build_name}.ys", "yosys -l {build_name}.rpt {build_name}.ys",
"nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config \ "nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config \
--{architecture} --package {package} --speed {speed_grade} {timefailarg} {ignoreloops} --seed {seed}", --{architecture} --package {package} --speed {speed_grade} {timefailarg} {ignoreloops} --seed {seed}",
"ecppack {build_name}.config --svf {build_name}.svf --bit {build_name}.bit --bootaddr {bootaddr}" "ecppack {build_name}.config --svf {build_name}.svf --bit {build_name}.bit --bootaddr {bootaddr} --spimode {spimode}"
] ]
def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict, ignoreloops, bootaddr, seed): def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict, ignoreloops, bootaddr, seed, spimode):
if sys.platform in ("win32", "cygwin"): if sys.platform in ("win32", "cygwin"):
script_ext = ".bat" script_ext = ".bat"
script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n" script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
@ -142,7 +142,8 @@ def _build_script(source, build_template, build_name, architecture, package, spe
ignoreloops = "--ignore-loops" if ignoreloops else "", ignoreloops = "--ignore-loops" if ignoreloops else "",
bootaddr = bootaddr, bootaddr = bootaddr,
fail_stmt = fail_stmt, fail_stmt = fail_stmt,
seed = seed) seed = seed,
spimode = spimode)
script_file = "build_" + build_name + script_ext script_file = "build_" + build_name + script_ext
tools.write_to_file(script_file, script_contents, force_unix=False) tools.write_to_file(script_file, script_contents, force_unix=False)
@ -190,6 +191,7 @@ class LatticeTrellisToolchain:
ignoreloops = False, ignoreloops = False,
bootaddr = 0, bootaddr = 0,
seed = 1, seed = 1,
spimode = "fast-read",
**kwargs): **kwargs):
# Create build directory # Create build directory
@ -221,7 +223,7 @@ class LatticeTrellisToolchain:
# Generate build script # Generate build script
script = _build_script(False, self.build_template, build_name, architecture, package, script = _build_script(False, self.build_template, build_name, architecture, package,
speed_grade, timingstrict, ignoreloops, bootaddr, seed) speed_grade, timingstrict, ignoreloops, bootaddr, seed, spimode)
# Run # Run
if run: if run:
_run_script(script) _run_script(script)
@ -249,6 +251,8 @@ def trellis_args(parser):
help="ignore combinational loops in timing analysis, i.e. pass '--ignore-loops' to nextpnr") help="ignore combinational loops in timing analysis, i.e. pass '--ignore-loops' to nextpnr")
parser.add_argument("--ecppack-bootaddr", default=0, parser.add_argument("--ecppack-bootaddr", default=0,
help="Set boot address for next image, i.e. pass '--bootaddr xxx' to ecppack") help="Set boot address for next image, i.e. pass '--bootaddr xxx' to ecppack")
parser.add_argument("--ecppack-spimode", default="fast-read",
help="Set slave SPI programming mode")
parser.add_argument("--nextpnr-seed", default=1, type=int, parser.add_argument("--nextpnr-seed", default=1, type=int,
help="seed to pass to nextpnr") help="seed to pass to nextpnr")
@ -258,5 +262,6 @@ def trellis_argdict(args):
"timingstrict": args.nextpnr_timingstrict, "timingstrict": args.nextpnr_timingstrict,
"ignoreloops": args.nextpnr_ignoreloops, "ignoreloops": args.nextpnr_ignoreloops,
"bootaddr": args.ecppack_bootaddr, "bootaddr": args.ecppack_bootaddr,
"spimode": args.ecppack_spimdoe,
"seed": args.nextpnr_seed, "seed": args.nextpnr_seed,
} }