DS_DMA
|
00001 00002 ------------------------------------------------------------------------------- 00003 -- 00004 -- (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved. 00005 -- 00006 -- This file contains confidential and proprietary information 00007 -- of Xilinx, Inc. and is protected under U.S. and 00008 -- international copyright and other intellectual property 00009 -- laws. 00010 -- 00011 -- DISCLAIMER 00012 -- This disclaimer is not a license and does not grant any 00013 -- rights to the materials distributed herewith. Except as 00014 -- otherwise provided in a valid license issued to you by 00015 -- Xilinx, and to the maximum extent permitted by applicable 00016 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND 00017 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES 00018 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING 00019 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- 00020 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and 00021 -- (2) Xilinx shall not be liable (whether in contract or tort, 00022 -- including negligence, or under any other theory of 00023 -- liability) for any loss or damage of any kind or nature 00024 -- related to, arising under or in connection with these 00025 -- materials, including for any direct, or any indirect, 00026 -- special, incidental, or consequential loss or damage 00027 -- (including loss of data, profits, goodwill, or any type of 00028 -- loss or damage suffered as a result of any action brought 00029 -- by a third party) even if such damage or loss was 00030 -- reasonably foreseeable or Xilinx had been advised of the 00031 -- possibility of the same. 00032 -- 00033 -- CRITICAL APPLICATIONS 00034 -- Xilinx products are not designed or intended to be fail- 00035 -- safe, or for use in any application requiring fail-safe 00036 -- performance, such as life-support or safety devices or 00037 -- systems, Class III medical devices, nuclear facilities, 00038 -- applications related to the deployment of airbags, or any 00039 -- other applications that could lead to death, personal 00040 -- injury, or severe property or environmental damage 00041 -- (individually and collectively, "Critical 00042 -- Applications"). Customer assumes the sole risk and 00043 -- liability of any use of Xilinx products in Critical 00044 -- Applications, subject only to applicable laws and 00045 -- regulations governing limitations on product liability. 00046 -- 00047 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS 00048 -- PART OF THIS FILE AT ALL TIMES. 00049 -- 00050 ------------------------------------------------------------------------------- 00051 -- Project : Virtex-6 Integrated Block for PCI Express 00052 -- File : pcie_bram_top_v6.vhd 00053 -- Version : 2.3 00054 ---- Description: BlockRAM top level module for Virtex6 PCIe Block 00055 ---- 00056 ---- 00057 ---- 00058 ---------------------------------------------------------------------------------- 00059 00060 library ieee; 00061 use ieee.std_logic_1164.all; 00062 use ieee.std_logic_unsigned.all; 00063 00064 entity pcie_bram_top_v6 is 00065 generic ( 00066 DEV_CAP_MAX_PAYLOAD_SUPPORTED : integer := 0; 00067 00068 VC0_TX_LASTPACKET : integer := 31; 00069 TLM_TX_OVERHEAD : integer := 24; 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 : bit_vector := x"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 ); 00080 port ( 00081 user_clk_i : in std_logic; 00082 reset_i : in std_logic; 00083 mim_tx_wen : in std_logic; 00084 mim_tx_waddr : in std_logic_vector(12 downto 0); 00085 mim_tx_wdata : in std_logic_vector(71 downto 0); 00086 mim_tx_ren : in std_logic; 00087 mim_tx_rce : in std_logic; 00088 mim_tx_raddr : in std_logic_vector(12 downto 0); 00089 mim_tx_rdata : out std_logic_vector(71 downto 0); 00090 mim_rx_wen : in std_logic; 00091 mim_rx_waddr : in std_logic_vector(12 downto 0); 00092 mim_rx_wdata : in std_logic_vector(71 downto 0); 00093 mim_rx_ren : in std_logic; 00094 mim_rx_rce : in std_logic; 00095 mim_rx_raddr : in std_logic_vector(12 downto 0); 00096 mim_rx_rdata : out std_logic_vector(71 downto 0) 00097 ); 00098 end pcie_bram_top_v6; 00099 00100 architecture v6_pcie of pcie_bram_top_v6 is 00101 00102 component pcie_brams_v6 00103 generic ( 00104 NUM_BRAMS : integer; 00105 RAM_RADDR_LATENCY : integer; 00106 RAM_RDATA_LATENCY : integer; 00107 RAM_WRITE_LATENCY : integer); 00108 port ( 00109 user_clk_i : in std_logic; 00110 reset_i : in std_logic; 00111 wen : in std_logic; 00112 waddr : in std_logic_vector(12 downto 0); 00113 wdata : in std_logic_vector(71 downto 0); 00114 ren : in std_logic; 00115 rce : in std_logic; 00116 raddr : in std_logic_vector(12 downto 0); 00117 rdata : out std_logic_vector(71 downto 0)); 00118 end component; 00119 00120 -- TX calculations 00121 function cols_tx ( 00122 constant CMPS : integer; 00123 constant VC0_TX_LASTPACKET : integer; 00124 constant TLM_TX_OVERHEAD : integer) 00125 return integer is 00126 variable MPS_BYTES : integer := 128; 00127 variable BYTES_TX : integer := 0; 00128 variable COLS_TX : integer := 1; 00129 begin -- cols_tx 00130 00131 if (cmps = 0) then 00132 MPS_BYTES := 128; 00133 elsif (cmps = 1) then 00134 MPS_BYTES := 256; 00135 elsif (cmps = 2) then 00136 MPS_BYTES := 512; 00137 else 00138 MPS_BYTES := 1024; 00139 end if; 00140 BYTES_TX := ((VC0_TX_LASTPACKET + 1) * (MPS_BYTES + TLM_TX_OVERHEAD)); 00141 if (BYTES_TX <= 4096) then 00142 COLS_TX := 1; 00143 elsif (BYTES_TX <= 8192) then 00144 COLS_TX := 2; 00145 elsif (BYTES_TX <= 16384) then 00146 COLS_TX := 4; 00147 elsif (BYTES_TX <= 32768) then 00148 COLS_TX := 8; 00149 else 00150 COLS_TX := 18; 00151 end if; 00152 return COLS_TX; 00153 end cols_tx; 00154 00155 FUNCTION to_integer ( 00156 val_in : bit_vector) RETURN integer IS 00157 00158 CONSTANT vctr : bit_vector(val_in'high-val_in'low DOWNTO 0) := val_in; 00159 VARIABLE ret : integer := 0; 00160 BEGIN 00161 FOR index IN vctr'RANGE LOOP 00162 IF (vctr(index) = '1') THEN 00163 ret := ret + (2**index); 00164 END IF; 00165 END LOOP; 00166 RETURN(ret); 00167 END to_integer; 00168 00169 -- RX calculations 00170 function cols_rx ( 00171 constant VC0_RX_LIMIT : integer) 00172 return integer is 00173 variable COLS_RX : integer := 1; 00174 begin -- cols_rx 00175 00176 if (VC0_RX_LIMIT < 512) then -- X"0200" 00177 COLS_RX := 1; 00178 elsif (VC0_RX_LIMIT < 1024) then -- X"0400" 00179 COLS_RX := 2; 00180 elsif (VC0_RX_LIMIT < 2048) then -- X"0800" 00181 COLS_RX := 4; 00182 elsif (VC0_RX_LIMIT < 4096) then -- X"1000" 00183 COLS_RX := 8; 00184 else 00185 COLS_RX := 18; 00186 end if; 00187 return COLS_RX; 00188 end cols_rx; 00189 00190 00191 constant ROWS_TX : integer := 1; 00192 00193 constant ROWS_RX : integer := 1; 00194 00195 -- Declare intermediate signals for referenced outputs 00196 signal mim_tx_rdata_v6pcie1 : std_logic_vector(71 downto 0); 00197 signal mim_rx_rdata_v6pcie0 : std_logic_vector(71 downto 0); 00198 00199 begin 00200 -- Drive referenced outputs 00201 mim_tx_rdata <= mim_tx_rdata_v6pcie1; 00202 mim_rx_rdata <= mim_rx_rdata_v6pcie0; 00203 00204 -- process 00205 -- begin 00206 -- -- $display("[%t] %m ROWS_TX %0d COLS_TX %0d", now, to_stdlogic(ROWS_TX), to_stdlogicvector(COLS_TX, 13)); 00207 -- -- $display("[%t] %m ROWS_RX %0d COLS_RX %0d", now, to_stdlogic(ROWS_RX), to_stdlogicvector(COLS_RX, 13)); 00208 -- wait; 00209 -- end process; 00210 00211 00212 pcie_brams_tx : pcie_brams_v6 00213 generic map ( 00214 NUM_BRAMS => cols_tx(DEV_CAP_MAX_PAYLOAD_SUPPORTED, VC0_TX_LASTPACKET, TLM_TX_OVERHEAD), 00215 RAM_RADDR_LATENCY => TL_TX_RAM_RADDR_LATENCY, 00216 RAM_RDATA_LATENCY => TL_TX_RAM_RDATA_LATENCY, 00217 RAM_WRITE_LATENCY => TL_TX_RAM_WRITE_LATENCY 00218 ) 00219 port map ( 00220 user_clk_i => user_clk_i, 00221 reset_i => reset_i, 00222 00223 waddr => mim_tx_waddr, 00224 wen => mim_tx_wen, 00225 ren => mim_tx_ren, 00226 rce => mim_tx_rce, 00227 wdata => mim_tx_wdata, 00228 raddr => mim_tx_raddr , 00229 rdata => mim_tx_rdata_v6pcie1 00230 ); 00231 00232 00233 00234 pcie_brams_rx : pcie_brams_v6 00235 generic map ( 00236 NUM_BRAMS => cols_rx(to_integer(VC0_RX_LIMIT)), 00237 RAM_RADDR_LATENCY => TL_RX_RAM_RADDR_LATENCY, 00238 RAM_RDATA_LATENCY => TL_RX_RAM_RDATA_LATENCY, 00239 RAM_WRITE_LATENCY => TL_RX_RAM_WRITE_LATENCY 00240 ) 00241 port map ( 00242 user_clk_i => user_clk_i, 00243 reset_i => reset_i, 00244 00245 waddr => mim_rx_waddr, 00246 wen => mim_rx_wen, 00247 ren => mim_rx_ren, 00248 rce => mim_rx_rce, 00249 wdata => mim_rx_wdata, 00250 raddr => mim_rx_raddr , 00251 rdata => mim_rx_rdata_v6pcie0 00252 ); 00253 00254 end v6_pcie; 00255 00256 00257 00258 -- pcie_bram_top