From b3531cd2a879ff1ee84a03bf8e1b967951bd5094 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 7 Aug 2020 11:15:12 +0200 Subject: [PATCH] cores/cpu: add external cpu_type. Allows fully pluggable CPUs where cpu_type is set to "external" and cpu_cls provided externally. --- litex/soc/cores/cpu/__init__.py | 3 +++ litex/soc/integration/soc.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/litex/soc/cores/cpu/__init__.py b/litex/soc/cores/cpu/__init__.py index 4d0a0463..8c88922b 100644 --- a/litex/soc/cores/cpu/__init__.py +++ b/litex/soc/cores/cpu/__init__.py @@ -85,6 +85,9 @@ CPUS = { # None "None" : CPUNone, + # External (CPU class provided externally by design/user) + "external" : None, + # LM32 "lm32" : LM32, diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index cd45a0b4..ad216377 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -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( -- 2.30.2