FPGA Loading from Memory Card (work in progress!)

Xilinx's serial configuration ROMs are simple to use but expensive. It would be nicer to be able to use a common memory card such as the SD card.

The latter are harder to use, as they have a low-level serial interface plus a higher-level protocol for accessing blocks of data from the card.

One solution might be to have a small microcontroller managing this, but that is significant software effort.

Fortunately for me, someone has already designed the logic to do the job with a CPLD. It is available from the opencores website. This should run extremely fast.

Less fortunately for me, they wrote it in verilog. I'm not keen on learning yet another language, so I set about translating the design into code I would find easier to understand.

Translation

I found a peice of translation software that worked in demo mode without a licence. It translated files with less than 200 symbols but only displayed larger files on a window (no cut and pasting). This provided some guidance, though I don't know if my translated code works yet.

Documenation

As is often the case, there is almost none with the source code. So I have made my own notes below.

MMC/SD card information

It says 'no SD cards', but I suspect it ought to be able to use them because SD cards are supposedly to act like MMC cards to equipment expecting MMC cards.

Top Level View

The logic sits between the FPGA and an MMC card.

  No. MultiMedia™ card
MM mode SPI Mode
Name Type Name Type
  error <--   CPLD   nc? 1 Reserved !CS I
FPGA INIT --> init mmc_cmd <-> 2 CMD I/O/PP/OD DI I
        0V 3 Vss1 (Supply Voltage Ground)
        5V 4 VDD (Supply Voltage)
CCLK --> cclk mmc_clk --> 5 Serial Clock Input
DONE --> done   0V 6 Vss2 (Supply Voltage Ground)
DIN <-- <--- <---- <-------- <-- 7 DAT0 I/O/PP DO O/PP

The error signal just goes high during error conditions.

From the connections we can see that the card works in its own mode, not SPI mode.
This is a slight disappointment to me, because the SPI is well documented and available on a lot of microcontrollers.

The logic is independent of particular chips, but the fitter reports that it occupies 29 of the 36 cells in an XC9536XL.
This has a PLC44 package, which is fairly large considering the application only needs 6 I/O pins. The extra pins might be used for other purposes requiring non-volatile logic.

It is therefore worth investigating the use of a microcontroller, as these are available in small packages with enough ROM space for moderate tasks.