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

Subversion Repositories pcie_mini

[/] [pcie_mini/] [trunk/] [example_design/] [pcie_brams_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_brams_s6.vhd
45
-- Description: BlockRAM module for Spartan-6 PCIe Block
46
--
47
--              Arranges and connects brams
48
--              Implements address decoding, datapath muxing and
49
--              pipeline stages
50
--
51
-------------------------------------------------------------------------------
52
 
53
library ieee;
54
use ieee.std_logic_1164.all;
55
use ieee.std_logic_unsigned.all;
56
 
57
entity pcie_brams_s6 is
58
  generic (
59
    -- the number of BRAMs to use
60
    -- supported values are:
61
    -- 1,2,4,9
62
    NUM_BRAMS           : integer := 0;
63
 
64
    -- BRAM read address latency
65
    --
66
    -- value     meaning
67
    -- ====================================================
68
    --   0       BRAM read address port sample
69
    --   1       BRAM read address port sample and a pipeline stage on the address port
70
    RAM_RADDR_LATENCY   : integer := 1;
71
 
72
    -- BRAM read data latency
73
    --
74
    -- value     meaning
75
    -- ====================================================
76
    --   1       no BRAM OREG
77
    --   2       use BRAM OREG
78
    --   3       use BRAM OREG and a pipeline stage on the data port
79
    RAM_RDATA_LATENCY   : integer := 1;
80
 
81
    -- BRAM write latency
82
    -- The BRAM write port is synchronous
83
    --
84
    -- value     meaning
85
    -- ====================================================
86
    --   0       BRAM write port sample
87
    --   1       BRAM write port sample plus pipeline stage
88
    RAM_WRITE_LATENCY   : integer :=  1
89
  );
90
  port (
91
    user_clk_i          : in std_logic;
92
    reset_i             : in std_logic;
93
    wen                 : in std_logic;
94
    waddr               : in std_logic_vector(11 downto 0);
95
    wdata               : in std_logic_vector(35 downto 0);
96
    ren                 : in std_logic;
97
    rce                 : in std_logic;
98
    raddr               : in std_logic_vector(11 downto 0);
99
    rdata               : out std_logic_vector(35 downto 0)
100
  );
101
end pcie_brams_s6;
102
 
103
architecture rtl of pcie_brams_s6 is
104
 
105
  constant TCQ : time := 1 ns;  -- Clock-to-out delay to be modeled
106
 
107
  -- Turn on the bram output register
108
  function CALC_DOB_REG(constant RAM_RDATA_LATENCY : in integer) return integer is
109
    variable DOB_REG : integer;
110
  begin
111
    if   (RAM_RDATA_LATENCY > 1) then DOB_REG := 1;
112
    else                              DOB_REG := 0;
113
    end if;
114
    return DOB_REG;
115
  end function CALC_DOB_REG;
116
 
117
  -- Calculate the data width of the individual BRAMs
118
  function CALC_WIDTH(constant NUM_BRAMS : in integer) return integer is
119
    variable WIDTH : integer;
120
  begin
121
    if    (NUM_BRAMS = 1) then WIDTH := 36;
122
    elsif (NUM_BRAMS = 2) then WIDTH := 18;
123
    elsif (NUM_BRAMS = 4) then WIDTH := 9;
124
    else                       WIDTH := 4; -- NUM_BRAMS = 9
125
    end if;
126
    return WIDTH;
127
  end function CALC_WIDTH;
128
 
129
  component pcie_bram_s6 is
130
  generic (
131
    DOB_REG           : integer;
132
    WIDTH             : integer
133
  );
134
  port (
135
    user_clk_i : in std_logic;
136
    reset_i    : in std_logic;
137
 
138
    wen_i      : in std_logic;
139
    waddr_i    : in std_logic_vector(11 downto 0);
140
    wdata_i    : in std_logic_vector(CALC_WIDTH(NUM_BRAMS)-1 downto 0);
141
 
142
    ren_i      : in std_logic;
143
    rce_i      : in std_logic;
144
    raddr_i    : in std_logic_vector(11 downto 0);
145
 
146
    rdata_o    : out std_logic_vector(CALC_WIDTH(NUM_BRAMS)-1 downto 0) --  read data
147
  );
148
  end component;
149
 
150
  -- Model the delays for RAM write latency
151
  signal wen_int   : std_logic;
152
  signal waddr_int : std_logic_vector(11 downto 0);
153
  signal wdata_int : std_logic_vector(35 downto 0);
154
 
155
  -- Model the delays for RAM read latency
156
  signal ren_int   : std_logic;
157
  signal raddr_int : std_logic_vector(11 downto 0);
158
  signal rdata_int : std_logic_vector(35 downto 0);
159
 
160
begin
161
 
162
  --synthesis translate_off
163
  process begin
164
    case NUM_BRAMS is
165
      when 1 | 2 | 4 | 9 =>
166
        null;
167
      when others =>
168
        report "Error NUM_BRAMS size " & integer'image(NUM_BRAMS) & " is not supported." severity failure;
169
    end case; -- case NUM_BRAMS
170
 
171
    case RAM_RADDR_LATENCY is
172
      when 0 | 1 =>
173
        null;
174
      when others =>
175
        report "Error RAM_RADDR_LATENCY size " & integer'image(RAM_RADDR_LATENCY) & " is not supported." severity failure;
176
    end case; -- case RAM_RADDR_LATENCY
177
 
178
    case RAM_RDATA_LATENCY is
179
      when 1 | 2 | 3 =>
180
        null;
181
      when others =>
182
        report "Error RAM_RDATA_LATENCY size " & integer'image(RAM_RDATA_LATENCY) & " is not supported." severity failure;
183
    end case; -- case RAM_RDATA_LATENCY
184
 
185
    case RAM_WRITE_LATENCY is
186
      when 0 | 1 =>
187
        null;
188
      when others =>
189
        report "Error RAM_WRITE_LATENCY size " & integer'image(RAM_WRITE_LATENCY) & " is not supported." severity failure;
190
    end case; -- case RAM_WRITE_LATENCY
191
 
192
    wait;
193
  end process;
194
  --synthesis translate_on
195
 
196
  -- 1 stage RAM write pipeline
197
  wr_lat_1 : if(RAM_WRITE_LATENCY = 1) generate
198
    process (user_clk_i) begin
199
      if (reset_i = '1') then
200
        wen_int   <= '0' after TCQ;
201
        waddr_int <= (others => '0') after TCQ;
202
        wdata_int <= (others => '0') after TCQ;
203
      elsif (rising_edge(user_clk_i)) then
204
        wen_int   <= wen after TCQ;
205
        waddr_int <= waddr after TCQ;
206
        wdata_int <= wdata after TCQ;
207
      end if;
208
    end process;
209
  end generate wr_lat_1;
210
 
211
  -- No RAM write pipeline
212
  wr_lat_0 : if(RAM_WRITE_LATENCY /= 1) generate
213
    wen_int   <= wen;
214
    waddr_int <= waddr;
215
    wdata_int <= wdata;
216
  end generate wr_lat_0;
217
 
218
 
219
  -- 1 stage RAM read addr pipeline
220
  raddr_lat_1 : if(RAM_RADDR_LATENCY = 1) generate
221
    process (user_clk_i) begin
222
      if (reset_i = '1') then
223
        ren_int   <= '0' after TCQ;
224
        raddr_int <= (others => '0') after TCQ;
225
      elsif (rising_edge(user_clk_i)) then
226
        ren_int   <= ren after TCQ;
227
        raddr_int <= raddr after TCQ;
228
      end if;
229
    end process;
230
  end generate raddr_lat_1;
231
 
232
  -- No RAM read addr pipeline
233
  raddr_lat_0 : if(RAM_RADDR_LATENCY /= 1) generate
234
    ren_int   <= ren after TCQ;
235
    raddr_int <= raddr after TCQ;
236
  end generate raddr_lat_0;
237
 
238
  -- 3 stages RAM read data pipeline (first is internal to BRAM)
239
  rdata_lat_3 : if(RAM_RDATA_LATENCY = 3) generate
240
    process (user_clk_i) begin
241
      if (reset_i = '1') then
242
        rdata <= (others => '0') after TCQ;
243
      elsif (rising_edge(user_clk_i)) then
244
        rdata <= rdata_int after TCQ;
245
      end if;
246
    end process;
247
  end generate rdata_lat_3;
248
 
249
  -- 1 or 2 stages RAM read data pipeline
250
  rdata_lat_1_2 : if(RAM_RDATA_LATENCY /= 3) generate
251
    rdata <= rdata_int;
252
  end generate rdata_lat_1_2;
253
 
254
  -- Instantiate BRAM(s)
255
  brams : for i in 0 to (NUM_BRAMS - 1) generate
256
  begin
257
    ram : pcie_bram_s6
258
    generic map (
259
      DOB_REG => CALC_DOB_REG(RAM_RDATA_LATENCY),
260
      WIDTH   => CALC_WIDTH(NUM_BRAMS)
261
    )
262
    port map (
263
      user_clk_i => user_clk_i,
264
      reset_i    => reset_i,
265
      wen_i      => wen_int,
266
      waddr_i    => waddr_int,
267
      wdata_i    => wdata_int((((i + 1) * CALC_WIDTH(NUM_BRAMS)) - 1) downto (i * CALC_WIDTH(NUM_BRAMS))),
268
      ren_i      => ren_int,
269
      rce_i      => rce,
270
      raddr_i    => raddr_int,
271
      rdata_o    => rdata_int((((i + 1) * CALC_WIDTH(NUM_BRAMS)) - 1) downto (i * CALC_WIDTH(NUM_BRAMS)))
272
    );
273
  end generate brams;
274
 
275
end rtl;
276
 

powered by: WebSVN 2.1.0

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