1 |
2 |
dsmv |
|
2 |
|
|
-------------------------------------------------------------------------------
|
3 |
|
|
--
|
4 |
|
|
-- (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved.
|
5 |
|
|
--
|
6 |
|
|
-- This file contains confidential and proprietary information
|
7 |
|
|
-- of Xilinx, Inc. and is protected under U.S. and
|
8 |
|
|
-- international copyright and other intellectual property
|
9 |
|
|
-- laws.
|
10 |
|
|
--
|
11 |
|
|
-- DISCLAIMER
|
12 |
|
|
-- This disclaimer is not a license and does not grant any
|
13 |
|
|
-- rights to the materials distributed herewith. Except as
|
14 |
|
|
-- otherwise provided in a valid license issued to you by
|
15 |
|
|
-- Xilinx, and to the maximum extent permitted by applicable
|
16 |
|
|
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
17 |
|
|
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
18 |
|
|
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
19 |
|
|
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
20 |
|
|
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
21 |
|
|
-- (2) Xilinx shall not be liable (whether in contract or tort,
|
22 |
|
|
-- including negligence, or under any other theory of
|
23 |
|
|
-- liability) for any loss or damage of any kind or nature
|
24 |
|
|
-- related to, arising under or in connection with these
|
25 |
|
|
-- materials, including for any direct, or any indirect,
|
26 |
|
|
-- special, incidental, or consequential loss or damage
|
27 |
|
|
-- (including loss of data, profits, goodwill, or any type of
|
28 |
|
|
-- loss or damage suffered as a result of any action brought
|
29 |
|
|
-- by a third party) even if such damage or loss was
|
30 |
|
|
-- reasonably foreseeable or Xilinx had been advised of the
|
31 |
|
|
-- possibility of the same.
|
32 |
|
|
--
|
33 |
|
|
-- CRITICAL APPLICATIONS
|
34 |
|
|
-- Xilinx products are not designed or intended to be fail-
|
35 |
|
|
-- safe, or for use in any application requiring fail-safe
|
36 |
|
|
-- performance, such as life-support or safety devices or
|
37 |
|
|
-- systems, Class III medical devices, nuclear facilities,
|
38 |
|
|
-- applications related to the deployment of airbags, or any
|
39 |
|
|
-- other applications that could lead to death, personal
|
40 |
|
|
-- injury, or severe property or environmental damage
|
41 |
|
|
-- (individually and collectively, "Critical
|
42 |
|
|
-- Applications"). Customer assumes the sole risk and
|
43 |
|
|
-- liability of any use of Xilinx products in Critical
|
44 |
|
|
-- Applications, subject only to applicable laws and
|
45 |
|
|
-- regulations governing limitations on product liability.
|
46 |
|
|
--
|
47 |
|
|
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
48 |
|
|
-- PART OF THIS FILE AT ALL TIMES.
|
49 |
|
|
--
|
50 |
|
|
-------------------------------------------------------------------------------
|
51 |
|
|
-- Project : Virtex-6 Integrated Block for PCI Express
|
52 |
|
|
-- File : pcie_brams_v6.vhd
|
53 |
|
|
-- Version : 2.3
|
54 |
|
|
---- Description: BlockRAM module for Virtex6 PCIe Block
|
55 |
|
|
----
|
56 |
|
|
----
|
57 |
|
|
----
|
58 |
|
|
----------------------------------------------------------------------------------
|
59 |
|
|
|
60 |
|
|
library ieee;
|
61 |
|
|
use ieee.std_logic_1164.all;
|
62 |
|
|
use ieee.std_logic_unsigned.all;
|
63 |
|
|
|
64 |
|
|
entity pcie_brams_v6 is
|
65 |
|
|
generic (
|
66 |
|
|
-- the number of BRAMs to use
|
67 |
|
|
-- supported values are:
|
68 |
|
|
-- 1,2,4,8,18
|
69 |
|
|
NUM_BRAMS : integer := 0;
|
70 |
|
|
|
71 |
|
|
-- BRAM read address latency
|
72 |
|
|
--
|
73 |
|
|
-- value meaning
|
74 |
|
|
-- ====================================================
|
75 |
|
|
-- 0 BRAM read address port sample
|
76 |
|
|
-- 1 BRAM read address port sample and a pipeline stage on the address port
|
77 |
|
|
RAM_RADDR_LATENCY : integer := 1;
|
78 |
|
|
|
79 |
|
|
-- BRAM read data latency
|
80 |
|
|
--
|
81 |
|
|
-- value meaning
|
82 |
|
|
-- ====================================================
|
83 |
|
|
-- 1 no BRAM OREG
|
84 |
|
|
-- 2 use BRAM OREG
|
85 |
|
|
-- 3 use BRAM OREG and a pipeline stage on the data port
|
86 |
|
|
RAM_RDATA_LATENCY : integer := 1;
|
87 |
|
|
|
88 |
|
|
-- BRAM write latency
|
89 |
|
|
-- The BRAM write port is synchronous
|
90 |
|
|
--
|
91 |
|
|
-- value meaning
|
92 |
|
|
-- ====================================================
|
93 |
|
|
-- 0 BRAM write port sample
|
94 |
|
|
-- 1 BRAM write port sample plus pipeline stage
|
95 |
|
|
RAM_WRITE_LATENCY : integer := 1
|
96 |
|
|
|
97 |
|
|
);
|
98 |
|
|
port (
|
99 |
|
|
user_clk_i : in std_logic;
|
100 |
|
|
reset_i : in std_logic;
|
101 |
|
|
wen : in std_logic;
|
102 |
|
|
waddr : in std_logic_vector(12 downto 0);
|
103 |
|
|
wdata : in std_logic_vector(71 downto 0);
|
104 |
|
|
ren : in std_logic;
|
105 |
|
|
rce : in std_logic;
|
106 |
|
|
raddr : in std_logic_vector(12 downto 0);
|
107 |
|
|
rdata : out std_logic_vector(71 downto 0)
|
108 |
|
|
);
|
109 |
|
|
end pcie_brams_v6;
|
110 |
|
|
|
111 |
|
|
architecture v6_pcie of pcie_brams_v6 is
|
112 |
|
|
component pcie_bram_v6 is
|
113 |
|
|
generic (
|
114 |
|
|
DOB_REG : integer;
|
115 |
|
|
WIDTH : integer
|
116 |
|
|
);
|
117 |
|
|
port (
|
118 |
|
|
user_clk_i : in std_logic;
|
119 |
|
|
reset_i : in std_logic;
|
120 |
|
|
wen_i : in std_logic;
|
121 |
|
|
waddr_i : in std_logic_vector(12 downto 0);
|
122 |
|
|
wdata_i : in std_logic_vector(WIDTH - 1 downto 0);
|
123 |
|
|
ren_i : in std_logic;
|
124 |
|
|
rce_i : in std_logic;
|
125 |
|
|
raddr_i : in std_logic_vector(12 downto 0);
|
126 |
|
|
rdata_o : out std_logic_vector(WIDTH - 1 downto 0)
|
127 |
|
|
);
|
128 |
|
|
end component;
|
129 |
|
|
|
130 |
|
|
FUNCTION to_integer (
|
131 |
|
|
in_val : IN boolean) RETURN integer IS
|
132 |
|
|
BEGIN
|
133 |
|
|
IF (in_val) THEN
|
134 |
|
|
RETURN(1);
|
135 |
|
|
ELSE
|
136 |
|
|
RETURN(0);
|
137 |
|
|
END IF;
|
138 |
|
|
END to_integer;
|
139 |
|
|
|
140 |
|
|
-- turn on the bram output register
|
141 |
|
|
constant DOB_REG : integer := to_integer(RAM_RDATA_LATENCY > 1);
|
142 |
|
|
|
143 |
|
|
-- calculate the data width of the individual brams
|
144 |
|
|
function width (
|
145 |
|
|
constant NUM_BRAM : integer)
|
146 |
|
|
return integer is
|
147 |
|
|
variable WIDTH_BRAM : integer := 1;
|
148 |
|
|
begin -- width
|
149 |
|
|
|
150 |
|
|
if (NUM_BRAM = 1) then
|
151 |
|
|
WIDTH_BRAM := 72;
|
152 |
|
|
elsif (NUM_BRAM = 2) then
|
153 |
|
|
WIDTH_BRAM := 36;
|
154 |
|
|
elsif (NUM_BRAM = 4) then
|
155 |
|
|
WIDTH_BRAM := 18;
|
156 |
|
|
elsif (NUM_BRAM = 8) then
|
157 |
|
|
WIDTH_BRAM := 9;
|
158 |
|
|
else
|
159 |
|
|
WIDTH_BRAM := 4;
|
160 |
|
|
end if;
|
161 |
|
|
return WIDTH_BRAM;
|
162 |
|
|
end width;
|
163 |
|
|
|
164 |
|
|
constant BRAM_WIDTH : integer := width(NUM_BRAMS);
|
165 |
|
|
|
166 |
|
|
constant TCQ : integer := 1;
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
signal wen_int : std_logic;
|
170 |
|
|
signal waddr_int : std_logic_vector(12 downto 0);
|
171 |
|
|
signal wdata_int : std_logic_vector(71 downto 0);
|
172 |
|
|
|
173 |
|
|
signal wen_dly : std_logic := '0';
|
174 |
|
|
signal waddr_dly : std_logic_vector(12 downto 0) := (others => '0');
|
175 |
|
|
signal wdata_dly : std_logic_vector(71 downto 0) := (others => '0');
|
176 |
|
|
|
177 |
|
|
-- if (RAM_WRITE_LATENCY == 1)
|
178 |
|
|
|
179 |
|
|
-- model the delays for ram read latency
|
180 |
|
|
|
181 |
|
|
signal ren_int : std_logic;
|
182 |
|
|
signal raddr_int : std_logic_vector(12 downto 0);
|
183 |
|
|
signal rdata_int : std_logic_vector(71 downto 0);
|
184 |
|
|
|
185 |
|
|
signal ren_dly : std_logic;
|
186 |
|
|
signal raddr_dly : std_logic_vector(12 downto 0);
|
187 |
|
|
signal rdata_dly : std_logic_vector(71 downto 0);
|
188 |
|
|
|
189 |
|
|
begin
|
190 |
|
|
|
191 |
|
|
--synthesis translate_off
|
192 |
|
|
process
|
193 |
|
|
begin
|
194 |
|
|
-- $display("[%t] %m NUM_BRAMS %0d DOB_REG %0d WIDTH %0d RAM_WRITE_LATENCY %0d RAM_RADDR_LATENCY %0d RAM_RDATA_LATENCY %0d", now, to_stdlogic(NUM_BRAMS), to_stdlogicvector(DOB_REG, 13), ("00000000000000000000000000000000000000000000000000000000000000000" & WIDTH), to_stdlogic(RAM_WRITE_LATENCY), to_stdlogic(RAM_RADDR_LATENCY), to_stdlogicvector(RAM_RDATA_LATENCY, 13));
|
195 |
|
|
case NUM_BRAMS is
|
196 |
|
|
when 1 | 2 | 4 | 8 | 18 =>
|
197 |
|
|
when others =>
|
198 |
|
|
-- $display("[%t] %m Error NUM_BRAMS %0d not supported", now, to_stdlogic(NUM_BRAMS));
|
199 |
|
|
-- $finish();
|
200 |
|
|
end case; -- case(NUM_BRAMS)
|
201 |
|
|
case RAM_RADDR_LATENCY is
|
202 |
|
|
when 0 | 1 =>
|
203 |
|
|
when others =>
|
204 |
|
|
-- $display("[%t] %m Error RAM_READ_LATENCY %0d not supported", now, to_stdlogic(RAM_RADDR_LATENCY));
|
205 |
|
|
-- $finish();
|
206 |
|
|
end case; -- case (RAM_RADDR_LATENCY)
|
207 |
|
|
case RAM_RDATA_LATENCY is
|
208 |
|
|
when 1 | 2 | 3 =>
|
209 |
|
|
when others =>
|
210 |
|
|
-- $display("[%t] %m Error RAM_READ_LATENCY %0d not supported", now, to_stdlogic(RAM_RDATA_LATENCY));
|
211 |
|
|
-- $finish();
|
212 |
|
|
end case; -- case (RAM_RDATA_LATENCY)
|
213 |
|
|
case RAM_WRITE_LATENCY is
|
214 |
|
|
when 0 | 1 =>
|
215 |
|
|
when others =>
|
216 |
|
|
-- $display("[%t] %m Error RAM_WRITE_LATENCY %0d not supported", now, to_stdlogic(RAM_WRITE_LATENCY));
|
217 |
|
|
-- $finish();
|
218 |
|
|
end case; -- case(RAM_WRITE_LATENCY)
|
219 |
|
|
wait;
|
220 |
|
|
end process;
|
221 |
|
|
--synthesis translate_on
|
222 |
|
|
|
223 |
|
|
-- model the delays for ram write latency
|
224 |
|
|
wr_lat_2 : if (RAM_WRITE_LATENCY = 1) generate
|
225 |
|
|
process (user_clk_i)
|
226 |
|
|
begin
|
227 |
|
|
if (user_clk_i'event and user_clk_i = '1') then
|
228 |
|
|
if (reset_i = '1') then
|
229 |
|
|
wen_dly <= '0' after (TCQ)*1 ps;
|
230 |
|
|
waddr_dly <= "0000000000000" after (TCQ)*1 ps;
|
231 |
|
|
wdata_dly <= "000000000000000000000000000000000000000000000000000000000000000000000000" after (TCQ)*1 ps;
|
232 |
|
|
else
|
233 |
|
|
wen_dly <= wen after (TCQ)*1 ps;
|
234 |
|
|
waddr_dly <= waddr after (TCQ)*1 ps;
|
235 |
|
|
wdata_dly <= wdata after (TCQ)*1 ps;
|
236 |
|
|
end if;
|
237 |
|
|
end if;
|
238 |
|
|
end process;
|
239 |
|
|
|
240 |
|
|
wen_int <= wen_dly;
|
241 |
|
|
waddr_int <= waddr_dly;
|
242 |
|
|
wdata_int <= wdata_dly;
|
243 |
|
|
end generate;
|
244 |
|
|
|
245 |
|
|
wr_lat_1 : if (RAM_WRITE_LATENCY = 0) generate
|
246 |
|
|
wen_int <= wen;
|
247 |
|
|
waddr_int <= waddr;
|
248 |
|
|
wdata_int <= wdata;
|
249 |
|
|
end generate;
|
250 |
|
|
|
251 |
|
|
raddr_lat_2 : if (RAM_RADDR_LATENCY = 1) generate
|
252 |
|
|
|
253 |
|
|
process (user_clk_i)
|
254 |
|
|
begin
|
255 |
|
|
if (user_clk_i'event and user_clk_i = '1') then
|
256 |
|
|
if (reset_i = '1') then
|
257 |
|
|
ren_dly <= '0' after (TCQ)*1 ps;
|
258 |
|
|
raddr_dly <= "0000000000000" after (TCQ)*1 ps;
|
259 |
|
|
else
|
260 |
|
|
ren_dly <= ren after (TCQ)*1 ps;
|
261 |
|
|
raddr_dly <= raddr after (TCQ)*1 ps;
|
262 |
|
|
end if; -- else: !if(reset_i)
|
263 |
|
|
end if;
|
264 |
|
|
end process;
|
265 |
|
|
|
266 |
|
|
ren_int <= ren_dly;
|
267 |
|
|
raddr_int <= raddr_dly;
|
268 |
|
|
|
269 |
|
|
end generate; -- block: rd_lat_addr_2
|
270 |
|
|
|
271 |
|
|
raddr_lat_1 : if (not(RAM_RADDR_LATENCY = 1)) generate
|
272 |
|
|
ren_int <= ren;
|
273 |
|
|
raddr_int <= raddr;
|
274 |
|
|
end generate;
|
275 |
|
|
|
276 |
|
|
rdata_lat_3 : if (RAM_RDATA_LATENCY = 3) generate
|
277 |
|
|
|
278 |
|
|
process (user_clk_i)
|
279 |
|
|
begin
|
280 |
|
|
if (user_clk_i'event and user_clk_i = '1') then
|
281 |
|
|
if (reset_i = '1') then
|
282 |
|
|
rdata_dly <= "000000000000000000000000000000000000000000000000000000000000000000000000" after (TCQ)*1 ps;
|
283 |
|
|
else
|
284 |
|
|
rdata_dly <= rdata_int after (TCQ)*1 ps;
|
285 |
|
|
end if; -- else: !if(reset_i)
|
286 |
|
|
end if;
|
287 |
|
|
end process;
|
288 |
|
|
|
289 |
|
|
rdata <= rdata_dly;
|
290 |
|
|
|
291 |
|
|
end generate; -- block: rd_lat_data_3
|
292 |
|
|
|
293 |
|
|
rdata_lat_1_2 : if (not(RAM_RDATA_LATENCY = 3)) generate
|
294 |
|
|
rdata <= rdata_int after (TCQ)*1 ps;
|
295 |
|
|
end generate;
|
296 |
|
|
|
297 |
|
|
-- instantiate the brams
|
298 |
|
|
brams : for i in 0 to NUM_BRAMS - 1 generate
|
299 |
|
|
|
300 |
|
|
ram : pcie_bram_v6
|
301 |
|
|
generic map (
|
302 |
|
|
DOB_REG => DOB_REG,
|
303 |
|
|
WIDTH => BRAM_WIDTH
|
304 |
|
|
)
|
305 |
|
|
port map (
|
306 |
|
|
user_clk_i => user_clk_i,
|
307 |
|
|
reset_i => reset_i,
|
308 |
|
|
wen_i => wen_int,
|
309 |
|
|
waddr_i => waddr_int,
|
310 |
|
|
wdata_i => wdata_int((((i + 1) * BRAM_WIDTH) - 1) downto (i * BRAM_WIDTH)),
|
311 |
|
|
ren_i => ren_int,
|
312 |
|
|
raddr_i => raddr_int,
|
313 |
|
|
rdata_o => rdata_int((((i + 1) * BRAM_WIDTH) - 1) downto (i * BRAM_WIDTH)),
|
314 |
|
|
rce_i => rce
|
315 |
|
|
);
|
316 |
|
|
end generate;
|
317 |
|
|
-- pcie_brams_v6
|
318 |
|
|
end v6_pcie;
|
319 |
|
|
|
320 |
|
|
|