cores/cpu: add external cpu_type.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 7 Aug 2020 09:15:12 +0000 (11:15 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 7 Aug 2020 09:16:00 +0000 (11:16 +0200)
Allows fully pluggable CPUs where cpu_type is set to "external" and cpu_cls provided externally.

litex/soc/cores/cpu/__init__.py
litex/soc/integration/soc.py

index 4d0a04636f750a4deb5136a19eff6b12a43ed28b..8c88922b8299a07534969904c118ed70e8f7e20a 100644 (file)
@@ -85,6 +85,9 @@ CPUS = {
     # None
     "None"        : CPUNone,
 
+    # External (CPU class provided externally by design/user)
+    "external"    : None,
+
     # LM32
     "lm32"        : LM32,
 
index cd45a0b4a029723cecf84787079d3eab87c62fb0..ad216377ac3ede7674dd95c55427b38aa5c39085 100644 (file)
@@ -828,6 +828,11 @@ class SoC(Module):
                 colorer(", ".join(cpu.CPUS.keys()))))
             raise
         # Add CPU
+        if name == "external" and cls is None:
+            self.logger.error("{} CPU requires {} to be specified.".format(
+                colorer(name),
+                colorer("cpu_cls", color="red")))
+            raise
         cpu_cls = cls if cls is not None else cpu.CPUS[name]
         if variant not in cpu_cls.variants:
             self.logger.error("{} CPU variant {}, supporteds: {}.".format(