cores/spi: fix/simplify loopback

This commit is contained in:
Florent Kermarrec 2019-07-13 13:10:24 +02:00
parent 59fda8da93
commit d3aaaf5e6c

View file

@ -117,15 +117,16 @@ class SPIMaster(Module, AutoCSR):
self.sync += \ self.sync += \
If(shift, If(shift,
If(clk_rise, If(clk_rise,
miso.eq(pads.miso), If(self.loopback,
miso.eq(pads.mosi)
).Else(
miso.eq(pads.miso)
)
).Elif(clk_fall, ).Elif(clk_fall,
miso_data.eq(Cat(miso, miso_data[:-1])) miso_data.eq(Cat(miso, miso_data[:-1]))
) )
) )
# Loopback ---------------------------------------------------------------------------------
self.comb += If(self.loopback, pads.miso.eq(pads.mosi))
def add_control(self): def add_control(self):
self._control = CSRStorage(16) self._control = CSRStorage(16)
self._status = CSRStatus() self._status = CSRStatus()