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):
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 -----------------------------------------------------------------------------------

View file

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

View file

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