1 |
412 |
julius |
//*****************************************************************************
|
2 |
|
|
// DISCLAIMER OF LIABILITY
|
3 |
|
|
//
|
4 |
|
|
// This file contains proprietary and confidential information of
|
5 |
|
|
// Xilinx, Inc. ("Xilinx"), that is distributed under a license
|
6 |
|
|
// from Xilinx, and may be used, copied and/or disclosed only
|
7 |
|
|
// pursuant to the terms of a valid license agreement with Xilinx.
|
8 |
|
|
//
|
9 |
|
|
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION
|
10 |
|
|
// ("MATERIALS") "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
11 |
|
|
// EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING WITHOUT
|
12 |
|
|
// LIMITATION, ANY WARRANTY WITH RESPECT TO NONINFRINGEMENT,
|
13 |
|
|
// MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. Xilinx
|
14 |
|
|
// does not warrant that functions included in the Materials will
|
15 |
|
|
// meet the requirements of Licensee, or that the operation of the
|
16 |
|
|
// Materials will be uninterrupted or error-free, or that defects
|
17 |
|
|
// in the Materials will be corrected. Furthermore, Xilinx does
|
18 |
|
|
// not warrant or make any representations regarding use, or the
|
19 |
|
|
// results of the use, of the Materials in terms of correctness,
|
20 |
|
|
// accuracy, reliability or otherwise.
|
21 |
|
|
//
|
22 |
|
|
// Xilinx products are not designed or intended to be fail-safe,
|
23 |
|
|
// or for use in any application requiring fail-safe performance,
|
24 |
|
|
// such as life-support or safety devices or systems, Class III
|
25 |
|
|
// medical devices, nuclear facilities, applications related to
|
26 |
|
|
// the deployment of airbags, or any other applications that could
|
27 |
|
|
// lead to death, personal injury or severe property or
|
28 |
|
|
// environmental damage (individually and collectively, "critical
|
29 |
|
|
// applications"). Customer assumes the sole risk and liability
|
30 |
|
|
// of any use of Xilinx products in critical applications,
|
31 |
|
|
// subject only to applicable laws and regulations governing
|
32 |
|
|
// limitations on product liability.
|
33 |
|
|
//
|
34 |
|
|
// Copyright 2006, 2007 Xilinx, Inc.
|
35 |
|
|
// All rights reserved.
|
36 |
|
|
//
|
37 |
|
|
// This disclaimer and copyright notice must be retained as part
|
38 |
|
|
// of this file at all times.
|
39 |
|
|
//*****************************************************************************
|
40 |
|
|
// ____ ____
|
41 |
|
|
// / /\/ /
|
42 |
|
|
// /___/ \ / Vendor: Xilinx
|
43 |
|
|
// \ \ \/ Version: 3.0
|
44 |
|
|
// \ \ Application: MIG
|
45 |
|
|
// / / Filename: ddr2_usr_wr.v
|
46 |
|
|
// /___/ /\ Date Last Modified: $Date: 2008/12/23 14:26:01 $
|
47 |
|
|
// \ \ / \ Date Created: Mon Aug 28 2006
|
48 |
|
|
// \___\/\___\
|
49 |
|
|
//
|
50 |
|
|
//Device: Virtex-5
|
51 |
|
|
//Design Name: DDR/DDR2
|
52 |
|
|
//Purpose:
|
53 |
|
|
// This module instantiates the modules containing internal FIFOs
|
54 |
|
|
//Reference:
|
55 |
|
|
//Revision History:
|
56 |
|
|
//*****************************************************************************
|
57 |
|
|
|
58 |
|
|
`timescale 1ns/1ps
|
59 |
|
|
|
60 |
|
|
module ddr2_usr_wr #
|
61 |
|
|
(
|
62 |
|
|
// Following parameters are for 72-bit RDIMM design (for ML561 Reference
|
63 |
|
|
// board design). Actual values may be different. Actual parameters values
|
64 |
|
|
// are passed from design top module ddr2_mig module. Please refer to
|
65 |
|
|
// the ddr2_mig module for actual values.
|
66 |
|
|
parameter BANK_WIDTH = 2,
|
67 |
|
|
parameter COL_WIDTH = 10,
|
68 |
|
|
parameter CS_BITS = 0,
|
69 |
|
|
parameter DQ_WIDTH = 72,
|
70 |
|
|
parameter APPDATA_WIDTH = 144,
|
71 |
|
|
parameter ECC_ENABLE = 0,
|
72 |
|
|
parameter ROW_WIDTH = 14
|
73 |
|
|
)
|
74 |
|
|
(
|
75 |
|
|
input clk0,
|
76 |
|
|
input usr_clk, // jb
|
77 |
|
|
input clk90,
|
78 |
|
|
input rst0,
|
79 |
|
|
// Write data FIFO interface
|
80 |
|
|
input app_wdf_wren,
|
81 |
|
|
input [APPDATA_WIDTH-1:0] app_wdf_data,
|
82 |
|
|
input [(APPDATA_WIDTH/8)-1:0] app_wdf_mask_data,
|
83 |
|
|
input wdf_rden,
|
84 |
|
|
output app_wdf_afull,
|
85 |
|
|
output [(2*DQ_WIDTH)-1:0] wdf_data,
|
86 |
|
|
output [((2*DQ_WIDTH)/8)-1:0] wdf_mask_data
|
87 |
|
|
);
|
88 |
|
|
|
89 |
|
|
// determine number of FIFO72's to use based on data width
|
90 |
|
|
// round up to next integer value when determining WDF_FIFO_NUM
|
91 |
|
|
localparam WDF_FIFO_NUM = (ECC_ENABLE) ? (APPDATA_WIDTH+63)/64 :
|
92 |
|
|
((2*DQ_WIDTH)+63)/64;
|
93 |
|
|
// MASK_WIDTH = number of bytes in data bus
|
94 |
|
|
localparam MASK_WIDTH = DQ_WIDTH/8;
|
95 |
|
|
|
96 |
|
|
wire [WDF_FIFO_NUM-1:0] i_wdf_afull;
|
97 |
|
|
wire [DQ_WIDTH-1:0] i_wdf_data_fall_in;
|
98 |
|
|
wire [DQ_WIDTH-1:0] i_wdf_data_fall_out;
|
99 |
|
|
wire [(64*WDF_FIFO_NUM)-1:0] i_wdf_data_in;
|
100 |
|
|
wire [(64*WDF_FIFO_NUM)-1:0] i_wdf_data_out;
|
101 |
|
|
wire [DQ_WIDTH-1:0] i_wdf_data_rise_in;
|
102 |
|
|
wire [DQ_WIDTH-1:0] i_wdf_data_rise_out;
|
103 |
|
|
wire [MASK_WIDTH-1:0] i_wdf_mask_data_fall_in;
|
104 |
|
|
wire [MASK_WIDTH-1:0] i_wdf_mask_data_fall_out;
|
105 |
|
|
wire [(8*WDF_FIFO_NUM)-1:0] i_wdf_mask_data_in;
|
106 |
|
|
wire [(8*WDF_FIFO_NUM)-1:0] i_wdf_mask_data_out;
|
107 |
|
|
wire [MASK_WIDTH-1:0] i_wdf_mask_data_rise_in;
|
108 |
|
|
wire [MASK_WIDTH-1:0] i_wdf_mask_data_rise_out;
|
109 |
|
|
reg rst_r;
|
110 |
|
|
|
111 |
|
|
// ECC signals
|
112 |
|
|
wire [(2*DQ_WIDTH)-1:0] i_wdf_data_out_ecc;
|
113 |
|
|
wire [((2*DQ_WIDTH)/8)-1:0] i_wdf_mask_data_out_ecc;
|
114 |
|
|
wire [63:0] i_wdf_mask_data_out_ecc_wire;
|
115 |
|
|
wire [((2*DQ_WIDTH)/8)-1:0] mask_data_in_ecc;
|
116 |
|
|
wire [63:0] mask_data_in_ecc_wire;
|
117 |
|
|
|
118 |
|
|
//***************************************************************************
|
119 |
|
|
|
120 |
|
|
assign app_wdf_afull = i_wdf_afull[0];
|
121 |
|
|
|
122 |
|
|
always @(posedge clk0 )
|
123 |
|
|
rst_r <= rst0;
|
124 |
|
|
|
125 |
|
|
genvar wdf_di_i;
|
126 |
|
|
genvar wdf_do_i;
|
127 |
|
|
genvar mask_i;
|
128 |
|
|
genvar wdf_i;
|
129 |
|
|
generate
|
130 |
|
|
if(ECC_ENABLE) begin // ECC code
|
131 |
|
|
|
132 |
|
|
assign wdf_data = i_wdf_data_out_ecc;
|
133 |
|
|
|
134 |
|
|
// the byte 9 dm is always held to 0
|
135 |
|
|
assign wdf_mask_data = i_wdf_mask_data_out_ecc;
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
// generate for write data fifo .
|
140 |
|
|
for (wdf_i = 0; wdf_i < WDF_FIFO_NUM; wdf_i = wdf_i + 1) begin: gen_wdf
|
141 |
|
|
|
142 |
|
|
FIFO36_72 #
|
143 |
|
|
(
|
144 |
|
|
.ALMOST_EMPTY_OFFSET (9'h007),
|
145 |
|
|
.ALMOST_FULL_OFFSET (9'h00F),
|
146 |
|
|
.DO_REG (1), // extra CC output delay
|
147 |
|
|
.EN_ECC_WRITE ("TRUE"),
|
148 |
|
|
.EN_ECC_READ ("FALSE"),
|
149 |
|
|
.EN_SYN ("FALSE"),
|
150 |
|
|
.FIRST_WORD_FALL_THROUGH ("FALSE")
|
151 |
|
|
)
|
152 |
|
|
u_wdf_ecc
|
153 |
|
|
(
|
154 |
|
|
.ALMOSTEMPTY (),
|
155 |
|
|
.ALMOSTFULL (i_wdf_afull[wdf_i]),
|
156 |
|
|
.DBITERR (),
|
157 |
|
|
.DO (i_wdf_data_out_ecc[((64*(wdf_i+1))+(wdf_i *8))-1:
|
158 |
|
|
(64*wdf_i)+(wdf_i *8)]),
|
159 |
|
|
.DOP (i_wdf_data_out_ecc[(72*(wdf_i+1))-1:
|
160 |
|
|
(64*(wdf_i+1))+ (8*wdf_i) ]),
|
161 |
|
|
.ECCPARITY (),
|
162 |
|
|
.EMPTY (),
|
163 |
|
|
.FULL (),
|
164 |
|
|
.RDCOUNT (),
|
165 |
|
|
.RDERR (),
|
166 |
|
|
.SBITERR (),
|
167 |
|
|
.WRCOUNT (),
|
168 |
|
|
.WRERR (),
|
169 |
|
|
.DI (app_wdf_data[(64*(wdf_i+1))-1:
|
170 |
|
|
(64*wdf_i)]),
|
171 |
|
|
.DIP (),
|
172 |
|
|
.RDCLK (clk90),
|
173 |
|
|
.RDEN (wdf_rden),
|
174 |
|
|
.RST (rst_r), // or can use rst0
|
175 |
|
|
.WRCLK (clk0),
|
176 |
|
|
// .WRCLK (usr_clk), //jb
|
177 |
|
|
.WREN (app_wdf_wren)
|
178 |
|
|
);
|
179 |
|
|
end
|
180 |
|
|
|
181 |
|
|
// remapping the mask data. The mask data from user i/f does not have
|
182 |
|
|
// the mask for the ECC byte. Assigning 0 to the ECC mask byte.
|
183 |
|
|
for (mask_i = 0; mask_i < (DQ_WIDTH)/36;
|
184 |
|
|
mask_i = mask_i +1) begin: gen_mask
|
185 |
|
|
assign mask_data_in_ecc[((8*(mask_i+1))+ mask_i)-1:((8*mask_i)+mask_i)]
|
186 |
|
|
= app_wdf_mask_data[(8*(mask_i+1))-1:8*(mask_i)] ;
|
187 |
|
|
assign mask_data_in_ecc[((8*(mask_i+1))+mask_i)] = 1'd0;
|
188 |
|
|
end
|
189 |
|
|
|
190 |
|
|
// assign ecc bits to temp variables to avoid
|
191 |
|
|
// sim warnings. Not all the 64 bits of the fifo
|
192 |
|
|
// are used in ECC mode.
|
193 |
|
|
assign mask_data_in_ecc_wire[((2*DQ_WIDTH)/8)-1:0] = mask_data_in_ecc;
|
194 |
|
|
assign mask_data_in_ecc_wire[63:((2*DQ_WIDTH)/8)] =
|
195 |
|
|
{(64-((2*DQ_WIDTH)/8)){1'b0}};
|
196 |
|
|
assign i_wdf_mask_data_out_ecc =
|
197 |
|
|
i_wdf_mask_data_out_ecc_wire[((2*DQ_WIDTH)/8)-1:0];
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
FIFO36_72 #
|
201 |
|
|
(
|
202 |
|
|
.ALMOST_EMPTY_OFFSET (9'h007),
|
203 |
|
|
.ALMOST_FULL_OFFSET (9'h00F),
|
204 |
|
|
.DO_REG (1), // extra CC output delay
|
205 |
|
|
.EN_ECC_WRITE ("TRUE"),
|
206 |
|
|
.EN_ECC_READ ("FALSE"),
|
207 |
|
|
.EN_SYN ("FALSE"),
|
208 |
|
|
.FIRST_WORD_FALL_THROUGH ("FALSE")
|
209 |
|
|
)
|
210 |
|
|
u_wdf_ecc_mask
|
211 |
|
|
(
|
212 |
|
|
.ALMOSTEMPTY (),
|
213 |
|
|
.ALMOSTFULL (),
|
214 |
|
|
.DBITERR (),
|
215 |
|
|
.DO (i_wdf_mask_data_out_ecc_wire),
|
216 |
|
|
.DOP (),
|
217 |
|
|
.ECCPARITY (),
|
218 |
|
|
.EMPTY (),
|
219 |
|
|
.FULL (),
|
220 |
|
|
.RDCOUNT (),
|
221 |
|
|
.RDERR (),
|
222 |
|
|
.SBITERR (),
|
223 |
|
|
.WRCOUNT (),
|
224 |
|
|
.WRERR (),
|
225 |
|
|
.DI (mask_data_in_ecc_wire),
|
226 |
|
|
.DIP (),
|
227 |
|
|
.RDCLK (clk90),
|
228 |
|
|
.RDEN (wdf_rden),
|
229 |
|
|
.RST (rst_r), // or can use rst0
|
230 |
|
|
.WRCLK (clk0),
|
231 |
|
|
// .WRCLK (usr_clk), // jb
|
232 |
|
|
.WREN (app_wdf_wren)
|
233 |
|
|
);
|
234 |
|
|
end else begin
|
235 |
|
|
|
236 |
|
|
//***********************************************************************
|
237 |
|
|
|
238 |
|
|
// Define intermediate buses:
|
239 |
|
|
assign i_wdf_data_rise_in
|
240 |
|
|
= app_wdf_data[DQ_WIDTH-1:0];
|
241 |
|
|
assign i_wdf_data_fall_in
|
242 |
|
|
= app_wdf_data[(2*DQ_WIDTH)-1:DQ_WIDTH];
|
243 |
|
|
assign i_wdf_mask_data_rise_in
|
244 |
|
|
= app_wdf_mask_data[MASK_WIDTH-1:0];
|
245 |
|
|
assign i_wdf_mask_data_fall_in
|
246 |
|
|
= app_wdf_mask_data[(2*MASK_WIDTH)-1:MASK_WIDTH];
|
247 |
|
|
|
248 |
|
|
//***********************************************************************
|
249 |
|
|
// Write data FIFO Input:
|
250 |
|
|
// Arrange DQ's so that the rise data and fall data are interleaved.
|
251 |
|
|
// the data arrives at the input of the wdf fifo as {fall,rise}.
|
252 |
|
|
// It is remapped as:
|
253 |
|
|
// {...fall[15:8],rise[15:8],fall[7:0],rise[7:0]}
|
254 |
|
|
// This is done to avoid having separate fifo's for rise and fall data
|
255 |
|
|
// and to keep rise/fall data for the same DQ's on same FIFO
|
256 |
|
|
// Data masks are interleaved in a similar manner
|
257 |
|
|
// NOTE: Initialization data from PHY_INIT module does not need to be
|
258 |
|
|
// interleaved - it's already in the correct format - and the same
|
259 |
|
|
// initialization pattern from PHY_INIT is sent to all write FIFOs
|
260 |
|
|
//***********************************************************************
|
261 |
|
|
|
262 |
|
|
for (wdf_di_i = 0; wdf_di_i < MASK_WIDTH;
|
263 |
|
|
wdf_di_i = wdf_di_i + 1) begin: gen_wdf_data_in
|
264 |
|
|
assign i_wdf_data_in[(16*wdf_di_i)+15:(16*wdf_di_i)]
|
265 |
|
|
= {i_wdf_data_fall_in[(8*wdf_di_i)+7:(8*wdf_di_i)],
|
266 |
|
|
i_wdf_data_rise_in[(8*wdf_di_i)+7:(8*wdf_di_i)]};
|
267 |
|
|
assign i_wdf_mask_data_in[(2*wdf_di_i)+1:(2*wdf_di_i)]
|
268 |
|
|
= {i_wdf_mask_data_fall_in[wdf_di_i],
|
269 |
|
|
i_wdf_mask_data_rise_in[wdf_di_i]};
|
270 |
|
|
end
|
271 |
|
|
|
272 |
|
|
//***********************************************************************
|
273 |
|
|
// Write data FIFO Output:
|
274 |
|
|
// FIFO DQ and mask outputs must be untangled and put in the standard
|
275 |
|
|
// format of {fall,rise}. Same goes for mask output
|
276 |
|
|
//***********************************************************************
|
277 |
|
|
|
278 |
|
|
for (wdf_do_i = 0; wdf_do_i < MASK_WIDTH;
|
279 |
|
|
wdf_do_i = wdf_do_i + 1) begin: gen_wdf_data_out
|
280 |
|
|
assign i_wdf_data_rise_out[(8*wdf_do_i)+7:(8*wdf_do_i)]
|
281 |
|
|
= i_wdf_data_out[(16*wdf_do_i)+7:(16*wdf_do_i)];
|
282 |
|
|
assign i_wdf_data_fall_out[(8*wdf_do_i)+7:(8*wdf_do_i)]
|
283 |
|
|
= i_wdf_data_out[(16*wdf_do_i)+15:(16*wdf_do_i)+8];
|
284 |
|
|
assign i_wdf_mask_data_rise_out[wdf_do_i]
|
285 |
|
|
= i_wdf_mask_data_out[2*wdf_do_i];
|
286 |
|
|
assign i_wdf_mask_data_fall_out[wdf_do_i]
|
287 |
|
|
= i_wdf_mask_data_out[(2*wdf_do_i)+1];
|
288 |
|
|
end
|
289 |
|
|
|
290 |
|
|
assign wdf_data = {i_wdf_data_fall_out,
|
291 |
|
|
i_wdf_data_rise_out};
|
292 |
|
|
|
293 |
|
|
assign wdf_mask_data = {i_wdf_mask_data_fall_out,
|
294 |
|
|
i_wdf_mask_data_rise_out};
|
295 |
|
|
|
296 |
|
|
//***********************************************************************
|
297 |
|
|
|
298 |
|
|
for (wdf_i = 0; wdf_i < WDF_FIFO_NUM; wdf_i = wdf_i + 1) begin: gen_wdf
|
299 |
|
|
|
300 |
|
|
FIFO36_72 #
|
301 |
|
|
(
|
302 |
|
|
.ALMOST_EMPTY_OFFSET (9'h007),
|
303 |
|
|
.ALMOST_FULL_OFFSET (9'h00F),
|
304 |
|
|
.DO_REG (1), // extra CC output delay
|
305 |
|
|
.EN_ECC_WRITE ("FALSE"),
|
306 |
|
|
.EN_ECC_READ ("FALSE"),
|
307 |
|
|
.EN_SYN ("FALSE"),
|
308 |
|
|
.FIRST_WORD_FALL_THROUGH ("FALSE")
|
309 |
|
|
)
|
310 |
|
|
u_wdf
|
311 |
|
|
(
|
312 |
|
|
.ALMOSTEMPTY (),
|
313 |
|
|
.ALMOSTFULL (i_wdf_afull[wdf_i]),
|
314 |
|
|
.DBITERR (),
|
315 |
|
|
.DO (i_wdf_data_out[(64*(wdf_i+1))-1:64*wdf_i]),
|
316 |
|
|
.DOP (i_wdf_mask_data_out[(8*(wdf_i+1))-1:8*wdf_i]),
|
317 |
|
|
.ECCPARITY (),
|
318 |
|
|
.EMPTY (),
|
319 |
|
|
.FULL (),
|
320 |
|
|
.RDCOUNT (),
|
321 |
|
|
.RDERR (),
|
322 |
|
|
.SBITERR (),
|
323 |
|
|
.WRCOUNT (),
|
324 |
|
|
.WRERR (),
|
325 |
|
|
.DI (i_wdf_data_in[(64*(wdf_i+1))-1:64*wdf_i]),
|
326 |
|
|
.DIP (i_wdf_mask_data_in[(8*(wdf_i+1))-1:8*wdf_i]),
|
327 |
|
|
.RDCLK (clk90),
|
328 |
|
|
.RDEN (wdf_rden),
|
329 |
|
|
.RST (rst_r), // or can use rst0
|
330 |
|
|
.WRCLK (clk0),
|
331 |
|
|
// .WRCLK (usr_clk), //jb
|
332 |
|
|
.WREN (app_wdf_wren)
|
333 |
|
|
);
|
334 |
|
|
end
|
335 |
|
|
end
|
336 |
|
|
endgenerate
|
337 |
|
|
|
338 |
|
|
endmodule
|