1 |
11 |
barabba |
|
2 |
|
|
//-----------------------------------------------------------------------------
|
3 |
|
|
//
|
4 |
|
|
// (c) Copyright 2009 Xilinx, Inc. All rights reserved.
|
5 |
|
|
//
|
6 |
|
|
// This file contains confidential and proprietary information of Xilinx, Inc.
|
7 |
|
|
// and is protected under U.S. and international copyright and other
|
8 |
|
|
// intellectual property laws.
|
9 |
|
|
//
|
10 |
|
|
// DISCLAIMER
|
11 |
|
|
//
|
12 |
|
|
// This disclaimer is not a license and does not grant any rights to the
|
13 |
|
|
// materials distributed herewith. Except as otherwise provided in a valid
|
14 |
|
|
// license issued to you by Xilinx, and to the maximum extent permitted by
|
15 |
|
|
// applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
|
16 |
|
|
// FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
|
17 |
|
|
// IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
|
18 |
|
|
// MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
|
19 |
|
|
// and (2) Xilinx shall not be liable (whether in contract or tort, including
|
20 |
|
|
// negligence, or under any other theory of liability) for any loss or damage
|
21 |
|
|
// of any kind or nature related to, arising under or in connection with these
|
22 |
|
|
// materials, including for any direct, or any indirect, special, incidental,
|
23 |
|
|
// or consequential loss or damage (including loss of data, profits, goodwill,
|
24 |
|
|
// or any type of loss or damage suffered as a result of any action brought by
|
25 |
|
|
// a third party) even if such damage or loss was reasonably foreseeable or
|
26 |
|
|
// Xilinx had been advised of the possibility of the same.
|
27 |
|
|
//
|
28 |
|
|
// CRITICAL APPLICATIONS
|
29 |
|
|
//
|
30 |
|
|
// Xilinx products are not designed or intended to be fail-safe, or for use in
|
31 |
|
|
// any application requiring fail-safe performance, such as life-support or
|
32 |
|
|
// safety devices or systems, Class III medical devices, nuclear facilities,
|
33 |
|
|
// applications related to the deployment of airbags, or any other
|
34 |
|
|
// applications that could lead to death, personal injury, or severe property
|
35 |
|
|
// or environmental damage (individually and collectively, "Critical
|
36 |
|
|
// Applications"). Customer assumes the sole risk and liability of any use of
|
37 |
|
|
// Xilinx products in Critical Applications, subject only to applicable laws
|
38 |
|
|
// and regulations governing limitations on product liability.
|
39 |
|
|
//
|
40 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
|
41 |
|
|
// AT ALL TIMES.
|
42 |
|
|
//
|
43 |
|
|
//-----------------------------------------------------------------------------
|
44 |
|
|
// Project : Virtex-6 Integrated Block for PCI Express
|
45 |
|
|
// File : pcie_brams_v6.v
|
46 |
|
|
//--
|
47 |
|
|
//-- Description: BlockRAM module for Virtex6 PCIe Block
|
48 |
|
|
//--
|
49 |
|
|
//--
|
50 |
|
|
//--
|
51 |
|
|
//--------------------------------------------------------------------------------
|
52 |
|
|
|
53 |
|
|
`timescale 1ns/1ns
|
54 |
|
|
|
55 |
|
|
module pcie_brams_v6
|
56 |
|
|
#(
|
57 |
|
|
// the number of BRAMs to use
|
58 |
|
|
// supported values are:
|
59 |
|
|
// 1,2,4,8,18
|
60 |
|
|
parameter NUM_BRAMS = 0,
|
61 |
|
|
|
62 |
|
|
// BRAM read address latency
|
63 |
|
|
//
|
64 |
|
|
// value meaning
|
65 |
|
|
// ====================================================
|
66 |
|
|
// 0 BRAM read address port sample
|
67 |
|
|
// 1 BRAM read address port sample and a pipeline stage on the address port
|
68 |
|
|
parameter RAM_RADDR_LATENCY = 1,
|
69 |
|
|
|
70 |
|
|
// BRAM read data latency
|
71 |
|
|
//
|
72 |
|
|
// value meaning
|
73 |
|
|
// ====================================================
|
74 |
|
|
// 1 no BRAM OREG
|
75 |
|
|
// 2 use BRAM OREG
|
76 |
|
|
// 3 use BRAM OREG and a pipeline stage on the data port
|
77 |
|
|
parameter RAM_RDATA_LATENCY = 1,
|
78 |
|
|
|
79 |
|
|
// BRAM write latency
|
80 |
|
|
// The BRAM write port is synchronous
|
81 |
|
|
//
|
82 |
|
|
// value meaning
|
83 |
|
|
// ====================================================
|
84 |
|
|
// 0 BRAM write port sample
|
85 |
|
|
// 1 BRAM write port sample plus pipeline stage
|
86 |
|
|
parameter RAM_WRITE_LATENCY = 1
|
87 |
|
|
)
|
88 |
|
|
(
|
89 |
|
|
input user_clk_i,
|
90 |
|
|
input reset_i,
|
91 |
|
|
|
92 |
|
|
input wen,
|
93 |
|
|
input [12:0] waddr,
|
94 |
|
|
input [71:0] wdata,
|
95 |
|
|
input ren,
|
96 |
|
|
input rce,
|
97 |
|
|
input [12:0] raddr,
|
98 |
|
|
output [71:0] rdata
|
99 |
|
|
);
|
100 |
|
|
|
101 |
|
|
// turn on the bram output register
|
102 |
|
|
localparam DOB_REG = (RAM_RDATA_LATENCY > 1) ? 1 : 0;
|
103 |
|
|
|
104 |
|
|
// calculate the data width of the individual brams
|
105 |
|
|
localparam [6:0] WIDTH = ((NUM_BRAMS == 1) ? 72 :
|
106 |
|
|
(NUM_BRAMS == 2) ? 36 :
|
107 |
|
|
(NUM_BRAMS == 4) ? 18 :
|
108 |
|
|
(NUM_BRAMS == 8) ? 9 :
|
109 |
|
|
4
|
110 |
|
|
);
|
111 |
|
|
|
112 |
|
|
parameter TCQ = 1;
|
113 |
|
|
|
114 |
|
|
//synthesis translate_off
|
115 |
|
|
initial begin
|
116 |
|
|
$display("[%t] %m NUM_BRAMS %0d DOB_REG %0d WIDTH %0d RAM_WRITE_LATENCY %0d RAM_RADDR_LATENCY %0d RAM_RDATA_LATENCY %0d",
|
117 |
|
|
$time, NUM_BRAMS, DOB_REG, WIDTH, RAM_WRITE_LATENCY, RAM_RADDR_LATENCY, RAM_RDATA_LATENCY);
|
118 |
|
|
|
119 |
|
|
case (NUM_BRAMS)
|
120 |
|
|
1,2,4,8,18:;
|
121 |
|
|
default:
|
122 |
|
|
begin
|
123 |
|
|
$display("[%t] %m Error NUM_BRAMS %0d not supported", $time, NUM_BRAMS);
|
124 |
|
|
$finish;
|
125 |
|
|
end
|
126 |
|
|
endcase // case(NUM_BRAMS)
|
127 |
|
|
|
128 |
|
|
case (RAM_RADDR_LATENCY)
|
129 |
|
|
0,1:;
|
130 |
|
|
default:
|
131 |
|
|
begin
|
132 |
|
|
$display("[%t] %m Error RAM_READ_LATENCY %0d not supported", $time, RAM_RADDR_LATENCY);
|
133 |
|
|
$finish;
|
134 |
|
|
end
|
135 |
|
|
endcase // case (RAM_RADDR_LATENCY)
|
136 |
|
|
|
137 |
|
|
case (RAM_RDATA_LATENCY)
|
138 |
|
|
1,2,3:;
|
139 |
|
|
default:
|
140 |
|
|
begin
|
141 |
|
|
$display("[%t] %m Error RAM_READ_LATENCY %0d not supported", $time, RAM_RDATA_LATENCY);
|
142 |
|
|
$finish;
|
143 |
|
|
end
|
144 |
|
|
endcase // case (RAM_RDATA_LATENCY)
|
145 |
|
|
|
146 |
|
|
case (RAM_WRITE_LATENCY)
|
147 |
|
|
0,1:;
|
148 |
|
|
default:
|
149 |
|
|
begin
|
150 |
|
|
$display("[%t] %m Error RAM_WRITE_LATENCY %0d not supported", $time, RAM_WRITE_LATENCY);
|
151 |
|
|
$finish;
|
152 |
|
|
end
|
153 |
|
|
endcase // case(RAM_WRITE_LATENCY)
|
154 |
|
|
|
155 |
|
|
end
|
156 |
|
|
//synthesis translate_on
|
157 |
|
|
|
158 |
|
|
// model the delays for ram write latency
|
159 |
|
|
|
160 |
|
|
wire wen_int;
|
161 |
|
|
wire [12:0] waddr_int;
|
162 |
|
|
wire [71:0] wdata_int;
|
163 |
|
|
|
164 |
|
|
generate if (RAM_WRITE_LATENCY == 1) begin : wr_lat_2
|
165 |
|
|
reg wen_dly;
|
166 |
|
|
reg [12:0] waddr_dly;
|
167 |
|
|
reg [71:0] wdata_dly;
|
168 |
|
|
|
169 |
|
|
always @(posedge user_clk_i) begin
|
170 |
|
|
if (reset_i) begin
|
171 |
|
|
wen_dly <= #TCQ 1'b0;
|
172 |
|
|
waddr_dly <= #TCQ 13'b0;
|
173 |
|
|
wdata_dly <= #TCQ 72'b0;
|
174 |
|
|
end else begin
|
175 |
|
|
wen_dly <= #TCQ wen;
|
176 |
|
|
waddr_dly <= #TCQ waddr;
|
177 |
|
|
wdata_dly <= #TCQ wdata;
|
178 |
|
|
end
|
179 |
|
|
end
|
180 |
|
|
|
181 |
|
|
assign wen_int = wen_dly;
|
182 |
|
|
assign waddr_int = waddr_dly;
|
183 |
|
|
assign wdata_int = wdata_dly;
|
184 |
|
|
end // if (RAM_WRITE_LATENCY == 1)
|
185 |
|
|
|
186 |
|
|
else if (RAM_WRITE_LATENCY == 0) begin : wr_lat_1
|
187 |
|
|
assign wen_int = wen;
|
188 |
|
|
assign waddr_int = waddr;
|
189 |
|
|
assign wdata_int = wdata;
|
190 |
|
|
end
|
191 |
|
|
endgenerate
|
192 |
|
|
|
193 |
|
|
// model the delays for ram read latency
|
194 |
|
|
|
195 |
|
|
wire ren_int;
|
196 |
|
|
wire [12:0] raddr_int;
|
197 |
|
|
wire [71:0] rdata_int;
|
198 |
|
|
|
199 |
|
|
generate if (RAM_RADDR_LATENCY == 1) begin : raddr_lat_2
|
200 |
|
|
reg ren_dly;
|
201 |
|
|
reg [12:0] raddr_dly;
|
202 |
|
|
|
203 |
|
|
always @(posedge user_clk_i) begin
|
204 |
|
|
if (reset_i) begin
|
205 |
|
|
ren_dly <= #TCQ 1'b0;
|
206 |
|
|
raddr_dly <= #TCQ 13'b0;
|
207 |
|
|
end else begin
|
208 |
|
|
ren_dly <= #TCQ ren;
|
209 |
|
|
raddr_dly <= #TCQ raddr;
|
210 |
|
|
end // else: !if(reset_i)
|
211 |
|
|
end
|
212 |
|
|
|
213 |
|
|
assign ren_int = ren_dly;
|
214 |
|
|
assign raddr_int = raddr_dly;
|
215 |
|
|
end // block: rd_lat_addr_2
|
216 |
|
|
|
217 |
|
|
else begin : raddr_lat_1
|
218 |
|
|
assign ren_int = ren;
|
219 |
|
|
assign raddr_int = raddr;
|
220 |
|
|
end
|
221 |
|
|
endgenerate
|
222 |
|
|
|
223 |
|
|
generate if (RAM_RDATA_LATENCY == 3) begin : rdata_lat_3
|
224 |
|
|
reg [71:0] rdata_dly;
|
225 |
|
|
|
226 |
|
|
always @(posedge user_clk_i) begin
|
227 |
|
|
if (reset_i) begin
|
228 |
|
|
rdata_dly <= #TCQ 72'b0;
|
229 |
|
|
end else begin
|
230 |
|
|
rdata_dly <= #TCQ rdata_int;
|
231 |
|
|
end // else: !if(reset_i)
|
232 |
|
|
end
|
233 |
|
|
|
234 |
|
|
assign rdata = rdata_dly;
|
235 |
|
|
|
236 |
|
|
end // block: rd_lat_data_3
|
237 |
|
|
|
238 |
|
|
else begin : rdata_lat_1_2
|
239 |
|
|
assign #TCQ rdata = rdata_int;
|
240 |
|
|
end
|
241 |
|
|
endgenerate
|
242 |
|
|
|
243 |
|
|
// instantiate the brams
|
244 |
|
|
generate
|
245 |
|
|
genvar i;
|
246 |
|
|
for (i = 0; i < NUM_BRAMS; i = i + 1) begin : brams
|
247 |
|
|
pcie_bram_v6 #(.DOB_REG(DOB_REG), .WIDTH(WIDTH))
|
248 |
|
|
ram (.user_clk_i(user_clk_i), .reset_i(reset_i),
|
249 |
|
|
.wen_i(wen_int), .waddr_i(waddr_int), .wdata_i(wdata_int[(((i + 1) * WIDTH) - 1): (i * WIDTH)]),
|
250 |
|
|
.ren_i(ren_int), .raddr_i(raddr_int), .rdata_o(rdata_int[(((i + 1) * WIDTH) - 1): (i * WIDTH)]), .rce_i(rce));
|
251 |
|
|
end
|
252 |
|
|
endgenerate
|
253 |
|
|
endmodule // pcie_brams_v6
|