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

Subversion Repositories pcie_mini

[/] [pcie_mini/] [trunk/] [example_design/] [pcie_bram_top_s6.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 buenos
-------------------------------------------------------------------------------
2
--
3
-- (c) Copyright 2008, 2009 Xilinx, Inc. All rights reserved.
4
--
5
-- This file contains confidential and proprietary information of Xilinx, Inc.
6
-- and is protected under U.S. and international copyright and other
7
-- intellectual property laws.
8
--
9
-- DISCLAIMER
10
--
11
-- This disclaimer is not a license and does not grant any rights to the
12
-- materials distributed herewith. Except as otherwise provided in a valid
13
-- license issued to you by Xilinx, and to the maximum extent permitted by
14
-- applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
15
-- FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
16
-- IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
17
-- MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
18
-- and (2) Xilinx shall not be liable (whether in contract or tort, including
19
-- negligence, or under any other theory of liability) for any loss or damage
20
-- of any kind or nature related to, arising under or in connection with these
21
-- materials, including for any direct, or any indirect, special, incidental,
22
-- or consequential loss or damage (including loss of data, profits, goodwill,
23
-- or any type of loss or damage suffered as a result of any action brought by
24
-- a third party) even if such damage or loss was reasonably foreseeable or
25
-- Xilinx had been advised of the possibility of the same.
26
--
27
-- CRITICAL APPLICATIONS
28
--
29
-- Xilinx products are not designed or intended to be fail-safe, or for use in
30
-- any application requiring fail-safe performance, such as life-support or
31
-- safety devices or systems, Class III medical devices, nuclear facilities,
32
-- applications related to the deployment of airbags, or any other
33
-- applications that could lead to death, personal injury, or severe property
34
-- or environmental damage (individually and collectively, "Critical
35
-- Applications"). Customer assumes the sole risk and liability of any use of
36
-- Xilinx products in Critical Applications, subject only to applicable laws
37
-- and regulations governing limitations on product liability.
38
--
39
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
40
-- AT ALL TIMES.
41
--
42
-------------------------------------------------------------------------------
43
-- Project    : Spartan-6 Integrated Block for PCI Express
44
-- File       : pcie_bram_top_s6.vhd
45
-- Description: BlockRAM top level module for Spartan-6 PCIe Block
46
--
47
--              Given the selected core configuration, calculate the number of
48
--              BRAMs and pipeline stages and instantiate the BRAMS.
49
--
50
-------------------------------------------------------------------------------
51
 
52
library ieee;
53
use ieee.std_logic_1164.all;
54
use ieee.std_logic_arith.all;
55
use ieee.std_logic_unsigned.all;
56
 
57
entity pcie_bram_top_s6 is
58
  generic (
59
    DEV_CAP_MAX_PAYLOAD_SUPPORTED : integer    := 0;
60
 
61
    VC0_TX_LASTPACKET             : integer    := 31;
62
    TLM_TX_OVERHEAD               : integer    := 20;
63
    TL_TX_RAM_RADDR_LATENCY       : integer    := 1;
64
    TL_TX_RAM_RDATA_LATENCY       : integer    := 2;
65
    TL_TX_RAM_WRITE_LATENCY       : integer    := 1;
66
 
67
    VC0_RX_LIMIT                  : integer    := 16#1FFF#;
68
    TL_RX_RAM_RADDR_LATENCY       : integer    := 1;
69
    TL_RX_RAM_RDATA_LATENCY       : integer    := 2;
70
    TL_RX_RAM_WRITE_LATENCY       : integer    := 1
71
  );
72
  port (
73
    user_clk_i         : in  std_logic;
74
    reset_i            : in  std_logic;
75
 
76
    mim_tx_wen         : in  std_logic;
77
    mim_tx_waddr       : in  std_logic_vector(11 downto 0);
78
    mim_tx_wdata       : in  std_logic_vector(35 downto 0);
79
    mim_tx_ren         : in  std_logic;
80
    mim_tx_rce         : in  std_logic;
81
    mim_tx_raddr       : in  std_logic_vector(11 downto 0);
82
    mim_tx_rdata       : out std_logic_vector(35 downto 0);
83
 
84
    mim_rx_wen         : in  std_logic;
85
    mim_rx_waddr       : in  std_logic_vector(11 downto 0);
86
    mim_rx_wdata       : in  std_logic_vector(35 downto 0);
87
    mim_rx_ren         : in  std_logic;
88
    mim_rx_rce         : in  std_logic;
89
    mim_rx_raddr       : in  std_logic_vector(11 downto 0);
90
    mim_rx_rdata       : out std_logic_vector(35 downto 0)
91
  );
92
end pcie_bram_top_s6;
93
 
94
architecture rtl of pcie_bram_top_s6 is
95
 
96
  component pcie_brams_s6
97
    generic (
98
      NUM_BRAMS         : integer;
99
      RAM_RADDR_LATENCY : integer;
100
      RAM_RDATA_LATENCY : integer;
101
      RAM_WRITE_LATENCY : integer
102
    );
103
    port (
104
      user_clk_i  : in std_logic;
105
      reset_i     : in std_logic;
106
      wen         : in std_logic;
107
      waddr       : in std_logic_vector(11 downto 0);
108
      wdata       : in std_logic_vector(35 downto 0);
109
      ren         : in std_logic;
110
      rce         : in std_logic;
111
      raddr       : in std_logic_vector(11 downto 0);
112
      rdata       : out std_logic_vector(35 downto 0)
113
    );
114
  end component;
115
 
116
  function CALC_TX_COLS(constant MPS        : in integer;
117
                        constant LASTPACKET : in integer;
118
                        constant OVERHEAD   : in integer
119
                       ) return integer is
120
    variable MPS_BYTES : integer;
121
    variable BYTES_TX  : integer;
122
    variable COLS_TX   : integer;
123
  begin
124
    -- Decode MPS value
125
    if    (MPS = 0) then MPS_BYTES := 128;
126
    elsif (MPS = 1) then MPS_BYTES := 256;
127
    else                 MPS_BYTES := 512; -- MPS = 2
128
    end if;
129
 
130
    -- Calculate total bytes from MPS, number of packets, and overhead
131
    BYTES_TX := (LASTPACKET + 1) * (MPS_BYTES + OVERHEAD);
132
 
133
    -- Determine number of BRAM columns from total bytes
134
    if    (BYTES_TX <= 2048) then COLS_TX := 1;
135
    elsif (BYTES_TX <= 4096) then COLS_TX := 2;
136
    else                          COLS_TX := 4; -- BYTES_TX <= 8192
137
    end if;
138
    return COLS_TX;
139
  end function CALC_TX_COLS;
140
 
141
  function CALC_RX_COLS(constant LIMIT : in integer) return integer is
142
    variable COLS_RX   : integer;
143
  begin
144
    -- Determine number of BRAM columns from total RAM size
145
    if    (LIMIT <=  512) then COLS_RX := 1;
146
    elsif (LIMIT <= 1024) then COLS_RX := 2;
147
    else                       COLS_RX := 4; -- LIMIT <= 2048
148
    end if;
149
    return COLS_RX;
150
  end function CALC_RX_COLS;
151
 
152
begin
153
 
154
   pcie_brams_tx : pcie_brams_s6
155
   generic map(
156
     NUM_BRAMS         => CALC_TX_COLS(DEV_CAP_MAX_PAYLOAD_SUPPORTED, VC0_TX_LASTPACKET, TLM_TX_OVERHEAD),
157
     RAM_RADDR_LATENCY => TL_TX_RAM_RADDR_LATENCY,
158
     RAM_RDATA_LATENCY => TL_TX_RAM_RDATA_LATENCY,
159
     RAM_WRITE_LATENCY => TL_TX_RAM_WRITE_LATENCY
160
   )
161
   port map (
162
     user_clk_i => user_clk_i,
163
     reset_i    => reset_i,
164
 
165
     waddr      => mim_tx_waddr,
166
     wen        => mim_tx_wen,
167
     ren        => mim_tx_ren,
168
     rce        => mim_tx_rce,
169
     wdata      => mim_tx_wdata,
170
     raddr      => mim_tx_raddr,
171
     rdata      => mim_tx_rdata
172
   );
173
 
174
   pcie_brams_rx : pcie_brams_s6
175
   generic map(
176
     NUM_BRAMS         => CALC_RX_COLS(VC0_RX_LIMIT),
177
     RAM_RADDR_LATENCY => TL_RX_RAM_RADDR_LATENCY,
178
     RAM_RDATA_LATENCY => TL_RX_RAM_RDATA_LATENCY,
179
     RAM_WRITE_LATENCY => TL_RX_RAM_WRITE_LATENCY
180
   )
181
   port map (
182
     user_clk_i => user_clk_i,
183
     reset_i    => reset_i,
184
 
185
     waddr      => mim_rx_waddr,
186
     wen        => mim_rx_wen,
187
     ren        => mim_rx_ren,
188
     rce        => mim_rx_rce,
189
     wdata      => mim_rx_wdata,
190
     raddr      => mim_rx_raddr,
191
     rdata      => mim_rx_rdata
192
   );
193
 
194
end rtl;

powered by: WebSVN 2.1.0

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