I have managed to make a working Verilog module, it's format is like this
The STM32 act as SPI master and FPGA act as SPI slave, The first two bytes are Address low and high bytes, the third one is CMD, basically it can be used to tell if we are writing or reading the Block RAM, CMD[0] 0 means write and 1 means reading, also the rest of the bits can be used to concoct to a MUX so different Memories can be attached to this core,
I have tested this code with STM32H and Gowin FPGA with 100MHz clock for the FPGA,
The SPI mode is 0, and you can use STM32 DMA to do the job, something like this
//the address is 0 and the command LSB is 0, and some arbitrary values to write
uint8_t tx[30]={0,0,2,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88},rx[30];
HAL_SPI_TransmitReceive_DMA(&hspi2,tx,rx,20);
The maximum clock of the SPI from the MCU side is 15Mhz with this setting, If I go higher, the receive or read part do read and write garbage, so the question in here is What's wrong with this code so the STM32 SPI clock can be higher, can we reach 50MHz SPI clock to transfer correct DATA? do you have any Idea what's wrong with this code?