increase number of Memory ships to 3 in the large configuration
[fleet.git] / src / edu / berkeley / fleet / fpga / greg / ddr2_usr_top.v
1 //*****************************************************************************
2 // DISCLAIMER OF LIABILITY
3 // 
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.
15 //
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 
30 // purpose.
31 //
32 // Xilinx products are not intended for use in life support
33 // appliances, devices, or systems. Use in such applications is
34 // expressly prohibited.
35 //
36 // Any modifications that are made to the Source Code are 
37 // done at the user�s sole risk and will be unsupported.
38 //
39 // Copyright (c) 2006-2007 Xilinx, Inc. All rights reserved.
40 //
41 // This copyright and support notice must be retained as part 
42 // of this text at all times. 
43 //*****************************************************************************
44 //   ____  ____
45 //  /   /\/   /
46 // /___/  \  /    Vendor: Xilinx
47 // \   \   \/     Version: 2.3
48 //  \   \         Application: MIG
49 //  /   /         Filename: ddr2_usr_top.v
50 // /___/   /\     Date Last Modified: $Date: 2008/05/08 15:20:47 $
51 // \   \  /  \    Date Created: Mon Aug 28 2006
52 //  \___\/\___\
53 //
54 //Device: Virtex-5
55 //Design Name: DDR2
56 //Purpose:
57 //   This module interfaces with the user. The user should provide the data
58 //   and  various commands.
59 //Reference:
60 //Revision History:
61 //*****************************************************************************
62
63 `timescale 1ns/1ps
64
65 module ddr2_usr_top #
66   (
67    // Following parameters are for 72-bit RDIMM design (for ML561 Reference 
68    // board design). Actual values may be different. Actual parameters values 
69    // are passed from design top module ddr2_sdram module. Please refer to
70    // the ddr2_sdram module for actual values.
71    parameter BANK_WIDTH     = 2,
72    parameter CS_BITS        = 0,
73    parameter COL_WIDTH      = 10,
74    parameter DQ_WIDTH       = 72,
75    parameter DQ_PER_DQS     = 8,
76    parameter APPDATA_WIDTH  = 144,
77    parameter APPDATA_BURST_LEN = 2,
78    parameter APPDATA_BURST_BITS = 1,
79    parameter ECC_ENABLE     = 0,
80    parameter DQS_WIDTH      = 9,
81    parameter ROW_WIDTH      = 14,
82    parameter EN_SYN         = "FALSE"
83    )
84   (
85    input                                     clk0,
86    input                                     clk90,
87    input                                     rst0,
88    //added by xtan
89    input                                     af_clk,                    //address fifo clk
90    input                                     rb_clk,                    //read buffer clk
91    input                                     wb_clk,                    //write buffer clk
92    input                                     af_rst,                    //address fifo rst
93    input                                     rb_rst,                    //read buffer rst
94    input                                     wb_rst,                    //write buffer rst
95    output                                    rb_full,                   //read buffer is full
96    //end of add
97    input [DQ_WIDTH-1:0]                      rd_data_in_rise,
98    input [DQ_WIDTH-1:0]                      rd_data_in_fall,
99    input [DQS_WIDTH-1:0]                     phy_calib_rden,
100    input [DQS_WIDTH-1:0]                     phy_calib_rden_sel,
101    output                                    rd_data_valid,
102    input                                     rd_data_rden,
103    output [APPDATA_WIDTH-1:0]                rd_data_fifo_out,
104    input [2:0]                               app_af_cmd,
105    input [30:0]                              app_af_addr,
106    input                                     app_af_wren,
107    input                                     ctrl_af_rden,
108    output [2:0]                              af_cmd,
109    output [30:0]                             af_addr,
110    output                                    af_empty,
111    output                                    app_af_afull,
112    output [1:0]                              rd_ecc_error,
113    input                                     app_wdf_wren,
114    input [APPDATA_WIDTH-1:0]                 app_wdf_data,
115    input [(APPDATA_WIDTH/8)-1:0]             app_wdf_mask_data,
116    input                                     wdf_rden,
117    output                                    app_wdf_afull,
118    output [(2*DQ_WIDTH)-1:0]                 wdf_data,
119    output [((2*DQ_WIDTH)/8)-1:0]             wdf_mask_data,
120    output                                                                        wr_fifo_clear,
121    input                                     wr_fifo_burst,
122    output                                    rd_fifo_clear
123    );
124
125   wire [(APPDATA_WIDTH/2)-1:0] i_rd_data_fifo_out_fall;
126   wire [(APPDATA_WIDTH/2)-1:0] i_rd_data_fifo_out_rise;
127
128   //***************************************************************************
129
130   assign rd_data_fifo_out = {i_rd_data_fifo_out_fall,
131                              i_rd_data_fifo_out_rise};
132
133   // read data de-skew and ECC calculation
134   ddr2_usr_rd #
135     (
136      .DQ_PER_DQS    (DQ_PER_DQS),
137      .ECC_ENABLE    (ECC_ENABLE),
138      .APPDATA_WIDTH (APPDATA_WIDTH),
139      .APPDATA_BURST_LEN( APPDATA_BURST_LEN),
140      .APPDATA_BURST_BITS(APPDATA_BURST_BITS),
141      .DQS_WIDTH     (DQS_WIDTH),
142      .EN_SYN        (EN_SYN)
143      )
144      u_usr_rd
145       (
146        .clk0             (clk0),
147        .rst0             (rst0),
148        .rb_clk           (rb_clk),
149        .rb_rst           (rb_rst),
150        .rb_full          (rb_full),
151        .rd_data_in_rise  (rd_data_in_rise),
152        .rd_data_in_fall  (rd_data_in_fall),
153        .rd_ecc_error     (rd_ecc_error),
154        .ctrl_rden        (phy_calib_rden),
155        .ctrl_rden_sel    (phy_calib_rden_sel),
156        .rd_data_valid    (rd_data_valid),
157        .rd_data_rden     (rd_data_rden),
158        .rd_data_out_rise (i_rd_data_fifo_out_rise),
159        .rd_data_out_fall (i_rd_data_fifo_out_fall),
160        .rd_fifo_clear    (rd_fifo_clear)
161        );
162
163   // Command/Addres FIFO
164   ddr2_usr_addr_fifo #
165     (
166      .BANK_WIDTH (BANK_WIDTH),
167      .COL_WIDTH  (COL_WIDTH),
168      .CS_BITS    (CS_BITS),
169      .ROW_WIDTH  (ROW_WIDTH),
170      .EN_SYN     (EN_SYN)
171      )
172      u_usr_addr_fifo
173       (
174        .clk0         (clk0),
175        .af_clk       (af_clk),
176        .af_rst       (af_rst),
177        .rst0         (rst0),
178        .app_af_cmd   (app_af_cmd),
179        .app_af_addr  (app_af_addr),
180        .app_af_wren  (app_af_wren),
181        .ctrl_af_rden (ctrl_af_rden),
182        .af_cmd       (af_cmd),
183        .af_addr      (af_addr),
184        .af_empty     (af_empty),
185        .app_af_afull (app_af_afull)
186        );
187
188   ddr2_usr_wr #
189     (
190      .BANK_WIDTH    (BANK_WIDTH),
191      .COL_WIDTH     (COL_WIDTH),
192      .CS_BITS       (CS_BITS),
193      .DQ_WIDTH      (DQ_WIDTH),
194      .APPDATA_WIDTH (APPDATA_WIDTH),
195      .APPDATA_BURST_LEN(APPDATA_BURST_LEN),
196      .APPDATA_BURST_BITS(APPDATA_BURST_BITS),
197      .ECC_ENABLE    (ECC_ENABLE),
198      .ROW_WIDTH     (ROW_WIDTH)
199      )
200     u_usr_wr
201       (
202        .clk0              (clk0),
203        .wb_clk            (wb_clk),
204        .wb_rst            (wb_rst),
205        .clk90             (clk90),
206        .rst0              (rst0),
207        .app_wdf_wren      (app_wdf_wren),
208        .app_wdf_data      (app_wdf_data),
209        .app_wdf_mask_data (app_wdf_mask_data),
210        .wdf_rden          (wdf_rden),
211        .app_wdf_afull     (app_wdf_afull),
212        .wdf_data          (wdf_data),
213        .wdf_mask_data     (wdf_mask_data),
214        .wr_fifo_clear     (wr_fifo_clear),
215        .wr_fifo_burst     (wr_fifo_burst)
216        );
217
218 endmodule