So I've been giving some thought to setting up an SD card interface.
This is an important step as I intend to replace the existing CompactFlash card with an SD on the graphics card. The DECA board has a built-in SD card socket, making testing easy.
At this stage I've just been looking up information on how it should all work to get an overview. My gold-standard outcome would be for the FPGA to store and read files from a standard FAT16/32-formatted SD card and handle translation of files and directory structures between the FAT system and the system CP/M expects to see on the host uCOM. Depending on how difficult that would be to implement (I have no idea - I'm at the stage where I don't know what I don't know), I could always just copy the existing CF card system of sector-by-sector writing and not worrying about using FAT at all, but it would be great if I could access the SD card from a modern PC too, without faffing around with old/no longer supported
CPMtools etc.
I'm very early in the design stage at this time. I have identified an
existing project that appears to do what I want, perhaps with a little tweaking necessary, but should be up to the task without being too complex for me to understand.
What I'm trying to decide at the moment is the best way to connect the interface to the FPGA. The CF card works via IO calls to the card itself - software sets a memory address to read from or write to, calculates the appropriate address on the CF card to read/write as appropriate and it's all handled via IO calls and the Z80 handling the reading and writing. It's probably going to be a lot easier for me to copy this system and tweak it for the SD card - though it'll be slightly different in that the commands and data will go through the Z80_Bridge and SD interface in the FPGA, rather than direct to the SD card.
I think it'll be easiest if the commands are fed directly to the SD interface (via the Z80_Bridge), with a data buffer in DDR3 RAM or the FPGA's block RAM; the Z80 would write a 512-byte block of data to the FPGA, then use IO commands to signal to the SD interface (via the Z80_Bridge) where the block of data is (if it's not a fixed location) and where it's to be written to. A status register can tell the Z80 when the write is complete or if there are any errors. A read would work the same way, with the Z80 requesting data from a sector address (or filename, if I'm using FAT16/32 I guess) and copying the data block from GPU RAM (DDR3/block RAM) when the status register gives it the all-clear.
TL;DRSo really what I'm trying to decide is whether or not to use a read/write buffer in DDR3 and if so, what's the best way to connect the SD interface to it via the BrianHG_DDR3_Controller - do I just expand the PORTS and wire the SD interface to its own DDR3 R/W ports? The alternative is to stick with a more basic serial stream of data which the Z80 reads from the SD interface and writes to wherever it needs to write it? The issue with the second method is that I'm not sure the Z80 will keep up with the data from an SD card unless I really slow down the clock on the data transfers, and I don't know how compatible that will be with later SD cards.
Plus it's slower.