• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language Verilog
  • Created about 8 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SD-Card controller, using either SPI, SDIO, or eMMC interfaces

SD-Card controller

This repository contains two Verilog hardware RTL controllers for handling SD cards from an FPGA. The first and older controller handles SD cards via their (optional) SPI interface. The second and newer controller works using the SDIO interface. This second controller has also been demonstrated to handle eMMC cards as well.

SPI-based controller

The SDSPI controller exports an SD card controller interface from internal to an FPGA to the rest of the FPGA core, while taking care of the lower level details internal to the interface. Unlike the SDIO controller in this respository, this controller focuses on the SPI interface of the SD Card. While this is a slower interface, the SPI interface is necessary to access the card when using a XuLA2 board (for which it was originally written), or in general any time the full 9--bit, bi--directional interface to the SD card has not been implemented. Further, for those who are die--hard Verilog authors, this core is written in Verilog as opposed to the XESS provided demonstration SD Card controller found on GitHub, which was written in VHDL. For those who are not such die--hard Verilog authors, this controller provides a lower level interface to the card than these other controllers. Whereas the XESS controller will automatically start up the card and interact with it, this controller requires external software to be used when interacting with the card. This makes this SDSPI controller both more versatile, in the face of potential changes to the card interface, but also less turn-key.

While this core was written for the purpose of being used with the ZipCPU, as enhanced by the Wishbone DMA controller used by the ZipCPU, nothing in this core prevents it from being used with any other architecture that supports the 32-bit Wishbone interface of this core.

This core has been written as a wishbone slave, not a master. Using the core together with a separate master, such as a CPU or a DMA controller, only makes sense. This design choice, however, also restricts the core from being able to use the multiple block write or multiple block read commands, restricting it to single block read and write commands alone.

Status: The SDSPI IP is silicon proven. It is no longer under active development. It has been used successfully in several FPGA projects. The components of this IP have formal proofs, which they are known to pass. A Verilator C++ model also exists which can fairly faithfully represent an SD card's SPI interface. A software library also exists which can act as a back end when using the FATFS library.

For more information, please consult the SDSPI user guide.

SDIO

This repository also contains a second and newer SD card controller, designed to exploit both the full SDIO protocol and the 8b EMMC protocol--either with or without data strobes. This controller has been tested against both SDIO and eMMC chips, with the differences between the two types of chips handled by software.

The interface to this controller is roughly the same as that of the SDSPI controller, although there are enough significant differences to warrant a separate user guide.

The controller is designed to support IO modes all the way up to the HS400 mode used by eMMC. HS400 is an eMMC DDR mode based off of a 200MHz IO clock, using a data strobe pin on return. Also supported are an SDR mode using a 200MHz clock, DDR and SDR modes using a 100MHz clock, as well as both DDR and SDR support for integer divisions of the 100MHz clock, starting with a 50MHz clock and going all the way down to 100kHz. This is all based upon a nominal 100MHz system clock, together with a 400MHz clock for SERDES support. For designs without 8:1 and 1:8 SERDES IO components, 100MHz and slower clocks are still supported, depending upon whether or not DDR I/O components are available. Both open-drain and push-pull IOs are supported, and the front end can switch between the two as necessary based upon options within a PHY configuration register. No support is planned for any of the UHS-II protocols.

Status: The SDIO controller has now been silicon proven. It is currently working successfully in its first FPGA project, where it is being used to control both an SD card as well as an eMMC chip. Many of the components of this IP have formal proofs, which they are known to pass. Notably missing among the component proofs is a proof of the front end. Both Verilog and C++ models have been built which can be used to test this controller in simulation, although only the Verilog SDIO model has been tested to date.

For more information, please consult the SDIO user guide.

Roadmap and TODO items

Although the RTL is now fully drafted, this project is far from finished. Several key steps remain before it will be a viable product:

  • C++ Model: An early Verilator C++ model has been drafted. It needs to be finished and tested. No data strobe support is planned for this model at present.

  • Multi-block: While simulation tests have demonstrated CMD17, READ_SINGLE_BLOCK, and CMD24, WRITE_BLOCK, the multiple block commands have not yet been tested. These include CMD18, READ_MULTIPLE_BLOCK, and CMD25, WRITE_MULTIPLE_BLOCK. Key features, such as the ability to read or write multiple blocks, or the ability to issue a command while a read or write operation is ongoing, are already drafted--they just need to be tested.

    Note: These commands are implemented and tested via simulation in the dev branch, as part of the new DMA upgrade. Their merge is pending a hardware test.

  • SW: Control software has been written, and has been used to demonstrate both SDIO and EMMC performance. This software is designed to work with the FATFS library.

  • OPT_DMA: An optional DMA extension is planned to allow data blocks to be transferred to memory at the full speed of the internal bus without CPU intervention.

    The DMA will be the focus of how the SDIO controller handles wider bus widths for higher throughput.

    Note: The DMA has been implemented, integrated, and tested (via simulation) in the dev branch. Its merge is pending a hardware test.

  • AXI Support: A version exists in the dev branch that supports an AXI-Lite interface.

  • eMMC Boot mode: No plan exists to support eMMC boot mode (at present). This decision will likely be revisited in the future.

    Boot mode will require support for eMMC CRC tokens, which aren't (yet) supported. These are 8'bit return values, indicating whether or not a page has been read or written and passes its CRC check.

