1 |
2 |
ZTEX |
//*****************************************************************************
|
2 |
|
|
// (c) Copyright 2009 Xilinx, Inc. All rights reserved.
|
3 |
|
|
//
|
4 |
|
|
// This file contains confidential and proprietary information
|
5 |
|
|
// of Xilinx, Inc. and is protected under U.S. and
|
6 |
|
|
// international copyright and other intellectual property
|
7 |
|
|
// laws.
|
8 |
|
|
//
|
9 |
|
|
// DISCLAIMER
|
10 |
|
|
// This disclaimer is not a license and does not grant any
|
11 |
|
|
// rights to the materials distributed herewith. Except as
|
12 |
|
|
// otherwise provided in a valid license issued to you by
|
13 |
|
|
// Xilinx, and to the maximum extent permitted by applicable
|
14 |
|
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
15 |
|
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
16 |
|
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
17 |
|
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
18 |
|
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
19 |
|
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
20 |
|
|
// including negligence, or under any other theory of
|
21 |
|
|
// liability) for any loss or damage of any kind or nature
|
22 |
|
|
// related to, arising under or in connection with these
|
23 |
|
|
// materials, including for any direct, or any indirect,
|
24 |
|
|
// special, incidental, or consequential loss or damage
|
25 |
|
|
// (including loss of data, profits, goodwill, or any type of
|
26 |
|
|
// loss or damage suffered as a result of any action brought
|
27 |
|
|
// by a third party) even if such damage or loss was
|
28 |
|
|
// reasonably foreseeable or Xilinx had been advised of the
|
29 |
|
|
// possibility of the same.
|
30 |
|
|
//
|
31 |
|
|
// CRITICAL APPLICATIONS
|
32 |
|
|
// Xilinx products are not designed or intended to be fail-
|
33 |
|
|
// safe, or for use in any application requiring fail-safe
|
34 |
|
|
// performance, such as life-support or safety devices or
|
35 |
|
|
// systems, Class III medical devices, nuclear facilities,
|
36 |
|
|
// applications related to the deployment of airbags, or any
|
37 |
|
|
// other applications that could lead to death, personal
|
38 |
|
|
// injury, or severe property or environmental damage
|
39 |
|
|
// (individually and collectively, "Critical
|
40 |
|
|
// Applications"). Customer assumes the sole risk and
|
41 |
|
|
// liability of any use of Xilinx products in Critical
|
42 |
|
|
// Applications, subject only to applicable laws and
|
43 |
|
|
// regulations governing limitations on product liability.
|
44 |
|
|
//
|
45 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
46 |
|
|
// PART OF THIS FILE AT ALL TIMES.
|
47 |
|
|
//
|
48 |
|
|
//*****************************************************************************
|
49 |
|
|
// ____ ____
|
50 |
|
|
// / /\/ /
|
51 |
|
|
// /___/ \ / Vendor : Xilinx
|
52 |
|
|
// \ \ \/ Version : 3.92
|
53 |
|
|
// \ \ Application : MIG
|
54 |
|
|
// / / Filename : sim_tb_top.v
|
55 |
|
|
// /___/ /\ Date Last Modified : $Date: 2011/06/02 07:17:00 $
|
56 |
|
|
// \ \ / \ Date Created : Mon Mar 2 2009
|
57 |
|
|
// \___\/\___\
|
58 |
|
|
//
|
59 |
|
|
// Device : Spartan-6
|
60 |
|
|
// Design Name : DDR/DDR2/DDR3/LPDDR
|
61 |
|
|
// Purpose : This is the simulation testbench which is used to verify the
|
62 |
|
|
// design. The basic clocks and resets to the interface are
|
63 |
|
|
// generated here. This also connects the memory interface to the
|
64 |
|
|
// memory model.
|
65 |
|
|
//*****************************************************************************
|
66 |
|
|
|
67 |
|
|
`timescale 1ps/1ps
|
68 |
|
|
module sim_tb_top;
|
69 |
|
|
|
70 |
|
|
// ========================================================================== //
|
71 |
|
|
// Parameters //
|
72 |
|
|
// ========================================================================== //
|
73 |
|
|
parameter DEBUG_EN = 0;
|
74 |
|
|
localparam DBG_WR_STS_WIDTH = 32;
|
75 |
|
|
localparam DBG_RD_STS_WIDTH = 32;
|
76 |
|
|
parameter C3_MEMCLK_PERIOD = 5000;
|
77 |
|
|
parameter C3_RST_ACT_LOW = 0;
|
78 |
|
|
parameter C3_INPUT_CLK_TYPE = "SINGLE_ENDED";
|
79 |
|
|
parameter C3_NUM_DQ_PINS = 16;
|
80 |
|
|
parameter C3_MEM_ADDR_WIDTH = 13;
|
81 |
|
|
parameter C3_MEM_BANKADDR_WIDTH = 2;
|
82 |
|
|
parameter C3_MEM_ADDR_ORDER = "ROW_BANK_COLUMN";
|
83 |
|
|
parameter C3_P0_MASK_SIZE = 4;
|
84 |
|
|
parameter C3_P0_DATA_PORT_SIZE = 32;
|
85 |
|
|
parameter C3_P1_MASK_SIZE = 4;
|
86 |
|
|
parameter C3_P1_DATA_PORT_SIZE = 32;
|
87 |
|
|
parameter C3_CALIB_SOFT_IP = "TRUE";
|
88 |
|
|
parameter C3_SIMULATION = "TRUE";
|
89 |
|
|
parameter C3_HW_TESTING = "FALSE";
|
90 |
|
|
|
91 |
|
|
// ========================================================================== //
|
92 |
|
|
// Signal Declarations //
|
93 |
|
|
// ========================================================================== //
|
94 |
|
|
// Clocks
|
95 |
|
|
reg c3_sys_clk;
|
96 |
|
|
wire c3_sys_clk_p;
|
97 |
|
|
wire c3_sys_clk_n;
|
98 |
|
|
// System Reset
|
99 |
|
|
reg c3_sys_rst;
|
100 |
|
|
wire c3_sys_rst_i;
|
101 |
|
|
|
102 |
|
|
// Design-Top Port Map
|
103 |
|
|
wire [C3_MEM_ADDR_WIDTH-1:0] mcb3_dram_a;
|
104 |
|
|
wire [C3_MEM_BANKADDR_WIDTH-1:0] mcb3_dram_ba;
|
105 |
|
|
wire mcb3_dram_ck;
|
106 |
|
|
wire mcb3_dram_ck_n;
|
107 |
|
|
wire [C3_NUM_DQ_PINS-1:0] mcb3_dram_dq;
|
108 |
|
|
wire mcb3_dram_dqs;
|
109 |
|
|
wire mcb3_dram_dm;
|
110 |
|
|
wire mcb3_dram_ras_n;
|
111 |
|
|
wire mcb3_dram_cas_n;
|
112 |
|
|
wire mcb3_dram_we_n;
|
113 |
|
|
wire mcb3_dram_cke;
|
114 |
|
|
|
115 |
|
|
wire mcb3_dram_udqs; // for X16 parts
|
116 |
|
|
wire mcb3_dram_udm; // for X16 parts
|
117 |
|
|
|
118 |
|
|
// Error & Calib Signals
|
119 |
|
|
wire error;
|
120 |
|
|
wire calib_done;
|
121 |
|
|
wire rzq3;
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
// ========================================================================== //
|
125 |
|
|
// Clocks Generation //
|
126 |
|
|
// ========================================================================== //
|
127 |
|
|
|
128 |
|
|
initial
|
129 |
|
|
c3_sys_clk = 1'b0;
|
130 |
|
|
always
|
131 |
|
|
#(C3_MEMCLK_PERIOD/2) c3_sys_clk = ~c3_sys_clk;
|
132 |
|
|
|
133 |
|
|
assign c3_sys_clk_p = c3_sys_clk;
|
134 |
|
|
assign c3_sys_clk_n = ~c3_sys_clk;
|
135 |
|
|
|
136 |
|
|
// ========================================================================== //
|
137 |
|
|
// Reset Generation //
|
138 |
|
|
// ========================================================================== //
|
139 |
|
|
|
140 |
|
|
initial begin
|
141 |
|
|
c3_sys_rst = 1'b0;
|
142 |
|
|
#20000;
|
143 |
|
|
c3_sys_rst = 1'b1;
|
144 |
|
|
end
|
145 |
|
|
assign c3_sys_rst_i = C3_RST_ACT_LOW ? c3_sys_rst : ~c3_sys_rst;
|
146 |
|
|
|
147 |
|
|
// ========================================================================== //
|
148 |
|
|
// Error Grouping //
|
149 |
|
|
// ========================================================================== //
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
PULLDOWN rzq_pulldown3 (.O(rzq3));
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
// ========================================================================== //
|
159 |
|
|
// DESIGN TOP INSTANTIATION //
|
160 |
|
|
// ========================================================================== //
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
example_top #(
|
165 |
|
|
|
166 |
|
|
.C3_P0_MASK_SIZE (C3_P0_MASK_SIZE ),
|
167 |
|
|
.C3_P0_DATA_PORT_SIZE (C3_P0_DATA_PORT_SIZE ),
|
168 |
|
|
.C3_P1_MASK_SIZE (C3_P1_MASK_SIZE ),
|
169 |
|
|
.C3_P1_DATA_PORT_SIZE (C3_P1_DATA_PORT_SIZE ),
|
170 |
|
|
.C3_MEMCLK_PERIOD (C3_MEMCLK_PERIOD),
|
171 |
|
|
.C3_RST_ACT_LOW (C3_RST_ACT_LOW),
|
172 |
|
|
.C3_INPUT_CLK_TYPE (C3_INPUT_CLK_TYPE),
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
.DEBUG_EN (DEBUG_EN),
|
176 |
|
|
|
177 |
|
|
.C3_MEM_ADDR_ORDER (C3_MEM_ADDR_ORDER ),
|
178 |
|
|
.C3_NUM_DQ_PINS (C3_NUM_DQ_PINS ),
|
179 |
|
|
.C3_MEM_ADDR_WIDTH (C3_MEM_ADDR_WIDTH ),
|
180 |
|
|
.C3_MEM_BANKADDR_WIDTH (C3_MEM_BANKADDR_WIDTH),
|
181 |
|
|
|
182 |
|
|
.C3_HW_TESTING (C3_HW_TESTING),
|
183 |
|
|
.C3_SIMULATION (C3_SIMULATION),
|
184 |
|
|
.C3_CALIB_SOFT_IP (C3_CALIB_SOFT_IP )
|
185 |
|
|
)
|
186 |
|
|
design_top (
|
187 |
|
|
|
188 |
|
|
.c3_sys_clk (c3_sys_clk),
|
189 |
|
|
.c3_sys_rst_i (c3_sys_rst_i),
|
190 |
|
|
|
191 |
|
|
.mcb3_dram_dq (mcb3_dram_dq),
|
192 |
|
|
.mcb3_dram_a (mcb3_dram_a),
|
193 |
|
|
.mcb3_dram_ba (mcb3_dram_ba),
|
194 |
|
|
.mcb3_dram_ras_n (mcb3_dram_ras_n),
|
195 |
|
|
.mcb3_dram_cas_n (mcb3_dram_cas_n),
|
196 |
|
|
.mcb3_dram_we_n (mcb3_dram_we_n),
|
197 |
|
|
.mcb3_dram_cke (mcb3_dram_cke),
|
198 |
|
|
.mcb3_dram_ck (mcb3_dram_ck),
|
199 |
|
|
.mcb3_dram_ck_n (mcb3_dram_ck_n),
|
200 |
|
|
.calib_done (calib_done),
|
201 |
|
|
.error (error),
|
202 |
|
|
.mcb3_dram_udqs (mcb3_dram_udqs), // for X16 parts
|
203 |
|
|
.mcb3_dram_udm (mcb3_dram_udm), // for X16 parts
|
204 |
|
|
.mcb3_dram_dm (mcb3_dram_dm),
|
205 |
|
|
.mcb3_rzq (rzq3),
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
.mcb3_dram_dqs (mcb3_dram_dqs)
|
209 |
|
|
);
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
// ========================================================================== //
|
214 |
|
|
// Memory model instances //
|
215 |
|
|
// ========================================================================== //
|
216 |
|
|
|
217 |
|
|
generate
|
218 |
|
|
if(C3_NUM_DQ_PINS == 16) begin : MEM_INST3
|
219 |
|
|
ddr_model_c3 u_mem3(
|
220 |
|
|
.Dq (mcb3_dram_dq),
|
221 |
|
|
.Dqs ({mcb3_dram_udqs,mcb3_dram_dqs}),
|
222 |
|
|
.Addr (mcb3_dram_a),
|
223 |
|
|
.Ba (mcb3_dram_ba),
|
224 |
|
|
.Clk (mcb3_dram_ck),
|
225 |
|
|
.Clk_n (mcb3_dram_ck_n),
|
226 |
|
|
.Cke (mcb3_dram_cke),
|
227 |
|
|
.Cs_n (1'b0),
|
228 |
|
|
.Ras_n (mcb3_dram_ras_n),
|
229 |
|
|
.Cas_n (mcb3_dram_cas_n),
|
230 |
|
|
.We_n (mcb3_dram_we_n),
|
231 |
|
|
.Dm ({mcb3_dram_udm,mcb3_dram_dm})
|
232 |
|
|
);
|
233 |
|
|
end else begin
|
234 |
|
|
ddr_model_c3 u_mem3(
|
235 |
|
|
.Dq (mcb3_dram_dq),
|
236 |
|
|
.Dqs (mcb3_dram_dqs),
|
237 |
|
|
.Addr (mcb3_dram_a),
|
238 |
|
|
.Ba (mcb3_dram_ba),
|
239 |
|
|
.Clk (mcb3_dram_ck),
|
240 |
|
|
.Clk_n (mcb3_dram_ck_n),
|
241 |
|
|
.Cke (mcb3_dram_cke),
|
242 |
|
|
.Cs_n (1'b0),
|
243 |
|
|
.Ras_n (mcb3_dram_ras_n),
|
244 |
|
|
.Cas_n (mcb3_dram_cas_n),
|
245 |
|
|
.We_n (mcb3_dram_we_n),
|
246 |
|
|
.Dm (mcb3_dram_dm)
|
247 |
|
|
);
|
248 |
|
|
end
|
249 |
|
|
endgenerate
|
250 |
|
|
|
251 |
|
|
// ========================================================================== //
|
252 |
|
|
// Reporting the test case status
|
253 |
|
|
// ========================================================================== //
|
254 |
|
|
initial
|
255 |
|
|
begin : Logging
|
256 |
|
|
fork
|
257 |
|
|
begin : calibration_done
|
258 |
|
|
wait (calib_done);
|
259 |
|
|
$display("Calibration Done");
|
260 |
|
|
#50000000;
|
261 |
|
|
if (!error) begin
|
262 |
|
|
$display("TEST PASSED");
|
263 |
|
|
end
|
264 |
|
|
else begin
|
265 |
|
|
$display("TEST FAILED: DATA ERROR");
|
266 |
|
|
end
|
267 |
|
|
disable calib_not_done;
|
268 |
|
|
$finish;
|
269 |
|
|
end
|
270 |
|
|
|
271 |
|
|
begin : calib_not_done
|
272 |
|
|
#200000000;
|
273 |
|
|
if (!calib_done) begin
|
274 |
|
|
$display("TEST FAILED: INITIALIZATION DID NOT COMPLETE");
|
275 |
|
|
end
|
276 |
|
|
disable calibration_done;
|
277 |
|
|
$finish;
|
278 |
|
|
end
|
279 |
|
|
join
|
280 |
|
|
end
|
281 |
|
|
|
282 |
|
|
endmodule
|