OpenCores
URL https://opencores.org/ocsvn/sd_card_controller/sd_card_controller/trunk

Subversion Repositories sd_card_controller

[/] [sd_card_controller/] [trunk/] [doc/] [src/] [hdl_if.tex] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 rozpruwacz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
%%%%                                                              %%%%
3
%%%% WISHBONE SD Card Controller IP Core                          %%%%
4
%%%%                                                              %%%%
5
%%%% hdl_if.tex                                                   %%%%
6
%%%%                                                              %%%%
7
%%%% This file is part of the WISHBONE SD Card                    %%%%
8
%%%% Controller IP Core project                                   %%%%
9 8 rozpruwacz
%%%% http://opencores.org/project,sd_card_controller              %%%%
10 3 rozpruwacz
%%%%                                                              %%%%
11
%%%% Description                                                  %%%%
12
%%%% documentation 'HDL interface' chapter                        %%%%
13
%%%%                                                              %%%%
14
%%%% Author(s):                                                   %%%%
15
%%%%     - Marek Czerski, ma.czerski@gmail.com                    %%%%
16
%%%%                                                              %%%%
17
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
%%%%                                                              %%%%
19
%%%% Copyright (C) 2013 Authors                                   %%%%
20
%%%%                                                              %%%%
21
%%%% This source file may be used and distributed without         %%%%
22
%%%% restriction provided that this copyright statement is not    %%%%
23
%%%% removed from the file and that any derivative work contains  %%%%
24
%%%% the original copyright notice and the associated disclaimer. %%%%
25
%%%%                                                              %%%%
26
%%%% This source file is free software; you can redistribute it   %%%%
27
%%%% and/or modify it under the terms of the GNU Lesser General   %%%%
28
%%%% Public License as published by the Free Software Foundation; %%%%
29
%%%% either version 2.1 of the License, or (at your option) any   %%%%
30
%%%% later version.                                               %%%%
31
%%%%                                                              %%%%
32
%%%% This source is distributed in the hope that it will be       %%%%
33
%%%% useful, but WITHOUT ANY WARRANTY; without even the implied   %%%%
34
%%%% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      %%%%
35
%%%% PURPOSE. See the GNU Lesser General Public License for more  %%%%
36
%%%% details.                                                     %%%%
37
%%%%                                                              %%%%
38
%%%% You should have received a copy of the GNU Lesser General    %%%%
39
%%%% Public License along with this source; if not, download it   %%%%
40
%%%% from http://www.opencores.org/lgpl.shtml                     %%%%
41
%%%%                                                              %%%%
42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43
\section{HDL interface}
44
\label{sec:hdl_if}
45
 
46 13 jclaytons
    This IP core has a very simple interface:
47 3 rozpruwacz
    \begin{figure}[H]
48
        \centering
49
        \includegraphics[width=11cm]{../bin/ip_core_if.png}
50
        % ip_core.png: 384x469 pixel, 96dpi, 10.16x12.41 cm, bb=
51
        \caption{Wishbone SD Card Controller IP Core interface}
52
        \label{img:ip_core_if}
53
    \end{figure}
54 13 jclaytons
    The Wishbone slave interface provides access from CPU to all IP core registers (see \ref{sec:regs}). It must
55
    be connected to a data master. The Wishbone master interface provides access from the DMA engine to RAM (see \ref{sec:dma}).
56
    It must be connected to a RAM memory slave. Interrupt signals provide a mechanism to notify the CPU about finished transactions (data and command tranfers).
57
    They are not necessary for proper operation, if you don't want to use interrupts. The MMC/SD card interface communicates with external MMC/SD cards.
58
    It must be mapped to external pins of the FPGA which are connected to a MMC/SD card connector. Because those external pins are bidirectional, this IP core
59 3 rozpruwacz
    provides inputs, outputs and output enables for these signals.
60 13 jclaytons
    Table \ref{tab:signals} presents all the IP core signals with descriptions.
61 3 rozpruwacz
 
62
    \begin{table}
63 13 jclaytons
    \caption{Description of signals}
64 3 rozpruwacz
        \begin{center}
65
            \begin{tabular}{l|l|l|l}
66
                    \rowcolor[gray]{0.7} name & direction & width & description \\ \hline \hline
