interconnect/wishbone: integrate Wishbone2CSR.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 27 May 2020 16:15:05 +0000 (18:15 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 27 May 2020 16:15:05 +0000 (18:15 +0200)
litex/soc/integration/soc.py
litex/soc/interconnect/wishbone.py
litex/soc/interconnect/wishbone2csr.py [deleted file]

index 7356a5ed3682f68b72f8dc2704704fd65493dd11..f2bb7c40faf219dbf702221e3eb0f62bcedfe074 100644 (file)
@@ -19,7 +19,6 @@ from litex.soc.cores.spi import SPIMaster
 from litex.soc.interconnect.csr import *
 from litex.soc.interconnect import csr_bus
 from litex.soc.interconnect import wishbone
-from litex.soc.interconnect import wishbone2csr
 from litex.soc.interconnect import axi
 
 logging.basicConfig(level=logging.INFO)
@@ -760,10 +759,10 @@ class SoC(Module):
         self.add_ram(name, origin, size, contents, mode="r")
 
     def add_csr_bridge(self, origin):
-        self.submodules.csr_bridge = wishbone2csr.WB2CSR(
+        self.submodules.csr_bridge = wishbone.Wishbone2CSR(
             bus_csr       = csr_bus.Interface(
-                address_width = self.csr.address_width,
-                data_width    = self.csr.data_width))
+            address_width = self.csr.address_width,
+            data_width    = self.csr.data_width))
         csr_size   = 2**(self.csr.address_width + 2)
         csr_region = SoCRegion(origin=origin, size=csr_size, cached=False)
         self.bus.add_slave("csr", self.csr_bridge.wishbone, csr_region)
index 187f2c3138326cf1779ff1fe7fc6767022519ba9..be2f9f8df9029b60f27bf94a97eb3d43a7660c40 100644 (file)
@@ -362,6 +362,40 @@ class SRAM(Module):
             If(self.bus.cyc & self.bus.stb & ~self.bus.ack, self.bus.ack.eq(1))
         ]
 
+# Wishbone To CSR ----------------------------------------------------------------------------------
+
+class Wishbone2CSR(Module):
+    def __init__(self, bus_wishbone=None, bus_csr=None):
+        self.csr = bus_csr
+        if self.csr is None:
+            # If no CSR bus provided, create it with default parameters.
+            self.csr = csr_bus.Interface()
+        self.wishbone = bus_wishbone
+        if self.wishbone is None:
+            # If no Wishbone bus provided, create it with default parameters.
+            self.wishbone = Interface()
+
+        # # #
+
+        self.comb += [
+            self.csr.dat_w.eq(self.wishbone.dat_w),
+            self.wishbone.dat_r.eq(self.csr.dat_r)
+        ]
+
+        fsm = FSM(reset_state="WRITE-READ")
+        self.submodules += fsm
+        fsm.act("WRITE-READ",
+            If(self.wishbone.cyc & self.wishbone.stb,
+                self.csr.adr.eq(self.wishbone.adr),
+                self.csr.we.eq(self.wishbone.we),
+                NextState("ACK")
+            )
+        )
+        fsm.act("ACK",
+            self.wishbone.ack.eq(1),
+            NextState("WRITE-READ")
+        )
+
 # Wishbone Cache -----------------------------------------------------------------------------------
 
 class Cache(Module):
diff --git a/litex/soc/interconnect/wishbone2csr.py b/litex/soc/interconnect/wishbone2csr.py
deleted file mode 100644 (file)
index 1484719..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# This file is Copyright (c) 2015 Sebastien Bourdeauducq <sb@m-labs.hk>
-# This file is Copyright (c) 2015-2019 Florent Kermarrec <florent@enjoy-digital.fr>
-# License: BSD
-
-from migen import *
-from migen.genlib.misc import timeline
-
-from litex.soc.interconnect import csr_bus, wishbone
-
-
-class WB2CSR(Module):
-    def __init__(self, bus_wishbone=None, bus_csr=None):
-        self.csr = bus_csr
-        if self.csr is None:
-            # If no CSR bus provided, create it with default parameters.
-            self.csr = csr_bus.Interface()
-        self.wishbone = bus_wishbone
-        if self.wishbone is None:
-            # If no Wishbone bus provided, create it with default parameters.
-            self.wishbone = wishbone.Interface()
-
-        # # #
-
-        self.comb += [
-            self.csr.dat_w.eq(self.wishbone.dat_w),
-            self.wishbone.dat_r.eq(self.csr.dat_r)
-        ]
-
-        fsm = FSM(reset_state="WRITE-READ")
-        self.submodules += fsm
-        fsm.act("WRITE-READ",
-            If(self.wishbone.cyc & self.wishbone.stb,
-                self.csr.adr.eq(self.wishbone.adr),
-                self.csr.we.eq(self.wishbone.we),
-                NextState("ACK")
-            )
-        )
-        fsm.act("ACK",
-            self.wishbone.ack.eq(1),
-            NextState("WRITE-READ")
-        )