build/lattice/diamond.py,platform.py: allows adding custom strategy

This commit is contained in:
Gwenhael Goavec-Merou 2024-10-16 13:46:43 +02:00
parent 331e1938c9
commit ea81314866
2 changed files with 8 additions and 0 deletions

View File

@ -121,6 +121,10 @@ class LatticeDiamondToolchain(GenericToolchain):
for filename in self.platform.ips:
tcl.append("prj_src add \"{}\" -work {}".format(tcl_path(filename), library))
# Add Strategy
for filename, strategy_name in self.platform.strategy:
tcl.append("prj_strgy import -name {} -file {}".format(strategy_name, tcl_path(filename)))
# Set top level
tcl.append("prj_impl option top \"{}\"".format(self._build_name))

View File

@ -24,6 +24,7 @@ class LatticePlatform(GenericPlatform):
def __init__(self, *args, toolchain="diamond", **kwargs):
GenericPlatform.__init__(self, *args, **kwargs)
self.ips = set()
self.strategy = set()
if toolchain == "diamond":
self.toolchain = diamond.LatticeDiamondToolchain()
elif toolchain == "trellis":
@ -41,6 +42,9 @@ class LatticePlatform(GenericPlatform):
def add_ip(self, filename):
self.ips.add((os.path.abspath(filename)))
def add_strategy(self, filename, strategy_name):
self.strategy.add((os.path.abspath(filename), strategy_name))
def get_verilog(self, *args, special_overrides=dict(), **kwargs):
so = dict() # No common overrides between ECP5 and iCE40.
so.update(self.toolchain.special_overrides)