Logic usage

Current logic usage is being tracked for iCE40 and Xilinx 6-LUT devices in the usage.txt file in the RTL/ directory.

Commercial Applications

Should you find the GPLv3 license insufficient for your needs, other licenses may be purchased from Gisselquist Technology, LLC.

More Repositories

1

zipcpu

A small, light weight, RISC CPU soft core
Verilog
1,268
star
2

wb2axip

Bus bridges and other odds and ends
Verilog
469
star
3

wbuart32

A simple, basic, formally verified UART controller
Verilog
272
star
4

dblclockfft

A configurable C++ generator of pipelined Verilog FFT cores
C++
213
star
5

autofpga

A utility for Composing FPGA designs from Peripherals
C++
167
star
6

vgasim

A Video display simulator
Verilog
154
star
7

eth10g

10Gb Ethernet Switch
C
147
star
8

dspfilters

A collection of demonstration digital filters
Verilog
138
star
9

openarty

An Open Source configuration of the Arty platform
Verilog
119
star
10

dpll

A collection of phase locked loop (PLL) related projects
Verilog
95
star
11

cordic

A series of CORDIC related projects
C++
85
star
12

qspiflash

A set of Wishbone Controlled SPI Flash Controllers
Verilog
72
star
13

wbscope

A wishbone controlled scope for FPGA's
Verilog
72
star
14

sdr

A basic Soft(Gate)ware Defined Radio architecture
Verilog
71
star
15

interpolation

Digital Interpolation Techniques Applied to Digital Signal Processing
Verilog
53
star
16

zbasic

A bare bones, basic, ZipCPU system designed for both testing and quick integration into new systems
Verilog
42
star
17

wbi2c

Wishbone controlled I2C controllers
Verilog
40
star
18

fftdemo

A demonstration showing how several components can be compsed to build a simulated spectrogram
Verilog
39
star
19

s6soc

CMod-S6 SoC
Verilog
35
star
20

dbgbus

A collection of debugging busses developed and presented at zipcpu.com
Verilog
33
star
21

rtcclock

A Real Time Clock core for FPGA's
Verilog
22
star
22

arrowzip

A ZipCPU based demonstration of the MAX1000 FPGA board
Verilog
21
star
23

wbfmtx

A wishbone controlled FM transmitter hack
Verilog
21
star
24

icozip

A ZipCPU demonstration port for the icoboard
Verilog
17
star
25

xulalx25soc

A System on a Chip Implementation for the XuLA2-LX25 board
Verilog
16
star
26

wbpwmaudio

A wishbone controlled PWM (audio) controller
Verilog
15
star
27

videozip

A ZipCPU SoC for the Nexys Video board supporting video functionality
Verilog
14
star
28

wbspi

A collection of SPI related cores
Verilog
14
star
29

website

The ZipCPU blog
HTML
14
star
30

wbpmic

Wishbone controller for a MEMs microphone
Verilog
14
star
31

qoiimg

Quite OK image compression Verilog implementation
Verilog
14
star
32

fwmpy

A multiply core generator
C++
13
star
33

zipversa

A Versa Board implementation using the AutoFPGA/ZipCPU infrastructure
Verilog
13
star
34

wbhyperram

A cross platform, formally verified, open source, hyperRAM controller with simulator
11
star
35

axidmacheck

AXI DMA Check: A utility to measure DMA speeds in simulation
Verilog
10
star
36

wbicapetwo

Wishbone to ICAPE interface conversion
Verilog
8
star
37

tinyzip

A ZipCPU based demonstration for the TinyFPGA BX board
Verilog
8
star
38

wbsata

Wishbone SATA Controller
Verilog
8
star
39

tttt

A 4x4x4 Tic-Tac-Toe game suitable for porting to embedded hardware platforms
C
8
star
40

autofpga-demo

A demonstration of how AutoFPGA can compose a design from simple components
Verilog
8
star
41

debouncer

Digital logic necessary to debounce buttons
Verilog
8
star
42

kimos

Enclustra Mercury demonstration project
C
8
star
43

openz7

OpenZ7, an open source Zynq demo based on the Arty Z7-20
Verilog
6
star
44

zipstormmx

ZipSTORM-MX, an iCE40 ZipCPU demonstration project
Verilog
5
star
45

cputest-harness

A simulation test harness, containing serial port, QSPI flash, and an output done I/O--just provide the CPU
C++
4
star
46

xtimesheet

A very simple timesheet tracking program using text files and a GTK/Glade interface
C++
1
star