From 7358c1fe67208bbd3e2284b6ebcc01e1020afd34 Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Mon, 25 Nov 2024 15:50:29 -0600 Subject: [PATCH] Fixed sublte bug in the spi_fifo which allows for spurious write to fifo. Fixed fpga zsbl so that is uses read fifo interrupt pending (IP) rather than transmit fifo IP. Resolves issue with stalled load reading the wrong fifo status. --- fpga/zsbl/spi.c | 2 +- fpga/zsbl/spi.h | 2 +- src/uncore/spi_fifo.sv | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fpga/zsbl/spi.c b/fpga/zsbl/spi.c index 04d609648..4e75086ad 100644 --- a/fpga/zsbl/spi.c +++ b/fpga/zsbl/spi.c @@ -31,7 +31,7 @@ uint8_t spi_txrx(uint8_t byte) { spi_sendbyte(byte); - waittx(); + waitrx(); return spi_readbyte(); } diff --git a/fpga/zsbl/spi.h b/fpga/zsbl/spi.h index f9e88fa6d..5a472142f 100644 --- a/fpga/zsbl/spi.h +++ b/fpga/zsbl/spi.h @@ -106,7 +106,7 @@ static inline void waittx() { } static inline void waitrx() { - while(read_reg(SPI_IP) & 2) {} + while(!(read_reg(SPI_IP) & 2)) {} } static inline uint8_t spi_readbyte() { diff --git a/src/uncore/spi_fifo.sv b/src/uncore/spi_fifo.sv index 1e4910faf..514e9df7b 100644 --- a/src/uncore/spi_fifo.sv +++ b/src/uncore/spi_fifo.sv @@ -26,7 +26,7 @@ module spi_fifo #(parameter M=3, N=8)( // 2^M entries of N bits assign rdata = mem[raddr]; always_ff @(posedge PCLK) - if (winc & ~wfull) mem[waddr] <= wdata; + if (winc & wen & ~wfull) mem[waddr] <= wdata; // write and read are enabled always_ff @(posedge PCLK)