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_cmp.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 generates the error signal in case of bit errors. It compares
|
54 |
|
|
// the read data with expected data value.
|
55 |
|
|
//Reference:
|
56 |
|
|
//Revision History:
|
57 |
|
|
//*****************************************************************************
|
58 |
|
|
|
59 |
|
|
`timescale 1ns/1ps
|
60 |
|
|
|
61 |
|
|
module ddr2_tb_test_cmp #
|
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 DQ_WIDTH = 72,
|
68 |
|
|
parameter APPDATA_WIDTH = 144,
|
69 |
|
|
parameter ECC_ENABLE = 0
|
70 |
|
|
)
|
71 |
|
|
(
|
72 |
|
|
input clk,
|
73 |
|
|
input rst,
|
74 |
|
|
input phy_init_done,
|
75 |
|
|
input rd_data_valid,
|
76 |
|
|
input [APPDATA_WIDTH-1:0] app_cmp_data,
|
77 |
|
|
input [APPDATA_WIDTH-1:0] rd_data_fifo_in,
|
78 |
|
|
output reg error,
|
79 |
|
|
output reg error_cmp
|
80 |
|
|
);
|
81 |
|
|
|
82 |
|
|
wire [(APPDATA_WIDTH/16)-1:0] byte_err_fall;
|
83 |
|
|
reg [(APPDATA_WIDTH/16)-1:0] byte_err_fall_r;
|
84 |
|
|
wire [(APPDATA_WIDTH/16)-1:0] byte_err_rise;
|
85 |
|
|
reg [(APPDATA_WIDTH/16)-1:0] byte_err_rise_r;
|
86 |
|
|
wire [(APPDATA_WIDTH/2)-1:0] cmp_data_fall;
|
87 |
|
|
wire [(APPDATA_WIDTH/2)-1:0] cmp_data_rise;
|
88 |
|
|
wire [APPDATA_WIDTH-1:0] cmp_data_r;
|
89 |
|
|
reg [APPDATA_WIDTH-1:0] cmp_data_r1;
|
90 |
|
|
reg cmp_start;
|
91 |
|
|
wire [(APPDATA_WIDTH/2)-1:0] data_fall_r;
|
92 |
|
|
wire [(APPDATA_WIDTH/2)-1:0] data_rise_r;
|
93 |
|
|
reg err_fall;
|
94 |
|
|
reg err_rise;
|
95 |
|
|
reg error_tmp_r;
|
96 |
|
|
wire error_tmp_r1;
|
97 |
|
|
wire error_tmp_r2;
|
98 |
|
|
wire [APPDATA_WIDTH-1:0] rd_data_r;
|
99 |
|
|
wire [APPDATA_WIDTH-1:0] rd_data_r1;
|
100 |
|
|
reg [APPDATA_WIDTH-1:0] rd_data_r2;
|
101 |
|
|
wire rd_data_valid_r;
|
102 |
|
|
reg rd_data_valid_r1;
|
103 |
|
|
reg rd_data_valid_r2;
|
104 |
|
|
reg rst_r
|
105 |
|
|
/* synthesis syn_preserve = 1 */;
|
106 |
|
|
reg rst_r1
|
107 |
|
|
/* synthesis syn_maxfan = 10 */;
|
108 |
|
|
|
109 |
|
|
// XST attributes for local reset "tree"
|
110 |
|
|
// synthesis attribute shreg_extract of rst_r is "no";
|
111 |
|
|
// synthesis attribute shreg_extract of rst_r1 is "no";
|
112 |
|
|
// synthesis attribute equivalent_register_removal of rst_r is "no"
|
113 |
|
|
|
114 |
|
|
//***************************************************************************
|
115 |
|
|
|
116 |
|
|
// local reset "tree" for controller logic only. Create this to ease timing
|
117 |
|
|
// on reset path. Prohibit equivalent register removal on RST_R to prevent
|
118 |
|
|
// "sharing" with other local reset trees (caution: make sure global fanout
|
119 |
|
|
// limit is set to larger than fanout on RST_R, otherwise SLICES will be
|
120 |
|
|
// used for fanout control on RST_R.
|
121 |
|
|
always @(posedge clk) begin
|
122 |
|
|
rst_r <= rst;
|
123 |
|
|
rst_r1 <= rst_r;
|
124 |
|
|
end
|
125 |
|
|
|
126 |
|
|
// instantiate discrete flops for better timing
|
127 |
|
|
genvar rd_data_i;
|
128 |
|
|
generate
|
129 |
|
|
for (rd_data_i = 0; rd_data_i < APPDATA_WIDTH;
|
130 |
|
|
rd_data_i = rd_data_i + 1) begin: gen_rd_data
|
131 |
|
|
FDRSE ff_rd_data
|
132 |
|
|
(
|
133 |
|
|
.Q (rd_data_r[rd_data_i]),
|
134 |
|
|
.C (clk),
|
135 |
|
|
.CE (1'b1),
|
136 |
|
|
.D (rd_data_fifo_in[rd_data_i]),
|
137 |
|
|
.R (1'b0),
|
138 |
|
|
.S (1'b0)
|
139 |
|
|
);
|
140 |
|
|
|
141 |
|
|
FDRSE ff_rd_data_r1
|
142 |
|
|
(
|
143 |
|
|
.Q (rd_data_r1[rd_data_i]),
|
144 |
|
|
.C (clk),
|
145 |
|
|
.CE (1'b1),
|
146 |
|
|
.D (rd_data_r[rd_data_i]),
|
147 |
|
|
.R (1'b0),
|
148 |
|
|
.S (1'b0)
|
149 |
|
|
);
|
150 |
|
|
end
|
151 |
|
|
endgenerate
|
152 |
|
|
|
153 |
|
|
genvar cmp_data_i;
|
154 |
|
|
generate
|
155 |
|
|
for (cmp_data_i = 0; cmp_data_i < APPDATA_WIDTH;
|
156 |
|
|
cmp_data_i = cmp_data_i + 1) begin: gen_cmp_data
|
157 |
|
|
FDRSE ff_cmp_data
|
158 |
|
|
(
|
159 |
|
|
.Q (cmp_data_r[cmp_data_i]),
|
160 |
|
|
.C (clk),
|
161 |
|
|
.CE (1'b1),
|
162 |
|
|
.D (app_cmp_data[cmp_data_i]),
|
163 |
|
|
.R (1'b0),
|
164 |
|
|
.S (1'b0)
|
165 |
|
|
);
|
166 |
|
|
end
|
167 |
|
|
endgenerate
|
168 |
|
|
|
169 |
|
|
assign data_fall_r = rd_data_r2[APPDATA_WIDTH-1:(APPDATA_WIDTH/2)];
|
170 |
|
|
assign data_rise_r = rd_data_r2[(APPDATA_WIDTH/2)-1:0];
|
171 |
|
|
assign cmp_data_fall = cmp_data_r[APPDATA_WIDTH-1:(APPDATA_WIDTH/2)];
|
172 |
|
|
assign cmp_data_rise = cmp_data_r[(APPDATA_WIDTH/2)-1:0];
|
173 |
|
|
|
174 |
|
|
// Instantiate ff for timing.
|
175 |
|
|
FDRSE ff_rd_data_valid_r
|
176 |
|
|
(
|
177 |
|
|
.Q (rd_data_valid_r),
|
178 |
|
|
.C (clk),
|
179 |
|
|
.CE (1'b1),
|
180 |
|
|
.D (rd_data_valid),
|
181 |
|
|
.R (1'b0),
|
182 |
|
|
.S (1'b0)
|
183 |
|
|
);
|
184 |
|
|
|
185 |
|
|
always @(posedge clk) begin
|
186 |
|
|
if (rst_r1) begin
|
187 |
|
|
rd_data_valid_r1 <= 1'd0;
|
188 |
|
|
end else begin
|
189 |
|
|
rd_data_valid_r1 <= rd_data_valid_r & phy_init_done;
|
190 |
|
|
end
|
191 |
|
|
end
|
192 |
|
|
|
193 |
|
|
always @(posedge clk)begin
|
194 |
|
|
rd_data_r2 <= rd_data_r1;
|
195 |
|
|
cmp_data_r1 <= cmp_data_r;
|
196 |
|
|
rd_data_valid_r2 <= rd_data_valid_r1;
|
197 |
|
|
end
|
198 |
|
|
|
199 |
|
|
genvar cmp_i;
|
200 |
|
|
generate
|
201 |
|
|
for (cmp_i = 0; cmp_i < APPDATA_WIDTH/16; cmp_i = cmp_i + 1) begin: gen_cmp
|
202 |
|
|
assign byte_err_fall[cmp_i]
|
203 |
|
|
= (rd_data_valid_r2 &&
|
204 |
|
|
(data_fall_r[8*(cmp_i+1)-1:8*cmp_i] !=
|
205 |
|
|
cmp_data_fall[8*(cmp_i+1)-1:8*cmp_i]));
|
206 |
|
|
assign byte_err_rise[cmp_i]
|
207 |
|
|
= (rd_data_valid_r2 &&
|
208 |
|
|
(data_rise_r[8*(cmp_i+1)-1:8*cmp_i] !=
|
209 |
|
|
cmp_data_rise[8*(cmp_i+1)-1:8*cmp_i]));
|
210 |
|
|
end
|
211 |
|
|
endgenerate
|
212 |
|
|
|
213 |
|
|
always @(posedge clk) begin
|
214 |
|
|
byte_err_rise_r <= byte_err_rise;
|
215 |
|
|
byte_err_fall_r <= byte_err_fall;
|
216 |
|
|
end
|
217 |
|
|
|
218 |
|
|
always @(posedge clk)
|
219 |
|
|
if (rst_r1) begin
|
220 |
|
|
err_rise <= 1'bx;
|
221 |
|
|
err_fall <= 1'bx;
|
222 |
|
|
cmp_start <= 1'b0;
|
223 |
|
|
error_tmp_r <= 1'b0;
|
224 |
|
|
end else begin
|
225 |
|
|
err_rise <= | byte_err_rise_r;
|
226 |
|
|
err_fall <= | byte_err_fall_r;
|
227 |
|
|
// start comparing when initialization/calibration complete, and we
|
228 |
|
|
// get first valid readback
|
229 |
|
|
if (rd_data_valid_r2)
|
230 |
|
|
cmp_start <= 1'b1;
|
231 |
|
|
if (cmp_start && !error_tmp_r)
|
232 |
|
|
error_tmp_r <= err_rise | err_fall;
|
233 |
|
|
//synthesis translate_off
|
234 |
|
|
if ((err_rise || err_fall) && cmp_start)
|
235 |
|
|
$display ("ERROR at time %t" , $time);
|
236 |
|
|
//synthesis translate_on
|
237 |
|
|
end
|
238 |
|
|
|
239 |
|
|
// FF inst to force synthesis to infer ff's.
|
240 |
|
|
// Done for timing.
|
241 |
|
|
FDRSE ff_error_1
|
242 |
|
|
(
|
243 |
|
|
.Q (error_tmp_r1),
|
244 |
|
|
.C (clk),
|
245 |
|
|
.CE (1'b1),
|
246 |
|
|
.D (error_tmp_r),
|
247 |
|
|
.R (1'b0),
|
248 |
|
|
.S (1'b0)
|
249 |
|
|
);
|
250 |
|
|
|
251 |
|
|
FDRSE ff_error_2
|
252 |
|
|
(
|
253 |
|
|
.Q (error_tmp_r2),
|
254 |
|
|
.C (clk),
|
255 |
|
|
.CE (1'b1),
|
256 |
|
|
.D (error_tmp_r1),
|
257 |
|
|
.R (1'b0),
|
258 |
|
|
.S (1'b0)
|
259 |
|
|
);
|
260 |
|
|
|
261 |
|
|
always @(posedge clk) begin
|
262 |
|
|
error <= error_tmp_r2;
|
263 |
|
|
error_cmp <= err_rise | err_fall;
|
264 |
|
|
end
|
265 |
|
|
|
266 |
|
|
endmodule
|