fvdhoef / vera-module

Versatile Embedded Retro Adapter
MIT License
107 stars 44 forks source link

Narrow timing window may prevent SPI auto tx from initiating #5

Closed jburks closed 7 months ago

jburks commented 2 years ago

In this code in top.v:

        if (spi_autotx_r && access_addr == 5'h1E && do_read) begin
            spi_txdata = 8'hFF;
            spi_txstart = 1;
        end

It looks like the SPI auto tx will only start if access_addr is 5'h1E while the do_read strobe is active. The access_addr signal is updated with the contents of rdaddr_r which in turn is updated on the falling edge of bus_read. Since do_read is only active for 40ns and bus_read is active for 62ns, it appears that there may be a 22ns window of opportunity for the start condition to be missed.

fvdhoef commented 2 years ago

I already noticed some problems on the real hardware with the SPI auto-tx. So the SD card access code now uses the slow path without auto-tx, but that will give reduced speed.

jburks commented 7 months ago

It is believed that this can now be closed. The final issue was that the flag in fat32/regs.inc was $08 instead of $04. Read throughput is about 50% faster with auto tx enabled on the X16 at 8MHz (206995 bytes/sec vs. 133293 bytes/sec).