67
                    \multicolumn{4}{c}{Wishbone common signals} \\ \hline
68
                    \texttt{wb\_clk\_i} & input & 1 & clock for both master and slave wishbone transactions \\ \hline
69
                    \texttt{wb\_rst\_i} & input & 1 & reset for whole IP core \\ \hline
70
                    \multicolumn{4}{c}{Wishbone slave signals} \\ \hline
71
                    \texttt{wb\_dat\_i} & input & 32 & data input \\ \hline
72
                    \texttt{wb\_dat\_o} & output & 32 & data output \\ \hline
73
                    \texttt{wb\_adr\_i} & input & 32 & address \\ \hline
74
                    \texttt{wb\_sel\_i} & input & 4 & byte select \\ \hline
75
                    \texttt{wb\_we\_i} & input & 1 & write enable \\ \hline
76
                    \texttt{wb\_cyc\_i} & input & 1 & cycle flag \\ \hline
77
                    \texttt{wb\_stb\_i} & input & 1 & strobe \\ \hline
78
                    \texttt{wb\_ack\_o} & output & 1 & acknowledge flag \\ \hline
79
                    \multicolumn{4}{c}{Wishbone master signals} \\ \hline
80
                    \texttt{m\_wb\_dat\_o} & output & 32 & data output \\ \hline
81
                    \texttt{m\_wb\_dat\_i} & input & 32 & data input \\ \hline
82
                    \texttt{m\_wb\_adr\_o} & output & 32 & address \\ \hline
83
                    \texttt{m\_wb\_sel\_o} & output & 4 & byte select \\ \hline
84
                    \texttt{m\_wb\_we\_o} & output & 1 & write enable \\ \hline
85
                    \texttt{m\_wb\_cyc\_o} & output & 1 & cycle flag \\ \hline
86
                    \texttt{m\_wb\_stb\_o} & output & 1 & strobe \\ \hline
87
                    \texttt{m\_wb\_ack\_i} & input & 1 & acknowledge flag \\ \hline
88
                    \texttt{m\_wb\_cti\_o} & output & 3 & cycle type identifier (always 000) \\ \hline
89
                    \texttt{m\_wb\_bte\_o} & output & 2 & burst type (always 00) \\ \hline
90
                    \multicolumn{4}{c}{MMC/SD signals} \\ \hline
91
                    \texttt{sd\_cmd\_dat\_i} & input & 1 & command line input \\ \hline
92
                    \texttt{sd\_cmd\_out\_o} & output & 1 & command line output \\ \hline
93
                    \texttt{sd\_cmd\_oe\_o} & output & 1 & command line output enable \\ \hline
94
                    \texttt{sd\_dat\_dat\_i} & input & 4 & data line inputs \\ \hline
95
                    \texttt{sd\_dat\_out\_o} & output & 4 & data line outputs \\ \hline
96
                    \texttt{sd\_dat\_oe\_o} & output & 1 & data line outputs enable \\ \hline
97
                    \texttt{sd\_clk\_o\_pad} & output & 1 & clock for external MMC/SD card \\ \hline
98
                    \texttt{sd\_clk\_i\_pad} & input & 1 & clock for MMC/SD interface \\ \hline
99
                    \multicolumn{4}{c}{Interrupts} \\ \hline
100
                    \texttt{int\_cmd} & output & 1 & command transaction finished interrupt \\ \hline
101
                    \texttt{int\_data} & output & 1 & data transaction finished interrupt \\ \hline
102
                    \hline
103
            \end{tabular}
104 13 jclaytons
            \label{tab:signals}
105 3 rozpruwacz
        \end{center}
106
    \end{table}
107
 
108
    \subsection{Clock consideration}
109
    \label{sec:clock}
110
 
111 13 jclaytons
    The IP core needs two clock sources. The first is for Wishbone bus operation (\texttt{wb\_clk\_i}). There are no constraints for this clock.
112
    The second is for MMC/SD interface operation (\texttt{sd\_clk\_i\_pad}).
113
    \texttt{sd\_clk\_i\_pad} is used to drive the \texttt{sd\_clk\_o\_pad} output, which is the external MMC/SD card clock source, through an internal
