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

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [core/] [ds_dma64/] [pcie_src/] [pcie_core64_m1/] [source_artix7/] [cl_a7pcie_x4_pcie_bram_top_7x.vhd] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 dsmv
-------------------------------------------------------------------------------
2
--
3
-- (c) Copyright 2010-2011 Xilinx, Inc. All rights reserved.
4
--
5
-- This file contains confidential and proprietary information
6
-- of Xilinx, Inc. and is protected under U.S. and
7
-- international copyright and other intellectual property
8
-- laws.
9
--
10
-- DISCLAIMER
11
-- This disclaimer is not a license and does not grant any
12
-- rights to the materials distributed herewith. Except as
13
-- otherwise provided in a valid license issued to you by
14
-- Xilinx, and to the maximum extent permitted by applicable
15
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
16
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
17
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
18
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
19
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
20
-- (2) Xilinx shall not be liable (whether in contract or tort,
21
-- including negligence, or under any other theory of
22
-- liability) for any loss or damage of any kind or nature
23
-- related to, arising under or in connection with these
24
-- materials, including for any direct, or any indirect,
25
-- special, incidental, or consequential loss or damage
26
-- (including loss of data, profits, goodwill, or any type of
27
-- loss or damage suffered as a result of any action brought
28
-- by a third party) even if such damage or loss was
29
-- reasonably foreseeable or Xilinx had been advised of the
30
-- possibility of the same.
31
--
32
-- CRITICAL APPLICATIONS
33
-- Xilinx products are not designed or intended to be fail-
34
-- safe, or for use in any application requiring fail-safe
35
-- performance, such as life-support or safety devices or
36
-- systems, Class III medical devices, nuclear facilities,
37
-- applications related to the deployment of airbags, or any
38
-- other applications that could lead to death, personal
39
-- injury, or severe property or environmental damage
40
-- (individually and collectively, "Critical
41
-- Applications"). Customer assumes the sole risk and
42
-- liability of any use of Xilinx products in Critical
43
-- Applications, subject only to applicable laws and
44
-- regulations governing limitations on product liability.
45
--
46
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
47
-- PART OF THIS FILE AT ALL TIMES.
48
--
49
-------------------------------------------------------------------------------
50
-- Project    : Series-7 Integrated Block for PCI Express
51
-- File       : cl_a7pcie_x4_pcie_bram_top_7x.vhd
52 48 dsmv
-- Version    : 1.10
53 46 dsmv
--  Description : bram wrapper for Tx and Rx
54
--                given the pcie block attributes calculate the number of brams
55
--                and pipeline stages and instantiate the brams
56
--
57
--  Hierarchy:
58
--            pcie_bram_top    top level
59
--              pcie_brams     pcie_bram instantiations,
60
--                             pipeline stages (if any) then,
61
--                             address decode logic (if any) then,
62
--                             datapath muxing (if any) then
63
--                pcie_bram    bram library cell wrapper
64
--                             the pcie_bram entity can have a paramter that
65
--                             specifies the family (V6, V5, V4) then
66
--
67
-------------------------------------------------------------------------------
68
 
69
library ieee;
70
use ieee.std_logic_1164.all;
71
use ieee.std_logic_misc.all;
72
use ieee.std_logic_unsigned.all;
73
 
74
entity cl_a7pcie_x4_pcie_bram_top_7x is
75
generic(
76
   IMPL_TARGET                   : string := "HARD";        -- the implementation target : HARD, SOFT
77
   DEV_CAP_MAX_PAYLOAD_SUPPORTED : integer := 0;            -- MPS Supported : 0 - 128 B, 1 - 256 B, 2 - 512 B, 3 - 1024 B
78
   LINK_CAP_MAX_LINK_SPEED       : integer:= 1;             -- PCIe Link Speed : 1 - 2.5 GT/s; 2 - 5.0 GT/s
79
   LINK_CAP_MAX_LINK_WIDTH       : integer:= 8;             -- PCIe Link Width : 1 / 2 / 4 / 8
80
 
81
   VC0_TX_LASTPACKET             : integer:= 31;            -- Number of Packets in Transmit
82
   TLM_TX_OVERHEAD               : integer:= 24;            -- Overhead Bytes for Packets (Transmit)
83
   TL_TX_RAM_RADDR_LATENCY       : integer:= 1;             -- BRAM Read Address Latency (Transmit)
84
   TL_TX_RAM_RDATA_LATENCY       : integer:= 2;             -- BRAM Read Data Latency (Transmit)
85
   TL_TX_RAM_WRITE_LATENCY       : integer:= 1;             -- BRAM Write Latency (Transmit)
86
 
87
   VC0_RX_RAM_LIMIT              : bit_vector := x"1FFF";   -- 'h1FFFF RAM Size (Receive)
88
   TL_RX_RAM_RADDR_LATENCY       : integer:= 1;             -- BRAM Read Address Latency (Receive)
89
   TL_RX_RAM_RDATA_LATENCY       : integer:= 2;             -- BRAM Read Data Latency (Receive)
90
   TL_RX_RAM_WRITE_LATENCY       : integer:= 1              -- BRAM Write Latency (Receive)
91
);
92
port (
93
   user_clk_i : in std_logic;                          --  Clock input
94
   reset_i : in std_logic;                             --  Reset input
95
 
96
   mim_tx_wen   : in std_logic;                        -- Write Enable for Transmit path BRAM
97
   mim_tx_waddr : in std_logic_vector(12 downto 0);    -- Write Address for Transmit path BRAM
98
   mim_tx_wdata : in std_logic_vector(71 downto 0);    -- Write Data for Transmit path BRAM
99
   mim_tx_ren   : in std_logic;                        -- Read Enable for Transmit path BRAM
100
   mim_tx_rce   : in std_logic;                        -- Read Output Register Clock Enable for Transmit path BRAM
101
   mim_tx_raddr : in std_logic_vector(12 downto 0);    -- Read Address for Transmit path BRAM
102
   mim_tx_rdata : out std_logic_vector(71 downto 0);   -- Read Data for Transmit path BRAM
103
 
104
   mim_rx_wen   : in std_logic;                        -- Write Enable for Receive path BRAM
105
   mim_rx_waddr : in std_logic_vector(12 downto 0);    -- Write Address for Receive path BRAM
106
   mim_rx_wdata : in std_logic_vector(71 downto 0);    -- Write Data for Receive path BRAM
107
   mim_rx_ren   : in std_logic;                        -- Read Enable for Receive path BRAM
108
   mim_rx_rce   : in std_logic;                        -- Read Output Register Clock Enable for Receive path BRAM
109
   mim_rx_raddr : in std_logic_vector(12 downto 0);    -- Read Address for Receive path BRAM
110
   mim_rx_rdata : out std_logic_vector(71 downto 0)    -- Read Data for Receive path BRAM
111
);
112
 
113
end cl_a7pcie_x4_pcie_bram_top_7x;
114
 
115
 
116
architecture pcie_7x of cl_a7pcie_x4_pcie_bram_top_7x is
117
 
118
  component cl_a7pcie_x4_pcie_brams_7x
119
   generic (
120
     LINK_CAP_MAX_LINK_SPEED : integer := 1;        -- PCIe Link Speed : 1 - 2.5 GT/s; 2 - 5.0 GT/s
121
     LINK_CAP_MAX_LINK_WIDTH : integer := 8;        -- PCIe Link Width : 1 / 2 / 4 / 8
122
     IMPL_TARGET             : string := "HARD";    -- the implementation target : HARD, SOFT
123
     NUM_BRAMS               : integer := 0;
124
     RAM_RADDR_LATENCY       : integer := 1;
125
     RAM_RDATA_LATENCY       :integer := 1;
126
     RAM_WRITE_LATENCY       :integer := 1
127
   );
128
   port (
129
     user_clk_i : in std_logic;
130
     reset_i    : in std_logic;
131
     wen        : in std_logic;
132
     waddr      : in std_logic_vector(12 downto 0);
133
     wdata      : in std_logic_vector(71 downto 0);
134
     ren        : in std_logic;
135
     rce        : in std_logic;
136
     raddr      : in std_logic_vector(12 downto 0);
137
     rdata      : out std_logic_vector(71 downto 0));
138
  end component;
139
 
140
  -- TX calculations
141
  function cols_tx (
142
    constant CMPS                : integer;
143
    constant VC0_TX_LASTPACKET   : integer;
144
    constant TLM_TX_OVERHEAD     : integer)
145
    return integer is
146
     variable MPS_BYTES : integer := 128;
147
     variable BYTES_TX : integer := 0;
148
     variable COLS_TX : integer := 1;
149
  begin  -- cols_tx
150
 
151
    if (cmps = 0) then
152
      MPS_BYTES := 128;
153
    elsif (cmps = 1) then
154
      MPS_BYTES := 256;
155
    elsif (cmps = 2) then
156
      MPS_BYTES := 512;
157
    else
158
      MPS_BYTES := 1024;
159
    end if;
160
    BYTES_TX := ((VC0_TX_LASTPACKET + 1) * (MPS_BYTES + TLM_TX_OVERHEAD));
161
    if (BYTES_TX <= 4096) then
162
      COLS_TX := 1;
163
    elsif (BYTES_TX <= 8192) then
164
      COLS_TX := 2;
165
    elsif (BYTES_TX <= 16384) then
166
      COLS_TX := 4;
167
    elsif (BYTES_TX <= 32768) then
168
      COLS_TX := 8;
169
    else
170
      COLS_TX := 18;
171
    end if;
172
    return COLS_TX;
173
  end cols_tx;
174
 
175
  FUNCTION to_integer (
176
      val_in    : bit_vector) RETURN integer IS
177
 
178
      CONSTANT vctr   : bit_vector(val_in'high-val_in'low DOWNTO 0) := val_in;
179
      VARIABLE ret    : integer := 0;
180
   BEGIN
181
      FOR index IN vctr'RANGE LOOP
182
         IF (vctr(index) = '1') THEN
183
            ret := ret + (2**index);
184
         END IF;
185
      END LOOP;
186
      RETURN(ret);
187
   END to_integer;
188
 
189
  -- RX calculations
190
  function cols_rx (
191
    constant VC0_RX_RAM_LIMIT   : integer)
192
    return integer is
193
     variable COLS_RX : integer := 1;
194
  begin  -- cols_rx
195
    if (VC0_RX_RAM_LIMIT < 512) then        -- X"0200"
196
      COLS_RX := 1;
197
    elsif (VC0_RX_RAM_LIMIT < 1024) then    -- X"0400"
198
      COLS_RX := 2;
199
    elsif (VC0_RX_RAM_LIMIT < 2048) then    -- X"0800"
200
      COLS_RX := 4;
201
    elsif (VC0_RX_RAM_LIMIT < 4096) then    -- X"1000"
202
      COLS_RX := 8;
203
    else
204
      COLS_RX := 18;
205
    end if;
206
    return COLS_RX;
207
  end cols_rx;
208
 
209
   constant ROWS_TX                                : integer := 1;
210
   constant ROWS_RX                                : integer := 1;
211
 
212
--   process 
213
--   begin
214
--      -- $display("[%t] %m ROWS_TX %0d COLS_TX %0d", now, to_stdlogic(ROWS_TX), to_stdlogicvector(COLS_TX, 13));
215
--      -- $display("[%t] %m ROWS_RX %0d COLS_RX %0d", now, to_stdlogic(ROWS_RX), to_stdlogicvector(COLS_RX, 13));
216
--      wait;
217
--   end process;
218
  begin
219
  pcie_brams_tx: cl_a7pcie_x4_pcie_brams_7x
220
  generic map (
221
    LINK_CAP_MAX_LINK_WIDTH =>  LINK_CAP_MAX_LINK_WIDTH ,
222
    LINK_CAP_MAX_LINK_SPEED =>  LINK_CAP_MAX_LINK_SPEED ,
223
    IMPL_TARGET             =>  IMPL_TARGET ,
224
    NUM_BRAMS               =>  cols_tx(DEV_CAP_MAX_PAYLOAD_SUPPORTED, VC0_TX_LASTPACKET, TLM_TX_OVERHEAD) ,
225
    RAM_RADDR_LATENCY       =>  TL_TX_RAM_RADDR_LATENCY ,
226
    RAM_RDATA_LATENCY       =>  TL_TX_RAM_RDATA_LATENCY ,
227
    RAM_WRITE_LATENCY       =>  TL_TX_RAM_WRITE_LATENCY
228
  )
229
  port map (
230
    user_clk_i =>  user_clk_i ,
231
    reset_i    =>  reset_i ,
232
    waddr      =>  mim_tx_waddr ,
233
    wen        =>  mim_tx_wen ,
234
    ren        =>  mim_tx_ren ,
235
    rce        =>  mim_tx_rce ,
236
    wdata      =>  mim_tx_wdata ,
237
    raddr      =>  mim_tx_raddr ,
238
    rdata      =>  mim_tx_rdata
239
  );
240
 
241
 pcie_brams_rx: cl_a7pcie_x4_pcie_brams_7x
242
  generic map(
243
    LINK_CAP_MAX_LINK_WIDTH =>  LINK_CAP_MAX_LINK_WIDTH ,
244
    LINK_CAP_MAX_LINK_SPEED =>  LINK_CAP_MAX_LINK_SPEED ,
245
    IMPL_TARGET             =>  IMPL_TARGET ,
246
    NUM_BRAMS               =>  cols_rx(to_integer(VC0_RX_RAM_LIMIT)) ,
247
    RAM_RADDR_LATENCY       =>  TL_RX_RAM_RADDR_LATENCY ,
248
    RAM_RDATA_LATENCY       =>  TL_RX_RAM_RDATA_LATENCY ,
249
    RAM_WRITE_LATENCY       =>  TL_RX_RAM_WRITE_LATENCY
250
  )
251
  port map (
252
    user_clk_i =>  user_clk_i ,
253
    reset_i    =>  reset_i ,
254
    waddr      =>  mim_rx_waddr ,
255
    wen        =>  mim_rx_wen ,
256
    ren        =>  mim_rx_ren ,
257
    rce        =>  mim_rx_rce ,
258
    wdata      =>  mim_rx_wdata ,
259
    raddr      =>  mim_rx_raddr ,
260
    rdata      =>  mim_rx_rdata
261
   );
262
 
263
end pcie_7x; -- pcie_bram_top
264
 

powered by: WebSVN 2.1.0

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