DS_DMA
|
00001 ------------------------------------------------------------------------------- 00002 -- 00003 -- (c) Copyright 2008, 2009 Xilinx, Inc. All rights reserved. 00004 -- 00005 -- This file contains confidential and proprietary information 00006 -- of Xilinx, Inc. and is protected under U.S. and 00007 -- international copyright and other intellectual property 00008 -- laws. 00009 -- 00010 -- DISCLAIMER 00011 -- This disclaimer is not a license and does not grant any 00012 -- rights to the materials distributed herewith. Except as 00013 -- otherwise provided in a valid license issued to you by 00014 -- Xilinx, and to the maximum extent permitted by applicable 00015 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND 00016 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES 00017 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING 00018 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- 00019 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and 00020 -- (2) Xilinx shall not be liable (whether in contract or tort, 00021 -- including negligence, or under any other theory of 00022 -- liability) for any loss or damage of any kind or nature 00023 -- related to, arising under or in connection with these 00024 -- materials, including for any direct, or any indirect, 00025 -- special, incidental, or consequential loss or damage 00026 -- (including loss of data, profits, goodwill, or any type of 00027 -- loss or damage suffered as a result of any action brought 00028 -- by a third party) even if such damage or loss was 00029 -- reasonably foreseeable or Xilinx had been advised of the 00030 -- possibility of the same. 00031 -- 00032 -- CRITICAL APPLICATIONS 00033 -- Xilinx products are not designed or intended to be fail- 00034 -- safe, or for use in any application requiring fail-safe 00035 -- performance, such as life-support or safety devices or 00036 -- systems, Class III medical devices, nuclear facilities, 00037 -- applications related to the deployment of airbags, or any 00038 -- other applications that could lead to death, personal 00039 -- injury, or severe property or environmental damage 00040 -- (individually and collectively, "Critical 00041 -- Applications"). Customer assumes the sole risk and 00042 -- liability of any use of Xilinx products in Critical 00043 -- Applications, subject only to applicable laws and 00044 -- regulations governing limitations on product liability. 00045 -- 00046 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS 00047 -- PART OF THIS FILE AT ALL TIMES. 00048 -- 00049 ------------------------------------------------------------------------------- 00050 -- Project : Spartan-6 Integrated Block for PCI Express 00051 -- File : pcie_bram_top_s6.vhd 00052 -- Description: BlockRAM top level module for Spartan-6 PCIe Block 00053 -- 00054 -- Given the selected core configuration, calculate the number of 00055 -- BRAMs and pipeline stages and instantiate the BRAMS. 00056 -- 00057 ------------------------------------------------------------------------------- 00058 00059 library ieee; 00060 use ieee.std_logic_1164.all; 00061 use ieee.std_logic_arith.all; 00062 use ieee.std_logic_unsigned.all; 00063 00064 entity pcie_bram_top_s6 is 00065 generic ( 00066 DEV_CAP_MAX_PAYLOAD_SUPPORTED : integer := 0; 00067 00068 VC0_TX_LASTPACKET : integer := 31; 00069 TLM_TX_OVERHEAD : integer := 20; 00070 TL_TX_RAM_RADDR_LATENCY : integer := 1; 00071 TL_TX_RAM_RDATA_LATENCY : integer := 2; 00072 TL_TX_RAM_WRITE_LATENCY : integer := 1; 00073 00074 VC0_RX_LIMIT : integer := 16#1FFF#; 00075 TL_RX_RAM_RADDR_LATENCY : integer := 1; 00076 TL_RX_RAM_RDATA_LATENCY : integer := 2; 00077 TL_RX_RAM_WRITE_LATENCY : integer := 1 00078 ); 00079 port ( 00080 user_clk_i : in std_logic; 00081 reset_i : in std_logic; 00082 00083 mim_tx_wen : in std_logic; 00084 mim_tx_waddr : in std_logic_vector(11 downto 0); 00085 mim_tx_wdata : in std_logic_vector(35 downto 0); 00086 mim_tx_ren : in std_logic; 00087 mim_tx_rce : in std_logic; 00088 mim_tx_raddr : in std_logic_vector(11 downto 0); 00089 mim_tx_rdata : out std_logic_vector(35 downto 0); 00090 00091 mim_rx_wen : in std_logic; 00092 mim_rx_waddr : in std_logic_vector(11 downto 0); 00093 mim_rx_wdata : in std_logic_vector(35 downto 0); 00094 mim_rx_ren : in std_logic; 00095 mim_rx_rce : in std_logic; 00096 mim_rx_raddr : in std_logic_vector(11 downto 0); 00097 mim_rx_rdata : out std_logic_vector(35 downto 0) 00098 ); 00099 end pcie_bram_top_s6; 00100 00101 architecture rtl of pcie_bram_top_s6 is 00102 00103 component pcie_brams_s6 00104 generic ( 00105 NUM_BRAMS : integer; 00106 RAM_RADDR_LATENCY : integer; 00107 RAM_RDATA_LATENCY : integer; 00108 RAM_WRITE_LATENCY : integer 00109 ); 00110 port ( 00111 user_clk_i : in std_logic; 00112 reset_i : in std_logic; 00113 wen : in std_logic; 00114 waddr : in std_logic_vector(11 downto 0); 00115 wdata : in std_logic_vector(35 downto 0); 00116 ren : in std_logic; 00117 rce : in std_logic; 00118 raddr : in std_logic_vector(11 downto 0); 00119 rdata : out std_logic_vector(35 downto 0) 00120 ); 00121 end component; 00122 00123 function CALC_TX_COLS(constant MPS : in integer; 00124 constant LASTPACKET : in integer; 00125 constant OVERHEAD : in integer 00126 ) return integer is 00127 variable MPS_BYTES : integer; 00128 variable BYTES_TX : integer; 00129 variable COLS_TX : integer; 00130 begin 00131 -- Decode MPS value 00132 if (MPS = 0) then MPS_BYTES := 128; 00133 elsif (MPS = 1) then MPS_BYTES := 256; 00134 else MPS_BYTES := 512; -- MPS = 2 00135 end if; 00136 00137 -- Calculate total bytes from MPS, number of packets, and overhead 00138 BYTES_TX := (LASTPACKET + 1) * (MPS_BYTES + OVERHEAD); 00139 00140 -- Determine number of BRAM columns from total bytes 00141 if (BYTES_TX <= 2048) then COLS_TX := 1; 00142 elsif (BYTES_TX <= 4096) then COLS_TX := 2; 00143 else COLS_TX := 4; -- BYTES_TX <= 8192 00144 end if; 00145 return COLS_TX; 00146 end function CALC_TX_COLS; 00147 00148 function CALC_RX_COLS(constant LIMIT : in integer) return integer is 00149 variable COLS_RX : integer; 00150 begin 00151 -- Determine number of BRAM columns from total RAM size 00152 if (LIMIT <= 512) then COLS_RX := 1; 00153 elsif (LIMIT <= 1024) then COLS_RX := 2; 00154 else COLS_RX := 4; -- LIMIT <= 2048 00155 end if; 00156 return COLS_RX; 00157 end function CALC_RX_COLS; 00158 00159 begin 00160 00161 pcie_brams_tx : pcie_brams_s6 00162 generic map( 00163 NUM_BRAMS => CALC_TX_COLS(DEV_CAP_MAX_PAYLOAD_SUPPORTED, VC0_TX_LASTPACKET, TLM_TX_OVERHEAD), 00164 RAM_RADDR_LATENCY => TL_TX_RAM_RADDR_LATENCY, 00165 RAM_RDATA_LATENCY => TL_TX_RAM_RDATA_LATENCY, 00166 RAM_WRITE_LATENCY => TL_TX_RAM_WRITE_LATENCY 00167 ) 00168 port map ( 00169 user_clk_i => user_clk_i, 00170 reset_i => reset_i, 00171 00172 waddr => mim_tx_waddr, 00173 wen => mim_tx_wen, 00174 ren => mim_tx_ren, 00175 rce => mim_tx_rce, 00176 wdata => mim_tx_wdata, 00177 raddr => mim_tx_raddr, 00178 rdata => mim_tx_rdata 00179 ); 00180 00181 pcie_brams_rx : pcie_brams_s6 00182 generic map( 00183 NUM_BRAMS => CALC_RX_COLS(VC0_RX_LIMIT), 00184 RAM_RADDR_LATENCY => TL_RX_RAM_RADDR_LATENCY, 00185 RAM_RDATA_LATENCY => TL_RX_RAM_RDATA_LATENCY, 00186 RAM_WRITE_LATENCY => TL_RX_RAM_WRITE_LATENCY 00187 ) 00188 port map ( 00189 user_clk_i => user_clk_i, 00190 reset_i => reset_i, 00191 00192 waddr => mim_rx_waddr, 00193 wen => mim_rx_wen, 00194 ren => mim_rx_ren, 00195 rce => mim_rx_rce, 00196 wdata => mim_rx_wdata, 00197 raddr => mim_rx_raddr, 00198 rdata => mim_rx_rdata 00199 ); 00200 00201 end rtl;