soc/cores/spi/SPISlave: Minor cleanup.

This commit is contained in:
Florent Kermarrec 2021-04-30 12:16:49 +02:00
parent 75bb78a413
commit 5dc3ad3b29
1 changed files with 17 additions and 15 deletions

View File

@ -182,14 +182,13 @@ class SPISlave(Module):
self.pads = pads
self.data_width = data_width
self.start = Signal()
self.length = Signal(8)
self.done = Signal()
self.irq = Signal()
self.mosi = Signal(data_width)
self.miso = Signal(data_width)
self.cs = Signal()
self.loopback = Signal()
self.start = Signal() # o, Signal a start of SPI Xfer.
self.length = Signal(8) # o, Signal the length of the SPI Xfer (in bits).
self.done = Signal() # o, Signal that SPI Xfer is done/inactive.
self.irq = Signal() # o, Signal the end of a SPI Xfer.
self.mosi = Signal(data_width) # i, Data to send on SPI MOSI.
self.miso = Signal(data_width) # o, Data received on SPI MISO.
self.loopback = Signal() # i, Loopback enable.
# # #
@ -235,21 +234,24 @@ class SPISlave(Module):
# Master In Slave Out (MISO) generation (generated on spi_clk falling edge) ----------------
miso_data = Signal(data_width)
self.sync += \
self.sync += [
If(self.start,
miso_data.eq(self.miso)
).Elif(cs & clk_fall,
miso_data.eq(Cat(Signal(), miso_data[:-1]))
)
self.comb += \
]
self.comb += [
If(self.loopback,
miso.eq(mosi)
).Else(
miso.eq(miso_data[-1]),
)
]
# Master Out Slave In (MOSI) capture (captured on spi_clk rising edge) ---------------------
self.sync += \
self.sync += [
If(cs & clk_rise,
self.mosi.eq(Cat(mosi, self.mosi[:-1]))
)
]