114
    clock divider. This clock divider is able to divide the \texttt{sd\_clk\_i\_pad} clock by 2, 4, 6, 8, ... etc. (2*n where n = [1..256]).
115
    The \texttt{sd\_clk\_o\_pad} clock frequency depends on the MMC/SD specification. To fully utilize the transmission bandwidth \texttt{sd\_clk\_o\_pad}
116
    should be able to perform at 25MHz frequency which imposes a minimum constraint of 50MHz on \texttt{sd\_clk\_i\_pad} clock.
117 3 rozpruwacz
    Clock inputs \texttt{wb\_clk\_i} and \texttt{sd\_clk\_i\_pad} can be sourced by the same signal.
118
 
119
    \subsection{DMA engine}
120
    \label{sec:dma}
121
 
122 13 jclaytons
    The DMA engine is used to lower the CPU usage during data transactions\footnote{"Data transaction" refers to any traffic on the data lines of MMC/SD card interface.}.
123
    The DMA engine starts its operation immediately after the successful end of any read or write command transactions\footnote{"Command transaction" refers to any traffic on the command line.}
124
    \footnote{"Read" or "write" commands refer to commands with data payload such as \textit{block read}(CMD17) or \textit{block write}(CMD24).}.
125
    During write transactions, data is fetched from RAM automatically, starting from a known address. This address has to be configured by the CPU before sending any write commands.
126
    Similarly, during read transactions, data is written to RAM automatically, starting from a known address.
127
    This address also has to be configured by the CPU before sending any read commands. Because data transmission is half-duplex,
128
    read and write addresses are placed in the same configuration register. The function of this register thus depends on the command to be sent.
129 3 rozpruwacz
 
130
    \subsection{Interrupt generation}
131
    \label{sec:interrupt}
132
 
133 13 jclaytons
    Interrupts are useful when polling is not an option. There are two interrupt sources: One to signify the end of the command transaction (\texttt{int\_cmd} signal) and
134
    one to signify the end of the data transaction (\texttt{int\_data} signal). Both interrupts use active high logic. All events that trigger an interrupt can be masked. (see \ref{sec:regs})
135
    Events which are masked do not participate in interrupt generation(see Fig. \ref{img:events}).
136 3 rozpruwacz
    \begin{figure}[H]
137
        \centering
138
        \includegraphics[width=11cm]{../bin/events.png}
139
        % ip_core.png: 384x469 pixel, 96dpi, 10.16x12.41 cm, bb=
140
        \caption{Interrupt generation scheme}
141
        \label{img:events}
142
    \end{figure}
143
 
144
    \subsubsection{Command transaction events}
145
    \label{sec:cmd_events}
146
 
147 13 jclaytons
    The command transaction end interrupt is driven in response to command transaction events. The events are:
148 3 rozpruwacz
    \begin{description}
149 13 jclaytons
    \item[completion] - transaction completed successfully,
150
    \item[error] - transaction completed with error (one or more of the following events occurred),
151 3 rozpruwacz
    \item[timeout] - timeout error (the card did not respond in a timely fashion),
152 13 jclaytons
    \item[wrong CRC] - CRC check error (CRC calculated from received response data did not match to the CRC field of the response),
153 3 rozpruwacz
    \item[wrong index] - index check error (response consists of wrong index field value).
154
    \end{description}
155
 
156
    \subsubsection{Data transaction events}
157
    \label{sec:data_events}
158
 
159 13 jclaytons
    The data transaction end interrupt is driven in response to data transaction events. The events are:
160 3 rozpruwacz
    \begin{description}
161 13 jclaytons
    \item[completion] - transaction completed successfully,
162
    \item[wrong CRC] - CRC check error (in case of write transaction, CRC received in response to write transaction was different than the one calculated by the core;
163
    in case of read transaction, the CRC calculated from received data did not match to the CRC field of the received data),
164
    \item[FIFO error] - internal FIFO error (in case of write transaction, tx FIFO became empty before all data was sent; in case of read transaction, rx FIFO became
165
    full; both cases are caused by too slow of a wishbone bus or the wishbone bus being busy for too long)).
166 3 rozpruwacz
    \end{description}
167
 
168
 
169
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.