OpenCores
URL https://opencores.org/ocsvn/genesys_ddr2/genesys_ddr2/trunk

Subversion Repositories genesys_ddr2

[/] [genesys_ddr2/] [trunk/] [rtl/] [ipcore_dir/] [MEMCtrl/] [user_design/] [sim/] [ddr2_tb_top.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 oana.bonca
//*****************************************************************************
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.1
44
//  \   \         Application: MIG
45
//  /   /         Filename: ddr2_tb_top.v
46
// /___/   /\     Date Last Modified: $Date: 2010/11/26 18:26:02 $
47
// \   \  /  \    Date Created: Fri Sep 01 2006
48
//  \___\/\___\
49
//
50
//Device: Virtex-5
51
//Design Name: DDR2
52
//Purpose:
53
//   This module is the synthesizable test bench for the memory interface.
54
//   This Test bench is to compare the write and the read data and generate
55
//   an error flag.
56
//Reference:
57
//Revision History:
58
//*****************************************************************************
59
 
60
`timescale 1ns/1ps
61
 
62
module ddr2_tb_top #
63
  (
64
   // Following parameters are for 72-bit RDIMM design (for ML561 Reference 
65
   // board design). Actual values may be different. Actual parameters values 
66
   // are passed from design top module MEMCtrl module. Please refer to
67
   // the MEMCtrl module for actual values.
68
   parameter BANK_WIDTH    = 2,
69
   parameter COL_WIDTH     = 10,
70
   parameter DM_WIDTH      = 9,
71
   parameter DQ_WIDTH      = 72,
72
   parameter ROW_WIDTH     = 14,
73
   parameter APPDATA_WIDTH = 144,
74
   parameter ECC_ENABLE    = 0,
75
   parameter BURST_LEN     = 4
76
   )
77
  (
78
   input                                  clk0,
79
   input                                  rst0,
80
   input                                  app_af_afull,
81
   input                                  app_wdf_afull,
82
   input                                  rd_data_valid,
83
   input [APPDATA_WIDTH-1:0]              rd_data_fifo_out,
84
   input                                  phy_init_done,
85
   output                                 app_af_wren,
86
   output [2:0]                           app_af_cmd,
87
   output [30:0]                          app_af_addr,
88
   output                                 app_wdf_wren,
89
   output [APPDATA_WIDTH-1:0]             app_wdf_data,
90
   output [(APPDATA_WIDTH/8)-1:0]         app_wdf_mask_data,
91
   output                                 error,
92
   output                                 error_cmp
93
   );
94
 
95
  localparam BURST_LEN_DIV2 = BURST_LEN/2;
96
 
97
  localparam TB_IDLE  = 3'b000;
98
  localparam TB_WRITE = 3'b001;
99
  localparam TB_READ  = 3'b010;
100
 
101
  wire                     app_af_afull_r  ;
102
  wire                     app_af_afull_r1 ;
103
  wire                     app_af_afull_r2;
104
  reg                      app_af_not_afull_r;
105
  wire [APPDATA_WIDTH-1:0] app_cmp_data;
106
  wire                     app_wdf_afull_r;
107
  wire                     app_wdf_afull_r1 ;
108
  wire                     app_wdf_afull_r2;
109
  reg                      app_wdf_not_afull_r ;
110
  reg [2:0]                burst_cnt;
111
  reg                      phy_init_done_tb_r;
112
  wire                     phy_init_done_r;
113
  reg                      rst_r
114
                           /* synthesis syn_preserve = 1 */;
115
  reg                      rst_r1
116
                           /* synthesis syn_maxfan = 10 */;
117
  reg [2:0]                state;
118
  reg [3:0]                state_cnt;
119
  reg                      wr_addr_en ;
120
  reg                      wr_data_en ;
121
 
122
  // XST attributes for local reset "tree"
123
  // synthesis attribute shreg_extract of rst_r is "no";
124
  // synthesis attribute shreg_extract of rst_r1 is "no";
125
  // synthesis attribute equivalent_register_removal of rst_r is "no"
126
 
127
  //*****************************************************************
128
 
129
  // local reset "tree" for controller logic only. Create this to ease timing
130
  // on reset path. Prohibit equivalent register removal on RST_R to prevent
131
  // "sharing" with other local reset trees (caution: make sure global fanout
132
  // limit is set to larger than fanout on RST_R, otherwise SLICES will be
133
  // used for fanout control on RST_R.
134
  always @(posedge clk0) begin
135
    rst_r  <= rst0;
136
    rst_r1 <= rst_r;
137
  end
138
 
139
  // Instantiate flops for timing.
140
  FDRSE ff_af_afull_r
141
    (
142
     .Q   (app_af_afull_r),
143
     .C   (clk0),
144
     .CE  (1'b1),
145
     .D   (app_af_afull),
146
     .R   (1'b0),
147
     .S   (1'b0)
148
     );
149
 
150
  FDRSE ff_af_afull_r1
151
    (
152
     .Q   (app_af_afull_r1),
153
     .C   (clk0),
154
     .CE  (1'b1),
155
     .D   (app_af_afull_r),
156
     .R   (1'b0),
157
     .S   (1'b0)
158
     );
159
 
160
   FDRSE ff_af_afull_r2
161
    (
162
     .Q   (app_af_afull_r2),
163
     .C   (clk0),
164
     .CE  (1'b1),
165
     .D   (app_af_afull_r1),
166
     .R   (1'b0),
167
     .S   (1'b0)
168
     );
169
 
170
 
171
  FDRSE ff_wdf_afull_r
172
    (
173
     .Q   (app_wdf_afull_r),
174
     .C   (clk0),
175
     .CE  (1'b1),
176
     .D   (app_wdf_afull),
177
     .R   (1'b0),
178
     .S   (1'b0)
179
     );
180
 
181
  FDRSE ff_wdf_afull_r1
182
    (
183
     .Q   (app_wdf_afull_r1),
184
     .C   (clk0),
185
     .CE  (1'b1),
186
     .D   (app_wdf_afull_r),
187
     .R   (1'b0),
188
     .S   (1'b0)
189
     );
190
 
191
   FDRSE ff_wdf_afull_r2
192
    (
193
     .Q   (app_wdf_afull_r2),
194
     .C   (clk0),
195
     .CE  (1'b1),
196
     .D   (app_wdf_afull_r1),
197
     .R   (1'b0),
198
     .S   (1'b0)
199
     );
200
 
201
    FDRSE ff_phy_init_done
202
    (
203
     .Q   (phy_init_done_r),
204
     .C   (clk0),
205
     .CE  (1'b1),
206
     .D   (phy_init_done),
207
     .R   (1'b0),
208
     .S   (1'b0)
209
     );
210
 
211
  //***************************************************************************
212
  // State Machine for writing to WRITE DATA & ADDRESS FIFOs
213
  // state machine changed for low FIFO threshold values
214
  //***************************************************************************
215
 
216
  always @(posedge clk0) begin
217
    if (rst_r1) begin
218
      wr_data_en          <= 1'bx;
219
      wr_addr_en          <= 1'bx;
220
      state[2:0]          <= TB_IDLE;
221
      state_cnt           <= 4'bxxxx;
222
      app_af_not_afull_r  <= 1'bx;
223
      app_wdf_not_afull_r <= 1'bx;
224
      burst_cnt           <= 3'bxxx;
225
      phy_init_done_tb_r  <= 1'bx;
226
    end else begin
227
      wr_data_en          <= 1'b0;
228
      wr_addr_en          <= 1'b0;
229
      app_af_not_afull_r  <= ~app_af_afull_r2;
230
      app_wdf_not_afull_r <= ~app_wdf_afull_r2;
231
      phy_init_done_tb_r  <= phy_init_done_r;
232
 
233
      case (state)
234
        TB_IDLE: begin
235
          state_cnt  <= 4'd0;
236
          burst_cnt  <= BURST_LEN_DIV2 - 1;
237
          // only start writing when initialization done
238
          if (app_wdf_not_afull_r && app_af_not_afull_r && phy_init_done_tb_r)
239
            state <= TB_WRITE;
240
        end
241
 
242
        TB_WRITE:
243
          if (app_wdf_not_afull_r && app_af_not_afull_r) begin
244
            wr_data_en <= 1'b1;
245
            // When we're done with the current burst...
246
            if (burst_cnt == 3'd0) begin
247
              burst_cnt <= BURST_LEN_DIV2 - 1;
248
              wr_addr_en <= 1'b1;
249
              // Writes occurs in groups of 8 consecutive bursts. Once 8 writes
250
              // have been issued, now issue the corresponding read back bursts
251
              if (state_cnt == 4'd7) begin
252
                state      <= TB_READ;
253
                state_cnt  <= 4'd0;
254
              end else
255
                state_cnt  <= state_cnt + 1;
256
            end else
257
              burst_cnt <= burst_cnt - 1;
258
          end
259
 
260
        TB_READ: begin
261
          burst_cnt <= BURST_LEN_DIV2 - 1;
262
          if (app_af_not_afull_r) begin
263
            wr_addr_en <= 1'b1;
264
            // if finished with all 8 reads, proceed to next 8 writes
265
            if (state_cnt == 4'd7) begin
266
              state     <= TB_WRITE;
267
              state_cnt <= 4'd0;
268
            end else
269
              state_cnt <= state_cnt + 1;
270
          end
271
        end
272
      endcase
273
    end
274
  end
275
 
276
  // Read data comparision
277
  ddr2_tb_test_cmp #
278
    (
279
     .DQ_WIDTH      (DQ_WIDTH),
280
     .APPDATA_WIDTH (APPDATA_WIDTH),
281
     .ECC_ENABLE    (ECC_ENABLE)
282
     )
283
    u_tb_test_cmp
284
      (
285
       .clk              (clk0),
286
       .rst              (rst0),
287
       .phy_init_done    (phy_init_done_tb_r),
288
       .rd_data_valid    (rd_data_valid),
289
       .app_cmp_data     (app_cmp_data),
290
       .rd_data_fifo_in  (rd_data_fifo_out),
291
       .error            (error),
292
       .error_cmp        (error_cmp)
293
       );
294
 
295
  // Command/Address and Write Data generation
296
  ddr2_tb_test_gen #
297
    (
298
     .BANK_WIDTH    (BANK_WIDTH),
299
     .COL_WIDTH     (COL_WIDTH),
300
     .DM_WIDTH      (DM_WIDTH),
301
     .DQ_WIDTH      (DQ_WIDTH),
302
     .APPDATA_WIDTH (APPDATA_WIDTH),
303
     .ECC_ENABLE    (ECC_ENABLE),
304
     .ROW_WIDTH     (ROW_WIDTH)
305
     )
306
    u_tb_test_gen
307
      (
308
       .clk               (clk0),
309
       .rst               (rst0),
310
       .wr_addr_en        (wr_addr_en),
311
       .wr_data_en        (wr_data_en),
312
       .rd_data_valid     (rd_data_valid),
313
       .app_af_wren       (app_af_wren),
314
       .app_af_cmd        (app_af_cmd),
315
       .app_af_addr       (app_af_addr),
316
       .app_wdf_wren      (app_wdf_wren),
317
       .app_wdf_data      (app_wdf_data),
318
       .app_wdf_mask_data (app_wdf_mask_data),
319
       .app_cmp_data      (app_cmp_data)
320
       );
321
 
322
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.