build/osfpga: Remane FOEDAGToolchain to OSFPGAToolchain and add Foedag/Raptor support through toolchain parameter.

This commit is contained in:
Florent Kermarrec 2022-05-17 19:42:26 +02:00
parent f16f8e5f9e
commit 4401b5a5e8
3 changed files with 15 additions and 14 deletions

View file

@ -22,7 +22,7 @@ _io = [
class Platform(OSFPGAPlatform): class Platform(OSFPGAPlatform):
def __init__(self): def __init__(self):
OSFPGAPlatform.__init__(self, device=None, io=_io) # FIXME: Add device support. OSFPGAPlatform.__init__(self, device=None, toolchain="raptor", io=_io) # FIXME: Add device support.
# Minimal Design ----------------------------------------------------------------------------------- # Minimal Design -----------------------------------------------------------------------------------

View file

@ -62,13 +62,14 @@ def _build_tcl(name, device, files, build_name):
with open("build.tcl", "w") as f: with open("build.tcl", "w") as f:
f.write("\n".join(tcl)) f.write("\n".join(tcl))
# FOEDAGToolchain ----------------------------------------------------------------------------------- # OSFPGAToolchain -----------------------------------------------------------------------------------
class FOEDAGToolchain: class OSFPGAToolchain:
attr_translate = {} attr_translate = {}
def __init__(self): def __init__(self, toolchain):
self.clocks = dict() self.toolchain = toolchain
self.clocks = dict()
def build(self, platform, fragment, def build(self, platform, fragment,
build_dir = "build", build_dir = "build",
@ -114,14 +115,14 @@ class FOEDAGToolchain:
# Run # Run
if run: if run:
foedag_sh = "foedag" toolchain_sh = self.toolchain
if which(foedag_sh) is None: if which(toolchain_sh) is None:
msg = "Unable to find FOEDAG toolchain, please:\n" msg = f"Unable to find {toolchain_sh.upper()} toolchain, please:\n"
msg += "- Add FOEDAG toolchain to your $PATH." msg += f"- Add {toolchain_sh.upper()} toolchain to your $PATH."
raise OSError(msg) raise OSError(msg)
if subprocess.call([foedag_sh, "--batch", "--script", "build.tcl"]) != 0: if subprocess.call([toolchain_sh, "--batch", "--script", "build.tcl"]) != 0:
raise OSError("Error occured during FOEDAG's script execution.") raise OSError(f"Error occured during {toolchain_sh.upper()}'s script execution.")
os.chdir(cwd) os.chdir(cwd)

View file

@ -7,7 +7,7 @@
import os import os
from litex.build.generic_platform import GenericPlatform from litex.build.generic_platform import GenericPlatform
from litex.build.osfpga import common, foedag from litex.build.osfpga import common, osfpga
# OSFPGAPlatform ----------------------------------------------------------------------------------- # OSFPGAPlatform -----------------------------------------------------------------------------------
@ -17,8 +17,8 @@ class OSFPGAPlatform(GenericPlatform):
def __init__(self, device, *args, toolchain="foedag", devicename=None, **kwargs): def __init__(self, device, *args, toolchain="foedag", devicename=None, **kwargs):
GenericPlatform.__init__(self, device, *args, **kwargs) GenericPlatform.__init__(self, device, *args, **kwargs)
self.devicename = devicename self.devicename = devicename
if toolchain == "foedag": if toolchain in ["foedag", "raptor"]:
self.toolchain = foedag.FOEDAGToolchain() self.toolchain = osfpga.OSFPGAToolchain(toolchain=toolchain)
else: else:
raise ValueError(f"Unknown toolchain {toolchain}") raise ValueError(f"Unknown toolchain {toolchain}")