Merge marina project in subdirectory marina/
[fleet.git] / src / edu / berkeley / fleet / fpga / ddr2 / 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 users 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 ECC_ENABLE     = 0,
78    parameter DQS_WIDTH      = 9,
79    parameter ROW_WIDTH      = 14
80    )
81   (
82    input                                     clk0,
83    input                                     clk90,
84    input                                     rst0,
85    input [DQ_WIDTH-1:0]                      rd_data_in_rise,
86    input [DQ_WIDTH-1:0]                      rd_data_in_fall,
87    input [DQS_WIDTH-1:0]                     phy_calib_rden,
88    input [DQS_WIDTH-1:0]                     phy_calib_rden_sel,
89    output                                    rd_data_valid,
90    output [APPDATA_WIDTH-1:0]                rd_data_fifo_out,
91    input [2:0]                               app_af_cmd,
92    input [30:0]                              app_af_addr,
93    input                                     app_af_wren,
94    input                                     ctrl_af_rden,
95    output [2:0]                              af_cmd,
96    output [30:0]                             af_addr,
97    output                                    af_empty,
98    output                                    app_af_afull,
99    output [1:0]                              rd_ecc_error,
100    input                                     app_wdf_wren,
101    input [APPDATA_WIDTH-1:0]                 app_wdf_data,
102    input [(APPDATA_WIDTH/8)-1:0]             app_wdf_mask_data,
103    input                                     wdf_rden,
104    output                                    app_wdf_afull,
105    output [(2*DQ_WIDTH)-1:0]                 wdf_data,
106    output [((2*DQ_WIDTH)/8)-1:0]             wdf_mask_data
107    );
108
109   wire [(APPDATA_WIDTH/2)-1:0] i_rd_data_fifo_out_fall;
110   wire [(APPDATA_WIDTH/2)-1:0] i_rd_data_fifo_out_rise;
111
112   //***************************************************************************
113
114   assign rd_data_fifo_out = {i_rd_data_fifo_out_fall,
115                              i_rd_data_fifo_out_rise};
116
117   // read data de-skew and ECC calculation
118   ddr2_usr_rd #
119     (
120      .DQ_PER_DQS    (DQ_PER_DQS),
121      .ECC_ENABLE    (ECC_ENABLE),
122      .APPDATA_WIDTH (APPDATA_WIDTH),
123      .DQS_WIDTH     (DQS_WIDTH)
124      )
125      u_usr_rd
126       (
127        .clk0             (clk0),
128        .rst0             (rst0),
129        .rd_data_in_rise  (rd_data_in_rise),
130        .rd_data_in_fall  (rd_data_in_fall),
131        .rd_ecc_error     (rd_ecc_error),
132        .ctrl_rden        (phy_calib_rden),
133        .ctrl_rden_sel    (phy_calib_rden_sel),
134        .rd_data_valid    (rd_data_valid),
135        .rd_data_out_rise (i_rd_data_fifo_out_rise),
136        .rd_data_out_fall (i_rd_data_fifo_out_fall)
137        );
138
139   // Command/Addres FIFO
140   ddr2_usr_addr_fifo #
141     (
142      .BANK_WIDTH (BANK_WIDTH),
143      .COL_WIDTH  (COL_WIDTH),
144      .CS_BITS    (CS_BITS),
145      .ROW_WIDTH  (ROW_WIDTH)
146      )
147      u_usr_addr_fifo
148       (
149        .clk0         (clk0),
150        .rst0         (rst0),
151        .app_af_cmd   (app_af_cmd),
152        .app_af_addr  (app_af_addr),
153        .app_af_wren  (app_af_wren),
154        .ctrl_af_rden (ctrl_af_rden),
155        .af_cmd       (af_cmd),
156        .af_addr      (af_addr),
157        .af_empty     (af_empty),
158        .app_af_afull (app_af_afull)
159        );
160
161   ddr2_usr_wr #
162     (
163      .BANK_WIDTH    (BANK_WIDTH),
164      .COL_WIDTH     (COL_WIDTH),
165      .CS_BITS       (CS_BITS),
166      .DQ_WIDTH      (DQ_WIDTH),
167      .APPDATA_WIDTH (APPDATA_WIDTH),
168      .ECC_ENABLE    (ECC_ENABLE),
169      .ROW_WIDTH     (ROW_WIDTH)
170      )
171     u_usr_wr
172       (
173        .clk0              (clk0),
174        .clk90             (clk90),
175        .rst0              (rst0),
176        .app_wdf_wren      (app_wdf_wren),
177        .app_wdf_data      (app_wdf_data),
178        .app_wdf_mask_data (app_wdf_mask_data),
179        .wdf_rden          (wdf_rden),
180        .app_wdf_afull     (app_wdf_afull),
181        .wdf_data          (wdf_data),
182        .wdf_mask_data     (wdf_mask_data)
183        );
184
185 endmodule