from litex.boards.platforms import versa_ecp5
-from litex.build.lattice.trellis import yosys_args, yosys_argdict
+from litex.build.lattice.trellis import trellis_args, trellis_argdict
from litex.soc.cores.clock import *
from litex.soc.integration.soc_sdram import *
help='gateware toolchain to use, diamond (default) or trellis')
builder_args(parser)
soc_sdram_args(parser)
- yosys_args(parser)
+ trellis_args(parser)
parser.add_argument("--sys-clk-freq", default=75e6,
help="system clock frequency (default=75MHz)")
parser.add_argument("--with-ethernet", action="store_true",
cls = EthernetSoC if args.with_ethernet else BaseSoC
soc = cls(toolchain=args.toolchain, sys_clk_freq=int(float(args.sys_clk_freq)), **soc_sdram_argdict(args))
builder = Builder(soc, **builder_argdict(args))
- builder.build(**yosys_argdict(args))
+ builder.build(**trellis_argdict(args))
if __name__ == "__main__":
main()
def _build_script(source, build_template, build_name, architecture,
- package, freq_constraint):
+ package, freq_constraint, timingstrict):
if sys.platform in ("win32", "cygwin"):
script_ext = ".bat"
build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n"
architecture=architecture,
package=package,
freq_constraint=freq_constraint,
+ timefailarg="--timing-allow-fail" if not timingstrict else "",
fail_stmt=fail_stmt)
build_script_file = "build_" + build_name + script_ext
self.build_template = [
"yosys -q -l {build_name}.rpt {build_name}.ys",
- "nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config --{architecture} --package {package} --freq {freq_constraint} --timing-allow-fail",
+ "nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config --{architecture} --package {package} --freq {freq_constraint} {timefailarg}",
"ecppack {build_name}.config --svf {build_name}.svf --bit {build_name}.bit"
]
self.freq_constraints = dict()
def build(self, platform, fragment, build_dir="build", build_name="top",
- toolchain_path=None, run=True, nowidelut=False, **kwargs):
+ toolchain_path=None, run=True,
+ nowidelut=False, timingstrict=False,
+ **kwargs):
if toolchain_path is None:
toolchain_path = "/usr/share/trellis/"
os.makedirs(build_dir, exist_ok=True)
default=0.0))
script = _build_script(False, self.build_template, build_name,
- architecture, package, freq_constraint)
+ architecture, package, freq_constraint,
+ timingstrict)
# run scripts
if run:
def add_period_constraint(self, platform, clk, period):
platform.add_platform_command("""FREQUENCY PORT "{clk}" {freq} MHz;""".format(freq=str(float(1/period)*1000), clk="{clk}"), clk=clk)
-def yosys_args(parser):
+def trellis_args(parser):
parser.add_argument("--yosys-nowidelut", action="store_true",
help="pass '-nowidelut' to yosys synth_ecp5")
+ parser.add_argument("--nextpnr-timingstrict", action="store_true",
+ help="fail if timing not met, i.e., do NOT pass '--timing-allow-fail' to nextpnr")
-def yosys_argdict(args):
+def trellis_argdict(args):
return {
- "nowidelut": args.yosys_nowidelut
+ "nowidelut": args.yosys_nowidelut,
+ "timingstrict": args.nextpnr_timingstrict,
}