URL
https://opencores.org/ocsvn/aoocs/aoocs/trunk
Subversion Repositories aoocs
[/] [aoocs/] [trunk/] [doc/] [doxygen/] [html/] [bus__sd_8v_source.html] - Rev 2
Compare with Previous | Blame | View Log
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>aoOCS: bus_sd.v Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Design Unit List</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>bus_sd.v</h1> </div> </div> <div class="contents"> <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> <a name="l00002"></a>00002 <span class="keyword"> Copyright 2010, Aleksander Osman, alfik@poczta.fm. All rights reserved.</span> <a name="l00003"></a>00003 <span class="keyword"> </span> <a name="l00004"></a>00004 <span class="keyword"> Redistribution and use in source and binary forms, with or without modification, are</span> <a name="l00005"></a>00005 <span class="keyword"> permitted provided that the following conditions are met:</span> <a name="l00006"></a>00006 <span class="keyword"> </span> <a name="l00007"></a>00007 <span class="keyword"> 1. Redistributions of source code must retain the above copyright notice, this list of</span> <a name="l00008"></a>00008 <span class="keyword"> conditions and the following disclaimer.</span> <a name="l00009"></a>00009 <span class="keyword"> </span> <a name="l00010"></a>00010 <span class="keyword"> 2. Redistributions in binary form must reproduce the above copyright notice, this list</span> <a name="l00011"></a>00011 <span class="keyword"> of conditions and the following disclaimer in the documentation and/or other materials</span> <a name="l00012"></a>00012 <span class="keyword"> provided with the distribution.</span> <a name="l00013"></a>00013 <span class="keyword"> </span> <a name="l00014"></a>00014 <span class="keyword"> THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED</span> <a name="l00015"></a>00015 <span class="keyword"> WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND</span> <a name="l00016"></a>00016 <span class="keyword"> FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR</span> <a name="l00017"></a>00017 <span class="keyword"> CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span> <a name="l00018"></a>00018 <span class="keyword"> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR</span> <a name="l00019"></a>00019 <span class="keyword"> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON</span> <a name="l00020"></a>00020 <span class="keyword"> ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span> <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> <a name="l00022"></a>00022 <span class="keyword"> ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00023"></a>00023 <span class="keyword"> */</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="keyword">/*! \file</span> <a name="l00026"></a>00026 <span class="keyword"> \brief 1-bit SD bus driver for SD cards with WISHBONE master and slave interface.</span> <a name="l00027"></a>00027 <span class="keyword"> */</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="keyword">/*! \brief \copybrief bus_sd.v</span> <a name="l00030"></a>00030 <span class="keyword">*/</span> <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>( <a name="l00032"></a>00032 <span class="keyword">//% \name Clock and reset </span> <a name="l00033"></a>00033 <span class="keyword">//% @{</span> <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>, <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>, <a name="l00036"></a>00036 <span class="keyword">//% @}</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keyword">//% \name WISHBONE master </span> <a name="l00039"></a>00039 <span class="keyword">//% @{</span> <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>, <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>, <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>, <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>, <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>, <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>, <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>, <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>, <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>, <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>, <a name="l00050"></a>00050 <span class="keyword">// TAG_TYPE: TGC_O</span> <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>, <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>, <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>, <a name="l00054"></a>00054 <span class="keyword">// TAG_TYPE: TGA_O</span> <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>, <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>, <a name="l00057"></a>00057 <span class="keyword">//% @}</span> <a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="keyword">//% \name WISHBONE slave </span> <a name="l00060"></a>00060 <span class="keyword">//% @{</span> <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>, <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>, <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>, <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>, <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>, <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>, <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>, <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>, <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>, <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>, <a name="l00071"></a>00071 <span class="keyword">//% @}</span> <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="keyword">//% \name SD bus 1-bit hardware interface </span> <a name="l00074"></a>00074 <span class="keyword">//% @{</span> <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'b0</span>, <a name="l00076"></a>00076 <span class="vhdlkeyword">inout</span> sd_cmd_io, <a name="l00077"></a>00077 <span class="vhdlkeyword">inout</span> sd_dat_io, <a name="l00078"></a>00078 <span class="keyword">//% @}</span> <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="keyword">//% \name Debug signals </span> <a name="l00081"></a>00081 <span class="keyword">//% @{</span> <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> <a name="l00083"></a>00083 <span class="keyword">//% @}</span> <a name="l00084"></a>00084 ); <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="keyword">/***********************************************************************************************************************</span> <a name="l00087"></a>00087 <span class="keyword"> Wishbone interface</span> <a name="l00088"></a>00088 <span class="keyword"> ***********************************************************************************************************************/</span> <a name="l00089"></a>00089 <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'b0</span>), (<a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> == <span class="vhdllogic">16'd65535</span>), <span class="vhdllogic">2'b0</span>, <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> }; <a name="l00091"></a>00091 <a name="l00092"></a>00092 <span class="keyword">//---------------------------------------------------- wishbone master</span> <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'b1</span>; <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'b0</span>; <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'b0</span>; <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'b1111</span>; <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'b00</span>; <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'b000</span>; <a name="l00099"></a>00099 <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>; <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>; <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>; <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>; <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="keyword">//STB_O,CYC_O,WE_O,DAT_O,</span> <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> <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'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00108"></a>00108 <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a> <= <span class="vhdllogic">30'd0</span>; <a name="l00109"></a>00109 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00110"></a>00110 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00111"></a>00111 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00112"></a>00112 <a class="code" href="classbus__sd.html#a48e4e8652304be3427d6f7272ee0cad9">DAT_O</a> <= <span class="vhdllogic">32'd0</span>; <a name="l00113"></a>00113 <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00114"></a>00114 <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00115"></a>00115 <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00116"></a>00116 <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a> <= <span class="vhdllogic">32'd0</span>; <a name="l00117"></a>00117 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00120"></a>00120 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00121"></a>00121 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00122"></a>00122 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00123"></a>00123 <a name="l00124"></a>00124 <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00125"></a>00125 <span class="vhdlkeyword">end</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00127"></a>00127 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00128"></a>00128 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00129"></a>00129 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00130"></a>00130 <span class="vhdlkeyword">end</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00132"></a>00132 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00133"></a>00133 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00134"></a>00134 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00135"></a>00135 <a name="l00136"></a>00136 <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00137"></a>00137 <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00138"></a>00138 <span class="vhdlkeyword">end</span> <a name="l00139"></a>00139 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00140"></a>00140 <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a> <= <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> + { <span class="vhdllogic">23'b0</span>, <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> }; <a name="l00141"></a>00141 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00142"></a>00142 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00143"></a>00143 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00144"></a>00144 <a class="code" href="classbus__sd.html#a48e4e8652304be3427d6f7272ee0cad9">DAT_O</a> <= <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>; <a name="l00145"></a>00145 <span class="vhdlkeyword">end</span> <a name="l00146"></a>00146 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00149"></a>00149 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00150"></a>00150 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00151"></a>00151 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00152"></a>00152 <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a> <= <a class="code" href="classbus__sd.html#ac9c12028bdaca2ad04524559664d5da1">DAT_I</a>; <a name="l00153"></a>00153 <a name="l00154"></a>00154 <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00155"></a>00155 <span class="vhdlkeyword">end</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00157"></a>00157 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00158"></a>00158 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00159"></a>00159 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00160"></a>00160 <span class="vhdlkeyword">end</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00162"></a>00162 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00163"></a>00163 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00164"></a>00164 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00165"></a>00165 <a name="l00166"></a>00166 <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00167"></a>00167 <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00168"></a>00168 <span class="vhdlkeyword">end</span> <a name="l00169"></a>00169 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00170"></a>00170 <a class="code" href="classbus__sd.html#af0a83491f43579a33a015345664fe563">ADR_O</a> <= <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> + { <span class="vhdllogic">23'b0</span>, <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> }; <a name="l00171"></a>00171 <a class="code" href="classbus__sd.html#a20d9eef34c5b3e2f6c813dadfc50908c">STB_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00172"></a>00172 <a class="code" href="classbus__sd.html#a759d830af39dfe0f44f595dae4afc925">CYC_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00173"></a>00173 <a class="code" href="classbus__sd.html#abd5dd26acfc6f0f07d9dc1acabb17088">WE_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00174"></a>00174 <span class="vhdlkeyword">end</span> <a name="l00175"></a>00175 <span class="vhdlkeyword">end</span> <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> && <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> <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> <a name="l00178"></a>00178 <a class="code" href="classbus__sd.html#a5689aec15eb900ec61f0039a3722d0d8">bus_error</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00179"></a>00179 <span class="vhdlkeyword">end</span> <a name="l00180"></a>00180 <a name="l00181"></a>00181 <a class="code" href="classbus__sd.html#a0080e3fc52d6bb928e7416b135d8a855">data_read</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00182"></a>00182 <a class="code" href="classbus__sd.html#a3b19e874c40489129e36cfeb44ff1f14">data_write</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00183"></a>00183 <span class="vhdlkeyword">end</span> <a name="l00184"></a>00184 <span class="vhdlkeyword">end</span> <a name="l00185"></a>00185 <a name="l00186"></a>00186 <span class="keyword">//---------------------------------------------------- wishbone slave</span> <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'b0</span>; <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'b0</span>; <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'd0</span>, <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a>[<span class="vhdllogic">2</span>:<span class="vhdllogic">0</span>]}; <a name="l00190"></a>00190 <a name="l00191"></a>00191 <span class="keyword">// write only</span> <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>; <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>; <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>; <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>; <a name="l00196"></a>00196 <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>] <a name="l00198"></a>00198 <a class="code" href="classbus__sd.html#a0d6a1a0bbfc5f191b4d1766784dcdeb4">CONTROL_IDLE</a> = <span class="vhdllogic">2'd0</span>, <a name="l00199"></a>00199 <a class="code" href="classbus__sd.html#ac9f608398c5aba2e8fa2656c7b63da05">CONTROL_REINIT</a> = <span class="vhdllogic">2'd1</span>, <a name="l00200"></a>00200 <a class="code" href="classbus__sd.html#ac41ad9206f43eee68311ac70795c6d56">CONTROL_READ</a> = <span class="vhdllogic">2'd2</span>, <a name="l00201"></a>00201 <a class="code" href="classbus__sd.html#a93a7de63cfcce62192aac0c31cc0e3a3">CONTROL_WRITE</a> = <span class="vhdllogic">2'd3</span>; <a name="l00202"></a>00202 <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> <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'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00205"></a>00205 <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> <= <span class="vhdllogic">30'd0</span>; <a name="l00206"></a>00206 <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a> <= <span class="vhdllogic">32'd0</span>; <a name="l00207"></a>00207 <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> <= <span class="vhdllogic">32'd0</span>; <a name="l00208"></a>00208 <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> <= <span class="vhdllogic">2'd0</span>; <a name="l00209"></a>00209 <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00210"></a>00210 <span class="vhdlkeyword">end</span> <a name="l00211"></a>00211 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <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> <a name="l00213"></a>00213 <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> <= <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> - <span class="vhdllogic">32'd1</span>; <a name="l00214"></a>00214 <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a> <= <a class="code" href="classbus__sd.html#a355b5794aae7c191d8db8c8e59d16d85">sd_address</a> + <span class="vhdllogic">32'd1</span>; <a name="l00215"></a>00215 <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> <= <a class="code" href="classbus__sd.html#ab02bfcad9bd25490726c2a255f9d0155">wb_address_base</a> + <span class="vhdllogic">30'd128</span>; <a name="l00216"></a>00216 <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'd1</span>) <a class="code" href="classbus__sd.html#a3dfdd8641ea95c0d33fa04f8223cf687">control</a> <= <a class="code" href="classbus__sd.html#a0d6a1a0bbfc5f191b4d1766784dcdeb4">CONTROL_IDLE</a>; <a name="l00218"></a>00218 <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00219"></a>00219 <span class="vhdlkeyword">end</span> <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'b1</span> && <a class="code" href="classbus__sd.html#a142a3da1f5773ed79bc9a4127ea123e0">STB_I</a> == <span class="vhdllogic">1'b1</span> && <a class="code" href="classbus__sd.html#abbaba763cf6e2f07ef4d79308026ca10">WE_I</a> == <span class="vhdllogic">1'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00221"></a>00221 <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00222"></a>00222 <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'b00</span>) <span class="vhdlkeyword">begin</span> <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">3</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">2</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">1</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1'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>]; <a name="l00228"></a>00228 <span class="vhdlkeyword">end</span> <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'b01</span>) <span class="vhdlkeyword">begin</span> <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">3</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">2</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">1</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1'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>]; <a name="l00234"></a>00234 <span class="vhdlkeyword">end</span> <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'b10</span>) <span class="vhdlkeyword">begin</span> <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">3</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">2</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">1</span>] == <span class="vhdllogic">1'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>]; <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1'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>]; <a name="l00240"></a>00240 <span class="vhdlkeyword">end</span> <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'b11</span>) <span class="vhdlkeyword">begin</span> <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>] <= (<a class="code" href="classbus__sd.html#aa47af53fe7451025be4de6071d3c2dca">SEL_I</a>[<span class="vhdllogic">0</span>] == <span class="vhdllogic">1'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>]; <a name="l00243"></a>00243 <span class="vhdlkeyword">end</span> <a name="l00244"></a>00244 <span class="vhdlkeyword">end</span> <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'b1</span> && <a class="code" href="classbus__sd.html#a142a3da1f5773ed79bc9a4127ea123e0">STB_I</a> == <span class="vhdllogic">1'b1</span> && <a class="code" href="classbus__sd.html#abbaba763cf6e2f07ef4d79308026ca10">WE_I</a> == <span class="vhdllogic">1'b0</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'b00</span>) <span class="vhdlkeyword">begin</span> <a name="l00246"></a>00246 <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00247"></a>00247 <span class="vhdlkeyword">end</span> <a name="l00248"></a>00248 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00249"></a>00249 <a class="code" href="classbus__sd.html#a6f32205e33f439a0738359670cace59a">ACK_O</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00250"></a>00250 <span class="vhdlkeyword">end</span> <a name="l00251"></a>00251 <span class="vhdlkeyword">end</span> <a name="l00252"></a>00252 <a name="l00253"></a>00253 <span class="vhdlkeyword">end</span> <a name="l00254"></a>00254 <a name="l00255"></a>00255 <span class="keyword">/***********************************************************************************************************************</span> <a name="l00256"></a>00256 <span class="keyword"> Control state machine</span> <a name="l00257"></a>00257 <span class="keyword"> ***********************************************************************************************************************/</span> <a name="l00258"></a>00258 <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>; <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>; <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>; <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>; <a name="l00263"></a>00263 <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>; <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>; <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>; <a name="l00267"></a>00267 <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>] <a name="l00269"></a>00269 <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>] <a name="l00271"></a>00271 <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a> = <span class="vhdllogic">4'd0</span>, <a name="l00272"></a>00272 <a class="code" href="classbus__sd.html#aebb74ba03ead1fc2c6b4c945fa92112d">S_CTRL_CMD0</a> = <span class="vhdllogic">4'd1</span>, <a name="l00273"></a>00273 <a class="code" href="classbus__sd.html#a08682c661fb9a83979669263c74f5474">S_CTRL_CMD8</a> = <span class="vhdllogic">4'd2</span>, <a name="l00274"></a>00274 <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a> = <span class="vhdllogic">4'd3</span>, <a name="l00275"></a>00275 <a class="code" href="classbus__sd.html#adfbaf9794186f1c4d7b320008cd92dfc">S_CTRL_ACMD41</a> = <span class="vhdllogic">4'd4</span>, <a name="l00276"></a>00276 <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a> = <span class="vhdllogic">4'd5</span>, <a name="l00277"></a>00277 <a class="code" href="classbus__sd.html#a2366734acfd3297d5f4ebc3f2a568229">S_CTRL_CMD3</a> = <span class="vhdllogic">4'd6</span>, <a name="l00278"></a>00278 <a class="code" href="classbus__sd.html#a137d67bd720a29db1f7c687b5418b5f0">S_CTRL_CMD7</a> = <span class="vhdllogic">4'd7</span>, <a name="l00279"></a>00279 <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a> = <span class="vhdllogic">4'd8</span>, <a name="l00280"></a>00280 <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a> = <span class="vhdllogic">4'd9</span>, <a name="l00281"></a>00281 <a class="code" href="classbus__sd.html#ac83f3e28ac9435b053fea3f5a5aefab6">S_CTRL_CMD17_READ</a> = <span class="vhdllogic">4'd10</span>, <a name="l00282"></a>00282 <a class="code" href="classbus__sd.html#a857357404854de264f698ab75a9b3777">S_CTRL_CMD24_WRITE</a> = <span class="vhdllogic">4'd11</span>; <a name="l00283"></a>00283 <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>] <a name="l00285"></a>00285 <a class="code" href="classbus__sd.html#a9520e13b2b7cc9286ed8ee13b57e7f61">STATUS_INIT</a> = <span class="vhdllogic">3'd0</span>, <a name="l00286"></a>00286 <a class="code" href="classbus__sd.html#ac68c34cb9cc2305411b0a7f070c75115">STATUS_INIT_ERROR</a> = <span class="vhdllogic">3'd1</span>, <a name="l00287"></a>00287 <a class="code" href="classbus__sd.html#a7051c67ccf2ab73e7b58ab5025c5a309">STATUS_IDLE</a> = <span class="vhdllogic">3'd2</span>, <a name="l00288"></a>00288 <a class="code" href="classbus__sd.html#a76a8bdb27f3ac49a997add5c4bcda1d9">STATUS_READ</a> = <span class="vhdllogic">3'd3</span>, <a name="l00289"></a>00289 <a class="code" href="classbus__sd.html#a294f0a9f11a50c707ad32f76465ec117">STATUS_WRITE</a> = <span class="vhdllogic">3'd4</span>, <a name="l00290"></a>00290 <a class="code" href="classbus__sd.html#a9b15e063dbb64dabc5d2fb1f14060059">STATUS_ERROR</a> = <span class="vhdllogic">3'd5</span>; <a name="l00291"></a>00291 <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> <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'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00294"></a>00294 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00295"></a>00295 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#a9520e13b2b7cc9286ed8ee13b57e7f61">STATUS_INIT</a>; <a name="l00296"></a>00296 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= <span class="vhdllogic">38'd0</span>; <a name="l00297"></a>00297 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00298"></a>00298 <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00299"></a>00299 <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00300"></a>00300 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00301"></a>00301 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> == <span class="vhdllogic">16'd65535</span>) <span class="vhdlkeyword">begin</span> <a name="l00303"></a>00303 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#ac68c34cb9cc2305411b0a7f070c75115">STATUS_INIT_ERROR</a>; <a name="l00304"></a>00304 <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> <a name="l00306"></a>00306 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00307"></a>00307 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00308"></a>00308 <span class="vhdlkeyword">end</span> <a name="l00309"></a>00309 <span class="vhdlkeyword">end</span> <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> <a name="l00311"></a>00311 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#a9520e13b2b7cc9286ed8ee13b57e7f61">STATUS_INIT</a>; <a name="l00312"></a>00312 <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00314"></a>00314 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00315"></a>00315 <span class="keyword">//CMD0, no arguments</span> <a name="l00316"></a>00316 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd0</span>, <span class="vhdllogic">32'd0</span> }; <a name="l00317"></a>00317 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#aebb74ba03ead1fc2c6b4c945fa92112d">S_CTRL_CMD0</a>; <a name="l00318"></a>00318 <span class="vhdlkeyword">end</span> <a name="l00319"></a>00319 <span class="vhdlkeyword">end</span> <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> <a name="l00321"></a>00321 <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> <a name="l00323"></a>00323 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00324"></a>00324 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00325"></a>00325 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00327"></a>00327 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00328"></a>00328 <span class="keyword">//CMD8, supply voltage, check pattern</span> <a name="l00329"></a>00329 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd8</span>, <span class="vhdllogic">20'd0</span>, <span class="vhdllogic">4'b0001</span>, <span class="vhdllogic">8'b10101010</span> }; <a name="l00330"></a>00330 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a08682c661fb9a83979669263c74f5474">S_CTRL_CMD8</a>; <a name="l00331"></a>00331 <span class="vhdlkeyword">end</span> <a name="l00332"></a>00332 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00333"></a>00333 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00336"></a>00336 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00337"></a>00337 <span class="vhdlkeyword">end</span> <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> || <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> && <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> != { <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'd8</span>, <span class="vhdllogic">20'd0</span>, <span class="vhdllogic">4'b0001</span>, <span class="vhdllogic">8'b10101010</span>, <a class="code" href="classbus__sd.html#a857791fdae3d128e0045f77c7d192d7c">`CRC7_REVERSE</a><span class="vhdlchar"></span>, <span class="vhdllogic">1'b1</span> }) <a name="l00340"></a>00340 ) <span class="vhdlkeyword">begin</span> <a name="l00341"></a>00341 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00342"></a>00342 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00343"></a>00343 <span class="vhdlkeyword">end</span> <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> <a name="l00345"></a>00345 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00346"></a>00346 <span class="keyword">//CMD55, RCA</span> <a name="l00347"></a>00347 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd55</span>, <span class="vhdllogic">16'd0</span>, <span class="vhdllogic">16'd0</span>}; <a name="l00348"></a>00348 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a>; <a name="l00349"></a>00349 <span class="vhdlkeyword">end</span> <a name="l00350"></a>00350 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00353"></a>00353 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00354"></a>00354 <span class="vhdlkeyword">end</span> <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> || <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> && <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'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'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'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'b0</span> || <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'b1</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1'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'b1</span> } <a name="l00359"></a>00359 ) <a name="l00360"></a>00360 ) <a name="l00361"></a>00361 ) <span class="vhdlkeyword">begin</span> <a name="l00362"></a>00362 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00363"></a>00363 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00364"></a>00364 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00366"></a>00366 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00367"></a>00367 <span class="keyword">//ACMD41, </span> <a name="l00368"></a>00368 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd41</span>, <span class="keyword">//command index</span> <a name="l00369"></a>00369 <span class="vhdllogic">1'b0</span>, <span class="keyword">//reserved bit</span> <a name="l00370"></a>00370 <span class="vhdllogic">1'b1</span>, <span class="keyword">//host capacity support HCS(OCR[30])</span> <a name="l00371"></a>00371 <span class="vhdllogic">6'b0</span>, <span class="keyword">//reserved bits</span> <a name="l00372"></a>00372 <span class="vhdllogic">24'b0001_0000_0000_0000_0000_0000</span> <span class="keyword">//VDD voltage window OCR[23:0]</span> <a name="l00373"></a>00373 }; <a name="l00374"></a>00374 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#adfbaf9794186f1c4d7b320008cd92dfc">S_CTRL_ACMD41</a>; <a name="l00375"></a>00375 <span class="vhdlkeyword">end</span> <a name="l00376"></a>00376 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00379"></a>00379 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00380"></a>00380 <span class="vhdlkeyword">end</span> <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> || <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> && (<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'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'b111111</span> } || <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'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'b1111111</span>, <span class="vhdllogic">1'b1</span> }) <a name="l00384"></a>00384 ) <a name="l00385"></a>00385 ) <span class="vhdlkeyword">begin</span> <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'd65535</span>) <span class="vhdlkeyword">begin</span> <a name="l00387"></a>00387 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00388"></a>00388 <span class="vhdlkeyword">end</span> <a name="l00389"></a>00389 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00390"></a>00390 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00391"></a>00391 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00392"></a>00392 <span class="keyword">//CMD55, RCA</span> <a name="l00393"></a>00393 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd55</span>, <span class="vhdllogic">16'd0</span>, <span class="vhdllogic">16'd0</span>}; <a name="l00394"></a>00394 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5289869552dea6588012023457fa3cb7">S_CTRL_CMD55</a>; <a name="l00395"></a>00395 <span class="vhdlkeyword">end</span> <a name="l00396"></a>00396 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00398"></a>00398 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00399"></a>00399 <span class="keyword">//CMD2, no arguments</span> <a name="l00400"></a>00400 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd2</span>, <span class="vhdllogic">32'd0</span> }; <a name="l00401"></a>00401 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a938f1ce712895a2530081f66a819ad94">S_CTRL_CMD2</a>; <a name="l00402"></a>00402 <span class="vhdlkeyword">end</span> <a name="l00403"></a>00403 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00406"></a>00406 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00407"></a>00407 <span class="vhdlkeyword">end</span> <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> || <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> && <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">0</span>] != <span class="vhdllogic">1'b1</span>) <a name="l00410"></a>00410 ) <span class="vhdlkeyword">begin</span> <a name="l00411"></a>00411 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00412"></a>00412 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00413"></a>00413 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00415"></a>00415 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00416"></a>00416 <span class="keyword">//CMD3, no arguments</span> <a name="l00417"></a>00417 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd3</span>, <span class="vhdllogic">32'd0</span> }; <a name="l00418"></a>00418 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a2366734acfd3297d5f4ebc3f2a568229">S_CTRL_CMD3</a>; <a name="l00419"></a>00419 <span class="vhdlkeyword">end</span> <a name="l00420"></a>00420 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00423"></a>00423 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00424"></a>00424 <span class="vhdlkeyword">end</span> <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> || <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> && <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'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'd3</span> } || <a name="l00428"></a>00428 <span class="keyword">/*23:8= 23,22,19,12:0 from card status**/</span> <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'b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">13</span>] != <span class="vhdllogic">1'b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1'b0</span> || <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'b1</span> } <a name="l00431"></a>00431 ) <a name="l00432"></a>00432 ) <a name="l00433"></a>00433 ) <span class="vhdlkeyword">begin</span> <a name="l00434"></a>00434 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00435"></a>00435 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00436"></a>00436 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00438"></a>00438 <a name="l00439"></a>00439 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00440"></a>00440 <span class="keyword">//CMD7, no arguments</span> <a name="l00441"></a>00441 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd7</span>, <span class="keyword">//command index</span> <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> <a name="l00443"></a>00443 <span class="vhdllogic">16'd0</span> <span class="keyword">//stuff bits</span> <a name="l00444"></a>00444 }; <a name="l00445"></a>00445 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a137d67bd720a29db1f7c687b5418b5f0">S_CTRL_CMD7</a>; <a name="l00446"></a>00446 <span class="vhdlkeyword">end</span> <a name="l00447"></a>00447 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00450"></a>00450 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00451"></a>00451 <span class="vhdlkeyword">end</span> <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> || <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> && <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'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'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'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'b0</span> || <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'b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1'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'b1</span> } <a name="l00456"></a>00456 ) <a name="l00457"></a>00457 ) <a name="l00458"></a>00458 ) <span class="vhdlkeyword">begin</span> <a name="l00459"></a>00459 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00460"></a>00460 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00461"></a>00461 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00463"></a>00463 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00464"></a>00464 <a name="l00465"></a>00465 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00466"></a>00466 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00467"></a>00467 <span class="vhdlkeyword">end</span> <a name="l00468"></a>00468 <span class="vhdlkeyword">end</span> <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> <a name="l00470"></a>00470 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00471"></a>00471 <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'b1</span>) <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd65535</span>; <a name="l00473"></a>00473 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> != <span class="vhdllogic">16'd0</span>) <span class="vhdlkeyword">begin</span> <a name="l00475"></a>00475 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#a9b15e063dbb64dabc5d2fb1f14060059">STATUS_ERROR</a>; <a name="l00476"></a>00476 <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> <a name="l00478"></a>00478 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00479"></a>00479 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00480"></a>00480 <span class="vhdlkeyword">end</span> <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> <a name="l00482"></a>00482 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a56945218906b82797329836b5f1c8a1e">S_CTRL_INIT</a>; <a name="l00483"></a>00483 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00484"></a>00484 <span class="vhdlkeyword">end</span> <a name="l00485"></a>00485 <span class="vhdlkeyword">end</span> <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> <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> && <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> != <span class="vhdllogic">32'd0</span>) <span class="vhdlkeyword">begin</span> <a name="l00488"></a>00488 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#a76a8bdb27f3ac49a997add5c4bcda1d9">STATUS_READ</a>; <a name="l00489"></a>00489 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00490"></a>00490 <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00491"></a>00491 <span class="keyword">//CMD17, sector address</span> <a name="l00492"></a>00492 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd17</span>, <span class="keyword">//command index</span> <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> <a name="l00494"></a>00494 }; <a name="l00495"></a>00495 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#ac83f3e28ac9435b053fea3f5a5aefab6">S_CTRL_CMD17_READ</a>; <a name="l00496"></a>00496 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a26eced59276b2896a1b1696dd5a4b911">sd_block_count</a> != <span class="vhdllogic">32'd0</span>) <span class="vhdlkeyword">begin</span> <a name="l00498"></a>00498 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#a294f0a9f11a50c707ad32f76465ec117">STATUS_WRITE</a>; <a name="l00499"></a>00499 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00500"></a>00500 <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00501"></a>00501 <span class="keyword">//CMD24, sector address</span> <a name="l00502"></a>00502 <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a> <= { <span class="vhdllogic">6'd24</span>, <span class="keyword">//command index</span> <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> <a name="l00504"></a>00504 }; <a name="l00505"></a>00505 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a857357404854de264f698ab75a9b3777">S_CTRL_CMD24_WRITE</a>; <a name="l00506"></a>00506 <span class="vhdlkeyword">end</span> <a name="l00507"></a>00507 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00508"></a>00508 <a class="code" href="classbus__sd.html#ab2c41efa038df0f8b0c0c4a554e62db9">status</a> <= <a class="code" href="classbus__sd.html#a7051c67ccf2ab73e7b58ab5025c5a309">STATUS_IDLE</a>; <a name="l00509"></a>00509 <span class="vhdlkeyword">end</span> <a name="l00510"></a>00510 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00513"></a>00513 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00514"></a>00514 <span class="vhdlkeyword">end</span> <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> || <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> && <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'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'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'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'b0</span> || <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'b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1'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'b1</span> } <a name="l00519"></a>00519 ) <a name="l00520"></a>00520 ) <a name="l00521"></a>00521 ) <span class="vhdlkeyword">begin</span> <a name="l00522"></a>00522 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00523"></a>00523 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00524"></a>00524 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span> && <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00526"></a>00526 <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00527"></a>00527 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span> && <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1'b0</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> <a name="l00529"></a>00529 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00530"></a>00530 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00531"></a>00531 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span> && <a class="code" href="classbus__sd.html#a1ef253ec1ddf7781eff08cf855baec9f">start_read</a> == <span class="vhdllogic">1'b0</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> <a name="l00533"></a>00533 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00534"></a>00534 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>; <a name="l00535"></a>00535 <span class="vhdlkeyword">end</span> <a name="l00536"></a>00536 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00539"></a>00539 <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00540"></a>00540 <span class="vhdlkeyword">end</span> <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> || <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> && <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'b0</span>, <span class="vhdllogic">1'b0</span>, <span class="vhdllogic">6'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'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'b0</span> || <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'b0</span> || <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a>[<span class="vhdllogic">11</span>] != <span class="vhdllogic">1'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'b1</span> } <a name="l00545"></a>00545 ) <a name="l00546"></a>00546 ) <a name="l00547"></a>00547 ) <span class="vhdlkeyword">begin</span> <a name="l00548"></a>00548 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00549"></a>00549 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00550"></a>00550 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span> && <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00552"></a>00552 <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00553"></a>00553 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span> && <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1'b0</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> <a name="l00555"></a>00555 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> + <span class="vhdllogic">16'd1</span>; <a name="l00556"></a>00556 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a5c24cabd710f94608a85c9c379e019f1">S_CTRL_IDLE</a>; <a name="l00557"></a>00557 <span class="vhdlkeyword">end</span> <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> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</span> && <a class="code" href="classbus__sd.html#a9c16bb550ab2a2f6b3d4f3c5e997fafa">start_write</a> == <span class="vhdllogic">1'b0</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> <a name="l00559"></a>00559 <a class="code" href="classbus__sd.html#aeafc420c4680098dc508aecb4748ba52">error_count</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00560"></a>00560 <a class="code" href="classbus__sd.html#a5859c0c30365a6458efee99d95d74963">control_state</a> <= <a class="code" href="classbus__sd.html#a54e19b6306dffb66b89294492af840c8">S_CTRL_PRE_IDLE</a>; <a name="l00561"></a>00561 <span class="vhdlkeyword">end</span> <a name="l00562"></a>00562 <span class="vhdlkeyword">end</span> <a name="l00563"></a>00563 <span class="vhdlkeyword">end</span> <a name="l00564"></a>00564 <a name="l00565"></a>00565 <span class="keyword">/***********************************************************************************************************************</span> <a name="l00566"></a>00566 <span class="keyword"> SD interface</span> <a name="l00567"></a>00567 <span class="keyword"> ***********************************************************************************************************************/</span> <a name="l00568"></a>00568 <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'b1</span>; <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'b1</span>; <a name="l00571"></a>00571 <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'b1</span>) ? <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> : <span class="vhdllogic">1'bZ</span>; <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'b1</span>) ? <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> : <span class="vhdllogic">1'bZ</span>; <a name="l00574"></a>00574 <a name="l00575"></a>00575 <span class="keyword">//CID register not interpreted: CRC7 not checked, always accepted</span> <a name="l00576"></a>00576 <a name="l00577"></a>00577 <span class="keyword">//---------------------------------------------------- SD data</span> <a name="l00578"></a>00578 <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>; <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>; <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>; <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>; <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>; <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>; <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>; <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>; <a name="l00587"></a>00587 <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>] <a name="l00589"></a>00589 <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a> = <span class="vhdllogic">4'd0</span>, <a name="l00590"></a>00590 <a class="code" href="classbus__sd.html#a13360617ecec417078b97acf8f2c8569">S_DATA_READ_START_BIT</a> = <span class="vhdllogic">4'd1</span>, <a name="l00591"></a>00591 <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a> = <span class="vhdllogic">4'd2</span>, <a name="l00592"></a>00592 <a class="code" href="classbus__sd.html#ada04262d8cb516a835ee25a3d9508830">S_DATA_READ_READY_PART</a> = <span class="vhdllogic">4'd3</span>, <a name="l00593"></a>00593 <a class="code" href="classbus__sd.html#a3e69ea7fb13e27a8dbdeb4fcebfbefae">S_DATA_READ_READY_PART_CONTINUE</a> = <span class="vhdllogic">4'd4</span>, <a name="l00594"></a>00594 <a class="code" href="classbus__sd.html#a4b6a23ae8c7568c44bafba26bb66927e">S_DATA_READ_CRC16_END_BIT</a> = <span class="vhdllogic">4'd5</span>, <a name="l00595"></a>00595 <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a> = <span class="vhdllogic">4'd6</span>, <a name="l00596"></a>00596 <a class="code" href="classbus__sd.html#acc2add7bba173a332d2002ad6989104f">S_DATA_WRITE_START_BIT</a> = <span class="vhdllogic">4'd7</span>, <a name="l00597"></a>00597 <a class="code" href="classbus__sd.html#a09da4987c43dc1a8411ae0dea169c1b7">S_DATA_WRITE_READY_PART</a> = <span class="vhdllogic">4'd8</span>, <a name="l00598"></a>00598 <a class="code" href="classbus__sd.html#a67f329d2cdf17104d88caf50ae248e02">S_DATA_WRITE_CONTENTS</a> = <span class="vhdllogic">4'd9</span>, <a name="l00599"></a>00599 <a class="code" href="classbus__sd.html#ad382b24aadcd85390a7fb27cc51c383c">S_DATA_WRITE_CRC16_END_BIT</a> = <span class="vhdllogic">4'd10</span>, <a name="l00600"></a>00600 <a class="code" href="classbus__sd.html#a2c25dd2a683085e8a751541ed382d740">S_DATA_WRITE_CRC_STATUS_START</a> = <span class="vhdllogic">4'd11</span>, <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'd12</span>, <a name="l00602"></a>00602 <a class="code" href="classbus__sd.html#a5e0b4025c9ad8522892dbec69bf590f1">S_DATA_WRITE_BUSY_START</a> = <span class="vhdllogic">4'd13</span>, <a name="l00603"></a>00603 <a class="code" href="classbus__sd.html#a96506aa2492a1ec2a65ce5168b54bb14">S_DATA_WRITE_BUSY_WAIT</a> = <span class="vhdllogic">4'd14</span>, <a name="l00604"></a>00604 <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a> = <span class="vhdllogic">4'd15</span>; <a name="l00605"></a>00605 <a name="l00606"></a>00606 <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> <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'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00609"></a>00609 <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00610"></a>00610 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>; <a name="l00611"></a>00611 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00612"></a>00612 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00613"></a>00613 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00614"></a>00614 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> <= <span class="vhdllogic">32'd0</span>; <a name="l00615"></a>00615 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00616"></a>00616 <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00617"></a>00617 <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00618"></a>00618 <span class="vhdlkeyword">end</span> <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> <a name="l00620"></a>00620 <span class="keyword">//do not wait for read command and reply</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00622"></a>00622 <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>; <a name="l00623"></a>00623 <span class="vhdlkeyword">end</span> <a name="l00624"></a>00624 <span class="keyword">//wait for write command and reply</span> <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'b1</span> && <a class="code" href="classbus__sd.html#a2784dce65002eba6095ea24674604615">start_cmd</a> == <span class="vhdllogic">1'b0</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> <a name="l00626"></a>00626 <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>; <a name="l00627"></a>00627 <span class="vhdlkeyword">end</span> <a name="l00628"></a>00628 <span class="vhdlkeyword">end</span> <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'd0</span>) <span class="vhdlkeyword">begin</span> <a name="l00630"></a>00630 <a name="l00631"></a>00631 <span class="keyword">//wait for response and data simultaneously (data read)</span> <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> <a name="l00633"></a>00633 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00634"></a>00634 <a name="l00635"></a>00635 <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00636"></a>00636 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= { <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>], <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>] }; <a name="l00638"></a>00638 <a name="l00639"></a>00639 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a>; <a name="l00640"></a>00640 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00641"></a>00641 <span class="vhdlkeyword">end</span> <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'd65535</span>) <span class="vhdlkeyword">begin</span> <a name="l00643"></a>00643 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>; <a name="l00644"></a>00644 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00645"></a>00645 <span class="vhdlkeyword">end</span> <a name="l00646"></a>00646 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00647"></a>00647 <span class="vhdlkeyword">end</span> <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> <a name="l00649"></a>00649 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= { <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 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>] }; <a name="l00651"></a>00651 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> <= { <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> }; <a name="l00652"></a>00652 <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'd30</span>) <span class="vhdlkeyword">begin</span> <a name="l00654"></a>00654 <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00655"></a>00655 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00656"></a>00656 <span class="vhdlkeyword">end</span> <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'd31</span>) <span class="vhdlkeyword">begin</span> <a name="l00658"></a>00658 <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>; <a name="l00659"></a>00659 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00660"></a>00660 <span class="vhdlkeyword">end</span> <a name="l00661"></a>00661 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00662"></a>00662 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00665"></a>00665 <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00666"></a>00666 <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>; <a name="l00667"></a>00667 <span class="vhdlkeyword">end</span> <a name="l00668"></a>00668 <span class="vhdlkeyword">end</span> <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> <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'd127</span>) <span class="vhdlkeyword">begin</span> <a name="l00671"></a>00671 <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>; <a name="l00672"></a>00672 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00673"></a>00673 <span class="vhdlkeyword">end</span> <a name="l00674"></a>00674 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00675"></a>00675 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#aaa28d2f413350e3c1f39201e76f3908c">S_DATA_READ_CONTENTS</a>; <a name="l00676"></a>00676 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> <= <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> + <span class="vhdllogic">7'd1</span>; <a name="l00677"></a>00677 <span class="vhdlkeyword">end</span> <a name="l00678"></a>00678 <span class="vhdlkeyword">end</span> <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> <a name="l00680"></a>00680 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> <= { <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>] }; <a name="l00681"></a>00681 <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'd16</span>) <span class="vhdlkeyword">begin</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00684"></a>00684 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a66bab12a055f153f6c4b247578cf6be4">S_DATA_READ_ERROR</a>; <a name="l00685"></a>00685 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00686"></a>00686 <span class="vhdlkeyword">end</span> <a name="l00687"></a>00687 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00688"></a>00688 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00689"></a>00689 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>; <a name="l00690"></a>00690 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00691"></a>00691 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00692"></a>00692 <span class="vhdlkeyword">end</span> <a name="l00693"></a>00693 <span class="vhdlkeyword">end</span> <a name="l00694"></a>00694 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00695"></a>00695 <span class="vhdlkeyword">end</span> <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> <a name="l00697"></a>00697 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00698"></a>00698 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>; <a name="l00699"></a>00699 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00700"></a>00700 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00701"></a>00701 <span class="vhdlkeyword">end</span> <a name="l00702"></a>00702 <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> <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> <a name="l00705"></a>00705 <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00706"></a>00706 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= { <span class="vhdllogic">1'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'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>], <a name="l00707"></a>00707 <span class="vhdllogic">1'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>] }; <a name="l00708"></a>00708 <a name="l00709"></a>00709 <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00710"></a>00710 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00711"></a>00711 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00712"></a>00712 <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>; <a name="l00713"></a>00713 <span class="vhdlkeyword">end</span> <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> <a name="l00715"></a>00715 <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00717"></a>00717 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00718"></a>00718 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a67f329d2cdf17104d88caf50ae248e02">S_DATA_WRITE_CONTENTS</a>; <a name="l00719"></a>00719 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> <= <a class="code" href="classbus__sd.html#a0abe5a5a11b3715fd1fb601add77d262">data_part_contents</a>; <a name="l00720"></a>00720 <span class="vhdlkeyword">end</span> <a name="l00721"></a>00721 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00722"></a>00722 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00723"></a>00723 <span class="vhdlkeyword">end</span> <a name="l00724"></a>00724 <span class="vhdlkeyword">end</span> <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> <a name="l00726"></a>00726 <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> <= <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a>[<span class="vhdllogic">31</span>]; <a name="l00727"></a>00727 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= { <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>], <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>] }; <a name="l00729"></a>00729 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> <= { <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'b0</span> }; <a name="l00730"></a>00730 <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'd31</span>) <span class="vhdlkeyword">begin</span> <a name="l00732"></a>00732 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00733"></a>00733 <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'd127</span>) <span class="vhdlkeyword">begin</span> <a name="l00735"></a>00735 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00736"></a>00736 <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>; <a name="l00737"></a>00737 <span class="vhdlkeyword">end</span> <a name="l00738"></a>00738 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00739"></a>00739 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00740"></a>00740 <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> <= <a class="code" href="classbus__sd.html#a86957a356ef6549a3237c95d07d84ac5">part_counter</a> + <span class="vhdllogic">7'd1</span>; <a name="l00741"></a>00741 <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>; <a name="l00742"></a>00742 <span class="vhdlkeyword">end</span> <a name="l00743"></a>00743 <span class="vhdlkeyword">end</span> <a name="l00744"></a>00744 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00745"></a>00745 <span class="vhdlkeyword">end</span> <a name="l00746"></a>00746 <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> <a name="l00748"></a>00748 <a class="code" href="classbus__sd.html#a164b04759ee9c40670b36b2270344f31">sd_dat_o</a> <= <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">0</span>]; <a name="l00749"></a>00749 <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'd16</span>) <span class="vhdlkeyword">begin</span> <a name="l00751"></a>00751 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00752"></a>00752 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= <span class="vhdllogic">16'd0</span>; <a name="l00753"></a>00753 <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>; <a name="l00754"></a>00754 <span class="vhdlkeyword">end</span> <a name="l00755"></a>00755 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00756"></a>00756 <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a> <= { <span class="vhdllogic">1'b1</span>, <a class="code" href="classbus__sd.html#a7cb6f3954b32fdd736c75530951755bb">crc16</a>[<span class="vhdllogic">15</span>:<span class="vhdllogic">1</span>] }; <a name="l00757"></a>00757 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00758"></a>00758 <span class="vhdlkeyword">end</span> <a name="l00759"></a>00759 <a name="l00760"></a>00760 <span class="vhdlkeyword">end</span> <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> <a name="l00762"></a>00762 <a class="code" href="classbus__sd.html#a7b5675fe34cfc9c7b618f69d3db112ec">sd_data_enable</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00763"></a>00763 <a name="l00764"></a>00764 <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00765"></a>00765 <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>; <a name="l00766"></a>00766 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'b0</span>; <a name="l00767"></a>00767 <span class="vhdlkeyword">end</span> <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'd65535</span>) <span class="vhdlkeyword">begin</span> <a name="l00769"></a>00769 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>; <a name="l00770"></a>00770 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'b0</span>; <a name="l00771"></a>00771 <span class="vhdlkeyword">end</span> <a name="l00772"></a>00772 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00773"></a>00773 <span class="vhdlkeyword">end</span> <a name="l00774"></a>00774 <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> <a name="l00776"></a>00776 <a class="code" href="classbus__sd.html#a9d470fb3a5111948c960f901e7aaeda1">data_part</a> <= { <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> }; <a name="l00777"></a>00777 <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'd3</span>) <span class="vhdlkeyword">begin</span> <a name="l00779"></a>00779 <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>; <a name="l00780"></a>00780 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'b0</span>; <a name="l00781"></a>00781 <span class="vhdlkeyword">end</span> <a name="l00782"></a>00782 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00783"></a>00783 <span class="vhdlkeyword">end</span> <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> <a name="l00785"></a>00785 <a name="l00786"></a>00786 <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00787"></a>00787 <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>; <a name="l00788"></a>00788 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'b0</span>; <a name="l00789"></a>00789 <span class="vhdlkeyword">end</span> <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'd65535</span>) <span class="vhdlkeyword">begin</span> <a name="l00791"></a>00791 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>; <a name="l00792"></a>00792 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'b0</span>; <a name="l00793"></a>00793 <span class="vhdlkeyword">end</span> <a name="l00794"></a>00794 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00795"></a>00795 <span class="vhdlkeyword">end</span> <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> <a name="l00797"></a>00797 <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1'b1</span> && <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'b0101</span>) <span class="vhdlkeyword">begin</span> <a name="l00798"></a>00798 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>; <a name="l00799"></a>00799 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00800"></a>00800 <span class="vhdlkeyword">end</span> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00802"></a>00802 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00803"></a>00803 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>; <a name="l00804"></a>00804 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00805"></a>00805 <span class="vhdlkeyword">end</span> <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'hFFFFFF</span>) <span class="vhdlkeyword">begin</span> <a name="l00807"></a>00807 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#af4b7e2b87918409d3d059ffc255060be">S_DATA_WRITE_ERROR</a>; <a name="l00808"></a>00808 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00809"></a>00809 <span class="vhdlkeyword">end</span> <a name="l00810"></a>00810 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> + <span class="vhdllogic">24'd1</span>; <a name="l00811"></a>00811 <span class="vhdlkeyword">end</span> <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> <a name="l00813"></a>00813 <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00814"></a>00814 <a class="code" href="classbus__sd.html#a37e9a09aa7b9b1a9b0bf4e70db242be3">data_state</a> <= <a class="code" href="classbus__sd.html#a0048957bb930ffa46c19c03aa9ce9b56">S_DATA_IDLE</a>; <a name="l00815"></a>00815 <a class="code" href="classbus__sd.html#a9807340b528b2e8b94ab365ef9066153">data_counter</a> <= <span class="vhdllogic">24'd0</span>; <a name="l00816"></a>00816 <span class="vhdlkeyword">end</span> <a name="l00817"></a>00817 <span class="vhdlkeyword">end</span> <a name="l00818"></a>00818 <span class="vhdlkeyword">end</span> <a name="l00819"></a>00819 <a name="l00820"></a>00820 <span class="keyword">//---------------------------------------------------- SD command</span> <a name="l00821"></a>00821 <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>; <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>; <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>; <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>; <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>; <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>; <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>; <a name="l00829"></a>00829 <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>] <a name="l00831"></a>00831 <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a> = <span class="vhdllogic">4'd0</span>, <a name="l00832"></a>00832 <a class="code" href="classbus__sd.html#a31d633d4b817944615ad58ab12c65a37">S_CMD_SEND_START_ONES</a> = <span class="vhdllogic">4'd1</span>, <a name="l00833"></a>00833 <a class="code" href="classbus__sd.html#aedddfe3e69609bd1498be9b0d5e62dd2">S_CMD_SEND_START_BIT</a> = <span class="vhdllogic">4'd2</span>, <a name="l00834"></a>00834 <a class="code" href="classbus__sd.html#a1108e27b7c52cd7b7e381406eac784de">S_CMD_SEND_START_HOST</a> = <span class="vhdllogic">4'd3</span>, <a name="l00835"></a>00835 <a class="code" href="classbus__sd.html#a08c0d53d6a1c1db4f54cf651242e534c">S_CMD_SEND_CONTENTS</a> = <span class="vhdllogic">4'd4</span>, <a name="l00836"></a>00836 <a class="code" href="classbus__sd.html#af23391dcde658bcfcb0c580244d23b38">S_CMD_SEND_CRC7</a> = <span class="vhdllogic">4'd5</span>, <a name="l00837"></a>00837 <a class="code" href="classbus__sd.html#aa8e966b2f8a90469b456ca462e72b817">S_CMD_SEND_END_BIT</a> = <span class="vhdllogic">4'd6</span>, <a name="l00838"></a>00838 <a class="code" href="classbus__sd.html#a01433c5cb45b74cdb9c60137d8cf91ae">S_CMD_SEND_END_ONES</a> = <span class="vhdllogic">4'd7</span>, <a name="l00839"></a>00839 <a class="code" href="classbus__sd.html#a5fa5e984766bfd618ea18a88e13d3676">S_CMD_REPLY_START_BIT</a> = <span class="vhdllogic">4'd8</span>, <a name="l00840"></a>00840 <a class="code" href="classbus__sd.html#aa7711dfcb90e1a1e4c6e7f8a770d7923">S_CMD_REPLY_CONTENTS</a> = <span class="vhdllogic">4'd9</span>, <a name="l00841"></a>00841 <a class="code" href="classbus__sd.html#a151e736037f5f19ea98daa933fdcbf55">S_CMD_REPLY_CRC7_END_BIT</a> = <span class="vhdllogic">4'd10</span>, <a name="l00842"></a>00842 <a class="code" href="classbus__sd.html#a255c30c2ecc9074da6af56403f9a738f">S_CMD_REPLY_FINISH_ONES</a> = <span class="vhdllogic">4'd11</span>, <a name="l00843"></a>00843 <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a> = <span class="vhdllogic">4'd12</span>; <a name="l00844"></a>00844 <a name="l00845"></a>00845 <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> <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'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00848"></a>00848 <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00849"></a>00849 <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a> <= <span class="vhdllogic">38'd0</span>; <a name="l00850"></a>00850 <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> <= <span class="vhdllogic">48'd0</span>; <a name="l00851"></a>00851 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>; <a name="l00852"></a>00852 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00853"></a>00853 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00854"></a>00854 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00855"></a>00855 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00856"></a>00856 <span class="vhdlkeyword">end</span> <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> <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'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00859"></a>00859 <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>; <a name="l00860"></a>00860 <span class="vhdlkeyword">end</span> <a name="l00861"></a>00861 <span class="vhdlkeyword">end</span> <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'd0</span> && <a class="code" href="classbus__sd.html#a9cd84ec41df06dbd360c3e51f46f7486">clk_master_ena</a> == <span class="vhdllogic">1'b1</span>) <span class="vhdlkeyword">begin</span> <a name="l00863"></a>00863 <a name="l00864"></a>00864 <span class="keyword">//send command</span> <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> <a name="l00866"></a>00866 <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00867"></a>00867 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00868"></a>00868 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00869"></a>00869 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00870"></a>00870 <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'd7</span>) <span class="vhdlkeyword">begin</span> <a name="l00872"></a>00872 <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>; <a name="l00873"></a>00873 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00874"></a>00874 <span class="vhdlkeyword">end</span> <a name="l00875"></a>00875 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00876"></a>00876 <span class="vhdlkeyword">end</span> <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> <a name="l00878"></a>00878 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00879"></a>00879 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= { <span class="vhdllogic">1'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'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>] }; <a name="l00880"></a>00880 <a name="l00881"></a>00881 <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>; <a name="l00882"></a>00882 <span class="vhdlkeyword">end</span> <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> <a name="l00884"></a>00884 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00885"></a>00885 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= { <span class="vhdllogic">1'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'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>] }; <a name="l00886"></a>00886 <a name="l00887"></a>00887 <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a> <= <a class="code" href="classbus__sd.html#a0ab7b8f1c1621014f4fb0d901ec55425">cmd_send_contents</a>; <a name="l00888"></a>00888 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a08c0d53d6a1c1db4f54cf651242e534c">S_CMD_SEND_CONTENTS</a>; <a name="l00889"></a>00889 <span class="vhdlkeyword">end</span> <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> <a name="l00891"></a>00891 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a>[<span class="vhdllogic">37</span>]; <a name="l00892"></a>00892 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= { <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>] }; <a name="l00893"></a>00893 <a class="code" href="classbus__sd.html#a1e42a166ebdca19c202b3a86bf50d91b">cmd_send</a> <= { <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'b0</span> }; <a name="l00894"></a>00894 <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'd37</span>) <span class="vhdlkeyword">begin</span> <a name="l00896"></a>00896 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#af23391dcde658bcfcb0c580244d23b38">S_CMD_SEND_CRC7</a>; <a name="l00897"></a>00897 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00898"></a>00898 <span class="vhdlkeyword">end</span> <a name="l00899"></a>00899 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00900"></a>00900 <span class="vhdlkeyword">end</span> <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> <a name="l00902"></a>00902 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">0</span>]; <a name="l00903"></a>00903 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= { <span class="vhdllogic">1'b0</span>, <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a>[<span class="vhdllogic">6</span>:<span class="vhdllogic">1</span>] }; <a name="l00904"></a>00904 <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'd6</span>) <span class="vhdlkeyword">begin</span> <a name="l00906"></a>00906 <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>; <a name="l00907"></a>00907 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00908"></a>00908 <span class="vhdlkeyword">end</span> <a name="l00909"></a>00909 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00910"></a>00910 <span class="vhdlkeyword">end</span> <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> <a name="l00912"></a>00912 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00913"></a>00913 <a name="l00914"></a>00914 <span class="keyword">// if CMD0: send ones</span> <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> <a name="l00916"></a>00916 <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>; <a name="l00917"></a>00917 <span class="vhdlkeyword">end</span> <a name="l00918"></a>00918 <span class="vhdlkeyword">else</span> <span class="vhdlkeyword">begin</span> <a name="l00919"></a>00919 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00920"></a>00920 <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>; <a name="l00921"></a>00921 <span class="vhdlkeyword">end</span> <a name="l00922"></a>00922 <span class="vhdlkeyword">end</span> <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> <a name="l00924"></a>00924 <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00925"></a>00925 <a class="code" href="classbus__sd.html#addb41adcb164f323ede9e3bd587a07a9">sd_cmd_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l00926"></a>00926 <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'd7</span>) <span class="vhdlkeyword">begin</span> <a name="l00928"></a>00928 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00929"></a>00929 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>; <a name="l00930"></a>00930 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00931"></a>00931 <span class="vhdlkeyword">end</span> <a name="l00932"></a>00932 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00933"></a>00933 <span class="vhdlkeyword">end</span> <a name="l00934"></a>00934 <a name="l00935"></a>00935 <span class="keyword">//wait for response: 48-bits with CRC7</span> <a name="l00936"></a>00936 <span class="keyword">//wait for response: 48-bits without CRC7</span> <a name="l00937"></a>00937 <span class="keyword">//wait for response: 136-bits (CMD2/R2)</span> <a name="l00938"></a>00938 <span class="keyword">//wait for response and busy on data line simultaneously: (CMD7/R1b)</span> <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> <a name="l00940"></a>00940 <a class="code" href="classbus__sd.html#a9b5356af8415976c78f855355bfc9b4e">sd_cmd_enable</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00941"></a>00941 <a name="l00942"></a>00942 <span class="vhdlkeyword">if</span>(<span class="vhdlchar">sd_cmd_io</span> == <span class="vhdllogic">1'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l00943"></a>00943 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= { <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>] }; <a name="l00944"></a>00944 <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> <= { <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> }; <a name="l00945"></a>00945 <a name="l00946"></a>00946 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#aa7711dfcb90e1a1e4c6e7f8a770d7923">S_CMD_REPLY_CONTENTS</a>; <a name="l00947"></a>00947 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00948"></a>00948 <span class="vhdlkeyword">end</span> <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'd255</span>) <span class="vhdlkeyword">begin</span> <a name="l00950"></a>00950 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= <span class="vhdllogic">7'd0</span>; <a name="l00951"></a>00951 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>; <a name="l00952"></a>00952 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00953"></a>00953 <span class="vhdlkeyword">end</span> <a name="l00954"></a>00954 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00955"></a>00955 <span class="vhdlkeyword">end</span> <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> <a name="l00957"></a>00957 <a class="code" href="classbus__sd.html#a0f0a24443e49d384933544eab9b87a06">crc7</a> <= { <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>] }; <a name="l00958"></a>00958 <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> <= { <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> }; <a name="l00959"></a>00959 <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> && <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8'd38</span>) || <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> && <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> == <span class="vhdllogic">8'd126</span>) <a name="l00962"></a>00962 ) <span class="vhdlkeyword">begin</span> <a name="l00963"></a>00963 <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>; <a name="l00964"></a>00964 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00965"></a>00965 <span class="vhdlkeyword">end</span> <a name="l00966"></a>00966 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00967"></a>00967 <span class="vhdlkeyword">end</span> <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> <a name="l00969"></a>00969 <a class="code" href="classbus__sd.html#a8300085e5ab03a14a53618851c84bd04">cmd_reply</a> <= { <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> }; <a name="l00970"></a>00970 <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'd7</span>) <span class="vhdlkeyword">begin</span> <a name="l00972"></a>00972 <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>; <a name="l00973"></a>00973 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00974"></a>00974 <span class="vhdlkeyword">end</span> <a name="l00975"></a>00975 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00976"></a>00976 <span class="vhdlkeyword">end</span> <a name="l00977"></a>00977 <span class="keyword">//at least 2 clock cycles required for data write</span> <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> <a name="l00979"></a>00979 <span class="keyword">//check is sd_dat_io busy for CMD7</span> <a name="l00980"></a>00980 <span class="vhdlkeyword">if</span>(<a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> >= <span class="vhdllogic">8'd7</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="vhdlchar">sd_dat_io</span> == <span class="vhdllogic">1'b1</span>)) <span class="vhdlkeyword">begin</span> <a name="l00981"></a>00981 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00982"></a>00982 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>; <a name="l00983"></a>00983 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00984"></a>00984 <span class="vhdlkeyword">end</span> <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'd255</span>) <span class="vhdlkeyword">begin</span> <a name="l00986"></a>00986 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a3b8b4196d6608879db2310ae4f963bba">S_CMD_REPLY_ERROR</a>; <a name="l00987"></a>00987 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00988"></a>00988 <span class="vhdlkeyword">end</span> <a name="l00989"></a>00989 <span class="vhdlkeyword">else</span> <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> + <span class="vhdllogic">8'd1</span>; <a name="l00990"></a>00990 <span class="vhdlkeyword">end</span> <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> <a name="l00992"></a>00992 <a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> <= <span class="vhdllogic">1'b0</span>; <a name="l00993"></a>00993 <a class="code" href="classbus__sd.html#af92ac4f8460f89c691e3d68a05b824c3">cmd_state</a> <= <a class="code" href="classbus__sd.html#a007749f9da50007c648bc1cd8f0ab1f0">S_CMD_IDLE</a>; <a name="l00994"></a>00994 <a class="code" href="classbus__sd.html#a6919b95b27d21385b63a32e9ea92546c">cmd_counter</a> <= <span class="vhdllogic">8'd0</span>; <a name="l00995"></a>00995 <span class="vhdlkeyword">end</span> <a name="l00996"></a>00996 <span class="vhdlkeyword">end</span> <a name="l00997"></a>00997 <span class="vhdlkeyword">end</span> <a name="l00998"></a>00998 <a name="l00999"></a>00999 <span class="keyword">//---------------------------------------------------- SD clock</span> <a name="l01000"></a>01000 <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>; <a name="l01002"></a>01002 <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> <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'b0</span>) <span class="vhdlkeyword">begin</span> <a name="l01005"></a>01005 <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> <= <span class="vhdllogic">1'b0</span>; <a name="l01006"></a>01006 <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> <= <span class="vhdllogic">2'd0</span>; <a name="l01007"></a>01007 <span class="vhdlkeyword">end</span> <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'd0</span>) <span class="vhdlkeyword">begin</span> <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'b1</span> && (<a class="code" href="classbus__sd.html#ac432a8c1ed2cc41616971fea1ab49b00">clk_cmd_ena</a> == <span class="vhdllogic">1'b1</span> || <a class="code" href="classbus__sd.html#ab248168b455618ccd7c58606bd6b89d9">clk_data_ena</a> == <span class="vhdllogic">1'b1</span>)) <span class="vhdlkeyword">begin</span> <a name="l01010"></a>01010 <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> <= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2'd1</span>; <a name="l01011"></a>01011 <span class="vhdlkeyword">end</span> <a name="l01012"></a>01012 <span class="vhdlkeyword">end</span> <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'd1</span>) <span class="vhdlkeyword">begin</span> <a name="l01014"></a>01014 <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> <= <span class="vhdllogic">1'b1</span>; <a name="l01015"></a>01015 <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> <= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2'd1</span>; <a name="l01016"></a>01016 <span class="vhdlkeyword">end</span> <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'd2</span>) <span class="vhdlkeyword">begin</span> <a name="l01018"></a>01018 <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> <= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2'd1</span>; <a name="l01019"></a>01019 <span class="vhdlkeyword">end</span> <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'd3</span>) <span class="vhdlkeyword">begin</span> <a name="l01021"></a>01021 <a class="code" href="classbus__sd.html#ae5b5d2744b20cb607a47e93f72606d20">sd_clk_o</a> <= <span class="vhdllogic">1'b0</span>; <a name="l01022"></a>01022 <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> <= <a class="code" href="classbus__sd.html#af5acc8ffdeba2303360d435a1e134fd9">clk_counter</a> + <span class="vhdllogic">2'd1</span>; <a name="l01023"></a>01023 <span class="vhdlkeyword">end</span> <a name="l01024"></a>01024 <span class="vhdlkeyword">end</span> <a name="l01025"></a>01025 <a name="l01026"></a>01026 <span class="vhdlkeyword">endmodule</span> <a name="l01027"></a>01027 </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Mon Dec 20 2010 21:20:18 for aoOCS by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address> </body> </html>