soc/cores/cpu/vexriscv: add support for the new variants.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 12 Dec 2018 08:39:30 +0000 (09:39 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 12 Dec 2018 08:39:30 +0000 (09:39 +0100)
litex/soc/cores/cpu/vexriscv/core.py

index aff606fb145ef086037e01f6dfe77ad43b5f2d73..6b9b7743a30659516c1f1a855509287bc00394cd 100644 (file)
@@ -14,7 +14,10 @@ class VexRiscv(Module, AutoCSR):
     linker_output_format = "elf32-littleriscv"
 
     def __init__(self, platform, cpu_reset_address, variant=None):
-        assert variant in (None, "debug"), "Unsupported variant %s" % variant
+        variant = "std" if variant is None else variant
+        variant = "std_debug" if variant == "debug" else variant
+        variants = ("std", "std_debug", "lite", "lite_debug", "min", "min_debug")
+        assert variant in variants, "Unsupported variant %s" % variant
         self.reset = Signal()
         self.ibus = i = wishbone.Interface()
         self.dbus = d = wishbone.Interface()
@@ -26,15 +29,22 @@ class VexRiscv(Module, AutoCSR):
         # Output reset signal -- set to 1 when CPU reset is asserted
         self.debug_reset = Signal()
 
-        if variant == None:
-            cpu_reset = ResetSignal()
-            cpu_args = {}
-            cpu_filename = "VexRiscv.v"
-        elif variant == "debug":
+        verilog_variants = {
+            "std":        "VexRiscv.v",
+            "std_debug":  "VexRiscv_Debug.v",
+            "lite":       "VexRiscv_Lite.v",
+            "lite_debug": "VexRiscv_LiteDebug.v",
+            "min":        "VexRiscv_Lite.v",
+            "min_debug":  "VexRiscv_LiteDebug.v",
+        }
+
+        cpu_reset = ResetSignal()
+        cpu_args = {}
+        cpu_filename = verilog_variants[variant]
+
+        if "debug" in variant:
             cpu_reset = Signal()
             cpu_args = {}
-            cpu_filename = "VexRiscv-Debug.v"
-
 
             self.i_cmd_valid = Signal()
             self.i_cmd_payload_wr = Signal()
@@ -157,5 +167,4 @@ class VexRiscv(Module, AutoCSR):
     @staticmethod
     def add_sources(platform, cpu_filename):
         vdir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "verilog")
-        platform.add_sources(os.path.join(vdir), cpu_filename)
-        platform.add_verilog_include_path(vdir)
+        platform.add_source(os.path.join(vdir, cpu_filename))