Skip to content

Commit

Permalink
Add option for ECP5 bistream compression
Browse files Browse the repository at this point in the history
  • Loading branch information
Disasm committed Dec 17, 2020
1 parent c474272 commit 2bc76f3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions litex/build/lattice/trellis.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def nextpnr_ecp5_parse_device(device):
"yosys -l {build_name}.rpt {build_name}.ys",
"nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config \
--{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"):
script_ext = ".bat"
script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
Expand All @@ -147,7 +147,8 @@ def _build_script(source, build_template, build_name, architecture, package, spe
bootaddr = bootaddr,
fail_stmt = fail_stmt,
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
tools.write_to_file(script_file, script_contents, force_unix=False)
Expand Down Expand Up @@ -197,6 +198,7 @@ def build(self, platform, fragment,
bootaddr = 0,
seed = 1,
spimode = None,
compress = False,
**kwargs):

# Create build directory
Expand Down Expand Up @@ -228,7 +230,7 @@ def build(self, platform, fragment,

# Generate build script
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
if run:
_run_script(script)
Expand Down Expand Up @@ -260,6 +262,8 @@ def trellis_args(parser):
help="Set boot address for next image, i.e. pass '--bootaddr xxx' to ecppack")
parser.add_argument("--ecppack-spimode", default=None,
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,
help="seed to pass to nextpnr")

Expand All @@ -271,5 +275,6 @@ def trellis_argdict(args):
"ignoreloops": args.nextpnr_ignoreloops,
"bootaddr": args.ecppack_bootaddr,
"spimode": args.ecppack_spimode,
"compress": args.ecppack_compress,
"seed": args.nextpnr_seed,
}

0 comments on commit 2bc76f3

Please sign in to comment.