soc/cores/cpu/vexriscv: move verilog variant selection to add_sources
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 9 Jan 2019 07:32:17 +0000 (08:32 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 9 Jan 2019 08:19:40 +0000 (09:19 +0100)
litex/soc/cores/cpu/vexriscv/core.py

index b5f87ec38ed6d09a510a4dfd28ed2189cbdcd098..1edcc3f7bba90c376b50aef7d8a4fb225a7ecf6e 100644 (file)
@@ -24,16 +24,6 @@ class VexRiscv(Module, AutoCSR):
 
         self.interrupt = Signal(32)
 
-        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_filename = verilog_variants[variant]
-
         self.cpu_params = dict(
                 i_clk=ClockSignal(),
                 i_reset=ResetSignal() | self.reset,
@@ -70,7 +60,7 @@ class VexRiscv(Module, AutoCSR):
             self.add_debug()
 
         # add verilog sources
-        self.add_sources(platform, cpu_filename)
+        self.add_sources(platform, variant)
 
     def add_debug(self):
         debug_reset = Signal()
@@ -159,7 +149,16 @@ class VexRiscv(Module, AutoCSR):
         )
 
     @staticmethod
-    def add_sources(platform, cpu_filename):
+    def add_sources(platform, variant="std"):
+        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_filename = verilog_variants[variant]
         vdir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "verilog")
         platform.add_source(os.path.join(vdir, cpu_filename))