From: Florent Kermarrec Date: Fri, 17 Jul 2020 13:38:52 +0000 (+0200) Subject: soc/cores/spi: make sure done and miso are synchronous. X-Git-Tag: 24jan2021_ls180~77 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1f34f6ef00d10011664bd7bccbd1934fde9097ba;p=litex.git soc/cores/spi: make sure done and miso are synchronous. --- diff --git a/litex/soc/cores/spi.py b/litex/soc/cores/spi.py index c495c58b..1ebc3ff3 100644 --- a/litex/soc/cores/spi.py +++ b/litex/soc/cores/spi.py @@ -41,6 +41,7 @@ class SPIMaster(Module, AutoCSR): # # # + done = Signal() bits = Signal(8) xfer = Signal() shift = Signal() @@ -64,7 +65,7 @@ class SPIMaster(Module, AutoCSR): # Control FSM ------------------------------------------------------------------------------ self.submodules.fsm = fsm = FSM(reset_state="IDLE") fsm.act("IDLE", - self.done.eq(1), + done.eq(1), If(self.start, NextValue(bits, 0), NextState("WAIT-CLK-FALL") @@ -91,6 +92,7 @@ class SPIMaster(Module, AutoCSR): shift.eq(1), self.irq.eq(1) ) + self.sync += self.done.eq(done & ~self.start) # Chip Select generation ------------------------------------------------------------------- if hasattr(pads, "cs_n"): @@ -125,7 +127,7 @@ class SPIMaster(Module, AutoCSR): If(clk_fall & shift, miso_data.eq(Cat(miso, miso_data)) ), - If(self.done, self.miso.eq(miso_data)), + If(done, self.miso.eq(miso_data)), ] def add_csr(self, with_cs=True, with_loopback=True):