cpus: use a common definition of gcc_triple for the RISC-V CPUs, reorganize CPU by...
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sun, 3 May 2020 19:29:54 +0000 (21:29 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sun, 3 May 2020 19:29:54 +0000 (21:29 +0200)
litex/soc/cores/cpu/__init__.py
litex/soc/cores/cpu/blackparrot/core.py
litex/soc/cores/cpu/minerva/core.py
litex/soc/cores/cpu/picorv32/core.py
litex/soc/cores/cpu/rocket/core.py
litex/soc/cores/cpu/serv/core.py
litex/soc/cores/cpu/vexriscv/core.py

index 21f7ce5d566a97011e19b6d6306dac319a00f999..bc106712394cfdfec35071dee101e68c8d514d71 100644 (file)
@@ -29,46 +29,72 @@ class CPUNone(CPU):
     periph_buses         = []
     memory_buses         = []
 
+CPU_GCC_TRIPLE_RISCV32 = (
+    "riscv64-unknown-elf",
+    "riscv32-unknown-elf",
+    "riscv-none-embed",
+    "riscv64-linux",
+    "riscv-sifive-elf",
+    "riscv64-none-elf",
+)
+
+CPU_GCC_TRIPLE_RISCV64 = (
+    "riscv64-unknown-elf",
+    "riscv64-linux",
+    "riscv-sifive-elf",
+    "riscv64-none-elf",
+)
+
 # CPUS ---------------------------------------------------------------------------------------------
 
 from litex.soc.cores.cpu.lm32 import LM32
 from litex.soc.cores.cpu.mor1kx import MOR1KX
+from litex.soc.cores.cpu.microwatt import Microwatt
+from litex.soc.cores.cpu.serv import SERV
 from litex.soc.cores.cpu.picorv32 import PicoRV32
-from litex.soc.cores.cpu.vexriscv import VexRiscv
 from litex.soc.cores.cpu.minerva import Minerva
+from litex.soc.cores.cpu.vexriscv import VexRiscv
 from litex.soc.cores.cpu.rocket import RocketRV64
-from litex.soc.cores.cpu.microwatt import Microwatt
 from litex.soc.cores.cpu.blackparrot import BlackParrotRV64
-from litex.soc.cores.cpu.serv import SERV
 
 CPUS = {
+    # None
     "None"        : CPUNone,
+
+    # LM32
     "lm32"        : LM32,
+
+    # OpenRisc
     "mor1kx"      : MOR1KX,
+
+    # Open Power
+    "microwatt"   : Microwatt,
+
+    # RISC-V 32-bit
+    "serv"        : SERV,
     "picorv32"    : PicoRV32,
-    "vexriscv"    : VexRiscv,
     "minerva"     : Minerva,
+    "vexriscv"    : VexRiscv,
+
+    # RISC-V 64-bit
     "rocket"      : RocketRV64,
-    "microwatt"   : Microwatt,
     "blackparrot" : BlackParrotRV64,
-    "serv"        : SERV
 }
 
 # CPU Variants/Extensions Definition ---------------------------------------------------------------
 
 CPU_VARIANTS = {
     # "official name": ["alias 1", "alias 2"],
-    "minimal" : ["min",],
-    "lite" : ["light", "zephyr", "nuttx"],
-    "standard": [None, "std"],
-    "full": [],
-    "linux" : [],
-    "linuxd" : [],
-    "linuxq" : [],
+    "minimal" :   ["min",],
+    "lite" :      ["light", "zephyr", "nuttx"],
+    "standard":   [None, "std"],
+    "full":       [],
+    "linux" :     [],
+    "linuxd" :    [],
+    "linuxq" :    [],
 }
 CPU_VARIANTS_EXTENSIONS = ["debug", "no-dsp"]
 
-
 class InvalidCPUVariantError(ValueError):
     def __init__(self, variant):
         msg = """\
index 302aa70dcc6bf5077ce14e21508da3c2d9c9eb01..9f3d4fb7c981f6098c71e0f24383db0fbf5267f3 100644 (file)
@@ -35,7 +35,7 @@ from migen import *
 from litex import get_data_mod
 from litex.soc.interconnect import axi
 from litex.soc.interconnect import wishbone
-from litex.soc.cores.cpu import CPU
+from litex.soc.cores.cpu import CPU, CPU_GCC_TRIPLE_RISCV64
 
 CPU_VARIANTS = {
     "standard": "freechips.rocketchip.system.LitexConfig",
@@ -50,8 +50,7 @@ class BlackParrotRV64(CPU):
     human_name           = "BlackParrotRV64[ia]"
     data_width           = 64
     endianness           = "little"
-    gcc_triple           = ("riscv64-unknown-elf", "riscv64-linux", "riscv-sifive-elf",
-                            "riscv64-none-elf")
+    gcc_triple           = CPU_GCC_TRIPLE_RISCV64
     linker_output_format = "elf64-littleriscv"
     nop                  = "nop"
     io_regions           = {0x50000000: 0x10000000} # origin, length
index 2a6f21f9eb68842e1563d50a51c712a4414caf44..64cf86662502870e36436f78bb8f3c143f783264 100644 (file)
@@ -9,7 +9,7 @@ from migen import *
 
 from litex import get_data_mod
 from litex.soc.interconnect import wishbone
-from litex.soc.cores.cpu import CPU
+from litex.soc.cores.cpu import CPU, CPU_GCC_TRIPLE_RISCV32
 
 CPU_VARIANTS = ["standard"]
 
@@ -19,8 +19,7 @@ class Minerva(CPU):
     human_name           = "Minerva"
     data_width           = 32
     endianness           = "little"
-    gcc_triple           = ("riscv64-unknown-elf", "riscv32-unknown-elf", "riscv-none-embed",
-                            "riscv64-linux", "riscv-sifive-elf", "riscv64-none-elf")
+    gcc_triple           = CPU_GCC_TRIPLE_RISCV32
     linker_output_format = "elf32-littleriscv"
     nop                  = "nop"
     io_regions           = {0x80000000: 0x80000000} # origin, length
index b3bfc0747cf1b243cdc2bc965e2de043c7f0e522..3f568db4b41795c4fb345f3ef0f00441c7040f2c 100644 (file)
@@ -13,7 +13,7 @@ from migen import *
 
 from litex import get_data_mod
 from litex.soc.interconnect import wishbone
-from litex.soc.cores.cpu import CPU
+from litex.soc.cores.cpu import CPU, CPU_GCC_TRIPLE_RISCV64
 
 
 CPU_VARIANTS = ["minimal", "standard"]
@@ -36,8 +36,7 @@ class PicoRV32(CPU):
     human_name           = "PicoRV32"
     data_width           = 32
     endianness           = "little"
-    gcc_triple           = ("riscv64-unknown-elf", "riscv32-unknown-elf", "riscv-none-embed",
-                            "riscv64-linux", "riscv-sifive-elf", "riscv64-none-elf")
+    gcc_triple           = CPU_GCC_TRIPLE_RISCV64
     linker_output_format = "elf32-littleriscv"
     nop                  = "nop"
     io_regions           = {0x80000000: 0x80000000} # origin, length
index e0100c769dcd4a7af74eb8a114fd5b3beff9c7f3..f08019fffcaaefd1c64309fb0570f05337e8603c 100644 (file)
@@ -36,7 +36,7 @@ from migen import *
 from litex import get_data_mod
 from litex.soc.interconnect import axi
 from litex.soc.interconnect import wishbone
-from litex.soc.cores.cpu import CPU
+from litex.soc.cores.cpu import CPU, CPU_GCC_TRIPLE_RISCV64
 
 
 CPU_VARIANTS = {
@@ -69,8 +69,7 @@ class RocketRV64(CPU):
     human_name           = "RocketRV64[imac]"
     data_width           = 64
     endianness           = "little"
-    gcc_triple           = ("riscv64-unknown-elf", "riscv64-linux", "riscv-sifive-elf",
-                            "riscv64-none-elf")
+    gcc_triple           = CPU_GCC_TRIPLE_RISCV64
     linker_output_format = "elf64-littleriscv"
     nop                  = "nop"
     io_regions           = {0x10000000: 0x70000000} # origin, length
index dbb6a1b4058c3cfb5818c925176ffb1815f68a67..739b83b6b181ef6319e2dfe814094d30616b5301 100644 (file)
@@ -8,7 +8,7 @@ from migen import *
 
 from litex import get_data_mod
 from litex.soc.interconnect import wishbone
-from litex.soc.cores.cpu import CPU
+from litex.soc.cores.cpu import CPU, CPU_GCC_TRIPLE_RISCV32
 
 
 CPU_VARIANTS = ["standard"]
@@ -19,8 +19,7 @@ class SERV(CPU):
     human_name           = "SERV"
     data_width           = 32
     endianness           = "little"
-    gcc_triple           = ("riscv64-unknown-elf", "riscv32-unknown-elf", "riscv-none-embed",
-                            "riscv64-linux", "riscv-sifive-elf", "riscv64-none-elf")
+    gcc_triple           = CPU_GCC_TRIPLE_RISCV32
     linker_output_format = "elf32-littleriscv"
     nop                  = "nop"
     io_regions           = {0x80000000: 0x80000000} # origin, length
index 45fc0df9dec55baa06532bb650d4f75deb376589..dc267ce98ec8323c88aaae28a4ffadc7804f8081 100644 (file)
@@ -15,7 +15,7 @@ from migen import *
 from litex import get_data_mod
 from litex.soc.interconnect import wishbone
 from litex.soc.interconnect.csr import *
-from litex.soc.cores.cpu import CPU
+from litex.soc.cores.cpu import CPU, CPU_GCC_TRIPLE_RISCV32
 
 
 CPU_VARIANTS = {
@@ -79,8 +79,7 @@ class VexRiscv(CPU, AutoCSR):
     human_name           = "VexRiscv"
     data_width           = 32
     endianness           = "little"
-    gcc_triple           = ("riscv64-unknown-elf", "riscv32-unknown-elf", "riscv-none-embed",
-                            "riscv64-linux", "riscv-sifive-elf", "riscv64-none-elf")
+    gcc_triple           = CPU_GCC_TRIPLE_RISCV32
     linker_output_format = "elf32-littleriscv"
     nop                  = "nop"
     io_regions           = {0x80000000: 0x80000000} # origin, length