mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
build/generic_platform build/xxx/platform soc/integration/builder:
generic_platform add a method to return extension for sram/flash vendor platform: bitstream_ext -> _bitstream_ext and replace by a dict when extension depends on mode builder: use `get_bitstream_extension` instead of directly using bitstream_ext
This commit is contained in:
parent
1ea94ca264
commit
c40963531c
11 changed files with 48 additions and 14 deletions
|
@ -13,7 +13,10 @@ from litex.build.altera import common, quartus
|
||||||
# AlteraPlatform -----------------------------------------------------------------------------------
|
# AlteraPlatform -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class AlteraPlatform(GenericPlatform):
|
class AlteraPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".sof"
|
_bitstream_ext = {
|
||||||
|
"sram" : ".sof",
|
||||||
|
"flash" : ".rbf"
|
||||||
|
}
|
||||||
create_rbf = True
|
create_rbf = True
|
||||||
|
|
||||||
_supported_toolchains = ["quartus"]
|
_supported_toolchains = ["quartus"]
|
||||||
|
|
|
@ -13,7 +13,7 @@ from litex.build.anlogic import common, anlogic
|
||||||
# AnlogicPlatform ----------------------------------------------------------------------------------
|
# AnlogicPlatform ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class AnlogicPlatform(GenericPlatform):
|
class AnlogicPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bit"
|
_bitstream_ext = ".bit"
|
||||||
|
|
||||||
_supported_toolchains = ["td"]
|
_supported_toolchains = ["td"]
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,10 @@ from litex.build.efinix import EfinixDbParser
|
||||||
# EfinixPlatform -----------------------------------------------------------------------------------
|
# EfinixPlatform -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class EfinixPlatform(GenericPlatform):
|
class EfinixPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bit"
|
_bitstream_ext = {
|
||||||
|
"sram" : ".bit",
|
||||||
|
"flash" : ".hex"
|
||||||
|
}
|
||||||
|
|
||||||
_supported_toolchains = ["efinity"]
|
_supported_toolchains = ["efinity"]
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,9 @@ class ConstraintManager:
|
||||||
|
|
||||||
class GenericPlatform:
|
class GenericPlatform:
|
||||||
device_family = None
|
device_family = None
|
||||||
|
_bitstream_ext = None # None by default, overridden by vendor platform, may
|
||||||
|
# be a string when same extension is used for sram and
|
||||||
|
# flash. A dict must be provided otherwise
|
||||||
|
|
||||||
def __init__(self, device, io, connectors=[], name=None):
|
def __init__(self, device, io, connectors=[], name=None):
|
||||||
self.toolchain = None
|
self.toolchain = None
|
||||||
|
@ -463,6 +466,31 @@ class GenericPlatform:
|
||||||
def build(self, fragment):
|
def build(self, fragment):
|
||||||
raise NotImplementedError("GenericPlatform.build must be overloaded")
|
raise NotImplementedError("GenericPlatform.build must be overloaded")
|
||||||
|
|
||||||
|
def get_bitstream_extension(self, mode="sram"):
|
||||||
|
"""
|
||||||
|
Return the bitstream's extension according to mode (sram / flash).
|
||||||
|
The default (generic) implementation check if `self._bitstream_ext`
|
||||||
|
is a dict or a string. For former case it return extension using `mode`
|
||||||
|
parameter, in latter case simply return `self._bitstream_ext`'s value.
|
||||||
|
When this behaviour is not adapted this method must be overriden by
|
||||||
|
a specific one at vendor level.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
mode: str
|
||||||
|
bitstream destination (must be sram or flash)
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
bitstream extension: str
|
||||||
|
"""
|
||||||
|
if self._bitstream_ext is None:
|
||||||
|
return None
|
||||||
|
elif type(self._bitstream_ext) == dict:
|
||||||
|
return self._bitstream_ext[mode]
|
||||||
|
else:
|
||||||
|
return self._bitstream_ext
|
||||||
|
|
||||||
def create_programmer(self):
|
def create_programmer(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ from litex.build.gowin import common, gowin
|
||||||
# GowinPlatform ------------------------------------------------------------------------------------
|
# GowinPlatform ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class GowinPlatform(GenericPlatform):
|
class GowinPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".fs"
|
_bitstream_ext = ".fs"
|
||||||
|
|
||||||
_supported_toolchains = ["gowin", "apicula"]
|
_supported_toolchains = ["gowin", "apicula"]
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from litex.build.lattice import common, diamond, icestorm, trellis, radiant, oxi
|
||||||
# LatticePlatform ----------------------------------------------------------------------------------
|
# LatticePlatform ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class LatticePlatform(GenericPlatform):
|
class LatticePlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bit"
|
_bitstream_ext = ".bit"
|
||||||
|
|
||||||
_supported_toolchains = {
|
_supported_toolchains = {
|
||||||
"ice40" : ["icestorm"],
|
"ice40" : ["icestorm"],
|
||||||
|
@ -26,7 +26,7 @@ class LatticePlatform(GenericPlatform):
|
||||||
elif toolchain == "trellis":
|
elif toolchain == "trellis":
|
||||||
self.toolchain = trellis.LatticeTrellisToolchain()
|
self.toolchain = trellis.LatticeTrellisToolchain()
|
||||||
elif toolchain == "icestorm":
|
elif toolchain == "icestorm":
|
||||||
self.bitstream_ext = ".bin"
|
self._bitstream_ext = ".bin"
|
||||||
self.toolchain = icestorm.LatticeIceStormToolchain()
|
self.toolchain = icestorm.LatticeIceStormToolchain()
|
||||||
elif toolchain == "radiant":
|
elif toolchain == "radiant":
|
||||||
self.toolchain = radiant.LatticeRadiantToolchain()
|
self.toolchain = radiant.LatticeRadiantToolchain()
|
||||||
|
|
|
@ -10,7 +10,7 @@ from litex.build.microsemi import common, libero_soc
|
||||||
# MicrosemiPlatform --------------------------------------------------------------------------------
|
# MicrosemiPlatform --------------------------------------------------------------------------------
|
||||||
|
|
||||||
class MicrosemiPlatform(GenericPlatform):
|
class MicrosemiPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bit"
|
_bitstream_ext = ".bit"
|
||||||
|
|
||||||
_supported_toolchains = ["libero_soc_polarfire"]
|
_supported_toolchains = ["libero_soc_polarfire"]
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from litex.build.osfpga import common, osfpga
|
||||||
# OSFPGAPlatform -----------------------------------------------------------------------------------
|
# OSFPGAPlatform -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class OSFPGAPlatform(GenericPlatform):
|
class OSFPGAPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bin"
|
_bitstream_ext = ".bin"
|
||||||
|
|
||||||
_supported_toolchains = ["osfpga"]
|
_supported_toolchains = ["osfpga"]
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from litex.build.quicklogic import common, f4pga
|
||||||
# QuickLogicPlatform -------------------------------------------------------------------------------
|
# QuickLogicPlatform -------------------------------------------------------------------------------
|
||||||
|
|
||||||
class QuickLogicPlatform(GenericPlatform):
|
class QuickLogicPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bit"
|
_bitstream_ext = ".bit"
|
||||||
|
|
||||||
_supported_toolchains = ["f4pga"]
|
_supported_toolchains = ["f4pga"]
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,10 @@ from litex.build.xilinx import common, vivado, ise, yosys_nextpnr
|
||||||
# XilinxPlatform -----------------------------------------------------------------------------------
|
# XilinxPlatform -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class XilinxPlatform(GenericPlatform):
|
class XilinxPlatform(GenericPlatform):
|
||||||
bitstream_ext = ".bit"
|
_bitstream_ext = {
|
||||||
|
"sram" : ".bit",
|
||||||
|
"flash" : ".bin"
|
||||||
|
}
|
||||||
|
|
||||||
_supported_toolchains = {
|
_supported_toolchains = {
|
||||||
"spartan6" : ["ise"],
|
"spartan6" : ["ise"],
|
||||||
|
|
|
@ -382,10 +382,7 @@ class Builder:
|
||||||
def get_bitstream_filename(self, mode="sram", ext=None):
|
def get_bitstream_filename(self, mode="sram", ext=None):
|
||||||
assert mode in ["sram", "flash"]
|
assert mode in ["sram", "flash"]
|
||||||
if ext is None:
|
if ext is None:
|
||||||
ext = {
|
ext = self.soc.platform.get_bitstream_extension(mode)
|
||||||
"sram" : self.soc.platform.bitstream_ext,
|
|
||||||
"flash" : ".bin" # FIXME.
|
|
||||||
}[mode]
|
|
||||||
return os.path.join(self.gateware_dir, self.soc.get_build_name() + ext)
|
return os.path.join(self.gateware_dir, self.soc.get_build_name() + ext)
|
||||||
|
|
||||||
# Builder Arguments --------------------------------------------------------------------------------
|
# Builder Arguments --------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue