1414from litespi .crossbar import LiteSPICrossbar
1515from litespi .core .master import LiteSPIMaster
1616from litespi .core .mmap import LiteSPIMMAP
17-
17+ from litespi . phy . generic import LiteSPIPHY
1818
1919class LiteSPICore (Module ):
2020 def __init__ (self ):
@@ -24,6 +24,7 @@ def __init__(self):
2424
2525
2626class LiteSPI (LiteXModule ):
27+ autocsr_exclude = {"ev" }
2728 """SPI Controller wrapper.
2829
2930 The ``LiteSPI`` class provides a wrapper that can instantiate both ``LiteSPIMMAP`` and ``LiteSPIMaster`` and connect them to the PHY.
@@ -70,8 +71,8 @@ class LiteSPI(LiteXModule):
7071
7172 def __init__ (self , phy , clock_domain = "sys" ,
7273 with_mmap = True , mmap_endianness = "big" ,
73- with_master = True , master_tx_fifo_depth = 1 , master_rx_fifo_depth = 1 ,
74- with_csr = True , with_mmap_write = False , mmap_cs_mask = 1 ):
74+ with_master = True , master_tx_fifo_depth = 1 , master_rx_fifo_depth = 1 , master_with_irq = False ,
75+ with_csr = True , with_mmap_write = False , mmap_cs_mask = 1 , ** kwargs ):
7576
7677 cs_width = len (phy .cs )
7778
@@ -97,12 +98,15 @@ def __init__(self, phy, clock_domain="sys",
9798 self .master = master = LiteSPIMaster (
9899 tx_fifo_depth = master_tx_fifo_depth ,
99100 rx_fifo_depth = master_rx_fifo_depth ,
101+ with_irq = master_with_irq ,
100102 cs_width = cs_width )
101103 port_master = crossbar .get_port (master .cs )
102104 self .comb += [
103105 port_master .source .connect (master .sink ),
104106 master .source .connect (port_master .sink ),
105107 ]
108+ if hasattr (master , "ev" ):
109+ self .ev = master .ev
106110
107111 if clock_domain != "sys" :
108112 self .comb += [
@@ -114,3 +118,18 @@ def __init__(self, phy, clock_domain="sys",
114118 crossbar .master .source .connect (phy .sink ),
115119 phy .source .connect (crossbar .master .sink ),
116120 ]
121+
122+ class LiteSPIWrapper (LiteXModule ):
123+ autocsr_exclude = {"ev" }
124+ def __init__ (self , pads = None , module = None , phy = None , ** kwargs ):
125+ assert pads is not None or module is not None , "Either pads or module must be provided."
126+ # PHY.
127+ self .phy = LiteSPIPHY (pads , module , ** kwargs ) if phy is None else phy
128+
129+ # Core.
130+ self .core = LiteSPI (self .phy , ** kwargs )
131+
132+ if hasattr (self .core , "bus" ):
133+ self .bus = self .core .bus
134+ if hasattr (self .core , "ev" ):
135+ self .ev = self .core .ev
0 commit comments