Merge pull request #2097 from trabucayre/build_diamond_addition

Build diamond addition
This commit is contained in:
enjoy-digital 2024-10-28 20:05:01 +01:00 committed by GitHub
commit 10184ad325
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 1 deletions

View File

@ -36,6 +36,7 @@ class LatticeDiamondToolchain(GenericToolchain):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.additional_ldf_commands = []
def build(self, platform, fragment, def build(self, platform, fragment,
timingstrict = False, timingstrict = False,
@ -116,9 +117,20 @@ class LatticeDiamondToolchain(GenericToolchain):
for filename, language, library, *copy in self.platform.sources: for filename, language, library, *copy in self.platform.sources:
tcl.append("prj_src add \"{}\" -work {}".format(tcl_path(filename), library)) 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))
# 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 # Set top level
tcl.append("prj_impl option top \"{}\"".format(self._build_name)) tcl.append("prj_impl option top \"{}\"".format(self._build_name))
# Add additional commands
tcl += self.additional_ldf_commands
# Save project # Save project
tcl.append("prj_project save") tcl.append("prj_project save")

View File

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

View File

@ -379,7 +379,7 @@ class ECP5JTAG(LiteXModule):
new_tck = Signal() new_tck = Signal()
self.specials += Instance("LUT4", self.specials += Instance("LUT4",
attr = {"keep"}, attr = {"keep"},
p_INIT = 2, p_init = 2,
i_A = tck, i_A = tck,
i_B = 0, i_B = 0,
i_C = 0, i_C = 0,