from litex.boards.platforms import versa_ecp5
+from litex.build.lattice.trellis import yosys_args, yosys_argdict
+
from litex.soc.cores.clock import *
from litex.soc.integration.soc_sdram import *
from litex.soc.integration.builder import *
help='gateware toolchain to use, diamond (default) or trellis')
builder_args(parser)
soc_sdram_args(parser)
+ yosys_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()
+ builder.build(**yosys_argdict(args))
if __name__ == "__main__":
main()
self.yosys_template = [
"{read_files}",
"attrmap -tocase keep -imap keep=\"true\" keep=1 -imap keep=\"false\" keep=0 -remove keep=0",
- "synth_ecp5 -abc9 -json {build_name}.json -top {build_name}",
+ "synth_ecp5 -abc9 {nwl} -json {build_name}.json -top {build_name}",
]
self.build_template = [
self.freq_constraints = dict()
def build(self, platform, fragment, build_dir="build", build_name="top",
- toolchain_path=None, run=True, **kwargs):
+ toolchain_path=None, run=True, nowidelut=False, **kwargs):
if toolchain_path is None:
toolchain_path = "/usr/share/trellis/"
os.makedirs(build_dir, exist_ok=True)
# generate yosys script
yosys_script_file = build_name + ".ys"
yosys_script_contents = "\n".join(_.format(build_name=build_name,
+ nwl="-nowidelut" if nowidelut else "",
read_files=yosys_import_sources(platform))
for _ in self.yosys_template)
tools.write_to_file(yosys_script_file, yosys_script_contents)
# constraints.
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):
+ parser.add_argument("--yosys-nowidelut", action="store_true",
+ help="pass '-nowidelut' to yosys synth_ecp5")
+
+def yosys_argdict(args):
+ return {
+ "nowidelut": args.yosys_nowidelut
+ }