Add option for ECP5 bistream compression

This commit is contained in:
Vadim Kaushan 2020-12-18 00:21:05 +03:00
parent c474272f53
commit 2bc76f3245
No known key found for this signature in database
GPG key ID: A501C5DF67C05C4E

View file

@ -122,10 +122,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} {spimode}" "ecppack {build_name}.config --svf {build_name}.svf --bit {build_name}.bit --bootaddr {bootaddr} {spimode} {compress}"
] ]
def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict, ignoreloops, bootaddr, seed, spimode): def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict, ignoreloops, bootaddr, seed, spimode, compress):
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"
@ -147,7 +147,8 @@ def _build_script(source, build_template, build_name, architecture, package, spe
bootaddr = bootaddr, bootaddr = bootaddr,
fail_stmt = fail_stmt, fail_stmt = fail_stmt,
seed = seed, seed = seed,
spimode = "" if spimode is None else "--spimode {}".format(spimode)) spimode = "" if spimode is None else "--spimode {}".format(spimode),
compress = "" if not compress else "--compress")
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)
@ -197,6 +198,7 @@ class LatticeTrellisToolchain:
bootaddr = 0, bootaddr = 0,
seed = 1, seed = 1,
spimode = None, spimode = None,
compress = False,
**kwargs): **kwargs):
# Create build directory # Create build directory
@ -228,7 +230,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, spimode) speed_grade, timingstrict, ignoreloops, bootaddr, seed, spimode, compress)
# Run # Run
if run: if run:
_run_script(script) _run_script(script)
@ -260,6 +262,8 @@ def trellis_args(parser):
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=None, parser.add_argument("--ecppack-spimode", default=None,
help="Set slave SPI programming mode") help="Set slave SPI programming mode")
parser.add_argument("--ecppack-compress", action="store_true",
help="Compress bitstream to reduce size")
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")
@ -271,5 +275,6 @@ def trellis_argdict(args):
"ignoreloops": args.nextpnr_ignoreloops, "ignoreloops": args.nextpnr_ignoreloops,
"bootaddr": args.ecppack_bootaddr, "bootaddr": args.ecppack_bootaddr,
"spimode": args.ecppack_spimode, "spimode": args.ecppack_spimode,
"compress": args.ecppack_compress,
"seed": args.nextpnr_seed, "seed": args.nextpnr_seed,
} }