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, 2008 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_test_data_gen.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 contains the data generation logic for the synthesizable
|
54 |
|
|
// testbench.
|
55 |
|
|
//Reference:
|
56 |
|
|
//Revision History:
|
57 |
|
|
//*****************************************************************************
|
58 |
|
|
|
59 |
|
|
`timescale 1ns/1ps
|
60 |
|
|
|
61 |
|
|
module ddr2_tb_test_data_gen #
|
62 |
|
|
(
|
63 |
|
|
// Following parameters are for 72-bit RDIMM design (for ML561 Reference
|
64 |
|
|
// board design). Actual values may be different. Actual parameters values
|
65 |
|
|
// are passed from design top module MEMCtrl module. Please refer to
|
66 |
|
|
// the MEMCtrl module for actual values.
|
67 |
|
|
parameter DM_WIDTH = 9,
|
68 |
|
|
parameter DQ_WIDTH = 72,
|
69 |
|
|
parameter APPDATA_WIDTH = 144,
|
70 |
|
|
parameter ECC_ENABLE = 0
|
71 |
|
|
)
|
72 |
|
|
(
|
73 |
|
|
input clk,
|
74 |
|
|
input rst,
|
75 |
|
|
input wr_data_en,
|
76 |
|
|
input rd_data_valid,
|
77 |
|
|
output app_wdf_wren,
|
78 |
|
|
output reg [APPDATA_WIDTH-1:0] app_wdf_data,
|
79 |
|
|
output reg [(APPDATA_WIDTH/8)-1:0] app_wdf_mask_data,
|
80 |
|
|
output [APPDATA_WIDTH-1:0] app_cmp_data
|
81 |
|
|
);
|
82 |
|
|
|
83 |
|
|
localparam WR_IDLE_FIRST_DATA = 2'b00;
|
84 |
|
|
localparam WR_SECOND_DATA = 2'b01;
|
85 |
|
|
localparam WR_THIRD_DATA = 2'b10;
|
86 |
|
|
localparam WR_FOURTH_DATA = 2'b11;
|
87 |
|
|
localparam RD_IDLE_FIRST_DATA = 2'b00;
|
88 |
|
|
localparam RD_SECOND_DATA = 2'b01;
|
89 |
|
|
localparam RD_THIRD_DATA = 2'b10;
|
90 |
|
|
localparam RD_FOURTH_DATA = 2'b11;
|
91 |
|
|
|
92 |
|
|
reg [APPDATA_WIDTH-1:0] app_wdf_data_r;
|
93 |
|
|
reg [(APPDATA_WIDTH/8)-1:0] app_wdf_mask_data_r;
|
94 |
|
|
wire app_wdf_wren_r;
|
95 |
|
|
reg [(APPDATA_WIDTH/2)-1:0] rd_data_pat_fall;
|
96 |
|
|
reg [(APPDATA_WIDTH/2)-1:0] rd_data_pat_rise;
|
97 |
|
|
wire rd_data_valid_r;
|
98 |
|
|
reg [1:0] rd_state;
|
99 |
|
|
reg rst_r
|
100 |
|
|
/* synthesis syn_preserve = 1 */;
|
101 |
|
|
reg rst_r1
|
102 |
|
|
/* synthesis syn_maxfan = 10 */;
|
103 |
|
|
wire [APPDATA_WIDTH-1:0] wr_data;
|
104 |
|
|
reg wr_data_en_r;
|
105 |
|
|
reg [(APPDATA_WIDTH/2)-1:0] wr_data_fall
|
106 |
|
|
/* synthesis syn_maxfan = 2 */;
|
107 |
|
|
reg [(APPDATA_WIDTH/2)-1:0] wr_data_rise
|
108 |
|
|
/* synthesis syn_maxfan = 2 */;
|
109 |
|
|
wire [(APPDATA_WIDTH/8)-1:0] wr_mask_data;
|
110 |
|
|
wire [(APPDATA_WIDTH/16)-1:0] wr_mask_data_fall;
|
111 |
|
|
wire [(APPDATA_WIDTH/16)-1:0] wr_mask_data_rise;
|
112 |
|
|
reg [1:0] wr_state;
|
113 |
|
|
|
114 |
|
|
// XST attributes for local reset "tree"
|
115 |
|
|
// synthesis attribute shreg_extract of rst_r is "no";
|
116 |
|
|
// synthesis attribute shreg_extract of rst_r1 is "no";
|
117 |
|
|
// synthesis attribute equivalent_register_removal of rst_r is "no"
|
118 |
|
|
|
119 |
|
|
//***************************************************************************
|
120 |
|
|
|
121 |
|
|
// local reset "tree" for controller logic only. Create this to ease timing
|
122 |
|
|
// on reset path. Prohibit equivalent register removal on RST_R to prevent
|
123 |
|
|
// "sharing" with other local reset trees (caution: make sure global fanout
|
124 |
|
|
// limit is set to larger than fanout on RST_R, otherwise SLICES will be
|
125 |
|
|
// used for fanout control on RST_R.
|
126 |
|
|
always @(posedge clk) begin
|
127 |
|
|
rst_r <= rst;
|
128 |
|
|
rst_r1 <= rst_r;
|
129 |
|
|
end
|
130 |
|
|
|
131 |
|
|
always @(posedge clk) begin
|
132 |
|
|
app_wdf_data_r <= wr_data;
|
133 |
|
|
app_wdf_mask_data_r <= wr_mask_data;
|
134 |
|
|
app_wdf_data <= app_wdf_data_r;
|
135 |
|
|
app_wdf_mask_data <= app_wdf_mask_data_r;
|
136 |
|
|
end
|
137 |
|
|
|
138 |
|
|
// inst ff for timing
|
139 |
|
|
FDRSE ff_wdf_wren
|
140 |
|
|
(
|
141 |
|
|
.Q (app_wdf_wren_r),
|
142 |
|
|
.C (clk),
|
143 |
|
|
.CE (1'b1),
|
144 |
|
|
.D (wr_data_en_r),
|
145 |
|
|
.R (1'b0),
|
146 |
|
|
.S (1'b0)
|
147 |
|
|
);
|
148 |
|
|
|
149 |
|
|
FDRSE ff_wdf_wren_r
|
150 |
|
|
(
|
151 |
|
|
.Q (app_wdf_wren),
|
152 |
|
|
.C (clk),
|
153 |
|
|
.CE (1'b1),
|
154 |
|
|
.D (app_wdf_wren_r),
|
155 |
|
|
.R (1'b0),
|
156 |
|
|
.S (1'b0)
|
157 |
|
|
);
|
158 |
|
|
|
159 |
|
|
FDRSE ff_rd_data_valid_r
|
160 |
|
|
(
|
161 |
|
|
.Q (rd_data_valid_r),
|
162 |
|
|
.C (clk),
|
163 |
|
|
.CE (1'b1),
|
164 |
|
|
.D (rd_data_valid),
|
165 |
|
|
.R (1'b0),
|
166 |
|
|
.S (1'b0)
|
167 |
|
|
);
|
168 |
|
|
|
169 |
|
|
//***************************************************************************
|
170 |
|
|
// DATA generation for WRITE DATA FIFOs & for READ DATA COMPARE
|
171 |
|
|
//***************************************************************************
|
172 |
|
|
|
173 |
|
|
assign wr_data = {wr_data_fall, wr_data_rise};
|
174 |
|
|
assign wr_mask_data = {wr_mask_data_fall, wr_mask_data_rise};
|
175 |
|
|
|
176 |
|
|
//*****************************************************************
|
177 |
|
|
// For now, don't vary data masks
|
178 |
|
|
//*****************************************************************
|
179 |
|
|
|
180 |
|
|
assign wr_mask_data_rise = {(APPDATA_WIDTH/8){1'b0}};
|
181 |
|
|
assign wr_mask_data_fall = {(APPDATA_WIDTH/8){1'b0}};
|
182 |
|
|
|
183 |
|
|
//*****************************************************************
|
184 |
|
|
// Write data logic
|
185 |
|
|
//*****************************************************************
|
186 |
|
|
|
187 |
|
|
// write data generation
|
188 |
|
|
//synthesis attribute max_fanout of wr_data_fall is 2
|
189 |
|
|
//synthesis attribute max_fanout of wr_data_rise is 2
|
190 |
|
|
always @(posedge clk) begin
|
191 |
|
|
if (rst_r1) begin
|
192 |
|
|
wr_data_rise <= {(APPDATA_WIDTH/2){1'bx}};
|
193 |
|
|
wr_data_fall <= {(APPDATA_WIDTH/2){1'bx}};
|
194 |
|
|
wr_state <= WR_IDLE_FIRST_DATA;
|
195 |
|
|
end else begin
|
196 |
|
|
case (wr_state)
|
197 |
|
|
WR_IDLE_FIRST_DATA:
|
198 |
|
|
if (wr_data_en) begin
|
199 |
|
|
wr_data_rise <= {(APPDATA_WIDTH/2){1'b1}}; // 0xF
|
200 |
|
|
wr_data_fall <= {(APPDATA_WIDTH/2){1'b0}}; // 0x0
|
201 |
|
|
wr_state <= WR_SECOND_DATA;
|
202 |
|
|
end
|
203 |
|
|
WR_SECOND_DATA:
|
204 |
|
|
if (wr_data_en) begin
|
205 |
|
|
wr_data_rise <= {(APPDATA_WIDTH/4){2'b10}}; // 0xA
|
206 |
|
|
wr_data_fall <= {(APPDATA_WIDTH/4){2'b01}}; // 0x5
|
207 |
|
|
wr_state <= WR_THIRD_DATA;
|
208 |
|
|
end
|
209 |
|
|
WR_THIRD_DATA:
|
210 |
|
|
if (wr_data_en) begin
|
211 |
|
|
wr_data_rise <= {(APPDATA_WIDTH/4){2'b01}}; // 0x5
|
212 |
|
|
wr_data_fall <= {(APPDATA_WIDTH/4){2'b10}}; // 0xA
|
213 |
|
|
wr_state <= WR_FOURTH_DATA;
|
214 |
|
|
end
|
215 |
|
|
WR_FOURTH_DATA:
|
216 |
|
|
if (wr_data_en) begin
|
217 |
|
|
wr_data_rise <= {(APPDATA_WIDTH/8){4'b1001}}; // 0x9
|
218 |
|
|
wr_data_fall <= {(APPDATA_WIDTH/8){4'b0110}}; // 0x6
|
219 |
|
|
wr_state <= WR_IDLE_FIRST_DATA;
|
220 |
|
|
end
|
221 |
|
|
endcase
|
222 |
|
|
end
|
223 |
|
|
end
|
224 |
|
|
|
225 |
|
|
always @(posedge clk)
|
226 |
|
|
if (rst_r1)
|
227 |
|
|
wr_data_en_r <= 1'b0;
|
228 |
|
|
else
|
229 |
|
|
wr_data_en_r <= wr_data_en;
|
230 |
|
|
|
231 |
|
|
//*****************************************************************
|
232 |
|
|
// Read data logic
|
233 |
|
|
//*****************************************************************
|
234 |
|
|
|
235 |
|
|
// read comparison data generation
|
236 |
|
|
always @(posedge clk)
|
237 |
|
|
if (rst_r1) begin
|
238 |
|
|
rd_data_pat_rise <= {(APPDATA_WIDTH/2){1'bx}};
|
239 |
|
|
rd_data_pat_fall <= {(APPDATA_WIDTH/2){1'bx}};
|
240 |
|
|
rd_state <= RD_IDLE_FIRST_DATA;
|
241 |
|
|
end else begin
|
242 |
|
|
case (rd_state)
|
243 |
|
|
RD_IDLE_FIRST_DATA:
|
244 |
|
|
if (rd_data_valid_r)
|
245 |
|
|
begin
|
246 |
|
|
rd_data_pat_rise <= {(APPDATA_WIDTH/2){1'b1}}; // 0xF
|
247 |
|
|
rd_data_pat_fall <= {(APPDATA_WIDTH/2){1'b0}}; // 0x0
|
248 |
|
|
rd_state <= RD_SECOND_DATA;
|
249 |
|
|
end
|
250 |
|
|
RD_SECOND_DATA:
|
251 |
|
|
if (rd_data_valid_r) begin
|
252 |
|
|
rd_data_pat_rise <= {(APPDATA_WIDTH/4){2'b10}}; // 0xA
|
253 |
|
|
rd_data_pat_fall <= {(APPDATA_WIDTH/4){2'b01}}; // 0x5
|
254 |
|
|
rd_state <= RD_THIRD_DATA;
|
255 |
|
|
end
|
256 |
|
|
RD_THIRD_DATA:
|
257 |
|
|
if (rd_data_valid_r) begin
|
258 |
|
|
rd_data_pat_rise <= {(APPDATA_WIDTH/4){2'b01}}; // 0x5
|
259 |
|
|
rd_data_pat_fall <= {(APPDATA_WIDTH/4){2'b10}}; // 0xA
|
260 |
|
|
rd_state <= RD_FOURTH_DATA;
|
261 |
|
|
end
|
262 |
|
|
RD_FOURTH_DATA:
|
263 |
|
|
if (rd_data_valid_r) begin
|
264 |
|
|
rd_data_pat_rise <= {(APPDATA_WIDTH/8){4'b1001}}; // 0x9
|
265 |
|
|
rd_data_pat_fall <= {(APPDATA_WIDTH/8){4'b0110}}; // 0x6
|
266 |
|
|
rd_state <= RD_IDLE_FIRST_DATA;
|
267 |
|
|
end
|
268 |
|
|
endcase
|
269 |
|
|
end
|
270 |
|
|
|
271 |
|
|
//data to the compare circuit during read
|
272 |
|
|
assign app_cmp_data = {rd_data_pat_fall, rd_data_pat_rise};
|
273 |
|
|
|
274 |
|
|
endmodule
|