source: XOpenSparcT1/trunk/Xilinx/ddr2_usr_wr.v @ 10

Revision 10, 13.0 KB checked in by pntsvt00, 13 years ago (diff)

versione sintetizzabile

Line 
1//*****************************************************************************
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.6
44//  \   \         Application: MIG
45//  /   /         Filename: ddr2_usr_wr.v
46// /___/   /\     Date Last Modified: $Date: 2010/06/29 12:03:43 $
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
60module 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 dram module. Please refer to
65   // the dram 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                         clk90,
77   input                         rst0,
78   // Write data FIFO interface
79   input                         app_wdf_wren,
80   input [APPDATA_WIDTH-1:0]     app_wdf_data,
81   input [(APPDATA_WIDTH/8)-1:0] app_wdf_mask_data,
82   input                         wdf_rden,
83   output                        app_wdf_afull,
84   output [(2*DQ_WIDTH)-1:0]     wdf_data,
85   output [((2*DQ_WIDTH)/8)-1:0] wdf_mask_data
86   );
87
88  // determine number of FIFO72's to use based on data width
89  // round up to next integer value when determining WDF_FIFO_NUM
90  localparam WDF_FIFO_NUM = (ECC_ENABLE) ? (APPDATA_WIDTH+63)/64 :
91             ((2*DQ_WIDTH)+63)/64;
92  // MASK_WIDTH = number of bytes in data bus
93  localparam MASK_WIDTH = DQ_WIDTH/8;
94
95  wire [WDF_FIFO_NUM-1:0]      i_wdf_afull;
96  wire [DQ_WIDTH-1:0]          i_wdf_data_fall_in;
97  wire [DQ_WIDTH-1:0]          i_wdf_data_fall_out;
98  wire [(64*WDF_FIFO_NUM)-1:0] i_wdf_data_in;
99  wire [(64*WDF_FIFO_NUM)-1:0] i_wdf_data_out;
100  wire [DQ_WIDTH-1:0]          i_wdf_data_rise_in;
101  wire [DQ_WIDTH-1:0]          i_wdf_data_rise_out;
102  wire [MASK_WIDTH-1:0]        i_wdf_mask_data_fall_in;
103  wire [MASK_WIDTH-1:0]        i_wdf_mask_data_fall_out;
104  wire [(8*WDF_FIFO_NUM)-1:0]  i_wdf_mask_data_in;
105  wire [(8*WDF_FIFO_NUM)-1:0]  i_wdf_mask_data_out;
106  wire [MASK_WIDTH-1:0]        i_wdf_mask_data_rise_in;
107  wire [MASK_WIDTH-1:0]        i_wdf_mask_data_rise_out;
108  reg                          rst_r;
109
110  // ECC signals
111  wire [(2*DQ_WIDTH)-1:0]      i_wdf_data_out_ecc;
112  wire [((2*DQ_WIDTH)/8)-1:0]  i_wdf_mask_data_out_ecc;
113  wire [63:0]                  i_wdf_mask_data_out_ecc_wire;
114  wire [((2*DQ_WIDTH)/8)-1:0]  mask_data_in_ecc;
115  wire [63:0]                  mask_data_in_ecc_wire;
116
117  //***************************************************************************
118
119  assign app_wdf_afull = i_wdf_afull[0];
120
121  always @(posedge clk0 )
122      rst_r <= rst0;
123
124  genvar wdf_di_i;
125  genvar wdf_do_i;
126  genvar mask_i;
127  genvar wdf_i;
128  generate
129    if(ECC_ENABLE) begin    // ECC code
130
131      assign wdf_data = i_wdf_data_out_ecc;
132
133      // the byte 9 dm is always held to 0
134      assign wdf_mask_data = i_wdf_mask_data_out_ecc;
135
136
137
138      // generate for write data fifo .
139      for (wdf_i = 0; wdf_i < WDF_FIFO_NUM; wdf_i = wdf_i + 1) begin: gen_wdf
140
141        FIFO36_72  #
142          (
143           .ALMOST_EMPTY_OFFSET     (9'h007),
144           .ALMOST_FULL_OFFSET      (9'h00F),
145           .DO_REG                  (1),          // extra CC output delay
146           .EN_ECC_WRITE            ("TRUE"),
147           .EN_ECC_READ             ("FALSE"),
148           .EN_SYN                  ("FALSE"),
149           .FIRST_WORD_FALL_THROUGH ("FALSE")
150           )
151          u_wdf_ecc
152            (
153             .ALMOSTEMPTY (),
154             .ALMOSTFULL  (i_wdf_afull[wdf_i]),
155             .DBITERR     (),
156             .DO          (i_wdf_data_out_ecc[((64*(wdf_i+1))+(wdf_i *8))-1:
157                                              (64*wdf_i)+(wdf_i *8)]),
158             .DOP         (i_wdf_data_out_ecc[(72*(wdf_i+1))-1:
159                                              (64*(wdf_i+1))+ (8*wdf_i) ]),
160             .ECCPARITY   (),
161             .EMPTY       (),
162             .FULL        (),
163             .RDCOUNT     (),
164             .RDERR       (),
165             .SBITERR     (),
166             .WRCOUNT     (),
167             .WRERR       (),
168             .DI          (app_wdf_data[(64*(wdf_i+1))-1:
169                                        (64*wdf_i)]),
170             .DIP         (),
171             .RDCLK       (clk90),
172             .RDEN        (wdf_rden),
173             .RST         (rst_r),          // or can use rst0
174             .WRCLK       (clk0),
175             .WREN        (app_wdf_wren)
176             );
177      end
178
179      // remapping the mask data. The mask data from user i/f does not have
180      // the mask for the ECC byte. Assigning 0 to the ECC mask byte.
181      for (mask_i = 0; mask_i < (DQ_WIDTH)/36;
182           mask_i = mask_i +1) begin: gen_mask
183        assign mask_data_in_ecc[((8*(mask_i+1))+ mask_i)-1:((8*mask_i)+mask_i)]
184                 = app_wdf_mask_data[(8*(mask_i+1))-1:8*(mask_i)] ;
185        assign mask_data_in_ecc[((8*(mask_i+1))+mask_i)] = 1'd0;
186      end
187
188      // assign ecc bits to temp variables to avoid
189      // sim warnings. Not all the 64 bits of the fifo
190      // are used in ECC mode.
191       assign  mask_data_in_ecc_wire[((2*DQ_WIDTH)/8)-1:0] = mask_data_in_ecc;
192       assign  mask_data_in_ecc_wire[63:((2*DQ_WIDTH)/8)]  =
193              {(64-((2*DQ_WIDTH)/8)){1'b0}};
194       assign i_wdf_mask_data_out_ecc =
195               i_wdf_mask_data_out_ecc_wire[((2*DQ_WIDTH)/8)-1:0];
196
197
198      FIFO36_72  #
199        (
200         .ALMOST_EMPTY_OFFSET     (9'h007),
201         .ALMOST_FULL_OFFSET      (9'h00F),
202         .DO_REG                  (1),          // extra CC output delay
203         .EN_ECC_WRITE            ("TRUE"),
204         .EN_ECC_READ             ("FALSE"),
205         .EN_SYN                  ("FALSE"),
206         .FIRST_WORD_FALL_THROUGH ("FALSE")
207         )
208        u_wdf_ecc_mask
209          (
210           .ALMOSTEMPTY (),
211           .ALMOSTFULL  (),
212           .DBITERR     (),
213           .DO          (i_wdf_mask_data_out_ecc_wire),
214           .DOP         (),
215           .ECCPARITY   (),
216           .EMPTY       (),
217           .FULL        (),
218           .RDCOUNT     (),
219           .RDERR       (),
220           .SBITERR     (),
221           .WRCOUNT     (),
222           .WRERR       (),
223           .DI          (mask_data_in_ecc_wire),
224           .DIP         (),
225           .RDCLK       (clk90),
226           .RDEN        (wdf_rden),
227           .RST         (rst_r),          // or can use rst0
228           .WRCLK       (clk0),
229           .WREN        (app_wdf_wren)
230           );
231    end else begin
232
233      //***********************************************************************
234
235      // Define intermediate buses:
236      assign i_wdf_data_rise_in
237        = app_wdf_data[DQ_WIDTH-1:0];
238      assign i_wdf_data_fall_in
239        = app_wdf_data[(2*DQ_WIDTH)-1:DQ_WIDTH];
240      assign i_wdf_mask_data_rise_in
241        = app_wdf_mask_data[MASK_WIDTH-1:0];
242      assign i_wdf_mask_data_fall_in
243        = app_wdf_mask_data[(2*MASK_WIDTH)-1:MASK_WIDTH];
244
245      //***********************************************************************
246      // Write data FIFO Input:
247      // Arrange DQ's so that the rise data and fall data are interleaved.
248      // the data arrives at the input of the wdf fifo as {fall,rise}.
249      // It is remapped as:
250      //     {...fall[15:8],rise[15:8],fall[7:0],rise[7:0]}
251      // This is done to avoid having separate fifo's for rise and fall data
252      // and to keep rise/fall data for the same DQ's on same FIFO
253      // Data masks are interleaved in a similar manner
254      // NOTE: Initialization data from PHY_INIT module does not need to be
255      //  interleaved - it's already in the correct format - and the same
256      //  initialization pattern from PHY_INIT is sent to all write FIFOs
257      //***********************************************************************
258
259      for (wdf_di_i = 0; wdf_di_i < MASK_WIDTH;
260           wdf_di_i = wdf_di_i + 1) begin: gen_wdf_data_in
261        assign i_wdf_data_in[(16*wdf_di_i)+15:(16*wdf_di_i)]
262                 = {i_wdf_data_fall_in[(8*wdf_di_i)+7:(8*wdf_di_i)],
263                    i_wdf_data_rise_in[(8*wdf_di_i)+7:(8*wdf_di_i)]};
264        assign i_wdf_mask_data_in[(2*wdf_di_i)+1:(2*wdf_di_i)]
265                 = {i_wdf_mask_data_fall_in[wdf_di_i],
266                    i_wdf_mask_data_rise_in[wdf_di_i]};
267      end
268
269      //***********************************************************************
270      // Write data FIFO Output:
271      // FIFO DQ and mask outputs must be untangled and put in the standard
272      // format of {fall,rise}. Same goes for mask output
273      //***********************************************************************
274
275      for (wdf_do_i = 0; wdf_do_i < MASK_WIDTH;
276           wdf_do_i = wdf_do_i + 1) begin: gen_wdf_data_out
277        assign i_wdf_data_rise_out[(8*wdf_do_i)+7:(8*wdf_do_i)]
278                 = i_wdf_data_out[(16*wdf_do_i)+7:(16*wdf_do_i)];
279        assign i_wdf_data_fall_out[(8*wdf_do_i)+7:(8*wdf_do_i)]
280                 = i_wdf_data_out[(16*wdf_do_i)+15:(16*wdf_do_i)+8];
281        assign i_wdf_mask_data_rise_out[wdf_do_i]
282                 = i_wdf_mask_data_out[2*wdf_do_i];
283        assign i_wdf_mask_data_fall_out[wdf_do_i]
284                 = i_wdf_mask_data_out[(2*wdf_do_i)+1];
285      end
286
287      assign wdf_data = {i_wdf_data_fall_out,
288                         i_wdf_data_rise_out};
289
290      assign wdf_mask_data = {i_wdf_mask_data_fall_out,
291                              i_wdf_mask_data_rise_out};
292
293      //***********************************************************************
294
295      for (wdf_i = 0; wdf_i < WDF_FIFO_NUM; wdf_i = wdf_i + 1) begin: gen_wdf
296
297        FIFO36_72  #
298          (
299           .ALMOST_EMPTY_OFFSET     (9'h007),
300           .ALMOST_FULL_OFFSET      (9'h00F),
301           .DO_REG                  (1),          // extra CC output delay
302           .EN_ECC_WRITE            ("FALSE"),
303           .EN_ECC_READ             ("FALSE"),
304           .EN_SYN                  ("FALSE"),
305           .FIRST_WORD_FALL_THROUGH ("FALSE")
306           )
307          u_wdf
308            (
309             .ALMOSTEMPTY (),
310             .ALMOSTFULL  (i_wdf_afull[wdf_i]),
311             .DBITERR     (),
312             .DO          (i_wdf_data_out[(64*(wdf_i+1))-1:64*wdf_i]),
313             .DOP         (i_wdf_mask_data_out[(8*(wdf_i+1))-1:8*wdf_i]),
314             .ECCPARITY   (),
315             .EMPTY       (),
316             .FULL        (),
317             .RDCOUNT     (),
318             .RDERR       (),
319             .SBITERR     (),
320             .WRCOUNT     (),
321             .WRERR       (),
322             .DI          (i_wdf_data_in[(64*(wdf_i+1))-1:64*wdf_i]),
323             .DIP         (i_wdf_mask_data_in[(8*(wdf_i+1))-1:8*wdf_i]),
324             .RDCLK       (clk90),
325             .RDEN        (wdf_rden),
326             .RST         (rst_r),          // or can use rst0
327             .WRCLK       (clk0),
328             .WREN        (app_wdf_wren)
329             );
330      end
331    end
332  endgenerate
333
334endmodule
Note: See TracBrowser for help on using the repository browser.