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 3

Go to most recent revision | 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
%%%% http://www.opencores.org/cores/xxx/                          %%%%
10
%%%%                                                              %%%%
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
    IP core has very simple interface:
47
    \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
    Wishbone slave interface provides access from CPU to all IP core registers (see \ref{sec:regs}). It must
55
    be connected to CPU data master. Wishbone master interface provides access for DMA engine to RAM (see \ref{sec:dma}).
56
    It must be connected to RAM memory slave. Interrupts signals provides mechanism to notify the CPU about finished transactions (data and command tranfers).
57
    They are not necesary for proper operation (if You don't want to use interrupts). MMC/SD card interface provides communication with external MMC/SD cards.
58
    It must be connected to external pins of the FPGA wich are connected to MMC/SD card connector. Because those external pins are bidirectional, IP core
59
    provides inputs, outputs and output enables for these signals.
60
    Table \ref{tab:singals} presents all IP core signals with descriptions.
61
 
62
    \begin{table}
63
    \caption{Signals description}
64
        \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
            \label{tab:singals}
105
        \end{center}
106
    \end{table}
107
 
108
    \subsection{Clock consideration}
109
    \label{sec:clock}
110
 
111
    IP core needs two clock sources. First one is for Wishbone bus operation (\texttt{wb\_clk\_i}). There are no constraints for this clock.
112
    Second one is for MMC/SD interface operation (\texttt{sd\_clk\_i\_pad}).
113
    \texttt{sd\_clk\_i\_pad} is used to drive \texttt{sd\_clk\_o\_pad} output, which is the external MMC/SD card clock source, through internal
114
    clock devider. This clock devider is able to devide \texttt{sd\_clk\_i\_pad} clock by 2, 4, 6, 8, ... etc. (2*n where n = [1..256]).
115
    \texttt{sd\_clk\_o\_pad} clock frequency depends on 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 constraint of minimum 50MHz on \texttt{sd\_clk\_i\_pad} clock.
117
    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
    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
    DMA starts its operation imidiately after succesful end of any read or write command transactions\footnote{Command transaction refers to any traffic on the command line.}
124
    \footnote{Read or write command refer to command 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 known address. This addres has to be configured by the CPU before sending any write command.
126
    Similarly, during read transactions, data is written to RAM automatically, starting from known address.
127
    This address also has to be configured by the CPU before sending any read command. Because data transmission is half-duplex,
128
    read and write addresses are placed in the same configuration register. Function of this register depends on the command to be sent.
129
 
130
    \subsection{Interrupt generation}
131
    \label{sec:interrupt}
132
 
133
    Interrupts are useful when polling technique is not an option. There are two interrupt sources. One to notify the end of the commans transaction (\texttt{int\_cmd} signal) and
134
    one to notify the end of the data transaction (\texttt{int\_data} signal). Both interrupts has active high logic. All events that triger each interrupts can be masked(see \ref{sec:regs})
135
    and therefore, do not participate in interrupt generation(see \ref{img:events}).
136
    \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
    Command transaction end interrupt is driven by the command transaction events. The events are:
148
    \begin{description}
149
    \item[completion] - transaction completed succesfuly,
150
    \item[error] - transaction completed with error (one or more of the following events occured),
151
    \item[timeout] - timeout error (the card did not respond in a timely fashion),
152
    \item[wrong crc] - crc check error (crc calculated from received response data did not match to the crc field of the response),
153
    \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
    Data transaction end interrupt is driven by the data transaction events. The events are:
160
    \begin{description}
161
    \item[completion] - transaction completed succesfuly,
162
    \item[wrong crc] - crc check error (in case of write transaction, crc received in response to write transaction was different than one calculated by the core;
163
    in case of read transaction, crc calculated from received data did not match to the crc field of received data),
164
    \item[fifo error] - internal fifo error (in case of write transaction, tx fifo became empty before all data was send; in case of read transaction, rx fifo became
165
    full; both cases are caused by to slow wishbone bus or wishbone bus been busy for to long)).
166
    \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.