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

Subversion Repositories aoocs

[/] [aoocs/] [trunk/] [doc/] [doxygen/] [html/] [bus__sd_8v_source.html] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
3
<head>
4
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5
<title>aoOCS: bus_sd.v Source File</title>
6
<link href="tabs.css" rel="stylesheet" type="text/css"/>
7
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
8
</head>
9
<body>
10
<!-- Generated by Doxygen 1.7.2 -->
11
<div class="navigation" id="top">
12
  <div class="tabs">
13
    <ul class="tablist">
14
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
15
      <li><a href="annotated.html"><span>Design&#160;Unit&#160;List</span></a></li>
16
      <li class="current"><a href="files.html"><span>Files</span></a></li>
17
    </ul>
18
  </div>
19
  <div class="tabs2">
20
    <ul class="tablist">
21
      <li><a href="files.html"><span>File&#160;List</span></a></li>
22
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
23
    </ul>
24
  </div>
25
<div class="header">
26
  <div class="headertitle">
27
<h1>bus_sd.v</h1>  </div>
28
</div>
29
<div class="contents">
30
<a href="bus__sd_8v.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001  <span class="keyword">/* </span>
31
<a name="l00002"></a>00002 <span class="keyword">  Copyright 2010, Aleksander Osman, alfik@poczta.fm. All rights reserved.</span>
32
<a name="l00003"></a>00003 <span class="keyword"> </span>
33
<a name="l00004"></a>00004 <span class="keyword">  Redistribution and use in source and binary forms, with or without modification, are</span>
34
<a name="l00005"></a>00005 <span class="keyword">  permitted provided that the following conditions are met:</span>
35
<a name="l00006"></a>00006 <span class="keyword"> </span>
36
<a name="l00007"></a>00007 <span class="keyword">   1. Redistributions of source code must retain the above copyright notice, this list of</span>
37
<a name="l00008"></a>00008 <span class="keyword">      conditions and the following disclaimer.</span>
38
<a name="l00009"></a>00009 <span class="keyword"> </span>
39
<a name="l00010"></a>00010 <span class="keyword">   2. Redistributions in binary form must reproduce the above copyright notice, this list</span>
40
<a name="l00011"></a>00011 <span class="keyword">      of conditions and the following disclaimer in the documentation and/or other materials</span>
41
<a name="l00012"></a>00012 <span class="keyword">      provided with the distribution.</span>
42
<a name="l00013"></a>00013 <span class="keyword"> </span>
43
<a name="l00014"></a>00014 <span class="keyword">  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS&#39;&#39; AND ANY EXPRESS OR IMPLIED</span>
44
<a name="l00015"></a>00015 <span class="keyword">  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND</span>
45
<a name="l00016"></a>00016 <span class="keyword">  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR</span>
46
<a name="l00017"></a>00017 <span class="keyword">  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span>
47
<a name="l00018"></a>00018 <span class="keyword">  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR</span>
48
<a name="l00019"></a>00019 <span class="keyword">  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON</span>
49
<a name="l00020"></a>00020 <span class="keyword">  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
50
<a name="l00021"></a>00021 <span class="keyword">  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF</span>
51
<a name="l00022"></a>00022 <span class="keyword">  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
52
<a name="l00023"></a>00023 <span class="keyword"> */</span>
53
<a name="l00024"></a>00024
54
<a name="l00025"></a>00025 <span class="keyword">/*! \file</span>
55
<a name="l00026"></a>00026 <span class="keyword">  \brief 1-bit SD bus driver for SD cards with WISHBONE master and slave interface.</span>
56
<a name="l00027"></a>00027 <span class="keyword"> */</span>
57
<a name="l00028"></a>00028
58
<a name="l00029"></a>00029 <span class="keyword">/*! \brief \copybrief bus_sd.v</span>
59
<a name="l00030"></a>00030 <span class="keyword">*/</span>
60
<a name="l00031"></a><a class="code" href="classbus__sd.html">00031</a> <span class="vhdlkeyword">module</span> <a class="code" href="classbus__sd.html">bus_sd</a>(
61
<a name="l00032"></a>00032     <span class="keyword">//% \name Clock and reset
62
</span>
63
<a name="l00033"></a>00033     <span class="keyword">//% @{</span>
64
<a name="l00034"></a><a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">00034</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a>,
65
<a name="l00035"></a><a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">00035</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>,
66
<a name="l00036"></a>00036     <span class="keyword">//% @}</span>
67
<a name="l00037"></a>00037
68
<a name="l00038"></a>00038     <span class="keyword">//% \name WISHBONE master
69
</span>
70
<a name="l00039"></a>00039     <span class="keyword">//% @{</span>
71
<a name="l00040"></a><a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">00040</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span>          <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a>,
72
<a name="l00041"></a><a class="code" href="classbus__sd.html#a48e4e8652304be3427d6f7272ee0cad9">00041</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>]   <a class="code" href="classbus__sd.html#a48e4e8652304be3427d6f7272ee0cad9">DAT_O</a>,
73
<a name="l00042"></a><a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">00042</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span>          <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a>,
74
<a name="l00043"></a><a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">00043</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span>          <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a>,
75
<a name="l00044"></a><a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">00044</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">2</span>]   <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a>,
76
<a name="l00045"></a><a class="code" href="classbus__sd.html#a80900c47b64b6e8fbfd2388ac046cc3e">00045</a>     <span class="vhdlkeyword">output</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>]        <a class="code" href="classbus__sd.html#a80900c47b64b6e8fbfd2388ac046cc3e">SEL_O</a>,
77
<a name="l00046"></a><a class="code" href="classbus__sd.html#ac9c12028bdaca2ad04524559664d5da1">00046</a>     <span class="vhdlkeyword">input</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>]        <a class="code" href="classbus__sd.html#ac9c12028bdaca2ad04524559664d5da1">DAT_I</a>,
78
<a name="l00047"></a><a class="code" href="classbus__sd.html#a061e1e23417561b3f770a78cf885b67f">00047</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#a061e1e23417561b3f770a78cf885b67f">ACK_I</a>,
79
<a name="l00048"></a><a class="code" href="classbus__sd.html#a8943042012ad4ff6cc3f8f7818fe1c1b">00048</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#a8943042012ad4ff6cc3f8f7818fe1c1b">ERR_I</a>,
80
<a name="l00049"></a><a class="code" href="classbus__sd.html#a3039cca7e4673f05fb44fdf21053a809">00049</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#a3039cca7e4673f05fb44fdf21053a809">RTY_I</a>,
81
<a name="l00050"></a>00050     <span class="keyword">// TAG_TYPE: TGC_O</span>
82
<a name="l00051"></a><a class="code" href="classbus__sd.html#a6333995e17548c2514d170d5341120e8">00051</a>     <span class="vhdlkeyword">output</span>              <a class="code" href="classbus__sd.html#a6333995e17548c2514d170d5341120e8">SGL_O</a>,
83
<a name="l00052"></a><a class="code" href="classbus__sd.html#aefa42b30ca2c95b87778eaf25f79a81a">00052</a>     <span class="vhdlkeyword">output</span>              <a class="code" href="classbus__sd.html#aefa42b30ca2c95b87778eaf25f79a81a">BLK_O</a>,
84
<a name="l00053"></a><a class="code" href="classbus__sd.html#a689186b78013051d35500c891f58ce27">00053</a>     <span class="vhdlkeyword">output</span>              <a class="code" href="classbus__sd.html#a689186b78013051d35500c891f58ce27">RMW_O</a>,
85
<a name="l00054"></a>00054     <span class="keyword">// TAG_TYPE: TGA_O</span>
86
<a name="l00055"></a><a class="code" href="classbus__sd.html#a8d7a8e5f3567ef5c434b776e0ccfcf8a">00055</a>     <span class="vhdlkeyword">output</span> [<span class="vhdllogic">2</span>:<span class="vhdllogic">0</span>]        <a class="code" href="classbus__sd.html#a8d7a8e5f3567ef5c434b776e0ccfcf8a">CTI_O</a>,
87
<a name="l00056"></a><a class="code" href="classbus__sd.html#a8323046005362330c65c7b264042e97c">00056</a>     <span class="vhdlkeyword">output</span> [<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>]        <a class="code" href="classbus__sd.html#a8323046005362330c65c7b264042e97c">BTE_O</a>,
88
<a name="l00057"></a>00057     <span class="keyword">//% @}</span>
89
<a name="l00058"></a>00058
90
<a name="l00059"></a>00059     <span class="keyword">//% \name WISHBONE slave
91
</span>
92
<a name="l00060"></a>00060     <span class="keyword">//% @{</span>
93
<a name="l00061"></a><a class="code" href="classbus__sd.html#a087c3d66a5087429858d92c23398069f">00061</a>     <span class="vhdlkeyword">output</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>]       <a class="code" href="classbus__sd.html#a087c3d66a5087429858d92c23398069f">slave_DAT_O</a>,
94
<a name="l00062"></a><a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">00062</a>     <span class="vhdlkeyword">input</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>]        <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>,
95
<a name="l00063"></a><a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">00063</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span>          <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a>,
96
<a name="l00064"></a><a class="code" href="classbus__sd.html#a54abbdeda6f942d17e9bf65e535159bf">00064</a>     <span class="vhdlkeyword">output</span>              <a class="code" href="classbus__sd.html#a54abbdeda6f942d17e9bf65e535159bf">ERR_O</a>,
97
<a name="l00065"></a><a class="code" href="classbus__sd.html#a66f73e6ffa7d68fe0376854bba70b0e1">00065</a>     <span class="vhdlkeyword">output</span>              <a class="code" href="classbus__sd.html#a66f73e6ffa7d68fe0376854bba70b0e1">RTY_O</a>,
98
<a name="l00066"></a><a class="code" href="classbus__sd.html#ad7e7614ed7fef87f49932689af47bc26">00066</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#ad7e7614ed7fef87f49932689af47bc26">CYC_I</a>,
99
<a name="l00067"></a><a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">00067</a>     <span class="vhdlkeyword">input</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">2</span>]         <a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">ADR_I</a>,
100
<a name="l00068"></a><a class="code" href="classbus__sd.html#a142a3da1f5773ed79bc9a4127ea123e0">00068</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#a142a3da1f5773ed79bc9a4127ea123e0">STB_I</a>,
101
<a name="l00069"></a><a class="code" href="classbus__sd.html#abbaba763cf6e2f07ef4d79308026ca10">00069</a>     <span class="vhdlkeyword">input</span>               <a class="code" href="classbus__sd.html#abbaba763cf6e2f07ef4d79308026ca10">WE_I</a>,
102
<a name="l00070"></a><a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">00070</a>     <span class="vhdlkeyword">input</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>]         <a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>,
103
<a name="l00071"></a>00071     <span class="keyword">//% @}</span>
104
<a name="l00072"></a>00072
105
<a name="l00073"></a>00073     <span class="keyword">//% \name SD bus 1-bit hardware interface
106
</span>
107
<a name="l00074"></a>00074     <span class="keyword">//% @{</span>
108
<a name="l00075"></a><a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">00075</a>     <span class="vhdlkeyword">output</span> <span class="vhdlkeyword">reg</span>          <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> = <span class="vhdllogic">1&#39;b0</span>,
109
<a name="l00076"></a>00076     <span class="vhdlkeyword">inout</span>               sd_cmd_io,
110
<a name="l00077"></a>00077     <span class="vhdlkeyword">inout</span>               sd_dat_io,
111
<a name="l00078"></a>00078     <span class="keyword">//% @}</span>
112
<a name="l00079"></a>00079
113
<a name="l00080"></a>00080     <span class="keyword">//% \name Debug signals
114
</span>
115
<a name="l00081"></a>00081     <span class="keyword">//% @{</span>
116
<a name="l00082"></a>00082     <span class="vhdlkeyword">output</span> [<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>]        <span class="vhdlchar">debug_sd</span>
117
<a name="l00083"></a>00083     <span class="keyword">//% @}</span>
118
<a name="l00084"></a>00084 );
119
<a name="l00085"></a>00085
120
<a name="l00086"></a>00086 <span class="keyword">/***********************************************************************************************************************</span>
121
<a name="l00087"></a>00087 <span class="keyword">                                                      Wishbone interface</span>
122
<a name="l00088"></a>00088 <span class="keyword"> ***********************************************************************************************************************/</span>
123
<a name="l00089"></a>00089
124
<a name="l00090"></a>00090 <span class="vhdlkeyword">assign</span> debug_sd = { (<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>), (<a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> == <span class="vhdllogic">16&#39;d65535</span>), <span class="vhdllogic">2&#39;b0</span>, <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> };
125
<a name="l00091"></a>00091
126
<a name="l00092"></a>00092 <span class="keyword">//---------------------------------------------------- wishbone master</span>
127
<a name="l00093"></a>00093 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a6333995e17548c2514d170d5341120e8">SGL_O</a> = <span class="vhdllogic">1&#39;b1</span>;
128
<a name="l00094"></a>00094 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#aefa42b30ca2c95b87778eaf25f79a81a">BLK_O</a> = <span class="vhdllogic">1&#39;b0</span>;
129
<a name="l00095"></a>00095 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a689186b78013051d35500c891f58ce27">RMW_O</a> = <span class="vhdllogic">1&#39;b0</span>;
130
<a name="l00096"></a>00096 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a80900c47b64b6e8fbfd2388ac046cc3e">SEL_O</a> = <span class="vhdllogic">4&#39;b1111</span>;
131
<a name="l00097"></a>00097 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a8323046005362330c65c7b264042e97c">BTE_O</a> = <span class="vhdllogic">2&#39;b00</span>;
132
<a name="l00098"></a>00098 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a8d7a8e5f3567ef5c434b776e0ccfcf8a">CTI_O</a> = <span class="vhdllogic">3&#39;b000</span>;
133
<a name="l00099"></a>00099
134
<a name="l00100"></a><a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">00100</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a>;
135
<a name="l00101"></a><a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">00101</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a>;
136
<a name="l00102"></a><a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">00102</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a>;
137
<a name="l00103"></a><a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">00103</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a>;
138
<a name="l00104"></a>00104
139
<a name="l00105"></a>00105 <span class="keyword">//STB_O,CYC_O,WE_O,DAT_O,</span>
140
<a name="l00106"></a><a class="code" href="classbus__sd.html#a3b2fe0fbf7891563128ea5814f02fc09">00106</a> <span class="vhdlkeyword">always</span> @(<span class="vhdlkeyword">posedge</span> <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a> <span class="vhdlkeyword">or</span> <span class="vhdlkeyword">negedge</span> <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>) <span class="vhdlkeyword">begin</span>
141
<a name="l00107"></a>00107     <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
142
<a name="l00108"></a>00108         <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a> &lt;= <span class="vhdllogic">30&#39;d0</span>;
143
<a name="l00109"></a>00109         <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
144
<a name="l00110"></a>00110         <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
145
<a name="l00111"></a>00111         <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
146
<a name="l00112"></a>00112         <a class="code" href="classbus__sd.html#a48e4e8652304be3427d6f7272ee0cad9">DAT_O</a> &lt;= <span class="vhdllogic">32&#39;d0</span>;
147
<a name="l00113"></a>00113         <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
148
<a name="l00114"></a>00114         <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
149
<a name="l00115"></a>00115         <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
150
<a name="l00116"></a>00116         <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a> &lt;= <span class="vhdllogic">32&#39;d0</span>;
151
<a name="l00117"></a>00117     <span class="vhdlkeyword">end</span>
152
<a name="l00118"></a>00118     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#ada04262d8cb516a835ee25a3d9508830">S_DATA_READ_READY_PART</a> &amp;&amp; <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
153
<a name="l00119"></a>00119         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a061e1e23417561b3f770a78cf885b67f">ACK_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
154
<a name="l00120"></a>00120             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
155
<a name="l00121"></a>00121             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
156
<a name="l00122"></a>00122             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
157
<a name="l00123"></a>00123
158
<a name="l00124"></a>00124             <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
159
<a name="l00125"></a>00125         <span class="vhdlkeyword">end</span>
160
<a name="l00126"></a>00126         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3039cca7e4673f05fb44fdf21053a809">RTY_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
161
<a name="l00127"></a>00127             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
162
<a name="l00128"></a>00128             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
163
<a name="l00129"></a>00129             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
164
<a name="l00130"></a>00130         <span class="vhdlkeyword">end</span>
165
<a name="l00131"></a>00131         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a8943042012ad4ff6cc3f8f7818fe1c1b">ERR_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
166
<a name="l00132"></a>00132             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
167
<a name="l00133"></a>00133             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
168
<a name="l00134"></a>00134             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
169
<a name="l00135"></a>00135
170
<a name="l00136"></a>00136             <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
171
<a name="l00137"></a>00137             <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
172
<a name="l00138"></a>00138         <span class="vhdlkeyword">end</span>
173
<a name="l00139"></a>00139         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
174
<a name="l00140"></a>00140             <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a> &lt;= <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> + { <span class="vhdllogic">23&#39;b0</span>, <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> };
175
<a name="l00141"></a>00141             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
176
<a name="l00142"></a>00142             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
177
<a name="l00143"></a>00143             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
178
<a name="l00144"></a>00144             <a class="code" href="classbus__sd.html#a48e4e8652304be3427d6f7272ee0cad9">DAT_O</a> &lt;= <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>;
179
<a name="l00145"></a>00145         <span class="vhdlkeyword">end</span>
180
<a name="l00146"></a>00146     <span class="vhdlkeyword">end</span>
181
<a name="l00147"></a>00147     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a> &amp;&amp; <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
182
<a name="l00148"></a>00148         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a061e1e23417561b3f770a78cf885b67f">ACK_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
183
<a name="l00149"></a>00149             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
184
<a name="l00150"></a>00150             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
185
<a name="l00151"></a>00151             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
186
<a name="l00152"></a>00152             <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a> &lt;= <a class="code" href="classbus__sd.html#ac9c12028bdaca2ad04524559664d5da1">DAT_I</a>;
187
<a name="l00153"></a>00153
188
<a name="l00154"></a>00154             <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
189
<a name="l00155"></a>00155         <span class="vhdlkeyword">end</span>
190
<a name="l00156"></a>00156         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3039cca7e4673f05fb44fdf21053a809">RTY_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
191
<a name="l00157"></a>00157             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
192
<a name="l00158"></a>00158             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
193
<a name="l00159"></a>00159             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
194
<a name="l00160"></a>00160         <span class="vhdlkeyword">end</span>
195
<a name="l00161"></a>00161         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a8943042012ad4ff6cc3f8f7818fe1c1b">ERR_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
196
<a name="l00162"></a>00162             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
197
<a name="l00163"></a>00163             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
198
<a name="l00164"></a>00164             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
199
<a name="l00165"></a>00165
200
<a name="l00166"></a>00166             <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
201
<a name="l00167"></a>00167             <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
202
<a name="l00168"></a>00168         <span class="vhdlkeyword">end</span>
203
<a name="l00169"></a>00169         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
204
<a name="l00170"></a>00170             <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a> &lt;= <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> + { <span class="vhdllogic">23&#39;b0</span>, <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> };
205
<a name="l00171"></a>00171             <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
206
<a name="l00172"></a>00172             <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
207
<a name="l00173"></a>00173             <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
208
<a name="l00174"></a>00174         <span class="vhdlkeyword">end</span>
209
<a name="l00175"></a>00175     <span class="vhdlkeyword">end</span>
210
<a name="l00176"></a>00176     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> != <a class="code" href="classbus__sd.html#ada04262d8cb516a835ee25a3d9508830">S_DATA_READ_READY_PART</a> &amp;&amp; <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> != <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a>) <span class="vhdlkeyword">begin</span>
211
<a name="l00177"></a>00177         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> == <a class="code" href="classbus__sd.html#a9b15e063dbb64dabc5d2fb1f14060059">STATUS_ERROR</a>) <span class="vhdlkeyword">begin</span>
212
<a name="l00178"></a>00178             <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
213
<a name="l00179"></a>00179         <span class="vhdlkeyword">end</span>
214
<a name="l00180"></a>00180
215
<a name="l00181"></a>00181         <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
216
<a name="l00182"></a>00182         <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
217
<a name="l00183"></a>00183     <span class="vhdlkeyword">end</span>
218
<a name="l00184"></a>00184 <span class="vhdlkeyword">end</span>
219
<a name="l00185"></a>00185
220
<a name="l00186"></a>00186 <span class="keyword">//---------------------------------------------------- wishbone slave</span>
221
<a name="l00187"></a>00187 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a54abbdeda6f942d17e9bf65e535159bf">ERR_O</a> = <span class="vhdllogic">1&#39;b0</span>;
222
<a name="l00188"></a>00188 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a66f73e6ffa7d68fe0376854bba70b0e1">RTY_O</a> = <span class="vhdllogic">1&#39;b0</span>;
223
<a name="l00189"></a>00189 <span class="vhdlkeyword">assign</span> <a class="code" href="classbus__sd.html#a087c3d66a5087429858d92c23398069f">slave_DAT_O</a> = {<span class="vhdllogic">29&#39;d0</span>, <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a>[<span class="vhdllogic">2</span>:<span class="vhdllogic">0</span>]};
224
<a name="l00190"></a>00190
225
<a name="l00191"></a>00191 <span class="keyword">// write only</span>
226
<a name="l00192"></a><a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">00192</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>;
227
<a name="l00193"></a><a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">00193</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>;
228
<a name="l00194"></a><a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">00194</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a>;
229
<a name="l00195"></a><a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">00195</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">2</span>] <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>;
230
<a name="l00196"></a>00196
231
<a name="l00197"></a><a class="code" href="classbus__sd.html#a93a7de63cfcce62192aac0c31cc0e3a3">00197</a> <span class="vhdlkeyword">parameter</span> [<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>]
232
<a name="l00198"></a>00198     <a class="code" href="classbus__sd.html#a0d6a1a0bbfc5f191b4d1766784dcdeb4">CONTROL_IDLE</a>        = <span class="vhdllogic">2&#39;d0</span>,
233
<a name="l00199"></a>00199     <a class="code" href="classbus__sd.html#ac9f608398c5aba2e8fa2656c7b63da05">CONTROL_REINIT</a>      = <span class="vhdllogic">2&#39;d1</span>,
234
<a name="l00200"></a>00200     <a class="code" href="classbus__sd.html#ac41ad9206f43eee68311ac70795c6d56">CONTROL_READ</a>        = <span class="vhdllogic">2&#39;d2</span>,
235
<a name="l00201"></a>00201     <a class="code" href="classbus__sd.html#a93a7de63cfcce62192aac0c31cc0e3a3">CONTROL_WRITE</a>       = <span class="vhdllogic">2&#39;d3</span>;
236
<a name="l00202"></a>00202
237
<a name="l00203"></a><a class="code" href="classbus__sd.html#a418c246329e4a9feed8b1c08abbadba2">00203</a> <span class="vhdlkeyword">always</span> @(<span class="vhdlkeyword">posedge</span> <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a> <span class="vhdlkeyword">or</span> <span class="vhdlkeyword">negedge</span> <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>) <span class="vhdlkeyword">begin</span>
238
<a name="l00204"></a>00204     <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
239
<a name="l00205"></a>00205         <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> &lt;= <span class="vhdllogic">30&#39;d0</span>;
240
<a name="l00206"></a>00206         <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a> &lt;= <span class="vhdllogic">32&#39;d0</span>;
241
<a name="l00207"></a>00207         <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> &lt;= <span class="vhdllogic">32&#39;d0</span>;
242
<a name="l00208"></a>00208         <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> &lt;= <span class="vhdllogic">2&#39;d0</span>;
243
<a name="l00209"></a>00209         <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
244
<a name="l00210"></a>00210     <span class="vhdlkeyword">end</span>
245
<a name="l00211"></a>00211     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
246
<a name="l00212"></a>00212         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>) <span class="vhdlkeyword">begin</span>
247
<a name="l00213"></a>00213             <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> &lt;= <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> - <span class="vhdllogic">32&#39;d1</span>;
248
<a name="l00214"></a>00214             <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a> &lt;= <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a> + <span class="vhdllogic">32&#39;d1</span>;
249
<a name="l00215"></a>00215             <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> &lt;= <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> + <span class="vhdllogic">30&#39;d128</span>;
250
<a name="l00216"></a>00216
251
<a name="l00217"></a>00217             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> == <span class="vhdllogic">32&#39;d1</span>) <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> &lt;= <a class="code" href="classbus__sd.html#a0d6a1a0bbfc5f191b4d1766784dcdeb4">CONTROL_IDLE</a>;
252
<a name="l00218"></a>00218             <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
253
<a name="l00219"></a>00219         <span class="vhdlkeyword">end</span>
254
<a name="l00220"></a>00220         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#ad7e7614ed7fef87f49932689af47bc26">CYC_I</a> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; <a class="code" href="classbus__sd.html#a142a3da1f5773ed79bc9a4127ea123e0">STB_I</a> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; <a class="code" href="classbus__sd.html#abbaba763cf6e2f07ef4d79308026ca10">WE_I</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
255
<a name="l00221"></a>00221             <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
256
<a name="l00222"></a>00222
257
<a name="l00223"></a>00223             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">ADR_I</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">2</span>] == <span class="vhdllogic">2&#39;b00</span>) <span class="vhdlkeyword">begin</span>
258
<a name="l00224"></a>00224                 <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">3</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>] : <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>];
259
<a name="l00225"></a>00225                 <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">2</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>] : <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>];
260
<a name="l00226"></a>00226                 <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">1</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>] : <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>];
261
<a name="l00227"></a>00227                 <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">2</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">2</span>] : <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">2</span>];
262
<a name="l00228"></a>00228             <span class="vhdlkeyword">end</span>
263
<a name="l00229"></a>00229             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">ADR_I</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">2</span>] == <span class="vhdllogic">2&#39;b01</span>) <span class="vhdlkeyword">begin</span>
264
<a name="l00230"></a>00230                 <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">3</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>] : <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>];
265
<a name="l00231"></a>00231                 <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">2</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>] : <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>];
266
<a name="l00232"></a>00232                 <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">1</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>] : <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>];
267
<a name="l00233"></a>00233                 <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] : <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>];
268
<a name="l00234"></a>00234             <span class="vhdlkeyword">end</span>
269
<a name="l00235"></a>00235             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">ADR_I</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">2</span>] == <span class="vhdllogic">2&#39;b10</span>) <span class="vhdlkeyword">begin</span>
270
<a name="l00236"></a>00236                 <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">3</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>] : <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">24</span>];
271
<a name="l00237"></a>00237                 <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">2</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>] : <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">16</span>];
272
<a name="l00238"></a>00238                 <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">1</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>] : <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">8</span>];
273
<a name="l00239"></a>00239                 <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] : <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>];
274
<a name="l00240"></a>00240             <span class="vhdlkeyword">end</span>
275
<a name="l00241"></a>00241             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">ADR_I</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">2</span>] == <span class="vhdllogic">2&#39;b11</span>) <span class="vhdlkeyword">begin</span>
276
<a name="l00242"></a>00242                 <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a>[<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>] &lt;= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a450d6eae3dbd270154ee07549dabaec4">slave_DAT_I</a>[<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>] : <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a>[<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>];
277
<a name="l00243"></a>00243             <span class="vhdlkeyword">end</span>
278
<a name="l00244"></a>00244         <span class="vhdlkeyword">end</span>
279
<a name="l00245"></a>00245         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#ad7e7614ed7fef87f49932689af47bc26">CYC_I</a> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; <a class="code" href="classbus__sd.html#a142a3da1f5773ed79bc9a4127ea123e0">STB_I</a> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; <a class="code" href="classbus__sd.html#abbaba763cf6e2f07ef4d79308026ca10">WE_I</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#af67a3f4d893df58c99e9cf0df11b3003">ADR_I</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">2</span>] == <span class="vhdllogic">2&#39;b00</span>) <span class="vhdlkeyword">begin</span>
280
<a name="l00246"></a>00246             <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
281
<a name="l00247"></a>00247         <span class="vhdlkeyword">end</span>
282
<a name="l00248"></a>00248         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
283
<a name="l00249"></a>00249             <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
284
<a name="l00250"></a>00250         <span class="vhdlkeyword">end</span>
285
<a name="l00251"></a>00251     <span class="vhdlkeyword">end</span>
286
<a name="l00252"></a>00252
287
<a name="l00253"></a>00253 <span class="vhdlkeyword">end</span>
288
<a name="l00254"></a>00254
289
<a name="l00255"></a>00255 <span class="keyword">/***********************************************************************************************************************</span>
290
<a name="l00256"></a>00256 <span class="keyword">                                                      Control state machine</span>
291
<a name="l00257"></a>00257 <span class="keyword"> ***********************************************************************************************************************/</span>
292
<a name="l00258"></a>00258
293
<a name="l00259"></a><a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">00259</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a>;
294
<a name="l00260"></a><a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">00260</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">15</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a>;
295
<a name="l00261"></a><a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">00261</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">2</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a>;
296
<a name="l00262"></a><a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">00262</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">37</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a>;
297
<a name="l00263"></a>00263
298
<a name="l00264"></a><a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">00264</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a>;
299
<a name="l00265"></a><a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">00265</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a>;
300
<a name="l00266"></a><a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">00266</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a>;
301
<a name="l00267"></a>00267
302
<a name="l00268"></a><a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">00268</a> <span class="preprocessor">`define</span> <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">CRC7_REVERSE</a> <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>],<a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">1</span>],<a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">2</span>],<a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">3</span>],<a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">4</span>],<a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">5</span>],<a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>]
303
<a name="l00269"></a>00269
304
<a name="l00270"></a><a class="code" href="classbus__sd.html#a857357404854de264f698ab75a9b3777">00270</a> <span class="vhdlkeyword">parameter</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>]
305
<a name="l00271"></a>00271     <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>         = <span class="vhdllogic">4&#39;d0</span>,
306
<a name="l00272"></a>00272     <a class="code" href="classbus__sd.html#aebb74ba03ead1fc2c6b4c945fa92112d">S_CTRL_CMD0</a>         = <span class="vhdllogic">4&#39;d1</span>,
307
<a name="l00273"></a>00273     <a class="code" href="classbus__sd.html#a08682c661fb9a83979669263c74f5474">S_CTRL_CMD8</a>         = <span class="vhdllogic">4&#39;d2</span>,
308
<a name="l00274"></a>00274     <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a>        = <span class="vhdllogic">4&#39;d3</span>,
309
<a name="l00275"></a>00275     <a class="code" href="classbus__sd.html#adfbaf9794186f1c4d7b320008cd92dfc">S_CTRL_ACMD41</a>       = <span class="vhdllogic">4&#39;d4</span>,
310
<a name="l00276"></a>00276     <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a>         = <span class="vhdllogic">4&#39;d5</span>,
311
<a name="l00277"></a>00277     <a class="code" href="classbus__sd.html#a2366734acfd3297d5f4ebc3f2a568229">S_CTRL_CMD3</a>         = <span class="vhdllogic">4&#39;d6</span>,
312
<a name="l00278"></a>00278     <a class="code" href="classbus__sd.html#a137d67bd720a29db1f7c687b5418b5f0">S_CTRL_CMD7</a>         = <span class="vhdllogic">4&#39;d7</span>,
313
<a name="l00279"></a>00279     <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>     = <span class="vhdllogic">4&#39;d8</span>,
314
<a name="l00280"></a>00280     <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>         = <span class="vhdllogic">4&#39;d9</span>,
315
<a name="l00281"></a>00281     <a class="code" href="classbus__sd.html#ac83f3e28ac9435b053fea3f5a5aefab6">S_CTRL_CMD17_READ</a>   = <span class="vhdllogic">4&#39;d10</span>,
316
<a name="l00282"></a>00282     <a class="code" href="classbus__sd.html#a857357404854de264f698ab75a9b3777">S_CTRL_CMD24_WRITE</a>  = <span class="vhdllogic">4&#39;d11</span>;
317
<a name="l00283"></a>00283
318
<a name="l00284"></a><a class="code" href="classbus__sd.html#a9b15e063dbb64dabc5d2fb1f14060059">00284</a> <span class="vhdlkeyword">parameter</span> [<span class="vhdllogic">2</span>:<span class="vhdllogic">0</span>]
319
<a name="l00285"></a>00285     <a class="code" href="classbus__sd.html#a9520e13b2b7cc9286ed8ee13b57e7f61">STATUS_INIT</a>         = <span class="vhdllogic">3&#39;d0</span>,
320
<a name="l00286"></a>00286     <a class="code" href="classbus__sd.html#ac68c34cb9cc2305411b0a7f070c75115">STATUS_INIT_ERROR</a>   = <span class="vhdllogic">3&#39;d1</span>,
321
<a name="l00287"></a>00287     <a class="code" href="classbus__sd.html#a7051c67ccf2ab73e7b58ab5025c5a309">STATUS_IDLE</a>         = <span class="vhdllogic">3&#39;d2</span>,
322
<a name="l00288"></a>00288     <a class="code" href="classbus__sd.html#a76a8bdb27f3ac49a997add5c4bcda1d9">STATUS_READ</a>         = <span class="vhdllogic">3&#39;d3</span>,
323
<a name="l00289"></a>00289     <a class="code" href="classbus__sd.html#a294f0a9f11a50c707ad32f76465ec117">STATUS_WRITE</a>        = <span class="vhdllogic">3&#39;d4</span>,
324
<a name="l00290"></a>00290     <a class="code" href="classbus__sd.html#a9b15e063dbb64dabc5d2fb1f14060059">STATUS_ERROR</a>        = <span class="vhdllogic">3&#39;d5</span>;
325
<a name="l00291"></a>00291
326
<a name="l00292"></a><a class="code" href="classbus__sd.html#aadd4c7e2554c83f181a137fbc4c3ad96">00292</a> <span class="vhdlkeyword">always</span> @(<span class="vhdlkeyword">posedge</span> <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a> <span class="vhdlkeyword">or</span> <span class="vhdlkeyword">negedge</span> <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>) <span class="vhdlkeyword">begin</span>
327
<a name="l00293"></a>00293     <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
328
<a name="l00294"></a>00294         <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
329
<a name="l00295"></a>00295         <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#a9520e13b2b7cc9286ed8ee13b57e7f61">STATUS_INIT</a>;
330
<a name="l00296"></a>00296         <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= <span class="vhdllogic">38&#39;d0</span>;
331
<a name="l00297"></a>00297         <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
332
<a name="l00298"></a>00298         <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
333
<a name="l00299"></a>00299         <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
334
<a name="l00300"></a>00300         <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
335
<a name="l00301"></a>00301     <span class="vhdlkeyword">end</span>
336
<a name="l00302"></a>00302     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a> &amp;&amp; <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> == <span class="vhdllogic">16&#39;d65535</span>) <span class="vhdlkeyword">begin</span>
337
<a name="l00303"></a>00303         <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#ac68c34cb9cc2305411b0a7f070c75115">STATUS_INIT_ERROR</a>;
338
<a name="l00304"></a>00304
339
<a name="l00305"></a>00305         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> == <a class="code" href="classbus__sd.html#ac9f608398c5aba2e8fa2656c7b63da05">CONTROL_REINIT</a>) <span class="vhdlkeyword">begin</span>
340
<a name="l00306"></a>00306             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
341
<a name="l00307"></a>00307             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
342
<a name="l00308"></a>00308         <span class="vhdlkeyword">end</span>
343
<a name="l00309"></a>00309     <span class="vhdlkeyword">end</span>
344
<a name="l00310"></a>00310     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>) <span class="vhdlkeyword">begin</span>
345
<a name="l00311"></a>00311         <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#a9520e13b2b7cc9286ed8ee13b57e7f61">STATUS_INIT</a>;
346
<a name="l00312"></a>00312
347
<a name="l00313"></a>00313         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
348
<a name="l00314"></a>00314             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
349
<a name="l00315"></a>00315             <span class="keyword">//CMD0, no arguments</span>
350
<a name="l00316"></a>00316             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= { <span class="vhdllogic">6&#39;d0</span>, <span class="vhdllogic">32&#39;d0</span> };
351
<a name="l00317"></a>00317             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#aebb74ba03ead1fc2c6b4c945fa92112d">S_CTRL_CMD0</a>;
352
<a name="l00318"></a>00318         <span class="vhdlkeyword">end</span>
353
<a name="l00319"></a>00319     <span class="vhdlkeyword">end</span>
354
<a name="l00320"></a>00320     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#aebb74ba03ead1fc2c6b4c945fa92112d">S_CTRL_CMD0</a>) <span class="vhdlkeyword">begin</span>
355
<a name="l00321"></a>00321
356
<a name="l00322"></a>00322         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>) <span class="vhdlkeyword">begin</span>
357
<a name="l00323"></a>00323             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
358
<a name="l00324"></a>00324             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
359
<a name="l00325"></a>00325         <span class="vhdlkeyword">end</span>
360
<a name="l00326"></a>00326         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
361
<a name="l00327"></a>00327             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
362
<a name="l00328"></a>00328             <span class="keyword">//CMD8, supply voltage, check pattern</span>
363
<a name="l00329"></a>00329             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= { <span class="vhdllogic">6&#39;d8</span>, <span class="vhdllogic">20&#39;d0</span>, <span class="vhdllogic">4&#39;b0001</span>, <span class="vhdllogic">8&#39;b10101010</span> };
364
<a name="l00330"></a>00330             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a08682c661fb9a83979669263c74f5474">S_CTRL_CMD8</a>;
365
<a name="l00331"></a>00331         <span class="vhdlkeyword">end</span>
366
<a name="l00332"></a>00332         <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
367
<a name="l00333"></a>00333     <span class="vhdlkeyword">end</span>
368
<a name="l00334"></a>00334     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a08682c661fb9a83979669263c74f5474">S_CTRL_CMD8</a>) <span class="vhdlkeyword">begin</span>
369
<a name="l00335"></a>00335         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
370
<a name="l00336"></a>00336             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
371
<a name="l00337"></a>00337         <span class="vhdlkeyword">end</span>
372
<a name="l00338"></a>00338         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
373
<a name="l00339"></a>00339             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;d8</span>, <span class="vhdllogic">20&#39;d0</span>, <span class="vhdllogic">4&#39;b0001</span>, <span class="vhdllogic">8&#39;b10101010</span>, <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1&#39;b1</span> })
374
<a name="l00340"></a>00340         ) <span class="vhdlkeyword">begin</span>
375
<a name="l00341"></a>00341             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
376
<a name="l00342"></a>00342             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
377
<a name="l00343"></a>00343         <span class="vhdlkeyword">end</span>
378
<a name="l00344"></a>00344         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>) <span class="vhdlkeyword">begin</span>
379
<a name="l00345"></a>00345             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
380
<a name="l00346"></a>00346             <span class="keyword">//CMD55, RCA</span>
381
<a name="l00347"></a>00347             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= { <span class="vhdllogic">6&#39;d55</span>, <span class="vhdllogic">16&#39;d0</span>, <span class="vhdllogic">16&#39;d0</span>};
382
<a name="l00348"></a>00348             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a>;
383
<a name="l00349"></a>00349         <span class="vhdlkeyword">end</span>
384
<a name="l00350"></a>00350     <span class="vhdlkeyword">end</span>
385
<a name="l00351"></a>00351     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a>) <span class="vhdlkeyword">begin</span>
386
<a name="l00352"></a>00352         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
387
<a name="l00353"></a>00353             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
388
<a name="l00354"></a>00354         <span class="vhdlkeyword">end</span>
389
<a name="l00355"></a>00355         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
390
<a name="l00356"></a>00356             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp;
391
<a name="l00357"></a>00357                 (<a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">47</span>:<span class="vhdllogic">40</span>] != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;d55</span> } || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">39</span>:<span class="vhdllogic">27</span>] != <span class="vhdllogic">13&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">24</span>:<span class="vhdllogic">21</span>] != <span class="vhdllogic">4&#39;b0</span> ||
392
<a name="l00358"></a>00358                  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">13</span>] != <span class="vhdllogic">1&#39;b1</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] != { <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1&#39;b1</span> }
393
<a name="l00359"></a>00359                 )
394
<a name="l00360"></a>00360             )
395
<a name="l00361"></a>00361         ) <span class="vhdlkeyword">begin</span>
396
<a name="l00362"></a>00362             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
397
<a name="l00363"></a>00363             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
398
<a name="l00364"></a>00364         <span class="vhdlkeyword">end</span>
399
<a name="l00365"></a>00365         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
400
<a name="l00366"></a>00366             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
401
<a name="l00367"></a>00367             <span class="keyword">//ACMD41, </span>
402
<a name="l00368"></a>00368             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= {  <span class="vhdllogic">6&#39;d41</span>,                              <span class="keyword">//command index</span>
403
<a name="l00369"></a>00369                                     <span class="vhdllogic">1&#39;b0</span>,                               <span class="keyword">//reserved bit</span>
404
<a name="l00370"></a>00370                                     <span class="vhdllogic">1&#39;b1</span>,                               <span class="keyword">//host capacity support HCS(OCR[30])</span>
405
<a name="l00371"></a>00371                                     <span class="vhdllogic">6&#39;b0</span>,                               <span class="keyword">//reserved bits</span>
406
<a name="l00372"></a>00372                                     <span class="vhdllogic">24&#39;b0001_0000_0000_0000_0000_0000</span>   <span class="keyword">//VDD voltage window OCR[23:0]</span>
407
<a name="l00373"></a>00373             };
408
<a name="l00374"></a>00374             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#adfbaf9794186f1c4d7b320008cd92dfc">S_CTRL_ACMD41</a>;
409
<a name="l00375"></a>00375         <span class="vhdlkeyword">end</span>
410
<a name="l00376"></a>00376     <span class="vhdlkeyword">end</span>
411
<a name="l00377"></a>00377     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#adfbaf9794186f1c4d7b320008cd92dfc">S_CTRL_ACMD41</a>) <span class="vhdlkeyword">begin</span>
412
<a name="l00378"></a>00378         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
413
<a name="l00379"></a>00379             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
414
<a name="l00380"></a>00380         <span class="vhdlkeyword">end</span>
415
<a name="l00381"></a>00381         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
416
<a name="l00382"></a>00382             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; (<a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">47</span>:<span class="vhdllogic">40</span>] != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;b111111</span> } ||
417
<a name="l00383"></a>00383                 <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">39</span>:<span class="vhdllogic">38</span>] != <span class="vhdllogic">2&#39;b11</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] != {<span class="vhdllogic">7&#39;b1111111</span>, <span class="vhdllogic">1&#39;b1</span> })
418
<a name="l00384"></a>00384             )
419
<a name="l00385"></a>00385         ) <span class="vhdlkeyword">begin</span>
420
<a name="l00386"></a>00386             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> == <span class="vhdllogic">16&#39;d65535</span>) <span class="vhdlkeyword">begin</span>
421
<a name="l00387"></a>00387                 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
422
<a name="l00388"></a>00388             <span class="vhdlkeyword">end</span>
423
<a name="l00389"></a>00389             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
424
<a name="l00390"></a>00390                 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
425
<a name="l00391"></a>00391                 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
426
<a name="l00392"></a>00392                 <span class="keyword">//CMD55, RCA</span>
427
<a name="l00393"></a>00393                 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= { <span class="vhdllogic">6&#39;d55</span>, <span class="vhdllogic">16&#39;d0</span>, <span class="vhdllogic">16&#39;d0</span>};
428
<a name="l00394"></a>00394                 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a>;
429
<a name="l00395"></a>00395             <span class="vhdlkeyword">end</span>
430
<a name="l00396"></a>00396         <span class="vhdlkeyword">end</span>
431
<a name="l00397"></a>00397         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
432
<a name="l00398"></a>00398             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
433
<a name="l00399"></a>00399             <span class="keyword">//CMD2, no arguments</span>
434
<a name="l00400"></a>00400             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= { <span class="vhdllogic">6&#39;d2</span>, <span class="vhdllogic">32&#39;d0</span> };
435
<a name="l00401"></a>00401             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a>;
436
<a name="l00402"></a>00402         <span class="vhdlkeyword">end</span>
437
<a name="l00403"></a>00403     <span class="vhdlkeyword">end</span>
438
<a name="l00404"></a>00404     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a>) <span class="vhdlkeyword">begin</span>
439
<a name="l00405"></a>00405         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
440
<a name="l00406"></a>00406             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
441
<a name="l00407"></a>00407         <span class="vhdlkeyword">end</span>
442
<a name="l00408"></a>00408         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
443
<a name="l00409"></a>00409             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">0</span>] != <span class="vhdllogic">1&#39;b1</span>)
444
<a name="l00410"></a>00410         ) <span class="vhdlkeyword">begin</span>
445
<a name="l00411"></a>00411             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
446
<a name="l00412"></a>00412             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
447
<a name="l00413"></a>00413         <span class="vhdlkeyword">end</span>
448
<a name="l00414"></a>00414         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
449
<a name="l00415"></a>00415             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
450
<a name="l00416"></a>00416             <span class="keyword">//CMD3, no arguments</span>
451
<a name="l00417"></a>00417             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= { <span class="vhdllogic">6&#39;d3</span>, <span class="vhdllogic">32&#39;d0</span> };
452
<a name="l00418"></a>00418             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a2366734acfd3297d5f4ebc3f2a568229">S_CTRL_CMD3</a>;
453
<a name="l00419"></a>00419         <span class="vhdlkeyword">end</span>
454
<a name="l00420"></a>00420     <span class="vhdlkeyword">end</span>
455
<a name="l00421"></a>00421     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a2366734acfd3297d5f4ebc3f2a568229">S_CTRL_CMD3</a>) <span class="vhdlkeyword">begin</span>
456
<a name="l00422"></a>00422         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
457
<a name="l00423"></a>00423             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
458
<a name="l00424"></a>00424         <span class="vhdlkeyword">end</span>
459
<a name="l00425"></a>00425         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
460
<a name="l00426"></a>00426             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp;
461
<a name="l00427"></a>00427                 (<a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">47</span>:<span class="vhdllogic">40</span>] != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;d3</span> } ||
462
<a name="l00428"></a>00428                  <span class="keyword">/*23:8= 23,22,19,12:0 from card status**/</span>
463
<a name="l00429"></a>00429                  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">23</span>:<span class="vhdllogic">21</span>] != <span class="vhdllogic">3&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">13</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1&#39;b0</span> ||
464
<a name="l00430"></a>00430                  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] != { <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1&#39;b1</span> }
465
<a name="l00431"></a>00431                 )
466
<a name="l00432"></a>00432             )
467
<a name="l00433"></a>00433         ) <span class="vhdlkeyword">begin</span>
468
<a name="l00434"></a>00434             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
469
<a name="l00435"></a>00435             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
470
<a name="l00436"></a>00436         <span class="vhdlkeyword">end</span>
471
<a name="l00437"></a>00437         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
472
<a name="l00438"></a>00438
473
<a name="l00439"></a>00439             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
474
<a name="l00440"></a>00440             <span class="keyword">//CMD7, no arguments</span>
475
<a name="l00441"></a>00441             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= {  <span class="vhdllogic">6&#39;d7</span>,               <span class="keyword">//command index</span>
476
<a name="l00442"></a>00442                                     <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">39</span>:<span class="vhdllogic">24</span>],   <span class="keyword">//RCA</span>
477
<a name="l00443"></a>00443                                     <span class="vhdllogic">16&#39;d0</span>               <span class="keyword">//stuff bits</span>
478
<a name="l00444"></a>00444             };
479
<a name="l00445"></a>00445             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a137d67bd720a29db1f7c687b5418b5f0">S_CTRL_CMD7</a>;
480
<a name="l00446"></a>00446         <span class="vhdlkeyword">end</span>
481
<a name="l00447"></a>00447     <span class="vhdlkeyword">end</span>
482
<a name="l00448"></a>00448     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a137d67bd720a29db1f7c687b5418b5f0">S_CTRL_CMD7</a>) <span class="vhdlkeyword">begin</span>
483
<a name="l00449"></a>00449         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
484
<a name="l00450"></a>00450             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
485
<a name="l00451"></a>00451         <span class="vhdlkeyword">end</span>
486
<a name="l00452"></a>00452         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
487
<a name="l00453"></a>00453             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp;
488
<a name="l00454"></a>00454                 (<a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">47</span>:<span class="vhdllogic">40</span>] != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;d7</span> } || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">39</span>:<span class="vhdllogic">27</span>] != <span class="vhdllogic">13&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">24</span>:<span class="vhdllogic">21</span>] != <span class="vhdllogic">4&#39;b0</span> ||
489
<a name="l00455"></a>00455                  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">13</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] != { <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1&#39;b1</span> }
490
<a name="l00456"></a>00456                 )
491
<a name="l00457"></a>00457             )
492
<a name="l00458"></a>00458         ) <span class="vhdlkeyword">begin</span>
493
<a name="l00459"></a>00459             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
494
<a name="l00460"></a>00460             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
495
<a name="l00461"></a>00461         <span class="vhdlkeyword">end</span>
496
<a name="l00462"></a>00462         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
497
<a name="l00463"></a>00463             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
498
<a name="l00464"></a>00464
499
<a name="l00465"></a>00465             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
500
<a name="l00466"></a>00466             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
501
<a name="l00467"></a>00467         <span class="vhdlkeyword">end</span>
502
<a name="l00468"></a>00468     <span class="vhdlkeyword">end</span>
503
<a name="l00469"></a>00469     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>) <span class="vhdlkeyword">begin</span>
504
<a name="l00470"></a>00470         <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
505
<a name="l00471"></a>00471
506
<a name="l00472"></a>00472         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> == <span class="vhdllogic">1&#39;b1</span>) <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d65535</span>;
507
<a name="l00473"></a>00473     <span class="vhdlkeyword">end</span>
508
<a name="l00474"></a>00474     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> != <span class="vhdllogic">16&#39;d0</span>) <span class="vhdlkeyword">begin</span>
509
<a name="l00475"></a>00475         <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#a9b15e063dbb64dabc5d2fb1f14060059">STATUS_ERROR</a>;
510
<a name="l00476"></a>00476
511
<a name="l00477"></a>00477         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> == <a class="code" href="classbus__sd.html#a0d6a1a0bbfc5f191b4d1766784dcdeb4">CONTROL_IDLE</a>) <span class="vhdlkeyword">begin</span>
512
<a name="l00478"></a>00478             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
513
<a name="l00479"></a>00479             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
514
<a name="l00480"></a>00480         <span class="vhdlkeyword">end</span>
515
<a name="l00481"></a>00481         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> == <a class="code" href="classbus__sd.html#ac9f608398c5aba2e8fa2656c7b63da05">CONTROL_REINIT</a>) <span class="vhdlkeyword">begin</span>
516
<a name="l00482"></a>00482             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>;
517
<a name="l00483"></a>00483             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
518
<a name="l00484"></a>00484         <span class="vhdlkeyword">end</span>
519
<a name="l00485"></a>00485     <span class="vhdlkeyword">end</span>
520
<a name="l00486"></a>00486     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>) <span class="vhdlkeyword">begin</span>
521
<a name="l00487"></a>00487         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> == <a class="code" href="classbus__sd.html#ac41ad9206f43eee68311ac70795c6d56">CONTROL_READ</a> &amp;&amp; <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> != <span class="vhdllogic">32&#39;d0</span>) <span class="vhdlkeyword">begin</span>
522
<a name="l00488"></a>00488             <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#a76a8bdb27f3ac49a997add5c4bcda1d9">STATUS_READ</a>;
523
<a name="l00489"></a>00489             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
524
<a name="l00490"></a>00490             <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
525
<a name="l00491"></a>00491             <span class="keyword">//CMD17, sector address</span>
526
<a name="l00492"></a>00492             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= {  <span class="vhdllogic">6&#39;d17</span>,              <span class="keyword">//command index</span>
527
<a name="l00493"></a>00493                                     <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>]    <span class="keyword">//sector address</span>
528
<a name="l00494"></a>00494             };
529
<a name="l00495"></a>00495             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#ac83f3e28ac9435b053fea3f5a5aefab6">S_CTRL_CMD17_READ</a>;
530
<a name="l00496"></a>00496         <span class="vhdlkeyword">end</span>
531
<a name="l00497"></a>00497         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> == <a class="code" href="classbus__sd.html#a93a7de63cfcce62192aac0c31cc0e3a3">CONTROL_WRITE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> != <span class="vhdllogic">32&#39;d0</span>) <span class="vhdlkeyword">begin</span>
532
<a name="l00498"></a>00498             <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#a294f0a9f11a50c707ad32f76465ec117">STATUS_WRITE</a>;
533
<a name="l00499"></a>00499             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
534
<a name="l00500"></a>00500             <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
535
<a name="l00501"></a>00501             <span class="keyword">//CMD24, sector address</span>
536
<a name="l00502"></a>00502             <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> &lt;= {  <span class="vhdllogic">6&#39;d24</span>,              <span class="keyword">//command index</span>
537
<a name="l00503"></a>00503                                     <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>]    <span class="keyword">//sector address</span>
538
<a name="l00504"></a>00504             };
539
<a name="l00505"></a>00505             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a857357404854de264f698ab75a9b3777">S_CTRL_CMD24_WRITE</a>;
540
<a name="l00506"></a>00506         <span class="vhdlkeyword">end</span>
541
<a name="l00507"></a>00507         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
542
<a name="l00508"></a>00508             <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> &lt;= <a class="code" href="classbus__sd.html#a7051c67ccf2ab73e7b58ab5025c5a309">STATUS_IDLE</a>;
543
<a name="l00509"></a>00509         <span class="vhdlkeyword">end</span>
544
<a name="l00510"></a>00510     <span class="vhdlkeyword">end</span>
545
<a name="l00511"></a>00511     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#ac83f3e28ac9435b053fea3f5a5aefab6">S_CTRL_CMD17_READ</a>) <span class="vhdlkeyword">begin</span>
546
<a name="l00512"></a>00512         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
547
<a name="l00513"></a>00513             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
548
<a name="l00514"></a>00514         <span class="vhdlkeyword">end</span>
549
<a name="l00515"></a>00515         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
550
<a name="l00516"></a>00516             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp;
551
<a name="l00517"></a>00517                 (<a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">47</span>:<span class="vhdllogic">40</span>] != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;d17</span> } || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">39</span>:<span class="vhdllogic">27</span>] != <span class="vhdllogic">13&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">24</span>:<span class="vhdllogic">21</span>] != <span class="vhdllogic">4&#39;b0</span> ||
552
<a name="l00518"></a>00518                  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">13</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] != { <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1&#39;b1</span> }
553
<a name="l00519"></a>00519                 )
554
<a name="l00520"></a>00520             )
555
<a name="l00521"></a>00521         ) <span class="vhdlkeyword">begin</span>
556
<a name="l00522"></a>00522             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
557
<a name="l00523"></a>00523             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
558
<a name="l00524"></a>00524         <span class="vhdlkeyword">end</span>
559
<a name="l00525"></a>00525         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
560
<a name="l00526"></a>00526             <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
561
<a name="l00527"></a>00527         <span class="vhdlkeyword">end</span>
562
<a name="l00528"></a>00528         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>) <span class="vhdlkeyword">begin</span>
563
<a name="l00529"></a>00529             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
564
<a name="l00530"></a>00530             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
565
<a name="l00531"></a>00531         <span class="vhdlkeyword">end</span>
566
<a name="l00532"></a>00532         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>) <span class="vhdlkeyword">begin</span>
567
<a name="l00533"></a>00533             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
568
<a name="l00534"></a>00534             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>;
569
<a name="l00535"></a>00535         <span class="vhdlkeyword">end</span>
570
<a name="l00536"></a>00536     <span class="vhdlkeyword">end</span>
571
<a name="l00537"></a>00537     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a857357404854de264f698ab75a9b3777">S_CTRL_CMD24_WRITE</a>) <span class="vhdlkeyword">begin</span>
572
<a name="l00538"></a>00538         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
573
<a name="l00539"></a>00539             <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
574
<a name="l00540"></a>00540         <span class="vhdlkeyword">end</span>
575
<a name="l00541"></a>00541         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> ||
576
<a name="l00542"></a>00542             (<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp;
577
<a name="l00543"></a>00543                 (<a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">47</span>:<span class="vhdllogic">40</span>] != { <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">1&#39;b0</span>, <span class="vhdllogic">6&#39;d24</span> } || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">39</span>:<span class="vhdllogic">27</span>] != <span class="vhdllogic">13&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">24</span>:<span class="vhdllogic">21</span>] != <span class="vhdllogic">4&#39;b0</span> ||
578
<a name="l00544"></a>00544                  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">13</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1&#39;b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>] != { <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1&#39;b1</span> }
579
<a name="l00545"></a>00545                 )
580
<a name="l00546"></a>00546             )
581
<a name="l00547"></a>00547         ) <span class="vhdlkeyword">begin</span>
582
<a name="l00548"></a>00548             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
583
<a name="l00549"></a>00549             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
584
<a name="l00550"></a>00550         <span class="vhdlkeyword">end</span>
585
<a name="l00551"></a>00551         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
586
<a name="l00552"></a>00552             <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
587
<a name="l00553"></a>00553         <span class="vhdlkeyword">end</span>
588
<a name="l00554"></a>00554         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>) <span class="vhdlkeyword">begin</span>
589
<a name="l00555"></a>00555             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16&#39;d1</span>;
590
<a name="l00556"></a>00556             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>;
591
<a name="l00557"></a>00557         <span class="vhdlkeyword">end</span>
592
<a name="l00558"></a>00558         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>) <span class="vhdlkeyword">begin</span>
593
<a name="l00559"></a>00559             <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
594
<a name="l00560"></a>00560             <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> &lt;= <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>;
595
<a name="l00561"></a>00561         <span class="vhdlkeyword">end</span>
596
<a name="l00562"></a>00562     <span class="vhdlkeyword">end</span>
597
<a name="l00563"></a>00563 <span class="vhdlkeyword">end</span>
598
<a name="l00564"></a>00564
599
<a name="l00565"></a>00565 <span class="keyword">/***********************************************************************************************************************</span>
600
<a name="l00566"></a>00566 <span class="keyword">                                                      SD interface</span>
601
<a name="l00567"></a>00567 <span class="keyword"> ***********************************************************************************************************************/</span>
602
<a name="l00568"></a>00568
603
<a name="l00569"></a><a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">00569</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> = <span class="vhdllogic">1&#39;b1</span>;
604
<a name="l00570"></a><a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">00570</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> = <span class="vhdllogic">1&#39;b1</span>;
605
<a name="l00571"></a>00571
606
<a name="l00572"></a>00572 <span class="vhdlkeyword">assign</span> <span class="vhdlchar">sd_cmd_io</span> = (<a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> : <span class="vhdllogic">1&#39;bZ</span>;
607
<a name="l00573"></a>00573 <span class="vhdlkeyword">assign</span> <span class="vhdlchar">sd_dat_io</span> = (<a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a> == <span class="vhdllogic">1&#39;b1</span>) ? <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> : <span class="vhdllogic">1&#39;bZ</span>;
608
<a name="l00574"></a>00574
609
<a name="l00575"></a>00575 <span class="keyword">//CID register not interpreted: CRC7 not checked, always accepted</span>
610
<a name="l00576"></a>00576
611
<a name="l00577"></a>00577 <span class="keyword">//---------------------------------------------------- SD data</span>
612
<a name="l00578"></a>00578
613
<a name="l00579"></a><a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">00579</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a>;
614
<a name="l00580"></a><a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">00580</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a>;
615
<a name="l00581"></a><a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">00581</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">23</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a>;
616
<a name="l00582"></a><a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">00582</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">6</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a>;
617
<a name="l00583"></a><a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">00583</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">15</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>;
618
<a name="l00584"></a><a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">00584</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">31</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>;
619
<a name="l00585"></a><a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">00585</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a>;
620
<a name="l00586"></a><a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">00586</a> <span class="vhdlkeyword">reg</span> <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a>;
621
<a name="l00587"></a>00587
622
<a name="l00588"></a><a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">00588</a> <span class="vhdlkeyword">parameter</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>]
623
<a name="l00589"></a>00589     <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>                                 = <span class="vhdllogic">4&#39;d0</span>,
624
<a name="l00590"></a>00590     <a class="code" href="classbus__sd.html#a13360617ecec417078b97acf8f2c8569">S_DATA_READ_START_BIT</a>                       = <span class="vhdllogic">4&#39;d1</span>,
625
<a name="l00591"></a>00591     <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a>                        = <span class="vhdllogic">4&#39;d2</span>,
626
<a name="l00592"></a>00592     <a class="code" href="classbus__sd.html#ada04262d8cb516a835ee25a3d9508830">S_DATA_READ_READY_PART</a>                      = <span class="vhdllogic">4&#39;d3</span>,
627
<a name="l00593"></a>00593     <a class="code" href="classbus__sd.html#a3e69ea7fb13e27a8dbdeb4fcebfbefae">S_DATA_READ_READY_PART_CONTINUE</a>             = <span class="vhdllogic">4&#39;d4</span>,
628
<a name="l00594"></a>00594     <a class="code" href="classbus__sd.html#a4b6a23ae8c7568c44bafba26bb66927e">S_DATA_READ_CRC16_END_BIT</a>                   = <span class="vhdllogic">4&#39;d5</span>,
629
<a name="l00595"></a>00595     <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>                           = <span class="vhdllogic">4&#39;d6</span>,
630
<a name="l00596"></a>00596     <a class="code" href="classbus__sd.html#acc2add7bba173a332d2002ad6989104f">S_DATA_WRITE_START_BIT</a>                      = <span class="vhdllogic">4&#39;d7</span>,
631
<a name="l00597"></a>00597     <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a>                     = <span class="vhdllogic">4&#39;d8</span>,
632
<a name="l00598"></a>00598     <a class="code" href="classbus__sd.html#a67f329d2cdf17104d88caf50ae248e02">S_DATA_WRITE_CONTENTS</a>                       = <span class="vhdllogic">4&#39;d9</span>,
633
<a name="l00599"></a>00599     <a class="code" href="classbus__sd.html#ad382b24aadcd85390a7fb27cc51c383c">S_DATA_WRITE_CRC16_END_BIT</a>                  = <span class="vhdllogic">4&#39;d10</span>,
634
<a name="l00600"></a>00600     <a class="code" href="classbus__sd.html#a2c25dd2a683085e8a751541ed382d740">S_DATA_WRITE_CRC_STATUS_START</a>               = <span class="vhdllogic">4&#39;d11</span>,
635
<a name="l00601"></a>00601     <a class="code" href="classbus__sd.html#a3e9d11bcf9e359c6b30bdbefc5bcec07">S_DATA_WRITE_CRC_STATUS_CONTENTS_END_BIT</a>    = <span class="vhdllogic">4&#39;d12</span>,
636
<a name="l00602"></a>00602     <a class="code" href="classbus__sd.html#a5e0b4025c9ad8522892dbec69bf590f1">S_DATA_WRITE_BUSY_START</a>                     = <span class="vhdllogic">4&#39;d13</span>,
637
<a name="l00603"></a>00603     <a class="code" href="classbus__sd.html#a96506aa2492a1ec2a65ce5168b54bb14">S_DATA_WRITE_BUSY_WAIT</a>                      = <span class="vhdllogic">4&#39;d14</span>,
638
<a name="l00604"></a>00604     <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>                          = <span class="vhdllogic">4&#39;d15</span>;
639
<a name="l00605"></a>00605
640
<a name="l00606"></a>00606
641
<a name="l00607"></a><a class="code" href="classbus__sd.html#ade1b248784d3704e0b47d8c6c027297f">00607</a> <span class="vhdlkeyword">always</span> @(<span class="vhdlkeyword">posedge</span> <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a> <span class="vhdlkeyword">or</span> <span class="vhdlkeyword">negedge</span> <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>) <span class="vhdlkeyword">begin</span>
642
<a name="l00608"></a>00608     <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
643
<a name="l00609"></a>00609         <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a>  &lt;= <span class="vhdllogic">1&#39;b0</span>;
644
<a name="l00610"></a>00610         <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a>      &lt;= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>;
645
<a name="l00611"></a>00611         <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a>    &lt;= <span class="vhdllogic">24&#39;d0</span>;
646
<a name="l00612"></a>00612         <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a>    &lt;= <span class="vhdllogic">7&#39;d0</span>;
647
<a name="l00613"></a>00613         <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>           &lt;= <span class="vhdllogic">16&#39;d0</span>;
648
<a name="l00614"></a>00614         <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>       &lt;= <span class="vhdllogic">32&#39;d0</span>;
649
<a name="l00615"></a>00615         <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a>    &lt;= <span class="vhdllogic">1&#39;b0</span>;
650
<a name="l00616"></a>00616         <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a>  &lt;= <span class="vhdllogic">1&#39;b1</span>;
651
<a name="l00617"></a>00617         <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a>        &lt;= <span class="vhdllogic">1&#39;b1</span>;
652
<a name="l00618"></a>00618     <span class="vhdlkeyword">end</span>
653
<a name="l00619"></a>00619     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>) <span class="vhdlkeyword">begin</span>
654
<a name="l00620"></a>00620         <span class="keyword">//do not wait for read command and reply</span>
655
<a name="l00621"></a>00621         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
656
<a name="l00622"></a>00622             <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a13360617ecec417078b97acf8f2c8569">S_DATA_READ_START_BIT</a>;
657
<a name="l00623"></a>00623         <span class="vhdlkeyword">end</span>
658
<a name="l00624"></a>00624         <span class="keyword">//wait for write command and reply</span>
659
<a name="l00625"></a>00625         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b0</span> &amp;&amp; <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>) <span class="vhdlkeyword">begin</span>
660
<a name="l00626"></a>00626             <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#acc2add7bba173a332d2002ad6989104f">S_DATA_WRITE_START_BIT</a>;
661
<a name="l00627"></a>00627         <span class="vhdlkeyword">end</span>
662
<a name="l00628"></a>00628     <span class="vhdlkeyword">end</span>
663
<a name="l00629"></a>00629     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> == <span class="vhdllogic">2&#39;d0</span>) <span class="vhdlkeyword">begin</span>
664
<a name="l00630"></a>00630
665
<a name="l00631"></a>00631         <span class="keyword">//wait for response and data simultaneously (data read)</span>
666
<a name="l00632"></a>00632         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a13360617ecec417078b97acf8f2c8569">S_DATA_READ_START_BIT</a>) <span class="vhdlkeyword">begin</span>
667
<a name="l00633"></a>00633             <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
668
<a name="l00634"></a>00634
669
<a name="l00635"></a>00635             <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
670
<a name="l00636"></a>00636                 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= { <span class="vhdlchar">sd_dat_io</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">12</span>], <span class="vhdlchar">sd_dat_io</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">11</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">10</span>:<span class="vhdllogic">5</span>],
671
<a name="l00637"></a>00637                     <span class="vhdlchar">sd_dat_io</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
672
<a name="l00638"></a>00638
673
<a name="l00639"></a>00639                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a>;
674
<a name="l00640"></a>00640                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
675
<a name="l00641"></a>00641             <span class="vhdlkeyword">end</span>
676
<a name="l00642"></a>00642             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d65535</span>) <span class="vhdlkeyword">begin</span>
677
<a name="l00643"></a>00643                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>;
678
<a name="l00644"></a>00644                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
679
<a name="l00645"></a>00645             <span class="vhdlkeyword">end</span>
680
<a name="l00646"></a>00646             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
681
<a name="l00647"></a>00647         <span class="vhdlkeyword">end</span>
682
<a name="l00648"></a>00648         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a>) <span class="vhdlkeyword">begin</span>
683
<a name="l00649"></a>00649             <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= { <span class="vhdlchar">sd_dat_io</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">12</span>], <span class="vhdlchar">sd_dat_io</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">11</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>],
684
<a name="l00650"></a>00650                 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">10</span>:<span class="vhdllogic">5</span>], <span class="vhdlchar">sd_dat_io</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
685
<a name="l00651"></a>00651             <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> &lt;= { <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">30</span>:<span class="vhdllogic">0</span>], <span class="vhdlchar">sd_dat_io</span> };
686
<a name="l00652"></a>00652
687
<a name="l00653"></a>00653             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d30</span>) <span class="vhdlkeyword">begin</span>
688
<a name="l00654"></a>00654                 <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
689
<a name="l00655"></a>00655                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
690
<a name="l00656"></a>00656             <span class="vhdlkeyword">end</span>
691
<a name="l00657"></a>00657             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d31</span>) <span class="vhdlkeyword">begin</span>
692
<a name="l00658"></a>00658                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#ada04262d8cb516a835ee25a3d9508830">S_DATA_READ_READY_PART</a>;
693
<a name="l00659"></a>00659                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
694
<a name="l00660"></a>00660             <span class="vhdlkeyword">end</span>
695
<a name="l00661"></a>00661             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
696
<a name="l00662"></a>00662         <span class="vhdlkeyword">end</span>
697
<a name="l00663"></a>00663         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#ada04262d8cb516a835ee25a3d9508830">S_DATA_READ_READY_PART</a>) <span class="vhdlkeyword">begin</span>
698
<a name="l00664"></a>00664             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
699
<a name="l00665"></a>00665                 <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
700
<a name="l00666"></a>00666                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a3e69ea7fb13e27a8dbdeb4fcebfbefae">S_DATA_READ_READY_PART_CONTINUE</a>;
701
<a name="l00667"></a>00667             <span class="vhdlkeyword">end</span>
702
<a name="l00668"></a>00668         <span class="vhdlkeyword">end</span>
703
<a name="l00669"></a>00669         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a3e69ea7fb13e27a8dbdeb4fcebfbefae">S_DATA_READ_READY_PART_CONTINUE</a>) <span class="vhdlkeyword">begin</span>
704
<a name="l00670"></a>00670             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> == <span class="vhdllogic">7&#39;d127</span>) <span class="vhdlkeyword">begin</span>
705
<a name="l00671"></a>00671                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a4b6a23ae8c7568c44bafba26bb66927e">S_DATA_READ_CRC16_END_BIT</a>;
706
<a name="l00672"></a>00672                 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> &lt;= <span class="vhdllogic">7&#39;d0</span>;
707
<a name="l00673"></a>00673             <span class="vhdlkeyword">end</span>
708
<a name="l00674"></a>00674             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
709
<a name="l00675"></a>00675                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a>;
710
<a name="l00676"></a>00676                 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> &lt;= <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> + <span class="vhdllogic">7&#39;d1</span>;
711
<a name="l00677"></a>00677             <span class="vhdlkeyword">end</span>
712
<a name="l00678"></a>00678         <span class="vhdlkeyword">end</span>
713
<a name="l00679"></a>00679         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a4b6a23ae8c7568c44bafba26bb66927e">S_DATA_READ_CRC16_END_BIT</a>) <span class="vhdlkeyword">begin</span>
714
<a name="l00680"></a>00680             <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> &lt;= { <span class="vhdlchar">sd_dat_io</span>, <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">1</span>] };
715
<a name="l00681"></a>00681
716
<a name="l00682"></a>00682             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d16</span>) <span class="vhdlkeyword">begin</span>
717
<a name="l00683"></a>00683                 <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>:<span class="vhdllogic">16</span>] != <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">0</span>] || <span class="vhdlchar">sd_dat_io</span> != <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
718
<a name="l00684"></a>00684                     <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>;
719
<a name="l00685"></a>00685                     <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
720
<a name="l00686"></a>00686                 <span class="vhdlkeyword">end</span>
721
<a name="l00687"></a>00687                 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
722
<a name="l00688"></a>00688                     <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
723
<a name="l00689"></a>00689                     <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>;
724
<a name="l00690"></a>00690                     <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
725
<a name="l00691"></a>00691                     <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
726
<a name="l00692"></a>00692                 <span class="vhdlkeyword">end</span>
727
<a name="l00693"></a>00693             <span class="vhdlkeyword">end</span>
728
<a name="l00694"></a>00694             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
729
<a name="l00695"></a>00695         <span class="vhdlkeyword">end</span>
730
<a name="l00696"></a>00696         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>) <span class="vhdlkeyword">begin</span>
731
<a name="l00697"></a>00697             <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
732
<a name="l00698"></a>00698             <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>;
733
<a name="l00699"></a>00699             <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
734
<a name="l00700"></a>00700             <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
735
<a name="l00701"></a>00701         <span class="vhdlkeyword">end</span>
736
<a name="l00702"></a>00702
737
<a name="l00703"></a>00703         <span class="keyword">//send data on data line, wait for crc status, wait while busy on data line (data write)</span>
738
<a name="l00704"></a>00704         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#acc2add7bba173a332d2002ad6989104f">S_DATA_WRITE_START_BIT</a>) <span class="vhdlkeyword">begin</span>
739
<a name="l00705"></a>00705             <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
740
<a name="l00706"></a>00706             <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= { <span class="vhdllogic">1&#39;b0</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">12</span>], <span class="vhdllogic">1&#39;b0</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">11</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">10</span>:<span class="vhdllogic">5</span>],
741
<a name="l00707"></a>00707                 <span class="vhdllogic">1&#39;b0</span> ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
742
<a name="l00708"></a>00708
743
<a name="l00709"></a>00709             <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
744
<a name="l00710"></a>00710             <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
745
<a name="l00711"></a>00711             <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
746
<a name="l00712"></a>00712             <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a>;
747
<a name="l00713"></a>00713         <span class="vhdlkeyword">end</span>
748
<a name="l00714"></a>00714         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a>) <span class="vhdlkeyword">begin</span>
749
<a name="l00715"></a>00715
750
<a name="l00716"></a>00716             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
751
<a name="l00717"></a>00717                 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
752
<a name="l00718"></a>00718                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a67f329d2cdf17104d88caf50ae248e02">S_DATA_WRITE_CONTENTS</a>;
753
<a name="l00719"></a>00719                 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> &lt;= <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a>;
754
<a name="l00720"></a>00720             <span class="vhdlkeyword">end</span>
755
<a name="l00721"></a>00721             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
756
<a name="l00722"></a>00722                 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
757
<a name="l00723"></a>00723             <span class="vhdlkeyword">end</span>
758
<a name="l00724"></a>00724         <span class="vhdlkeyword">end</span>
759
<a name="l00725"></a>00725         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a67f329d2cdf17104d88caf50ae248e02">S_DATA_WRITE_CONTENTS</a>) <span class="vhdlkeyword">begin</span>
760
<a name="l00726"></a>00726             <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> &lt;= <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>];
761
<a name="l00727"></a>00727             <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= { <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">12</span>], <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">11</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">10</span>:<span class="vhdllogic">5</span>],
762
<a name="l00728"></a>00728                 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
763
<a name="l00729"></a>00729             <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> &lt;= { <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">30</span>:<span class="vhdllogic">0</span>], <span class="vhdllogic">1&#39;b0</span> };
764
<a name="l00730"></a>00730
765
<a name="l00731"></a>00731             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d31</span>) <span class="vhdlkeyword">begin</span>
766
<a name="l00732"></a>00732                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
767
<a name="l00733"></a>00733
768
<a name="l00734"></a>00734                 <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> == <span class="vhdllogic">7&#39;d127</span>) <span class="vhdlkeyword">begin</span>
769
<a name="l00735"></a>00735                     <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> &lt;= <span class="vhdllogic">7&#39;d0</span>;
770
<a name="l00736"></a>00736                     <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#ad382b24aadcd85390a7fb27cc51c383c">S_DATA_WRITE_CRC16_END_BIT</a>;
771
<a name="l00737"></a>00737                 <span class="vhdlkeyword">end</span>
772
<a name="l00738"></a>00738                 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
773
<a name="l00739"></a>00739                     <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
774
<a name="l00740"></a>00740                     <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> &lt;= <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> + <span class="vhdllogic">7&#39;d1</span>;
775
<a name="l00741"></a>00741                     <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a>;
776
<a name="l00742"></a>00742                 <span class="vhdlkeyword">end</span>
777
<a name="l00743"></a>00743             <span class="vhdlkeyword">end</span>
778
<a name="l00744"></a>00744             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
779
<a name="l00745"></a>00745         <span class="vhdlkeyword">end</span>
780
<a name="l00746"></a>00746
781
<a name="l00747"></a>00747         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#ad382b24aadcd85390a7fb27cc51c383c">S_DATA_WRITE_CRC16_END_BIT</a>) <span class="vhdlkeyword">begin</span>
782
<a name="l00748"></a>00748             <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> &lt;= <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>];
783
<a name="l00749"></a>00749
784
<a name="l00750"></a>00750             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d16</span>) <span class="vhdlkeyword">begin</span>
785
<a name="l00751"></a>00751                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
786
<a name="l00752"></a>00752                 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= <span class="vhdllogic">16&#39;d0</span>;
787
<a name="l00753"></a>00753                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a2c25dd2a683085e8a751541ed382d740">S_DATA_WRITE_CRC_STATUS_START</a>;
788
<a name="l00754"></a>00754             <span class="vhdlkeyword">end</span>
789
<a name="l00755"></a>00755             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
790
<a name="l00756"></a>00756                 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> &lt;= { <span class="vhdllogic">1&#39;b1</span>, <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">1</span>] };
791
<a name="l00757"></a>00757                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
792
<a name="l00758"></a>00758             <span class="vhdlkeyword">end</span>
793
<a name="l00759"></a>00759
794
<a name="l00760"></a>00760         <span class="vhdlkeyword">end</span>
795
<a name="l00761"></a>00761         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a2c25dd2a683085e8a751541ed382d740">S_DATA_WRITE_CRC_STATUS_START</a>) <span class="vhdlkeyword">begin</span>
796
<a name="l00762"></a>00762             <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
797
<a name="l00763"></a>00763
798
<a name="l00764"></a>00764             <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
799
<a name="l00765"></a>00765                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a3e9d11bcf9e359c6b30bdbefc5bcec07">S_DATA_WRITE_CRC_STATUS_CONTENTS_END_BIT</a>;
800
<a name="l00766"></a>00766                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;b0</span>;
801
<a name="l00767"></a>00767             <span class="vhdlkeyword">end</span>
802
<a name="l00768"></a>00768             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d65535</span>) <span class="vhdlkeyword">begin</span>
803
<a name="l00769"></a>00769                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>;
804
<a name="l00770"></a>00770                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;b0</span>;
805
<a name="l00771"></a>00771             <span class="vhdlkeyword">end</span>
806
<a name="l00772"></a>00772             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
807
<a name="l00773"></a>00773         <span class="vhdlkeyword">end</span>
808
<a name="l00774"></a>00774
809
<a name="l00775"></a>00775         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a3e9d11bcf9e359c6b30bdbefc5bcec07">S_DATA_WRITE_CRC_STATUS_CONTENTS_END_BIT</a>) <span class="vhdlkeyword">begin</span>
810
<a name="l00776"></a>00776             <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> &lt;= { <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">30</span>:<span class="vhdllogic">0</span>], <span class="vhdlchar">sd_dat_io</span> };
811
<a name="l00777"></a>00777
812
<a name="l00778"></a>00778             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d3</span>) <span class="vhdlkeyword">begin</span>
813
<a name="l00779"></a>00779                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a5e0b4025c9ad8522892dbec69bf590f1">S_DATA_WRITE_BUSY_START</a>;
814
<a name="l00780"></a>00780                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;b0</span>;
815
<a name="l00781"></a>00781             <span class="vhdlkeyword">end</span>
816
<a name="l00782"></a>00782             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
817
<a name="l00783"></a>00783         <span class="vhdlkeyword">end</span>
818
<a name="l00784"></a>00784         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a5e0b4025c9ad8522892dbec69bf590f1">S_DATA_WRITE_BUSY_START</a>) <span class="vhdlkeyword">begin</span>
819
<a name="l00785"></a>00785
820
<a name="l00786"></a>00786             <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
821
<a name="l00787"></a>00787                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a96506aa2492a1ec2a65ce5168b54bb14">S_DATA_WRITE_BUSY_WAIT</a>;
822
<a name="l00788"></a>00788                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;b0</span>;
823
<a name="l00789"></a>00789             <span class="vhdlkeyword">end</span>
824
<a name="l00790"></a>00790             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;d65535</span>) <span class="vhdlkeyword">begin</span>
825
<a name="l00791"></a>00791                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>;
826
<a name="l00792"></a>00792                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;b0</span>;
827
<a name="l00793"></a>00793             <span class="vhdlkeyword">end</span>
828
<a name="l00794"></a>00794             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
829
<a name="l00795"></a>00795         <span class="vhdlkeyword">end</span>
830
<a name="l00796"></a>00796         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#a96506aa2492a1ec2a65ce5168b54bb14">S_DATA_WRITE_BUSY_WAIT</a>) <span class="vhdlkeyword">begin</span>
831
<a name="l00797"></a>00797             <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>] != <span class="vhdllogic">4&#39;b0101</span>) <span class="vhdlkeyword">begin</span>
832
<a name="l00798"></a>00798                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>;
833
<a name="l00799"></a>00799                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
834
<a name="l00800"></a>00800             <span class="vhdlkeyword">end</span>
835
<a name="l00801"></a>00801             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
836
<a name="l00802"></a>00802                 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
837
<a name="l00803"></a>00803                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>;
838
<a name="l00804"></a>00804                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
839
<a name="l00805"></a>00805             <span class="vhdlkeyword">end</span>
840
<a name="l00806"></a>00806             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> == <span class="vhdllogic">24&#39;hFFFFFF</span>) <span class="vhdlkeyword">begin</span>
841
<a name="l00807"></a>00807                 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>;
842
<a name="l00808"></a>00808                 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
843
<a name="l00809"></a>00809             <span class="vhdlkeyword">end</span>
844
<a name="l00810"></a>00810             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24&#39;d1</span>;
845
<a name="l00811"></a>00811         <span class="vhdlkeyword">end</span>
846
<a name="l00812"></a>00812         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> == <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>) <span class="vhdlkeyword">begin</span>
847
<a name="l00813"></a>00813             <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
848
<a name="l00814"></a>00814             <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> &lt;= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>;
849
<a name="l00815"></a>00815             <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> &lt;= <span class="vhdllogic">24&#39;d0</span>;
850
<a name="l00816"></a>00816         <span class="vhdlkeyword">end</span>
851
<a name="l00817"></a>00817     <span class="vhdlkeyword">end</span>
852
<a name="l00818"></a>00818 <span class="vhdlkeyword">end</span>
853
<a name="l00819"></a>00819
854
<a name="l00820"></a>00820 <span class="keyword">//---------------------------------------------------- SD command</span>
855
<a name="l00821"></a>00821
856
<a name="l00822"></a><a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">00822</a> <span class="vhdlkeyword">reg</span>         <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a>;
857
<a name="l00823"></a><a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">00823</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">37</span>:<span class="vhdllogic">0</span>]  <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>;
858
<a name="l00824"></a><a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">00824</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">47</span>:<span class="vhdllogic">0</span>]  <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>;
859
<a name="l00825"></a><a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">00825</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>]   <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a>;
860
<a name="l00826"></a><a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">00826</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">7</span>:<span class="vhdllogic">0</span>]   <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a>;
861
<a name="l00827"></a><a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">00827</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">6</span>:<span class="vhdllogic">0</span>]   <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>;
862
<a name="l00828"></a><a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">00828</a> <span class="vhdlkeyword">reg</span>         <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a>;
863
<a name="l00829"></a>00829
864
<a name="l00830"></a><a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">00830</a> <span class="vhdlkeyword">parameter</span> [<span class="vhdllogic">3</span>:<span class="vhdllogic">0</span>]
865
<a name="l00831"></a>00831     <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>                  = <span class="vhdllogic">4&#39;d0</span>,
866
<a name="l00832"></a>00832     <a class="code" href="classbus__sd.html#a31d633d4b817944615ad58ab12c65a37">S_CMD_SEND_START_ONES</a>       = <span class="vhdllogic">4&#39;d1</span>,
867
<a name="l00833"></a>00833     <a class="code" href="classbus__sd.html#aedddfe3e69609bd1498be9b0d5e62dd2">S_CMD_SEND_START_BIT</a>        = <span class="vhdllogic">4&#39;d2</span>,
868
<a name="l00834"></a>00834     <a class="code" href="classbus__sd.html#a1108e27b7c52cd7b7e381406eac784de">S_CMD_SEND_START_HOST</a>       = <span class="vhdllogic">4&#39;d3</span>,
869
<a name="l00835"></a>00835     <a class="code" href="classbus__sd.html#a08c0d53d6a1c1db4f54cf651242e534c">S_CMD_SEND_CONTENTS</a>         = <span class="vhdllogic">4&#39;d4</span>,
870
<a name="l00836"></a>00836     <a class="code" href="classbus__sd.html#af23391dcde658bcfcb0c580244d23b38">S_CMD_SEND_CRC7</a>             = <span class="vhdllogic">4&#39;d5</span>,
871
<a name="l00837"></a>00837     <a class="code" href="classbus__sd.html#aa8e966b2f8a90469b456ca462e72b817">S_CMD_SEND_END_BIT</a>          = <span class="vhdllogic">4&#39;d6</span>,
872
<a name="l00838"></a>00838     <a class="code" href="classbus__sd.html#a01433c5cb45b74cdb9c60137d8cf91ae">S_CMD_SEND_END_ONES</a>         = <span class="vhdllogic">4&#39;d7</span>,
873
<a name="l00839"></a>00839     <a class="code" href="classbus__sd.html#a5fa5e984766bfd618ea18a88e13d3676">S_CMD_REPLY_START_BIT</a>       = <span class="vhdllogic">4&#39;d8</span>,
874
<a name="l00840"></a>00840     <a class="code" href="classbus__sd.html#aa7711dfcb90e1a1e4c6e7f8a770d7923">S_CMD_REPLY_CONTENTS</a>        = <span class="vhdllogic">4&#39;d9</span>,
875
<a name="l00841"></a>00841     <a class="code" href="classbus__sd.html#a151e736037f5f19ea98daa933fdcbf55">S_CMD_REPLY_CRC7_END_BIT</a>    = <span class="vhdllogic">4&#39;d10</span>,
876
<a name="l00842"></a>00842     <a class="code" href="classbus__sd.html#a255c30c2ecc9074da6af56403f9a738f">S_CMD_REPLY_FINISH_ONES</a>     = <span class="vhdllogic">4&#39;d11</span>,
877
<a name="l00843"></a>00843     <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>           = <span class="vhdllogic">4&#39;d12</span>;
878
<a name="l00844"></a>00844
879
<a name="l00845"></a>00845
880
<a name="l00846"></a><a class="code" href="classbus__sd.html#a679a7205d19053ab5dd96c2300007d64">00846</a> <span class="vhdlkeyword">always</span> @(<span class="vhdlkeyword">posedge</span> <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a> <span class="vhdlkeyword">or</span> <span class="vhdlkeyword">negedge</span> <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>) <span class="vhdlkeyword">begin</span>
881
<a name="l00847"></a>00847     <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
882
<a name="l00848"></a>00848         <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a>   &lt;= <span class="vhdllogic">1&#39;b0</span>;
883
<a name="l00849"></a>00849         <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>        &lt;= <span class="vhdllogic">38&#39;d0</span>;
884
<a name="l00850"></a>00850         <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>       &lt;= <span class="vhdllogic">48&#39;d0</span>;
885
<a name="l00851"></a>00851         <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a>       &lt;= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>;
886
<a name="l00852"></a>00852         <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a>     &lt;= <span class="vhdllogic">8&#39;d0</span>;
887
<a name="l00853"></a>00853         <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>            &lt;= <span class="vhdllogic">7&#39;d0</span>;
888
<a name="l00854"></a>00854         <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a>     &lt;= <span class="vhdllogic">1&#39;b0</span>;
889
<a name="l00855"></a>00855         <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a>        &lt;= <span class="vhdllogic">1&#39;b1</span>;
890
<a name="l00856"></a>00856     <span class="vhdlkeyword">end</span>
891
<a name="l00857"></a>00857     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>) <span class="vhdlkeyword">begin</span>
892
<a name="l00858"></a>00858         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
893
<a name="l00859"></a>00859             <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a31d633d4b817944615ad58ab12c65a37">S_CMD_SEND_START_ONES</a>;
894
<a name="l00860"></a>00860         <span class="vhdlkeyword">end</span>
895
<a name="l00861"></a>00861     <span class="vhdlkeyword">end</span>
896
<a name="l00862"></a>00862     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> == <span class="vhdllogic">2&#39;d0</span> &amp;&amp; <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> == <span class="vhdllogic">1&#39;b1</span>) <span class="vhdlkeyword">begin</span>
897
<a name="l00863"></a>00863
898
<a name="l00864"></a>00864         <span class="keyword">//send command</span>
899
<a name="l00865"></a>00865         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a31d633d4b817944615ad58ab12c65a37">S_CMD_SEND_START_ONES</a>) <span class="vhdlkeyword">begin</span>
900
<a name="l00866"></a>00866             <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
901
<a name="l00867"></a>00867             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
902
<a name="l00868"></a>00868             <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
903
<a name="l00869"></a>00869             <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= <span class="vhdllogic">7&#39;d0</span>;
904
<a name="l00870"></a>00870
905
<a name="l00871"></a>00871             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d7</span>) <span class="vhdlkeyword">begin</span>
906
<a name="l00872"></a>00872                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#aedddfe3e69609bd1498be9b0d5e62dd2">S_CMD_SEND_START_BIT</a>;
907
<a name="l00873"></a>00873                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
908
<a name="l00874"></a>00874             <span class="vhdlkeyword">end</span>
909
<a name="l00875"></a>00875             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
910
<a name="l00876"></a>00876         <span class="vhdlkeyword">end</span>
911
<a name="l00877"></a>00877         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#aedddfe3e69609bd1498be9b0d5e62dd2">S_CMD_SEND_START_BIT</a>) <span class="vhdlkeyword">begin</span>
912
<a name="l00878"></a>00878             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
913
<a name="l00879"></a>00879             <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= { <span class="vhdllogic">1&#39;b0</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">5</span>], <span class="vhdllogic">1&#39;b0</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
914
<a name="l00880"></a>00880
915
<a name="l00881"></a>00881             <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a1108e27b7c52cd7b7e381406eac784de">S_CMD_SEND_START_HOST</a>;
916
<a name="l00882"></a>00882         <span class="vhdlkeyword">end</span>
917
<a name="l00883"></a>00883         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a1108e27b7c52cd7b7e381406eac784de">S_CMD_SEND_START_HOST</a>) <span class="vhdlkeyword">begin</span>
918
<a name="l00884"></a>00884             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
919
<a name="l00885"></a>00885             <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= { <span class="vhdllogic">1&#39;b1</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">5</span>], <span class="vhdllogic">1&#39;b1</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
920
<a name="l00886"></a>00886
921
<a name="l00887"></a>00887             <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a> &lt;= <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a>;
922
<a name="l00888"></a>00888             <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a08c0d53d6a1c1db4f54cf651242e534c">S_CMD_SEND_CONTENTS</a>;
923
<a name="l00889"></a>00889         <span class="vhdlkeyword">end</span>
924
<a name="l00890"></a>00890         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a08c0d53d6a1c1db4f54cf651242e534c">S_CMD_SEND_CONTENTS</a>) <span class="vhdlkeyword">begin</span>
925
<a name="l00891"></a>00891             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>[<span class="vhdllogic">37</span>];
926
<a name="l00892"></a>00892             <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= { <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>[<span class="vhdllogic">37</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">5</span>], <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>[<span class="vhdllogic">37</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
927
<a name="l00893"></a>00893             <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a> &lt;= { <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>[<span class="vhdllogic">36</span>:<span class="vhdllogic">0</span>], <span class="vhdllogic">1&#39;b0</span> };
928
<a name="l00894"></a>00894
929
<a name="l00895"></a>00895             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d37</span>) <span class="vhdlkeyword">begin</span>
930
<a name="l00896"></a>00896                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#af23391dcde658bcfcb0c580244d23b38">S_CMD_SEND_CRC7</a>;
931
<a name="l00897"></a>00897                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
932
<a name="l00898"></a>00898             <span class="vhdlkeyword">end</span>
933
<a name="l00899"></a>00899             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
934
<a name="l00900"></a>00900         <span class="vhdlkeyword">end</span>
935
<a name="l00901"></a>00901         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#af23391dcde658bcfcb0c580244d23b38">S_CMD_SEND_CRC7</a>) <span class="vhdlkeyword">begin</span>
936
<a name="l00902"></a>00902             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>];
937
<a name="l00903"></a>00903             <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= { <span class="vhdllogic">1&#39;b0</span>, <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">1</span>] };
938
<a name="l00904"></a>00904
939
<a name="l00905"></a>00905             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d6</span>) <span class="vhdlkeyword">begin</span>
940
<a name="l00906"></a>00906                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#aa8e966b2f8a90469b456ca462e72b817">S_CMD_SEND_END_BIT</a>;
941
<a name="l00907"></a>00907                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
942
<a name="l00908"></a>00908             <span class="vhdlkeyword">end</span>
943
<a name="l00909"></a>00909             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
944
<a name="l00910"></a>00910         <span class="vhdlkeyword">end</span>
945
<a name="l00911"></a>00911         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#aa8e966b2f8a90469b456ca462e72b817">S_CMD_SEND_END_BIT</a>) <span class="vhdlkeyword">begin</span>
946
<a name="l00912"></a>00912             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
947
<a name="l00913"></a>00913
948
<a name="l00914"></a>00914             <span class="keyword">// if CMD0: send ones</span>
949
<a name="l00915"></a>00915             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#aebb74ba03ead1fc2c6b4c945fa92112d">S_CTRL_CMD0</a>) <span class="vhdlkeyword">begin</span>
950
<a name="l00916"></a>00916                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a01433c5cb45b74cdb9c60137d8cf91ae">S_CMD_SEND_END_ONES</a>;
951
<a name="l00917"></a>00917             <span class="vhdlkeyword">end</span>
952
<a name="l00918"></a>00918             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span>
953
<a name="l00919"></a>00919                 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= <span class="vhdllogic">7&#39;d0</span>;
954
<a name="l00920"></a>00920                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a5fa5e984766bfd618ea18a88e13d3676">S_CMD_REPLY_START_BIT</a>;
955
<a name="l00921"></a>00921             <span class="vhdlkeyword">end</span>
956
<a name="l00922"></a>00922         <span class="vhdlkeyword">end</span>
957
<a name="l00923"></a>00923         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a01433c5cb45b74cdb9c60137d8cf91ae">S_CMD_SEND_END_ONES</a>) <span class="vhdlkeyword">begin</span>
958
<a name="l00924"></a>00924             <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
959
<a name="l00925"></a>00925             <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
960
<a name="l00926"></a>00926
961
<a name="l00927"></a>00927             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d7</span>) <span class="vhdlkeyword">begin</span>
962
<a name="l00928"></a>00928                 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
963
<a name="l00929"></a>00929                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>;
964
<a name="l00930"></a>00930                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
965
<a name="l00931"></a>00931             <span class="vhdlkeyword">end</span>
966
<a name="l00932"></a>00932             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
967
<a name="l00933"></a>00933         <span class="vhdlkeyword">end</span>
968
<a name="l00934"></a>00934
969
<a name="l00935"></a>00935         <span class="keyword">//wait for response: 48-bits with CRC7</span>
970
<a name="l00936"></a>00936         <span class="keyword">//wait for response: 48-bits without CRC7</span>
971
<a name="l00937"></a>00937         <span class="keyword">//wait for response: 136-bits (CMD2/R2)</span>
972
<a name="l00938"></a>00938         <span class="keyword">//wait for response and busy on data line simultaneously: (CMD7/R1b)</span>
973
<a name="l00939"></a>00939         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a5fa5e984766bfd618ea18a88e13d3676">S_CMD_REPLY_START_BIT</a>) <span class="vhdlkeyword">begin</span>
974
<a name="l00940"></a>00940             <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
975
<a name="l00941"></a>00941
976
<a name="l00942"></a>00942             <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_cmd_io</span> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
977
<a name="l00943"></a>00943                 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= { <span class="vhdlchar">sd_cmd_io</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">5</span>], <span class="vhdlchar">sd_cmd_io</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
978
<a name="l00944"></a>00944                 <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> &lt;= { <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">46</span>:<span class="vhdllogic">0</span>], <span class="vhdlchar">sd_cmd_io</span> };
979
<a name="l00945"></a>00945
980
<a name="l00946"></a>00946                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#aa7711dfcb90e1a1e4c6e7f8a770d7923">S_CMD_REPLY_CONTENTS</a>;
981
<a name="l00947"></a>00947                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
982
<a name="l00948"></a>00948             <span class="vhdlkeyword">end</span>
983
<a name="l00949"></a>00949             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d255</span>) <span class="vhdlkeyword">begin</span>
984
<a name="l00950"></a>00950                 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= <span class="vhdllogic">7&#39;d0</span>;
985
<a name="l00951"></a>00951                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>;
986
<a name="l00952"></a>00952                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
987
<a name="l00953"></a>00953             <span class="vhdlkeyword">end</span>
988
<a name="l00954"></a>00954             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
989
<a name="l00955"></a>00955         <span class="vhdlkeyword">end</span>
990
<a name="l00956"></a>00956         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#aa7711dfcb90e1a1e4c6e7f8a770d7923">S_CMD_REPLY_CONTENTS</a>) <span class="vhdlkeyword">begin</span>
991
<a name="l00957"></a>00957             <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> &lt;= { <span class="vhdlchar">sd_cmd_io</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">5</span>], <span class="vhdlchar">sd_cmd_io</span> ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">4</span>] ^ <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>], <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">3</span>:<span class="vhdllogic">1</span>] };
992
<a name="l00958"></a>00958             <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> &lt;= { <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">46</span>:<span class="vhdllogic">0</span>], <span class="vhdlchar">sd_cmd_io</span> };
993
<a name="l00959"></a>00959
994
<a name="l00960"></a>00960             <span class="vhdlkeyword">if</span>( (<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> != <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a> &amp;&amp; <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d38</span>) ||
995
<a name="l00961"></a>00961                 (<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> == <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a> &amp;&amp; <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d126</span>)
996
<a name="l00962"></a>00962             ) <span class="vhdlkeyword">begin</span>
997
<a name="l00963"></a>00963                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a151e736037f5f19ea98daa933fdcbf55">S_CMD_REPLY_CRC7_END_BIT</a>;
998
<a name="l00964"></a>00964                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
999
<a name="l00965"></a>00965             <span class="vhdlkeyword">end</span>
1000
<a name="l00966"></a>00966             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
1001
<a name="l00967"></a>00967         <span class="vhdlkeyword">end</span>
1002
<a name="l00968"></a>00968         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a151e736037f5f19ea98daa933fdcbf55">S_CMD_REPLY_CRC7_END_BIT</a>) <span class="vhdlkeyword">begin</span>
1003
<a name="l00969"></a>00969             <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> &lt;= { <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">46</span>:<span class="vhdllogic">0</span>], <span class="vhdlchar">sd_cmd_io</span> };
1004
<a name="l00970"></a>00970
1005
<a name="l00971"></a>00971             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d7</span>) <span class="vhdlkeyword">begin</span>
1006
<a name="l00972"></a>00972                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a255c30c2ecc9074da6af56403f9a738f">S_CMD_REPLY_FINISH_ONES</a>;
1007
<a name="l00973"></a>00973                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
1008
<a name="l00974"></a>00974             <span class="vhdlkeyword">end</span>
1009
<a name="l00975"></a>00975             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
1010
<a name="l00976"></a>00976         <span class="vhdlkeyword">end</span>
1011
<a name="l00977"></a>00977         <span class="keyword">//at least 2 clock cycles required for data write</span>
1012
<a name="l00978"></a>00978         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a255c30c2ecc9074da6af56403f9a738f">S_CMD_REPLY_FINISH_ONES</a>) <span class="vhdlkeyword">begin</span>
1013
<a name="l00979"></a>00979             <span class="keyword">//check is sd_dat_io busy for CMD7</span>
1014
<a name="l00980"></a>00980             <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &gt;= <span class="vhdllogic">8&#39;d7</span> &amp;&amp; (<a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> != <a class="code" href="classbus__sd.html#a137d67bd720a29db1f7c687b5418b5f0">S_CTRL_CMD7</a> || <span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1&#39;b1</span>)) <span class="vhdlkeyword">begin</span>
1015
<a name="l00981"></a>00981                 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
1016
<a name="l00982"></a>00982                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>;
1017
<a name="l00983"></a>00983                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
1018
<a name="l00984"></a>00984             <span class="vhdlkeyword">end</span>
1019
<a name="l00985"></a>00985             <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8&#39;d255</span>) <span class="vhdlkeyword">begin</span>
1020
<a name="l00986"></a>00986                 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>;
1021
<a name="l00987"></a>00987                 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
1022
<a name="l00988"></a>00988             <span class="vhdlkeyword">end</span>
1023
<a name="l00989"></a>00989             <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8&#39;d1</span>;
1024
<a name="l00990"></a>00990         <span class="vhdlkeyword">end</span>
1025
<a name="l00991"></a>00991         <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> == <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>) <span class="vhdlkeyword">begin</span>
1026
<a name="l00992"></a>00992             <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
1027
<a name="l00993"></a>00993             <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> &lt;= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>;
1028
<a name="l00994"></a>00994             <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> &lt;= <span class="vhdllogic">8&#39;d0</span>;
1029
<a name="l00995"></a>00995         <span class="vhdlkeyword">end</span>
1030
<a name="l00996"></a>00996     <span class="vhdlkeyword">end</span>
1031
<a name="l00997"></a>00997 <span class="vhdlkeyword">end</span>
1032
<a name="l00998"></a>00998
1033
<a name="l00999"></a>00999 <span class="keyword">//---------------------------------------------------- SD clock</span>
1034
<a name="l01000"></a>01000
1035
<a name="l01001"></a><a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">01001</a> <span class="vhdlkeyword">reg</span> [<span class="vhdllogic">1</span>:<span class="vhdllogic">0</span>] <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a>;
1036
<a name="l01002"></a>01002
1037
<a name="l01003"></a><a class="code" href="classbus__sd.html#a121e632b012fb6e5dc30dbaebb34e20a">01003</a> <span class="vhdlkeyword">always</span> @(<span class="vhdlkeyword">posedge</span> <a class="code" href="classbus__sd.html#ade14040679bbb70d0268cb2a5ffb76f3">clk_30</a> <span class="vhdlkeyword">or</span> <span class="vhdlkeyword">negedge</span> <a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a>) <span class="vhdlkeyword">begin</span>
1038
<a name="l01004"></a>01004     <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#aba023c49b875c1aa3e918d5e1092e0c6">reset_n</a> == <span class="vhdllogic">1&#39;b0</span>) <span class="vhdlkeyword">begin</span>
1039
<a name="l01005"></a>01005         <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
1040
<a name="l01006"></a>01006         <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> &lt;= <span class="vhdllogic">2&#39;d0</span>;
1041
<a name="l01007"></a>01007     <span class="vhdlkeyword">end</span>
1042
<a name="l01008"></a>01008     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> == <span class="vhdllogic">2&#39;d0</span>) <span class="vhdlkeyword">begin</span>
1043
<a name="l01009"></a>01009         <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> == <span class="vhdllogic">1&#39;b1</span> &amp;&amp; (<a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> == <span class="vhdllogic">1&#39;b1</span> || <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> == <span class="vhdllogic">1&#39;b1</span>)) <span class="vhdlkeyword">begin</span>
1044
<a name="l01010"></a>01010             <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> &lt;= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2&#39;d1</span>;
1045
<a name="l01011"></a>01011         <span class="vhdlkeyword">end</span>
1046
<a name="l01012"></a>01012     <span class="vhdlkeyword">end</span>
1047
<a name="l01013"></a>01013     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> == <span class="vhdllogic">2&#39;d1</span>) <span class="vhdlkeyword">begin</span>
1048
<a name="l01014"></a>01014         <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> &lt;= <span class="vhdllogic">1&#39;b1</span>;
1049
<a name="l01015"></a>01015         <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> &lt;= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2&#39;d1</span>;
1050
<a name="l01016"></a>01016     <span class="vhdlkeyword">end</span>
1051
<a name="l01017"></a>01017     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> == <span class="vhdllogic">2&#39;d2</span>) <span class="vhdlkeyword">begin</span>
1052
<a name="l01018"></a>01018         <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> &lt;= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2&#39;d1</span>;
1053
<a name="l01019"></a>01019     <span class="vhdlkeyword">end</span>
1054
<a name="l01020"></a>01020     <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> == <span class="vhdllogic">2&#39;d3</span>) <span class="vhdlkeyword">begin</span>
1055
<a name="l01021"></a>01021         <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> &lt;= <span class="vhdllogic">1&#39;b0</span>;
1056
<a name="l01022"></a>01022         <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> &lt;= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2&#39;d1</span>;
1057
<a name="l01023"></a>01023     <span class="vhdlkeyword">end</span>
1058
<a name="l01024"></a>01024 <span class="vhdlkeyword">end</span>
1059
<a name="l01025"></a>01025
1060
<a name="l01026"></a>01026 <span class="vhdlkeyword">endmodule</span>
1061
<a name="l01027"></a>01027
1062
</pre></div></div>
1063
</div>
1064
<hr class="footer"/><address class="footer"><small>Generated on Mon Dec 20 2010 21:20:18 for aoOCS by&#160;
1065
<a href="http://www.doxygen.org/index.html">
1066
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
1067
</body>
1068
</html>

powered by: WebSVN 2.1.0

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