cores/cpu: add external cpu_type.

Allows fully pluggable CPUs where cpu_type is set to "external" and cpu_cls provided externally.
This commit is contained in:
Florent Kermarrec 2020-08-07 11:15:12 +02:00
parent b9d3aab59d
commit b3531cd2a8
2 changed files with 8 additions and 0 deletions

View File

@ -85,6 +85,9 @@ CPUS = {
# None
"None" : CPUNone,
# External (CPU class provided externally by design/user)
"external" : None,
# LM32
"lm32" : LM32,

View 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(