Ensure that CS is not changed whilst the SPI controller is active, e.g. after a write into the FIFO that has not necessarily completed on the SPI bus.
It is safe to deassert the CS line when a read operation has completed because that necessarily blocks until completion.
The code worked in practice by dint of the CPU writes into the FIFO being slow enough that the SPI at 15Mbps can mostly keep up. If the SPI is slowed to eg. 30/8Mbps then the code sw/cheri/checks/spi_test produced incorrect results in Verilator simulation because the spidpi model responds to the changes on the CS line.
Such issues with the CS line-driving may exist elsewhere in the codebase and particularly for other SPI devices.
Ensure that CS is not changed whilst the SPI controller is active, e.g. after a write into the FIFO that has not necessarily completed on the SPI bus. It is safe to deassert the CS line when a read operation has completed because that necessarily blocks until completion.
The code worked in practice by dint of the CPU writes into the FIFO being slow enough that the SPI at 15Mbps can mostly keep up. If the SPI is slowed to eg. 30/8Mbps then the code
sw/cheri/checks/spi_test
produced incorrect results in Verilator simulation because the spidpi model responds to the changes on the CS line.Such issues with the CS line-driving may exist elsewhere in the codebase and particularly for other SPI devices.