build/lattice/diamond.py,platform.py: allows adding lattice's IPs

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

View File

@ -117,6 +117,10 @@ class LatticeDiamondToolchain(GenericToolchain):
for filename, language, library, *copy in self.platform.sources:
tcl.append("prj_src add \"{}\" -work {}".format(tcl_path(filename), library))
# Add IPs
for filename in self.platform.ips:
tcl.append("prj_src add \"{}\" -work {}".format(tcl_path(filename), library))
# Set top level
tcl.append("prj_impl option top \"{}\"".format(self._build_name))

View File

@ -5,6 +5,8 @@
# Copyright (c) 2017 William D. Jones <thor0505@comcast.net>
# SPDX-License-Identifier: BSD-2-Clause
import os
from litex.build.generic_platform import GenericPlatform
from litex.build.lattice import common, diamond, icestorm, trellis, radiant, oxide
@ -21,6 +23,7 @@ class LatticePlatform(GenericPlatform):
def __init__(self, *args, toolchain="diamond", **kwargs):
GenericPlatform.__init__(self, *args, **kwargs)
self.ips = set()
if toolchain == "diamond":
self.toolchain = diamond.LatticeDiamondToolchain()
elif toolchain == "trellis":
@ -35,6 +38,9 @@ class LatticePlatform(GenericPlatform):
else:
raise ValueError(f"Unknown toolchain {toolchain}")
def add_ip(self, filename):
self.ips.add((os.path.abspath(filename)))
def get_verilog(self, *args, special_overrides=dict(), **kwargs):
so = dict() # No common overrides between ECP5 and iCE40.
so.update(self.toolchain.special_overrides)