Professional Documents
Culture Documents
Frozen Content
Modied by on 6-Nov-2013
The Wishbone SDHC Controller component (WB_SDHC) provides an interface that enables a host
processor to eciently communicate with a Secure Digital (SD) or Secure Digital High-Capacity
(SDHC) storage device resident outside of the physical FPGA device to which the design is targeted.
Communication is over a 4-bit parallel data bus, with control implemented using a single-bit command
bus.
The WB_SDHC can be used with any of the 32-bit processors available in Altium Designer.
Features at-a-glance
Transmit commands through a simple register-based interface
Wishbone-compliant
Availability
From an OpenBus System document, the SDHC Controller component can be found in the
Peripherals region of the OpenBus Palette panel.
From a schematic document, the WB_SDHC component can be found in the FPGA Peripherals
(Wishbone) integrated library (FPGA Peripherals (Wishbone).IntLib), located in the
\Library\Fpga folder of the installation.
Pin Description
The following pin description is for the WB_SDHC component when used on the schematic. In an
OpenBus System, although the same signals are present, the abstract nature of the system hides the
pin-level Wishbone interfaces. The external interface signals will be made available as sheet entries,
associated with the parent sheet symbol used to reference the underlying OpenBus System.
Work In Progress
Operational Overview
The following sections outline the basic procedure in order to initiate communications with the target
SD/SDHC Card.
Two bits in the Status register are available to check if a card is inserted and/or has been changed:
Bit 0 reects the state of the input pin SD_DETECT. It is '1' if there is a card inserted.
Bit 2 is set if the card is removed. It stays '1' until you write a '1' into the bit from software.
Thus, if this bit is set, you must re-initialize the SD Card before further use.
Transmitting Commands
A commands always consists of 48 bits. It contains a start bit ('0'), a direction bit (host to card: '1'), 6
command bits, 32 argument bits, a 7-bit CRC and a stop bit ('1').
4. Wait until the CMD_TXENABLE bit disappears from the Status register
5. Wait until the CMD_TXBUSY bit disappears from the Status register
Receiving Responses
A response consists of 48 or 136 bits and can include a CRC. It always starts with a start bit ('0') a
direction bit ('0' as well) and ends with a stop bit ('1').
In order to reliably receive a response, you should indicate you want to receive an answer at the same
time you set up the transmission, as follows:
3. Write the expected number of response bytes (excluding CRC) in the CMD_RXSIZE register
5. Wait until the CMD_TXENABLE bit disappears from the Status register
6. Wait until the CMD_TXBUSY bit disappears from the Status register
8. While timeout did not elapse, check FIFO and copy response into memory. Stop if you've got all
bytes you want
Even though a message can contain up to 136 bits, the FIFO is large enough to store 16 bytes. The
17th byte in a long message always contains the CRC of the payload and is stripped by the WB_SDHC.
Transmitting Data
Data transmission can be done in single-block mode only. However, the SD Card protocol implements
a multi-block write command that can be used to transmit individual blocks in succession. It is not
needed to send data using the single_block_write command.
In order to transmit data, send the write_single_block command (SDMEM command 24) and wait
for response as usual. Then:
If you want to send multiple blocks, send a write_multiple_block command (SDMEM command
25), wait for response, than execute steps 1 and 2 only once and loop steps 3 6 until done. Then
send a transmission_stop command (SDMEM command 12).
Transmitting data may be followed by the card being busy. Check for DAT_READY before starting a
new read- or write-cycle.
Receiving Data
1. Write the buer address (must be in external memory!) into the DAT_MEMADR register
3. Write the number of bytes you want to receive in the DAT_RXSIZE register
5. Transmit and wait for the response to the data read command (SDMEM: cmd17 or cmd18)
7. Wait while timeout did not elapse and DAT_RXBUSY in the Status register is not set
The WB_SDHC core needs access to the memory every 8 SD_CLK cycles. The maximum frequency of
SD_CLK is CLK_I / 4. Since most SD cards accept faster clock speeds than this, the WB_SDHC DMA unit
typically will require access to memory every 32 system clock cycles during data transfer. You must
make sure in your design that this requirement is met or you will at one time run into DMA errors!
Register Interface
Main article: WB_SDHC - Accessible Internal Registers
The SD Card reader accessible by the User FPGA on a 3000-series NanoBoard (port-plugin
library: FPGA NB3000 Port-Plugin.IntLib).
The SD Card reader resident on a Mass Storage peripheral board (PB02) attached to a
NanoBoard NB2 (port-plugin library: FPGA PB02 Port-Plugin.IntLib).
Component
Component Symbol Description
Name
Resource Usage
As a rough guide (subject to change!) on a Xilinx Spartan3, the core currently takes approx. 761
LUTs, 8 dual port 16x1D RAMs and 456 register bits.
Example Reference Design
An example design, demonstrating the use of the SDHC Controller peripheral, is included as part of
your Altium Designer installation:
See Also