1 //*****************************************************************************
2 // DISCLAIMER OF LIABILITY
4 // This text/file contains proprietary, confidential
5 // information of Xilinx, Inc., is distributed under license
6 // from Xilinx, Inc., and may be used, copied and/or
7 // disclosed only pursuant to the terms of a valid license
8 // agreement with Xilinx, Inc. Xilinx hereby grants you a
9 // license to use this text/file solely for design, simulation,
10 // implementation and creation of design files limited
11 // to Xilinx devices or technologies. Use with non-Xilinx
12 // devices or technologies is expressly prohibited and
13 // immediately terminates your license unless covered by
14 // a separate agreement.
16 // Xilinx is providing this design, code, or information
17 // "as-is" solely for use in developing programs and
18 // solutions for Xilinx devices, with no obligation on the
19 // part of Xilinx to provide support. By providing this design,
20 // code, or information as one possible implementation of
21 // this feature, application or standard, Xilinx is making no
22 // representation that this implementation is free from any
23 // claims of infringement. You are responsible for
24 // obtaining any rights you may require for your implementation.
25 // Xilinx expressly disclaims any warranty whatsoever with
26 // respect to the adequacy of the implementation, including
27 // but not limited to any warranties or representations that this
28 // implementation is free from claims of infringement, implied
29 // warranties of merchantability or fitness for a particular
32 // Xilinx products are not intended for use in life support
33 // appliances, devices, or systems. Use in such applications is
34 // expressly prohibited.
36 // Any modifications that are made to the Source Code are
37 // done at the users sole risk and will be unsupported.
39 // Copyright (c) 2006-2007 Xilinx, Inc. All rights reserved.
41 // This copyright and support notice must be retained as part
42 // of this text at all times.
43 //*****************************************************************************
46 // /___/ \ / Vendor: Xilinx
47 // \ \ \/ Version: 2.3
48 // \ \ Application: MIG
49 // / / Filename: ddr2_usr_wr.v
50 // /___/ /\ Date Last Modified: $Date: 2008/05/08 15:20:47 $
51 // \ \ / \ Date Created: Mon Aug 28 2006
55 //Design Name: DDR/DDR2
57 // This module instantiates the modules containing internal FIFOs
60 //*****************************************************************************
66 // Following parameters are for 72-bit RDIMM design (for ML561 Reference
67 // board design). Actual values may be different. Actual parameters values
68 // are passed from design top module ddr2_sdram module. Please refer to
69 // the ddr2_sdram module for actual values.
70 parameter BANK_WIDTH = 2,
71 parameter COL_WIDTH = 10,
72 parameter CS_BITS = 0,
73 parameter DQ_WIDTH = 72,
74 parameter APPDATA_WIDTH = 144,
75 parameter ECC_ENABLE = 0,
76 parameter ROW_WIDTH = 14
82 // Write data FIFO interface
84 input [APPDATA_WIDTH-1:0] app_wdf_data,
85 input [(APPDATA_WIDTH/8)-1:0] app_wdf_mask_data,
88 output [(2*DQ_WIDTH)-1:0] wdf_data,
89 output [((2*DQ_WIDTH)/8)-1:0] wdf_mask_data
92 // determine number of FIFO72's to use based on data width
93 // round up to next integer value when determining WDF_FIFO_NUM
94 localparam WDF_FIFO_NUM = (ECC_ENABLE) ? (APPDATA_WIDTH+63)/64 :
96 // MASK_WIDTH = number of bytes in data bus
97 localparam MASK_WIDTH = DQ_WIDTH/8;
99 wire [WDF_FIFO_NUM-1:0] i_wdf_afull;
100 wire [DQ_WIDTH-1:0] i_wdf_data_fall_in;
101 wire [DQ_WIDTH-1:0] i_wdf_data_fall_out;
102 wire [(64*WDF_FIFO_NUM)-1:0] i_wdf_data_in;
103 wire [(64*WDF_FIFO_NUM)-1:0] i_wdf_data_out;
104 wire [DQ_WIDTH-1:0] i_wdf_data_rise_in;
105 wire [DQ_WIDTH-1:0] i_wdf_data_rise_out;
106 wire [MASK_WIDTH-1:0] i_wdf_mask_data_fall_in;
107 wire [MASK_WIDTH-1:0] i_wdf_mask_data_fall_out;
108 wire [(8*WDF_FIFO_NUM)-1:0] i_wdf_mask_data_in;
109 wire [(8*WDF_FIFO_NUM)-1:0] i_wdf_mask_data_out;
110 wire [MASK_WIDTH-1:0] i_wdf_mask_data_rise_in;
111 wire [MASK_WIDTH-1:0] i_wdf_mask_data_rise_out;
115 wire [(2*DQ_WIDTH)-1:0] i_wdf_data_out_ecc;
116 wire [((2*DQ_WIDTH)/8)-1:0] i_wdf_mask_data_out_ecc;
117 wire [63:0] i_wdf_mask_data_out_ecc_wire;
118 wire [((2*DQ_WIDTH)/8)-1:0] mask_data_in_ecc;
119 wire [63:0] mask_data_in_ecc_wire;
121 //***************************************************************************
123 assign app_wdf_afull = i_wdf_afull[0];
125 always @(posedge clk0 )
133 if(ECC_ENABLE) begin // ECC code
135 assign wdf_data = i_wdf_data_out_ecc;
137 // the byte 9 dm is always held to 0
138 assign wdf_mask_data = i_wdf_mask_data_out_ecc;
142 // generate for write data fifo .
143 for (wdf_i = 0; wdf_i < WDF_FIFO_NUM; wdf_i = wdf_i + 1) begin: gen_wdf
147 .ALMOST_EMPTY_OFFSET (9'h007),
148 .ALMOST_FULL_OFFSET (9'h00F),
149 .DO_REG (1), // extra CC output delay
150 .EN_ECC_WRITE ("TRUE"),
151 .EN_ECC_READ ("FALSE"),
153 .FIRST_WORD_FALL_THROUGH ("FALSE")
158 .ALMOSTFULL (i_wdf_afull[wdf_i]),
160 .DO (i_wdf_data_out_ecc[((64*(wdf_i+1))+(wdf_i *8))-1:
161 (64*wdf_i)+(wdf_i *8)]),
162 .DOP (i_wdf_data_out_ecc[(72*(wdf_i+1))-1:
163 (64*(wdf_i+1))+ (8*wdf_i) ]),
172 .DI (app_wdf_data[(64*(wdf_i+1))-1:
177 .RST (rst_r), // or can use rst0
183 // remapping the mask data. The mask data from user i/f does not have
184 // the mask for the ECC byte. Assigning 0 to the ECC mask byte.
185 for (mask_i = 0; mask_i < (DQ_WIDTH)/36;
186 mask_i = mask_i +1) begin: gen_mask
187 assign mask_data_in_ecc[((8*(mask_i+1))+ mask_i)-1:((8*mask_i)+mask_i)]
188 = app_wdf_mask_data[(8*(mask_i+1))-1:8*(mask_i)] ;
189 assign mask_data_in_ecc[((8*(mask_i+1))+mask_i)] = 1'd0;
192 // assign ecc bits to temp variables to avoid
193 // sim warnings. Not all the 64 bits of the fifo
194 // are used in ECC mode.
195 assign mask_data_in_ecc_wire[((2*DQ_WIDTH)/8)-1:0] = mask_data_in_ecc;
196 assign mask_data_in_ecc_wire[63:((2*DQ_WIDTH)/8)] =
197 {(64-((2*DQ_WIDTH)/8)){1'b0}};
198 assign i_wdf_mask_data_out_ecc =
199 i_wdf_mask_data_out_ecc_wire[((2*DQ_WIDTH)/8)-1:0];
204 .ALMOST_EMPTY_OFFSET (9'h007),
205 .ALMOST_FULL_OFFSET (9'h00F),
206 .DO_REG (1), // extra CC output delay
207 .EN_ECC_WRITE ("TRUE"),
208 .EN_ECC_READ ("FALSE"),
210 .FIRST_WORD_FALL_THROUGH ("FALSE")
217 .DO (i_wdf_mask_data_out_ecc_wire),
227 .DI (mask_data_in_ecc_wire),
231 .RST (rst_r), // or can use rst0
237 //***********************************************************************
239 // Define intermediate buses:
240 assign i_wdf_data_rise_in
241 = app_wdf_data[DQ_WIDTH-1:0];
242 assign i_wdf_data_fall_in
243 = app_wdf_data[(2*DQ_WIDTH)-1:DQ_WIDTH];
244 assign i_wdf_mask_data_rise_in
245 = app_wdf_mask_data[MASK_WIDTH-1:0];
246 assign i_wdf_mask_data_fall_in
247 = app_wdf_mask_data[(2*MASK_WIDTH)-1:MASK_WIDTH];
249 //***********************************************************************
250 // Write data FIFO Input:
251 // Arrange DQ's so that the rise data and fall data are interleaved.
252 // the data arrives at the input of the wdf fifo as {fall,rise}.
253 // It is remapped as:
254 // {...fall[15:8],rise[15:8],fall[7:0],rise[7:0]}
255 // This is done to avoid having separate fifo's for rise and fall data
256 // and to keep rise/fall data for the same DQ's on same FIFO
257 // Data masks are interleaved in a similar manner
258 // NOTE: Initialization data from PHY_INIT module does not need to be
259 // interleaved - it's already in the correct format - and the same
260 // initialization pattern from PHY_INIT is sent to all write FIFOs
261 //***********************************************************************
263 for (wdf_di_i = 0; wdf_di_i < MASK_WIDTH;
264 wdf_di_i = wdf_di_i + 1) begin: gen_wdf_data_in
265 assign i_wdf_data_in[(16*wdf_di_i)+15:(16*wdf_di_i)]
266 = {i_wdf_data_fall_in[(8*wdf_di_i)+7:(8*wdf_di_i)],
267 i_wdf_data_rise_in[(8*wdf_di_i)+7:(8*wdf_di_i)]};
268 assign i_wdf_mask_data_in[(2*wdf_di_i)+1:(2*wdf_di_i)]
269 = {i_wdf_mask_data_fall_in[wdf_di_i],
270 i_wdf_mask_data_rise_in[wdf_di_i]};
273 //***********************************************************************
274 // Write data FIFO Output:
275 // FIFO DQ and mask outputs must be untangled and put in the standard
276 // format of {fall,rise}. Same goes for mask output
277 //***********************************************************************
279 for (wdf_do_i = 0; wdf_do_i < MASK_WIDTH;
280 wdf_do_i = wdf_do_i + 1) begin: gen_wdf_data_out
281 assign i_wdf_data_rise_out[(8*wdf_do_i)+7:(8*wdf_do_i)]
282 = i_wdf_data_out[(16*wdf_do_i)+7:(16*wdf_do_i)];
283 assign i_wdf_data_fall_out[(8*wdf_do_i)+7:(8*wdf_do_i)]
284 = i_wdf_data_out[(16*wdf_do_i)+15:(16*wdf_do_i)+8];
285 assign i_wdf_mask_data_rise_out[wdf_do_i]
286 = i_wdf_mask_data_out[2*wdf_do_i];
287 assign i_wdf_mask_data_fall_out[wdf_do_i]
288 = i_wdf_mask_data_out[(2*wdf_do_i)+1];
291 assign wdf_data = {i_wdf_data_fall_out,
292 i_wdf_data_rise_out};
294 assign wdf_mask_data = {i_wdf_mask_data_fall_out,
295 i_wdf_mask_data_rise_out};
297 //***********************************************************************
299 for (wdf_i = 0; wdf_i < WDF_FIFO_NUM; wdf_i = wdf_i + 1) begin: gen_wdf
303 .ALMOST_EMPTY_OFFSET (9'h007),
304 .ALMOST_FULL_OFFSET (9'h00F),
305 .DO_REG (1), // extra CC output delay
306 .EN_ECC_WRITE ("FALSE"),
307 .EN_ECC_READ ("FALSE"),
309 .FIRST_WORD_FALL_THROUGH ("FALSE")
314 .ALMOSTFULL (i_wdf_afull[wdf_i]),
316 .DO (i_wdf_data_out[(64*(wdf_i+1))-1:64*wdf_i]),
317 .DOP (i_wdf_mask_data_out[(8*(wdf_i+1))-1:8*wdf_i]),
326 .DI (i_wdf_data_in[(64*(wdf_i+1))-1:64*wdf_i]),
327 .DIP (i_wdf_mask_data_in[(8*(wdf_i+1))-1:8*wdf_i]),
330 .RST (rst_r), // or can use rst0