samarth jain
02/26/2024, 4:35 AMTim Edwards
02/26/2024, 1:56 PMcaravel_mgmt_soc_litex
repository the testbench verilog/dv/tests-standalone/spi_master
.samarth jain
02/27/2024, 7:53 AMsamarth jain
02/27/2024, 9:43 AMsamarth jain
02/27/2024, 11:33 AMTim Edwards
02/27/2024, 2:47 PMsamarth jain
02/27/2024, 2:49 PMsamarth jain
02/28/2024, 1:44 PMsamarth jain
02/28/2024, 1:45 PMsamarth jain
02/28/2024, 1:45 PMTim Edwards
02/28/2024, 2:03 PM#define reg_spimaster_clk_divider (*(volatile uint32_t*) CSR_SPI_MASTER_CLK_DIVIDER_ADDR)
samarth jain
02/28/2024, 2:04 PMTim Edwards
02/28/2024, 2:16 PMTim Edwards
02/28/2024, 2:18 PMsamarth jain
02/28/2024, 2:25 PMsamarth jain
02/28/2024, 2:26 PMTim Edwards
02/28/2024, 2:27 PMsamarth jain
03/01/2024, 8:07 AMTim Edwards
03/01/2024, 2:21 PMcaravel_mgmt_soc_litex
in litex/caravel.py
as:
# Add a master SPI controller w/ a clock divider
spi_master = SPIMaster(
pads=platform.request("spi"),
data_width=8,
sys_clk_freq=sys_clk_freq,
spi_clk_freq=1e5,
)
spi_master.add_clk_divider()
I could not determine with a quick look how the clock divider works. The spi_clk_freq
is set to 1e5 "in Hz" although I have no idea how they determine what a "Hz" is in a system whose rate depends entirely on an external clock source (this is just one of the many stupidities of the whole LiteX system). But if somewhere the global rate of 10MHz is used for LiteX and that's consistent throughout the code, then the SPI has been configured to run at the slow, slow maximum rate of 100kHz, but I'm guessing that the value put into LiteX for the core clock rate was 40MHz (the maximum clock rate), so that if LiteX computed a 100kHz SPI master at 40MHz core clock, then it comes to 25kHz with the 10MHz clock on the development board. (All of this worked so much better when we (I) used the PicoRV32. The CPU was hopelessly crippled by switching to the LiteX VexRISC. I tried hard to prevent that switch but I got overruled). The best you can do is to get the CPU rate up from 10MHz on the board to 60 or 70MHz off of the DLL; if you additionally increase the vccd
supply to about 2V, you can potentially get the core clock rate up to 100MHz, but I don't think you will ever get the SPI master much above 200kHz.
You can try Marwan Abbas for additional questions (he has been writing the test code for characterizing blocks like the SPI master), although I think the analysis above is about as thorough as you're going to get.samarth jain
06/20/2024, 9:53 AMTim Edwards
06/20/2024, 8:53 PMsamarth jain
06/21/2024, 3:28 PM