Aveon-mm____sd_card IP Design

Source: Internet
Author: User

(1) Code

/************************************ * *****************************
* Module name: crazy_sdcard
* Author: crazy bingo
* Device: ep2c8q208c8
* version: Quartus II 10.1
* Date: 2011-3-3
* description:
************************************* *******************************/

/*************************************** *****************************
* Module name: crazy_key_led
* Author: crazy bingo
* Device: ep2c8q208c8
* Version: Quartus II 10.1
* Date: 2011-3-2
* Description:
**************************************** *****************************/
Module crazy_sdcard
(
// Aveon clock
Input csi_clk,
Input csi_rst_n,
// Aveon-mm
Input avs_chipselect,
Input [1:0] avs_address, // multiple of 4
// Input [1:0] avs_byteenable_n, // 128
Input avs_write,
Input [31: 0] avs_writedata, // 32bit CPU
Input avs_read,
Output [31: 0] avs_readdata, // 32bit CPU
// Aveon conducting it
Output Reg coe_sd_cs,
Output Reg coe_sd_clk,
Input coe_sd_miso,
Output Reg coe_sd_mosi // 2 bis led
);

// Write
Reg [1:0] coe_led_data_r;
Always @ (posedge csi_clk or negedge csi_rst_n)
Begin
If (! Csi_rst_n)
Begin
Coe_sd_cs <= 0;
Coe_sd_clk <= 0;
Coe_sd_mosi <= 0;
End
Else if (avs_chipselect & avs_write)
Begin
Case (avs_address)
0: coe_sd_cs <= avs_writedata [0];
2: coe_sd_clk <= avs_writedata [0];
3: coe_sd_mosi <= avs_writedata [0];
Default:; // 4
Endcase
End
End

// Read
Reg avs_readdata_r;
Always @ (posedge csi_clk or negedge csi_rst_n)
Begin
If (! Csi_rst_n)
Avs_readdata_r <= 0;
Else if (avs_chipselect & avs_read & (avs_address = 4) // For steady state
Avs_readdata_r <= coe_sd_miso;
End
Assign avs_readdata = avs_readdata_r;

Endmodule

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.