litex icon indicating copy to clipboard operation
litex copied to clipboard

Wishbone bus high latency in read on Vexriscv CPU "minimal" variant and read/write on others CPU.

Open mgaggero opened this issue 1 year ago • 3 comments

Hello, I'm currently working with LiteX on a Muselab IceSugar board equipped with a Lattice iCE40U5k FPGA. I've encountered an unexpectedly high latency when reading from the Wishbone bus. I've implemented a 32-bit counter that increments every clock cycle and can be reset and read.

What I've observed is that two consecutive reads show a difference of approximately 400 clock cycles when using the Vexriscv CPU with the "minimal" variant. Interestingly, the "lite" variant doesn't exhibit this latency. When employing other CPUs such as picorv32 and femtorv, both read and write operations result in a consistent 270 cycles latency.

This latency issue appears to be related to the Wishbone bus, as the Vexriscv32 "minimal" variant, picorv32, and femtorv all exhibit the same behavior.

mgaggero avatar Dec 29 '23 22:12 mgaggero

Hi,

What memory system are you using ? some XIP execution from flash ?

Dolu1990 avatar Jan 03 '24 09:01 Dolu1990

Absolutely, according to my understanding, the code is executed directly from the Quad SPI flash. There is no copying of program data to the SRAM. It's important to highlight that the Vexriscv 'minimal' variant lacks an instruction/data cache.

mgaggero avatar Jan 03 '24 18:01 mgaggero

I think the reason why picorv32, and femtorv are faster in that specific case, is because is pipelined => fetch stuff in advance, which endup being wrong sometime (branch missprediction) meaning it will trash some fetch bandwidth,

Dolu1990 avatar Jan 03 '24 21:01 Dolu1990