1 |
11 |
mikaeljf |
/****************************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* File Name: ddr2.v
|
4 |
|
|
* Version: 5.80
|
5 |
|
|
* Model: BUS Functional
|
6 |
|
|
*
|
7 |
|
|
* Dependencies: ddr2_parameters.vh
|
8 |
|
|
*
|
9 |
|
|
* Description: Micron SDRAM DDR2 (Double Data Rate 2)
|
10 |
|
|
*
|
11 |
|
|
* Limitation: - doesn't check for average refresh timings
|
12 |
|
|
* - positive ck and ck_n edges are used to form internal clock
|
13 |
|
|
* - positive dqs and dqs_n edges are used to latch data
|
14 |
|
|
* - test mode is not modeled
|
15 |
|
|
*
|
16 |
|
|
* Note: - Set simulator resolution to "ps" accuracy
|
17 |
|
|
* - Set Debug = 0 to disable $display messages
|
18 |
|
|
*
|
19 |
|
|
* Disclaimer This software code and all associated documentation, comments or other
|
20 |
|
|
* of Warranty: information (collectively "Software") is provided "AS IS" without
|
21 |
|
|
* warranty of any kind. MICRON TECHNOLOGY, INC. ("MTI") EXPRESSLY
|
22 |
|
|
* DISCLAIMS ALL WARRANTIES EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
23 |
|
|
* TO, NONINFRINGEMENT OF THIRD PARTY RIGHTS, AND ANY IMPLIED WARRANTIES
|
24 |
|
|
* OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. MTI DOES NOT
|
25 |
|
|
* WARRANT THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS, OR THAT THE
|
26 |
|
|
* OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE.
|
27 |
|
|
* FURTHERMORE, MTI DOES NOT MAKE ANY REPRESENTATIONS REGARDING THE USE OR
|
28 |
|
|
* THE RESULTS OF THE USE OF THE SOFTWARE IN TERMS OF ITS CORRECTNESS,
|
29 |
|
|
* ACCURACY, RELIABILITY, OR OTHERWISE. THE ENTIRE RISK ARISING OUT OF USE
|
30 |
|
|
* OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU. IN NO EVENT SHALL MTI,
|
31 |
|
|
* ITS AFFILIATED COMPANIES OR THEIR SUPPLIERS BE LIABLE FOR ANY DIRECT,
|
32 |
|
|
* INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES (INCLUDING,
|
33 |
|
|
* WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION,
|
34 |
|
|
* OR LOSS OF INFORMATION) ARISING OUT OF YOUR USE OF OR INABILITY TO USE
|
35 |
|
|
* THE SOFTWARE, EVEN IF MTI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
36 |
|
|
* DAMAGES. Because some jurisdictions prohibit the exclusion or
|
37 |
|
|
* limitation of liability for consequential or incidental damages, the
|
38 |
|
|
* above limitation may not apply to you.
|
39 |
|
|
*
|
40 |
|
|
* Copyright 2003 Micron Technology, Inc. All rights reserved.
|
41 |
|
|
*
|
42 |
|
|
* Rev Author Date Changes
|
43 |
|
|
* ---------------------------------------------------------------------------------------
|
44 |
|
|
* 1.00 JMK 07/29/03 Initial Release
|
45 |
|
|
* 1.10 JMK 08/09/03 Timing Parameter updates to tIS, tIH, tDS, tDH
|
46 |
|
|
* 2.20 JMK 08/07/03 General cleanup
|
47 |
|
|
* 2.30 JMK 11/26/03 Added CL_MIN, CL_MAX, wl_min and wl_max parameters.
|
48 |
|
|
* Added AL_MIN and AL_MAX parameters.
|
49 |
|
|
* Removed support for OCD.
|
50 |
|
|
* 2.40 JMK 01/15/04 Removed verilog 2001 constructs.
|
51 |
|
|
* 2.50 JMK 01/29/04 Removed tRP checks during Precharge command.
|
52 |
|
|
* 2.60 JMK 04/20/04 Fixed tWTR check.
|
53 |
|
|
* 2.70 JMK 04/30/04 Added tRFC maximum check.
|
54 |
|
|
* Combined Self Refresh and Power Down always blocks.
|
55 |
|
|
* Added Reset Function (CKE LOW Anytime).
|
56 |
|
|
* 2.80 JMK 08/19/04 Precharge is treated as NOP when bank is not active.
|
57 |
|
|
* Added checks for tRAS, tWR, tRTP to any bank during Pre-All.
|
58 |
|
|
* tRFC maximum violation will only display one time.
|
59 |
|
|
* 2.90 JMK 11/05/04 Fixed DQS checking during write.
|
60 |
|
|
* Fixed false tRFC max assertion during power up and self ref.
|
61 |
|
|
* Added warning for 200us CKE low time during initialization.
|
62 |
|
|
* Added -3, -3E, and -37V speed grades to ddr2_parameters.v
|
63 |
|
|
* 3.00 JMK 04/22/05 Removed ODT off requirement during power down.
|
64 |
|
|
* Added tAOND, tAOFD, tANPD, tAXPD, tAONPD, and tAOFPD parameters.
|
65 |
|
|
* Added ODT status messages.
|
66 |
|
|
* Updated the initialization sequence.
|
67 |
|
|
* Disable ODT and CLK pins during self refresh.
|
68 |
|
|
* Disable cmd and addr pins during power down and self refresh.
|
69 |
|
|
* 3.10 JMK 06/07/05 Disable trpa checking if the part does not have 8 banks.
|
70 |
|
|
* Changed tAXPD message from error to a warning.
|
71 |
|
|
* Added tDSS checking.
|
72 |
|
|
* Removed tDQSL checking during tWPRE and tWPST.
|
73 |
|
|
* Fixed a burst order error during writes.
|
74 |
|
|
* Renamed parameters file with .vh extension.
|
75 |
|
|
* 3.20 JMK 07/18/05 Removed 14 tCK requirement from LMR to READ.
|
76 |
|
|
* 3.30 JMK 08/03/05 Added check for interrupting a burst with auto precharge.
|
77 |
|
|
* 4.00 JMK 11/21/05 Parameter names all UPPERCASE, signal names all lowercase.
|
78 |
|
|
* Clock jitter can be tolerated within specification range.
|
79 |
|
|
* Clock frequency is sampled from the CK pin.
|
80 |
|
|
* Scaleable up to 64 DQ and 16 DQS bits.
|
81 |
|
|
* Read data can be randomly skewed using RANDOM_OUT_DELAY.
|
82 |
|
|
* Parameterized read and write DQS, and read DQ.
|
83 |
|
|
* Initialization can be bypassed using initialize task.
|
84 |
|
|
* 4.10 JMK 11/30/05 Fixed compile errors when `MAX_MEM was defined.
|
85 |
|
|
* 4.20 JMK 12/09/05 Fixed memory addressing error when `MAX_MEM was defined.
|
86 |
|
|
* 4.30 JMK 02/15/06 Added dummy write to initialization sequence.
|
87 |
|
|
* Removed tWPST maximum checking.
|
88 |
|
|
* Rising dqs_n edge latches data when enabled in EMR.
|
89 |
|
|
* Fixed a sign error in the tJIT(cc) calculation.
|
90 |
|
|
* 4.40 JMK 02/16/06 Fixed dummy write when`MAX_MEM was defined.
|
91 |
|
|
* 4.50 JMK 02/27/06 Fixed extra tDQSS assertions.
|
92 |
|
|
* Fixed tRCD and tWTR checking.
|
93 |
|
|
* Errors entering Power Down or Self Refresh will cause reset.
|
94 |
|
|
* Ignore dqs_n when disabled in EMR.
|
95 |
|
|
* 5.00 JMK 04/24/06 Test stimulus now included from external file (subtest.vh)
|
96 |
|
|
* Fixed tRFC max assertion during self refresh.
|
97 |
|
|
* Fixed tANPD checking during Power Down.
|
98 |
|
|
* Removed dummy write from initialization sequence.
|
99 |
|
|
* 5.01 JMK 04/28/06 Fixed Auto Precharge to Load Mode, Refresh and Self Refresh.
|
100 |
|
|
* Removed Auto Precharge error message during Power Down Enter.
|
101 |
|
|
* 5.10 JMK 07/26/06 Created internal clock using ck and ck_n.
|
102 |
|
|
* RDQS can only be enabled in EMR for x8 configurations.
|
103 |
|
|
* CAS latency is checked vs frequency when DLL locks.
|
104 |
|
|
* tMOD changed from tCK units to ns units.
|
105 |
|
|
* Added 50 Ohm setting for Rtt in EMR.
|
106 |
|
|
* Improved checking of DQS during writes.
|
107 |
|
|
* 5.20 JMK 10/02/06 Fixed DQS checking for interrupting write to write and x16.
|
108 |
|
|
* 5.30 JMK 05/25/07 Fixed checking for 0-Z transition on write postamble.
|
109 |
|
|
* 5.50 JMK 05/30/08 Renamed ddr2_dimm.v to ddr2_module.v and added SODIMM support.
|
110 |
|
|
* Added a register delay to ddr2_module.v when RDIMM is defined.
|
111 |
|
|
* Added multi-chip package model support in ddr2_mcp.v
|
112 |
|
|
* Added High Temp Self Refresh rate setting in EMRS2[7]
|
113 |
|
|
* 5.70 JMK 04/23/09 Updated tRPA definition
|
114 |
|
|
* Increased internal width to 72 bit DQ bus
|
115 |
|
|
* 5.80 SPH 08/12/09 Fixed tRAS maximum violation (only check if bank still open)
|
116 |
|
|
****************************************************************************************/
|
117 |
|
|
|
118 |
|
|
// DO NOT CHANGE THE TIMESCALE
|
119 |
|
|
// MAKE SURE YOUR SIMULATOR USES "PS" RESOLUTION
|
120 |
|
|
`timescale 1ps / 1ps
|
121 |
|
|
|
122 |
|
|
module ddr2 (
|
123 |
|
|
ck,
|
124 |
|
|
ck_n,
|
125 |
|
|
cke,
|
126 |
|
|
cs_n,
|
127 |
|
|
ras_n,
|
128 |
|
|
cas_n,
|
129 |
|
|
we_n,
|
130 |
|
|
dm_rdqs,
|
131 |
|
|
ba,
|
132 |
|
|
addr,
|
133 |
|
|
dq,
|
134 |
|
|
dqs,
|
135 |
|
|
dqs_n,
|
136 |
|
|
rdqs_n,
|
137 |
|
|
odt
|
138 |
|
|
);
|
139 |
|
|
|
140 |
|
|
`include "ddr2_parameters.vh"
|
141 |
|
|
|
142 |
|
|
// text macros
|
143 |
|
|
`define DQ_PER_DQS DQ_BITS/DQS_BITS
|
144 |
|
|
`define BANKS (1<<BA_BITS)
|
145 |
|
|
`define MAX_BITS (BA_BITS+ROW_BITS+COL_BITS-BL_BITS)
|
146 |
|
|
`define MAX_SIZE (1<<(BA_BITS+ROW_BITS+COL_BITS-BL_BITS))
|
147 |
|
|
`define MEM_SIZE (1<<MEM_BITS)
|
148 |
|
|
`define MAX_PIPE 2*(AL_MAX + CL_MAX)
|
149 |
|
|
|
150 |
|
|
// Declare Ports
|
151 |
|
|
input ck;
|
152 |
|
|
input ck_n;
|
153 |
|
|
input cke;
|
154 |
|
|
input cs_n;
|
155 |
|
|
input ras_n;
|
156 |
|
|
input cas_n;
|
157 |
|
|
input we_n;
|
158 |
|
|
inout [DM_BITS-1:0] dm_rdqs;
|
159 |
|
|
input [BA_BITS-1:0] ba;
|
160 |
|
|
input [ADDR_BITS-1:0] addr;
|
161 |
|
|
inout [DQ_BITS-1:0] dq;
|
162 |
|
|
inout [DQS_BITS-1:0] dqs;
|
163 |
|
|
inout [DQS_BITS-1:0] dqs_n;
|
164 |
|
|
output [DQS_BITS-1:0] rdqs_n;
|
165 |
|
|
input odt;
|
166 |
|
|
|
167 |
|
|
// clock jitter
|
168 |
|
|
real tck_avg;
|
169 |
|
|
time tck_sample [TDLLK-1:0];
|
170 |
|
|
time tch_sample [TDLLK-1:0];
|
171 |
|
|
time tcl_sample [TDLLK-1:0];
|
172 |
|
|
time tck_i;
|
173 |
|
|
time tch_i;
|
174 |
|
|
time tcl_i;
|
175 |
|
|
real tch_avg;
|
176 |
|
|
real tcl_avg;
|
177 |
|
|
time tm_ck_pos;
|
178 |
|
|
time tm_ck_neg;
|
179 |
|
|
real tjit_per_rtime;
|
180 |
|
|
integer tjit_cc_time;
|
181 |
|
|
real terr_nper_rtime;
|
182 |
|
|
|
183 |
|
|
// clock skew
|
184 |
|
|
real out_delay;
|
185 |
|
|
integer dqsck [DQS_BITS-1:0];
|
186 |
|
|
integer dqsck_min;
|
187 |
|
|
integer dqsck_max;
|
188 |
|
|
integer dqsq_min;
|
189 |
|
|
integer dqsq_max;
|
190 |
|
|
integer seed;
|
191 |
|
|
|
192 |
|
|
// Mode Registers
|
193 |
|
|
reg burst_order;
|
194 |
|
|
reg [BL_BITS:0] burst_length;
|
195 |
|
|
integer cas_latency;
|
196 |
|
|
integer additive_latency;
|
197 |
|
|
reg dll_reset;
|
198 |
|
|
reg dll_locked;
|
199 |
|
|
reg dll_en;
|
200 |
|
|
integer write_recovery;
|
201 |
|
|
reg low_power;
|
202 |
|
|
reg [1:0] odt_rtt;
|
203 |
|
|
reg odt_en;
|
204 |
|
|
reg [2:0] ocd;
|
205 |
|
|
reg dqs_n_en;
|
206 |
|
|
reg rdqs_en;
|
207 |
|
|
reg out_en;
|
208 |
|
|
integer read_latency;
|
209 |
|
|
integer write_latency;
|
210 |
|
|
|
211 |
|
|
// cmd encoding
|
212 |
|
|
parameter
|
213 |
|
|
LOAD_MODE = 4'b0000,
|
214 |
|
|
REFRESH = 4'b0001,
|
215 |
|
|
PRECHARGE = 4'b0010,
|
216 |
|
|
ACTIVATE = 4'b0011,
|
217 |
|
|
WRITE = 4'b0100,
|
218 |
|
|
READ = 4'b0101,
|
219 |
|
|
NOP = 4'b0111,
|
220 |
|
|
PWR_DOWN = 4'b1000,
|
221 |
|
|
SELF_REF = 4'b1001
|
222 |
|
|
;
|
223 |
|
|
|
224 |
|
|
reg [8*9-1:0] cmd_string [9:0];
|
225 |
|
|
initial begin
|
226 |
|
|
cmd_string[LOAD_MODE] = "Load Mode";
|
227 |
|
|
cmd_string[REFRESH ] = "Refresh ";
|
228 |
|
|
cmd_string[PRECHARGE] = "Precharge";
|
229 |
|
|
cmd_string[ACTIVATE ] = "Activate ";
|
230 |
|
|
cmd_string[WRITE ] = "Write ";
|
231 |
|
|
cmd_string[READ ] = "Read ";
|
232 |
|
|
cmd_string[NOP ] = "No Op ";
|
233 |
|
|
cmd_string[PWR_DOWN ] = "Pwr Down ";
|
234 |
|
|
cmd_string[SELF_REF ] = "Self Ref ";
|
235 |
|
|
end
|
236 |
|
|
|
237 |
|
|
// command state
|
238 |
|
|
reg [`BANKS-1:0] active_bank;
|
239 |
|
|
reg [`BANKS-1:0] auto_precharge_bank;
|
240 |
|
|
reg [`BANKS-1:0] write_precharge_bank;
|
241 |
|
|
reg [`BANKS-1:0] read_precharge_bank;
|
242 |
|
|
reg [ROW_BITS-1:0] active_row [`BANKS-1:0];
|
243 |
|
|
reg in_power_down;
|
244 |
|
|
reg in_self_refresh;
|
245 |
|
|
reg [3:0] init_mode_reg;
|
246 |
|
|
reg init_done;
|
247 |
|
|
integer init_step;
|
248 |
|
|
reg er_trfc_max;
|
249 |
|
|
reg odt_state;
|
250 |
|
|
reg prev_odt;
|
251 |
|
|
|
252 |
|
|
// cmd timers/counters
|
253 |
|
|
integer ref_cntr;
|
254 |
|
|
integer ck_cntr;
|
255 |
|
|
integer ck_load_mode;
|
256 |
|
|
integer ck_write;
|
257 |
|
|
integer ck_read;
|
258 |
|
|
integer ck_write_ap;
|
259 |
|
|
integer ck_power_down;
|
260 |
|
|
integer ck_slow_exit_pd;
|
261 |
|
|
integer ck_self_refresh;
|
262 |
|
|
integer ck_cke;
|
263 |
|
|
integer ck_odt;
|
264 |
|
|
integer ck_dll_reset;
|
265 |
|
|
integer ck_bank_write [`BANKS-1:0];
|
266 |
|
|
integer ck_bank_read [`BANKS-1:0];
|
267 |
|
|
time tm_refresh;
|
268 |
|
|
time tm_precharge;
|
269 |
|
|
time tm_precharge_all;
|
270 |
|
|
time tm_activate;
|
271 |
|
|
time tm_write_end;
|
272 |
|
|
time tm_self_refresh;
|
273 |
|
|
time tm_odt_en;
|
274 |
|
|
time tm_bank_precharge [`BANKS-1:0];
|
275 |
|
|
time tm_bank_activate [`BANKS-1:0];
|
276 |
|
|
time tm_bank_write_end [`BANKS-1:0];
|
277 |
|
|
time tm_bank_read_end [`BANKS-1:0];
|
278 |
|
|
|
279 |
|
|
// pipelines
|
280 |
|
|
reg [`MAX_PIPE:0] al_pipeline;
|
281 |
|
|
reg [`MAX_PIPE:0] wr_pipeline;
|
282 |
|
|
reg [`MAX_PIPE:0] rd_pipeline;
|
283 |
|
|
reg [`MAX_PIPE:0] odt_pipeline;
|
284 |
|
|
reg [BA_BITS-1:0] ba_pipeline [`MAX_PIPE:0];
|
285 |
|
|
reg [ROW_BITS-1:0] row_pipeline [`MAX_PIPE:0];
|
286 |
|
|
reg [COL_BITS-1:0] col_pipeline [`MAX_PIPE:0];
|
287 |
|
|
reg prev_cke;
|
288 |
|
|
|
289 |
|
|
// data state
|
290 |
|
|
reg [BL_MAX*DQ_BITS-1:0] memory_data;
|
291 |
|
|
reg [BL_MAX*DQ_BITS-1:0] bit_mask;
|
292 |
|
|
reg [BL_BITS-1:0] burst_position;
|
293 |
|
|
reg [BL_BITS:0] burst_cntr;
|
294 |
|
|
reg [DQ_BITS-1:0] dq_temp;
|
295 |
|
|
reg [35:0] check_write_postamble;
|
296 |
|
|
reg [35:0] check_write_preamble;
|
297 |
|
|
reg [35:0] check_write_dqs_high;
|
298 |
|
|
reg [35:0] check_write_dqs_low;
|
299 |
|
|
reg [17:0] check_dm_tdipw;
|
300 |
|
|
reg [71:0] check_dq_tdipw;
|
301 |
|
|
|
302 |
|
|
// data timers/counters
|
303 |
|
|
time tm_cke;
|
304 |
|
|
time tm_odt;
|
305 |
|
|
time tm_tdqss;
|
306 |
|
|
time tm_dm [17:0];
|
307 |
|
|
time tm_dqs [17:0];
|
308 |
|
|
time tm_dqs_pos [35:0];
|
309 |
|
|
time tm_dqss_pos [35:0];
|
310 |
|
|
time tm_dqs_neg [35:0];
|
311 |
|
|
time tm_dq [71:0];
|
312 |
|
|
time tm_cmd_addr [22:0];
|
313 |
|
|
reg [8*7-1:0] cmd_addr_string [22:0];
|
314 |
|
|
initial begin
|
315 |
|
|
cmd_addr_string[ 0] = "CS_N ";
|
316 |
|
|
cmd_addr_string[ 1] = "RAS_N ";
|
317 |
|
|
cmd_addr_string[ 2] = "CAS_N ";
|
318 |
|
|
cmd_addr_string[ 3] = "WE_N ";
|
319 |
|
|
cmd_addr_string[ 4] = "BA 0 ";
|
320 |
|
|
cmd_addr_string[ 5] = "BA 1 ";
|
321 |
|
|
cmd_addr_string[ 6] = "BA 2 ";
|
322 |
|
|
cmd_addr_string[ 7] = "ADDR 0";
|
323 |
|
|
cmd_addr_string[ 8] = "ADDR 1";
|
324 |
|
|
cmd_addr_string[ 9] = "ADDR 2";
|
325 |
|
|
cmd_addr_string[10] = "ADDR 3";
|
326 |
|
|
cmd_addr_string[11] = "ADDR 4";
|
327 |
|
|
cmd_addr_string[12] = "ADDR 5";
|
328 |
|
|
cmd_addr_string[13] = "ADDR 6";
|
329 |
|
|
cmd_addr_string[14] = "ADDR 7";
|
330 |
|
|
cmd_addr_string[15] = "ADDR 8";
|
331 |
|
|
cmd_addr_string[16] = "ADDR 9";
|
332 |
|
|
cmd_addr_string[17] = "ADDR 10";
|
333 |
|
|
cmd_addr_string[18] = "ADDR 11";
|
334 |
|
|
cmd_addr_string[19] = "ADDR 12";
|
335 |
|
|
cmd_addr_string[20] = "ADDR 13";
|
336 |
|
|
cmd_addr_string[21] = "ADDR 14";
|
337 |
|
|
cmd_addr_string[22] = "ADDR 15";
|
338 |
|
|
end
|
339 |
|
|
|
340 |
|
|
reg [8*5-1:0] dqs_string [1:0];
|
341 |
|
|
initial begin
|
342 |
|
|
dqs_string[0] = "DQS ";
|
343 |
|
|
dqs_string[1] = "DQS_N";
|
344 |
|
|
end
|
345 |
|
|
|
346 |
|
|
// Memory Storage
|
347 |
|
|
`ifdef MAX_MEM
|
348 |
|
|
reg [BL_MAX*DQ_BITS-1:0] memory [0:`MAX_SIZE-1];
|
349 |
|
|
`else
|
350 |
|
|
reg [BL_MAX*DQ_BITS-1:0] memory [0:`MEM_SIZE-1];
|
351 |
|
|
reg [`MAX_BITS-1:0] address [0:`MEM_SIZE-1];
|
352 |
|
|
reg [MEM_BITS:0] memory_index;
|
353 |
|
|
reg [MEM_BITS:0] memory_used;
|
354 |
|
|
`endif
|
355 |
|
|
|
356 |
|
|
// receive
|
357 |
|
|
reg ck_in;
|
358 |
|
|
reg ck_n_in;
|
359 |
|
|
reg cke_in;
|
360 |
|
|
reg cs_n_in;
|
361 |
|
|
reg ras_n_in;
|
362 |
|
|
reg cas_n_in;
|
363 |
|
|
reg we_n_in;
|
364 |
|
|
reg [17:0] dm_in;
|
365 |
|
|
reg [2:0] ba_in;
|
366 |
|
|
reg [15:0] addr_in;
|
367 |
|
|
reg [71:0] dq_in;
|
368 |
|
|
reg [35:0] dqs_in;
|
369 |
|
|
reg odt_in;
|
370 |
|
|
|
371 |
|
|
reg [17:0] dm_in_pos;
|
372 |
|
|
reg [17:0] dm_in_neg;
|
373 |
|
|
reg [71:0] dq_in_pos;
|
374 |
|
|
reg [71:0] dq_in_neg;
|
375 |
|
|
reg dq_in_valid;
|
376 |
|
|
reg dqs_in_valid;
|
377 |
|
|
integer wdqs_cntr;
|
378 |
|
|
integer wdq_cntr;
|
379 |
|
|
integer wdqs_pos_cntr [35:0];
|
380 |
|
|
reg b2b_write;
|
381 |
|
|
reg [35:0] prev_dqs_in;
|
382 |
|
|
reg diff_ck;
|
383 |
|
|
|
384 |
|
|
always @(ck ) ck_in <= #BUS_DELAY ck;
|
385 |
|
|
always @(ck_n ) ck_n_in <= #BUS_DELAY ck_n;
|
386 |
|
|
always @(cke ) cke_in <= #BUS_DELAY cke;
|
387 |
|
|
always @(cs_n ) cs_n_in <= #BUS_DELAY cs_n;
|
388 |
|
|
always @(ras_n ) ras_n_in <= #BUS_DELAY ras_n;
|
389 |
|
|
always @(cas_n ) cas_n_in <= #BUS_DELAY cas_n;
|
390 |
|
|
always @(we_n ) we_n_in <= #BUS_DELAY we_n;
|
391 |
|
|
always @(dm_rdqs) dm_in <= #BUS_DELAY dm_rdqs;
|
392 |
|
|
always @(ba ) ba_in <= #BUS_DELAY ba;
|
393 |
|
|
always @(addr ) addr_in <= #BUS_DELAY addr;
|
394 |
|
|
always @(dq ) dq_in <= #BUS_DELAY dq;
|
395 |
|
|
always @(dqs or dqs_n) dqs_in <= #BUS_DELAY (dqs_n<<18) | dqs;
|
396 |
|
|
always @(odt ) odt_in <= #BUS_DELAY odt;
|
397 |
|
|
// create internal clock
|
398 |
|
|
always @(posedge ck_in) diff_ck <= ck_in;
|
399 |
|
|
always @(posedge ck_n_in) diff_ck <= ~ck_n_in;
|
400 |
|
|
|
401 |
|
|
wire [17:0] dqs_even = dqs_in[17:0];
|
402 |
|
|
wire [17:0] dqs_odd = dqs_n_en ? dqs_in[35:18] : ~dqs_in[17:0];
|
403 |
|
|
wire [3:0] cmd_n_in = !cs_n_in ? {ras_n_in, cas_n_in, we_n_in} : NOP; //deselect = nop
|
404 |
|
|
|
405 |
|
|
// transmit
|
406 |
|
|
reg dqs_out_en;
|
407 |
|
|
reg [DQS_BITS-1:0] dqs_out_en_dly;
|
408 |
|
|
reg dqs_out;
|
409 |
|
|
reg [DQS_BITS-1:0] dqs_out_dly;
|
410 |
|
|
reg dq_out_en;
|
411 |
|
|
reg [DQ_BITS-1:0] dq_out_en_dly;
|
412 |
|
|
reg [DQ_BITS-1:0] dq_out;
|
413 |
|
|
reg [DQ_BITS-1:0] dq_out_dly;
|
414 |
|
|
integer rdqsen_cntr;
|
415 |
|
|
integer rdqs_cntr;
|
416 |
|
|
integer rdqen_cntr;
|
417 |
|
|
integer rdq_cntr;
|
418 |
|
|
|
419 |
|
|
bufif1 buf_dqs [DQS_BITS-1:0] (dqs, dqs_out_dly, dqs_out_en_dly & {DQS_BITS{out_en}});
|
420 |
|
|
bufif1 buf_dm [DM_BITS-1:0] (dm_rdqs, dqs_out_dly, dqs_out_en_dly & {DM_BITS {out_en}} & {DM_BITS{rdqs_en}});
|
421 |
|
|
bufif1 buf_dqs_n [DQS_BITS-1:0] (dqs_n, ~dqs_out_dly, dqs_out_en_dly & {DQS_BITS{out_en}} & {DQS_BITS{dqs_n_en}});
|
422 |
|
|
bufif1 buf_rdqs_n [DQS_BITS-1:0] (rdqs_n, ~dqs_out_dly, dqs_out_en_dly & {DQS_BITS{out_en}} & {DQS_BITS{dqs_n_en}} & {DQS_BITS{rdqs_en}});
|
423 |
|
|
bufif1 buf_dq [DQ_BITS-1:0] (dq, dq_out_dly, dq_out_en_dly & {DQ_BITS {out_en}});
|
424 |
|
|
|
425 |
|
|
initial begin
|
426 |
|
|
if (BL_MAX < 2)
|
427 |
|
|
$display("%m ERROR: BL_MAX parameter must be >= 2. \nBL_MAX = %d", BL_MAX);
|
428 |
|
|
if ((1<<BO_BITS) > BL_MAX)
|
429 |
|
|
$display("%m ERROR: 2^BO_BITS cannot be greater than BL_MAX parameter.");
|
430 |
|
|
$timeformat (-12, 1, " ps", 1);
|
431 |
|
|
reset_task;
|
432 |
|
|
seed = RANDOM_SEED;
|
433 |
|
|
ck_cntr = 0;
|
434 |
|
|
end
|
435 |
|
|
|
436 |
|
|
// calculate the absolute value of a real number
|
437 |
|
|
function real abs_value;
|
438 |
|
|
input arg;
|
439 |
|
|
real arg;
|
440 |
|
|
begin
|
441 |
|
|
if (arg < 0.0)
|
442 |
|
|
abs_value = -1.0 * arg;
|
443 |
|
|
else
|
444 |
|
|
abs_value = arg;
|
445 |
|
|
end
|
446 |
|
|
endfunction
|
447 |
|
|
|
448 |
|
|
`ifdef MAX_MEM
|
449 |
|
|
`else
|
450 |
|
|
function get_index;
|
451 |
|
|
input [`MAX_BITS-1:0] addr;
|
452 |
|
|
begin : index
|
453 |
|
|
get_index = 0;
|
454 |
|
|
for (memory_index=0; memory_index<memory_used; memory_index=memory_index+1) begin
|
455 |
|
|
if (address[memory_index] == addr) begin
|
456 |
|
|
get_index = 1;
|
457 |
|
|
disable index;
|
458 |
|
|
end
|
459 |
|
|
end
|
460 |
|
|
end
|
461 |
|
|
endfunction
|
462 |
|
|
`endif
|
463 |
|
|
|
464 |
|
|
task memory_write;
|
465 |
|
|
input [BA_BITS-1:0] bank;
|
466 |
|
|
input [ROW_BITS-1:0] row;
|
467 |
|
|
input [COL_BITS-1:0] col;
|
468 |
|
|
input [BL_MAX*DQ_BITS-1:0] data;
|
469 |
|
|
reg [`MAX_BITS-1:0] addr;
|
470 |
|
|
begin
|
471 |
|
|
// chop off the lowest address bits
|
472 |
|
|
addr = {bank, row, col}/BL_MAX;
|
473 |
|
|
`ifdef MAX_MEM
|
474 |
|
|
memory[addr] = data;
|
475 |
|
|
`else
|
476 |
|
|
if (get_index(addr)) begin
|
477 |
|
|
address[memory_index] = addr;
|
478 |
|
|
memory[memory_index] = data;
|
479 |
|
|
end else if (memory_used == `MEM_SIZE) begin
|
480 |
|
|
$display ("%m: at time %t ERROR: Memory overflow. Write to Address %h with Data %h will be lost.\nYou must increase the MEM_BITS parameter or define MAX_MEM.", $time, addr, data);
|
481 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
482 |
|
|
end else begin
|
483 |
|
|
address[memory_used] = addr;
|
484 |
|
|
memory[memory_used] = data;
|
485 |
|
|
memory_used = memory_used + 1;
|
486 |
|
|
end
|
487 |
|
|
`endif
|
488 |
|
|
end
|
489 |
|
|
endtask
|
490 |
|
|
|
491 |
|
|
task memory_read;
|
492 |
|
|
input [BA_BITS-1:0] bank;
|
493 |
|
|
input [ROW_BITS-1:0] row;
|
494 |
|
|
input [COL_BITS-1:0] col;
|
495 |
|
|
output [BL_MAX*DQ_BITS-1:0] data;
|
496 |
|
|
reg [`MAX_BITS-1:0] addr;
|
497 |
|
|
begin
|
498 |
|
|
// chop off the lowest address bits
|
499 |
|
|
addr = {bank, row, col}/BL_MAX;
|
500 |
|
|
`ifdef MAX_MEM
|
501 |
|
|
data = memory[addr];
|
502 |
|
|
`else
|
503 |
|
|
if (get_index(addr)) begin
|
504 |
|
|
data = memory[memory_index];
|
505 |
|
|
end else begin
|
506 |
|
|
data = {BL_MAX*DQ_BITS{1'bx}};
|
507 |
|
|
end
|
508 |
|
|
`endif
|
509 |
|
|
end
|
510 |
|
|
endtask
|
511 |
|
|
|
512 |
|
|
// Before this task runs, the model must be in a valid state for precharge power down.
|
513 |
|
|
// After this task runs, NOP commands must be issued until tRFC has been met
|
514 |
|
|
task initialize;
|
515 |
|
|
input [ADDR_BITS-1:0] mode_reg0;
|
516 |
|
|
input [ADDR_BITS-1:0] mode_reg1;
|
517 |
|
|
input [ADDR_BITS-1:0] mode_reg2;
|
518 |
|
|
input [ADDR_BITS-1:0] mode_reg3;
|
519 |
|
|
begin
|
520 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Performing Initialization Sequence", $time);
|
521 |
|
|
cmd_task(1, NOP, 'bx, 'bx);
|
522 |
|
|
cmd_task(1, PRECHARGE, 'bx, 1<<AP); // Precharege ALL
|
523 |
|
|
cmd_task(1, LOAD_MODE, 3, mode_reg3);
|
524 |
|
|
cmd_task(1, LOAD_MODE, 2, mode_reg2);
|
525 |
|
|
cmd_task(1, LOAD_MODE, 1, mode_reg1);
|
526 |
|
|
cmd_task(1, LOAD_MODE, 0, mode_reg0 | 'h100); // DLL Reset
|
527 |
|
|
cmd_task(1, PRECHARGE, 'bx, 1<<AP); // Precharege ALL
|
528 |
|
|
cmd_task(1, REFRESH, 'bx, 'bx);
|
529 |
|
|
cmd_task(1, REFRESH, 'bx, 'bx);
|
530 |
|
|
cmd_task(1, LOAD_MODE, 0, mode_reg0);
|
531 |
|
|
cmd_task(1, LOAD_MODE, 1, mode_reg1 | 'h380); // OCD Default
|
532 |
|
|
cmd_task(1, LOAD_MODE, 1, mode_reg1);
|
533 |
|
|
cmd_task(0, NOP, 'bx, 'bx);
|
534 |
|
|
end
|
535 |
|
|
endtask
|
536 |
|
|
|
537 |
|
|
task reset_task;
|
538 |
|
|
integer i;
|
539 |
|
|
begin
|
540 |
|
|
// disable inputs
|
541 |
|
|
dq_in_valid = 0;
|
542 |
|
|
dqs_in_valid <= 0;
|
543 |
|
|
wdqs_cntr = 0;
|
544 |
|
|
wdq_cntr = 0;
|
545 |
|
|
for (i=0; i<36; i=i+1) begin
|
546 |
|
|
wdqs_pos_cntr[i] <= 0;
|
547 |
|
|
end
|
548 |
|
|
b2b_write <= 0;
|
549 |
|
|
// disable outputs
|
550 |
|
|
out_en = 0;
|
551 |
|
|
dqs_n_en = 0;
|
552 |
|
|
rdqs_en = 0;
|
553 |
|
|
dq_out_en = 0;
|
554 |
|
|
rdq_cntr = 0;
|
555 |
|
|
dqs_out_en = 0;
|
556 |
|
|
rdqs_cntr = 0;
|
557 |
|
|
// disable ODT
|
558 |
|
|
odt_en = 0;
|
559 |
|
|
odt_state = 0;
|
560 |
|
|
// reset bank state
|
561 |
|
|
active_bank = {`BANKS{1'b1}};
|
562 |
|
|
auto_precharge_bank = 0;
|
563 |
|
|
read_precharge_bank = 0;
|
564 |
|
|
write_precharge_bank = 0;
|
565 |
|
|
// require initialization sequence
|
566 |
|
|
init_done = 0;
|
567 |
|
|
init_step = 0;
|
568 |
|
|
init_mode_reg = 0;
|
569 |
|
|
// reset DLL
|
570 |
|
|
dll_en = 0;
|
571 |
|
|
dll_reset = 0;
|
572 |
|
|
dll_locked = 0;
|
573 |
|
|
ocd = 0;
|
574 |
|
|
// exit power down and self refresh
|
575 |
|
|
in_power_down = 0;
|
576 |
|
|
in_self_refresh = 0;
|
577 |
|
|
// clear pipelines
|
578 |
|
|
al_pipeline = 0;
|
579 |
|
|
wr_pipeline = 0;
|
580 |
|
|
rd_pipeline = 0;
|
581 |
|
|
odt_pipeline = 0;
|
582 |
|
|
// clear memory
|
583 |
|
|
`ifdef MAX_MEM
|
584 |
|
|
for (i=0; i<=`MAX_SIZE; i=i+1) begin //erase memory ... one address at a time
|
585 |
|
|
memory[i] <= 'bx;
|
586 |
|
|
end
|
587 |
|
|
`else
|
588 |
|
|
memory_used <= 0; //erase memory
|
589 |
|
|
`endif
|
590 |
|
|
// clear maximum timing checks
|
591 |
|
|
tm_refresh <= 'bx;
|
592 |
|
|
for (i=0; i<`BANKS; i=i+1) begin
|
593 |
|
|
tm_bank_activate[i] <= 'bx;
|
594 |
|
|
end
|
595 |
|
|
end
|
596 |
|
|
endtask
|
597 |
|
|
|
598 |
|
|
task chk_err;
|
599 |
|
|
input samebank;
|
600 |
|
|
input [BA_BITS-1:0] bank;
|
601 |
|
|
input [3:0] fromcmd;
|
602 |
|
|
input [3:0] cmd;
|
603 |
|
|
reg err;
|
604 |
|
|
begin
|
605 |
|
|
// all matching case expressions will be evaluated
|
606 |
|
|
casex ({samebank, fromcmd, cmd})
|
607 |
|
|
{1'b0, LOAD_MODE, 4'b0xxx } : begin if (ck_cntr - ck_load_mode < TMRD) $display ("%m: at time %t ERROR: tMRD violation during %s", $time, cmd_string[cmd]); end
|
608 |
|
|
{1'b0, LOAD_MODE, 4'b100x } : begin if (ck_cntr - ck_load_mode < TMRD) begin $display ("%m: at time %t INFO: Load Mode to Reset condition.", $time); init_done = 0; end end
|
609 |
|
|
{1'b0, REFRESH , 4'b0xxx } : begin if ($time - tm_refresh < TRFC_MIN) $display ("%m: at time %t ERROR: tRFC violation during %s", $time, cmd_string[cmd]); end
|
610 |
|
|
{1'b0, REFRESH , PWR_DOWN } : ; // 1 tCK
|
611 |
|
|
{1'b0, REFRESH , SELF_REF } : begin if ($time - tm_refresh < TRFC_MIN) begin $display ("%m: at time %t INFO: Refresh to Reset condition", $time); init_done = 0; end end
|
612 |
|
|
{1'b0, PRECHARGE, 4'b000x } : begin if ($time - tm_precharge_all < TRPA) $display ("%m: at time %t ERROR: tRPA violation during %s", $time, cmd_string[cmd]);
|
613 |
|
|
if ($time - tm_precharge < TRP) $display ("%m: at time %t ERROR: tRP violation during %s", $time, cmd_string[cmd]); end
|
614 |
|
|
{1'b1, PRECHARGE, PRECHARGE} : begin if (DEBUG && ($time - tm_precharge_all < TRPA)) $display ("%m: at time %t INFO: Precharge All interruption during %s", $time, cmd_string[cmd]);
|
615 |
|
|
if (DEBUG && ($time - tm_bank_precharge[bank] < TRP)) $display ("%m: at time %t INFO: Precharge bank %d interruption during %s", $time, cmd_string[cmd], bank); end
|
616 |
|
|
{1'b1, PRECHARGE, ACTIVATE } : begin if ($time - tm_precharge_all < TRPA) $display ("%m: at time %t ERROR: tRPA violation during %s", $time, cmd_string[cmd]);
|
617 |
|
|
if ($time - tm_bank_precharge[bank] < TRP) $display ("%m: at time %t ERROR: tRP violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
618 |
|
|
{1'b0, PRECHARGE, PWR_DOWN } : ; //1 tCK, can be concurrent with auto precharge
|
619 |
|
|
{1'b0, PRECHARGE, SELF_REF } : begin if (($time - tm_precharge_all < TRPA) || ($time - tm_precharge < TRP)) begin $display ("%m: at time %t INFO: Precharge to Reset condition", $time); init_done = 0; end end
|
620 |
|
|
{1'b0, ACTIVATE , REFRESH } : begin if ($time - tm_activate < TRC) $display ("%m: at time %t ERROR: tRC violation during %s", $time, cmd_string[cmd]); end
|
621 |
|
|
{1'b1, ACTIVATE , PRECHARGE} : begin if (($time - tm_bank_activate[bank] > TRAS_MAX) && (active_bank[bank] === 1'b1)) $display ("%m: at time %t ERROR: tRAS maximum violation during %s to bank %d", $time, cmd_string[cmd], bank);
|
622 |
|
|
if ($time - tm_bank_activate[bank] < TRAS_MIN) $display ("%m: at time %t ERROR: tRAS minimum violation during %s to bank %d", $time, cmd_string[cmd], bank);end
|
623 |
|
|
{1'b0, ACTIVATE , ACTIVATE } : begin if ($time - tm_activate < TRRD) $display ("%m: at time %t ERROR: tRRD violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
624 |
|
|
{1'b1, ACTIVATE , ACTIVATE } : begin if ($time - tm_bank_activate[bank] < TRC) $display ("%m: at time %t ERROR: tRC violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
625 |
|
|
{1'b1, ACTIVATE , 4'b010x } : ; // tRCD is checked outside this task
|
626 |
|
|
{1'b1, ACTIVATE , PWR_DOWN } : ; // 1 tCK
|
627 |
|
|
{1'b1, WRITE , PRECHARGE} : begin if ((ck_cntr - ck_bank_write[bank] <= write_latency + burst_length/2) || ($time - tm_bank_write_end[bank] < TWR)) $display ("%m: at time %t ERROR: tWR violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
628 |
|
|
{1'b0, WRITE , WRITE } : begin if (ck_cntr - ck_write < TCCD) $display ("%m: at time %t ERROR: tCCD violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
629 |
|
|
{1'b0, WRITE , READ } : begin if ((ck_load_mode < ck_write) && (ck_cntr - ck_write < write_latency + burst_length/2 + 2 - additive_latency)) $display ("%m: at time %t ERROR: tWTR violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
630 |
|
|
{1'b0, WRITE , PWR_DOWN } : begin if ((ck_load_mode < ck_write) && (
|
631 |
|
|
|write_precharge_bank
|
632 |
|
|
|| (ck_cntr - ck_write_ap < 1)
|
633 |
|
|
|| (ck_cntr - ck_write < write_latency + burst_length/2 + 2)
|
634 |
|
|
|| ($time - tm_write_end < TWTR))) begin $display ("%m: at time %t INFO: Write to Reset condition", $time); init_done = 0; end end
|
635 |
|
|
{1'b1, READ , PRECHARGE} : begin if ((ck_cntr - ck_bank_read[bank] < additive_latency + burst_length/2) || ($time - tm_bank_read_end[bank] < TRTP)) $display ("%m: at time %t ERROR: tRTP violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
636 |
|
|
{1'b0, READ , WRITE } : begin if ((ck_load_mode < ck_read) && (ck_cntr - ck_read < read_latency + burst_length/2 + 1 - write_latency)) $display ("%m: at time %t ERROR: tRTW violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
637 |
|
|
{1'b0, READ , READ } : begin if (ck_cntr - ck_read < TCCD) $display ("%m: at time %t ERROR: tCCD violation during %s to bank %d", $time, cmd_string[cmd], bank); end
|
638 |
|
|
{1'b0, READ , PWR_DOWN } : begin if ((ck_load_mode < ck_read) && (ck_cntr - ck_read < read_latency + burst_length/2 + 1)) begin $display ("%m: at time %t INFO: Read to Reset condition", $time); init_done = 0; end end
|
639 |
|
|
{1'b0, PWR_DOWN , 4'b00xx } : begin if (ck_cntr - ck_power_down < TXP) $display ("%m: at time %t ERROR: tXP violation during %s", $time, cmd_string[cmd]); end
|
640 |
|
|
{1'b0, PWR_DOWN , WRITE } : begin if (ck_cntr - ck_power_down < TXP) $display ("%m: at time %t ERROR: tXP violation during %s", $time, cmd_string[cmd]); end
|
641 |
|
|
{1'b0, PWR_DOWN , READ } : begin if (ck_cntr - ck_slow_exit_pd < TXARDS - additive_latency) $display ("%m: at time %t ERROR: tXARDS violation during %s", $time, cmd_string[cmd]);
|
642 |
|
|
else if (ck_cntr - ck_power_down < TXARD) $display ("%m: at time %t ERROR: tXARD violation during %s", $time, cmd_string[cmd]); end
|
643 |
|
|
{1'b0, SELF_REF , 4'b00xx } : begin if ($time - tm_self_refresh < TXSNR) $display ("%m: at time %t ERROR: tXSNR violation during %s", $time, cmd_string[cmd]); end
|
644 |
|
|
{1'b0, SELF_REF , WRITE } : begin if ($time - tm_self_refresh < TXSNR) $display ("%m: at time %t ERROR: tXSNR violation during %s", $time, cmd_string[cmd]); end
|
645 |
|
|
{1'b0, SELF_REF , READ } : begin if (ck_cntr - ck_self_refresh < TXSRD) $display ("%m: at time %t ERROR: tXSRD violation during %s", $time, cmd_string[cmd]); end
|
646 |
|
|
{1'b0, 4'b100x , 4'b100x } : begin if (ck_cntr - ck_cke < TCKE) begin $display ("%m: at time %t ERROR: tCKE violation on CKE", $time); init_done = 0; end end
|
647 |
|
|
endcase
|
648 |
|
|
end
|
649 |
|
|
endtask
|
650 |
|
|
|
651 |
|
|
task cmd_task;
|
652 |
|
|
input cke;
|
653 |
|
|
input [2:0] cmd;
|
654 |
|
|
input [BA_BITS-1:0] bank;
|
655 |
|
|
input [ADDR_BITS-1:0] addr;
|
656 |
|
|
reg [`BANKS:0] i;
|
657 |
|
|
integer j;
|
658 |
|
|
reg [`BANKS:0] tfaw_cntr;
|
659 |
|
|
reg [COL_BITS-1:0] col;
|
660 |
|
|
begin
|
661 |
|
|
|
662 |
|
|
// tRFC max check
|
663 |
|
|
if (!er_trfc_max && !in_self_refresh) begin
|
664 |
|
|
if ($time - tm_refresh > TRFC_MAX) begin
|
665 |
|
|
$display ("%m: at time %t ERROR: tRFC maximum violation during %s", $time, cmd_string[cmd]);
|
666 |
|
|
er_trfc_max = 1;
|
667 |
|
|
end
|
668 |
|
|
end
|
669 |
|
|
if (cke) begin
|
670 |
|
|
if ((cmd < NOP) && ((cmd != PRECHARGE) || !addr[AP])) begin
|
671 |
|
|
for (j=0; j<NOP; j=j+1) begin
|
672 |
|
|
chk_err(1'b0, bank, j, cmd);
|
673 |
|
|
chk_err(1'b1, bank, j, cmd);
|
674 |
|
|
end
|
675 |
|
|
chk_err(1'b0, bank, PWR_DOWN, cmd);
|
676 |
|
|
chk_err(1'b0, bank, SELF_REF, cmd);
|
677 |
|
|
end
|
678 |
|
|
|
679 |
|
|
case (cmd)
|
680 |
|
|
LOAD_MODE : begin
|
681 |
|
|
if (|active_bank) begin
|
682 |
|
|
$display ("%m: at time %t ERROR: %s Failure. All banks must be Precharged.", $time, cmd_string[cmd]);
|
683 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
684 |
|
|
end else begin
|
685 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d", $time, cmd_string[cmd], bank);
|
686 |
|
|
case (bank)
|
687 |
|
|
|
688 |
|
|
// Burst Length
|
689 |
|
|
burst_length = 1<<addr[2:0];
|
690 |
|
|
if ((burst_length >= BL_MIN) && (burst_length <= BL_MAX)) begin
|
691 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Length = %d", $time, cmd_string[cmd], bank, burst_length);
|
692 |
|
|
end else begin
|
693 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Burst Length = %d", $time, cmd_string[cmd], bank, burst_length);
|
694 |
|
|
end
|
695 |
|
|
// Burst Order
|
696 |
|
|
burst_order = addr[3];
|
697 |
|
|
if (!burst_order) begin
|
698 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Order = Sequential", $time, cmd_string[cmd], bank);
|
699 |
|
|
end else if (burst_order) begin
|
700 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Order = Interleaved", $time, cmd_string[cmd], bank);
|
701 |
|
|
end else begin
|
702 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Burst Order = %d", $time, cmd_string[cmd], bank, burst_order);
|
703 |
|
|
end
|
704 |
|
|
// CAS Latency
|
705 |
|
|
cas_latency = addr[6:4];
|
706 |
|
|
read_latency = cas_latency + additive_latency;
|
707 |
|
|
write_latency = read_latency - 1;
|
708 |
|
|
if ((cas_latency >= CL_MIN) && (cas_latency <= CL_MAX)) begin
|
709 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d CAS Latency = %d", $time, cmd_string[cmd], bank, cas_latency);
|
710 |
|
|
end else begin
|
711 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal CAS Latency = %d", $time, cmd_string[cmd], bank, cas_latency);
|
712 |
|
|
end
|
713 |
|
|
// Test Mode
|
714 |
|
|
if (!addr[7]) begin
|
715 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Test Mode = Normal", $time, cmd_string[cmd], bank);
|
716 |
|
|
end else begin
|
717 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Test Mode = %d", $time, cmd_string[cmd], bank, addr[7]);
|
718 |
|
|
end
|
719 |
|
|
// DLL Reset
|
720 |
|
|
dll_reset = addr[8];
|
721 |
|
|
if (!dll_reset) begin
|
722 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Reset = Normal", $time, cmd_string[cmd], bank);
|
723 |
|
|
end else if (dll_reset) begin
|
724 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Reset = Reset DLL", $time, cmd_string[cmd], bank);
|
725 |
|
|
dll_locked = 0;
|
726 |
|
|
ck_dll_reset <= ck_cntr;
|
727 |
|
|
end else begin
|
728 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal DLL Reset = %d", $time, cmd_string[cmd], bank, dll_reset);
|
729 |
|
|
end
|
730 |
|
|
// Write Recovery
|
731 |
|
|
write_recovery = addr[11:9] + 1;
|
732 |
|
|
if ((write_recovery >= WR_MIN) && (write_recovery <= WR_MAX)) begin
|
733 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Write Recovery = %d", $time, cmd_string[cmd], bank, write_recovery);
|
734 |
|
|
end else begin
|
735 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Write Recovery = %d", $time, cmd_string[cmd], bank, write_recovery);
|
736 |
|
|
end
|
737 |
|
|
// Power Down Mode
|
738 |
|
|
low_power = addr[12];
|
739 |
|
|
if (!low_power) begin
|
740 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Power Down Mode = Fast Exit", $time, cmd_string[cmd], bank);
|
741 |
|
|
end else if (low_power) begin
|
742 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Power Down Mode = Slow Exit", $time, cmd_string[cmd], bank);
|
743 |
|
|
end else begin
|
744 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Power Down Mode = %d", $time, cmd_string[cmd], bank, low_power);
|
745 |
|
|
end
|
746 |
|
|
end
|
747 |
|
|
1 : begin
|
748 |
|
|
// DLL Enable
|
749 |
|
|
dll_en = !addr[0];
|
750 |
|
|
if (!dll_en) begin
|
751 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Enable = Disabled", $time, cmd_string[cmd], bank);
|
752 |
|
|
end else if (dll_en) begin
|
753 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Enable = Enabled", $time, cmd_string[cmd], bank);
|
754 |
|
|
end else begin
|
755 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal DLL Enable = %d", $time, cmd_string[cmd], bank, dll_en);
|
756 |
|
|
end
|
757 |
|
|
// Output Drive Strength
|
758 |
|
|
if (!addr[1]) begin
|
759 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Drive Strength = Full", $time, cmd_string[cmd], bank);
|
760 |
|
|
end else if (addr[1]) begin
|
761 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Drive Strength = Reduced", $time, cmd_string[cmd], bank);
|
762 |
|
|
end else begin
|
763 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Output Drive Strength = %d", $time, cmd_string[cmd], bank, addr[1]);
|
764 |
|
|
end
|
765 |
|
|
// ODT Rtt
|
766 |
|
|
odt_rtt = {addr[6], addr[2]};
|
767 |
|
|
if (odt_rtt == 2'b00) begin
|
768 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d ODT Rtt = Disabled", $time, cmd_string[cmd], bank);
|
769 |
|
|
odt_en = 0;
|
770 |
|
|
end else if (odt_rtt == 2'b01) begin
|
771 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d ODT Rtt = 75 Ohm", $time, cmd_string[cmd], bank);
|
772 |
|
|
odt_en = 1;
|
773 |
|
|
tm_odt_en <= $time;
|
774 |
|
|
end else if (odt_rtt == 2'b10) begin
|
775 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d ODT Rtt = 150 Ohm", $time, cmd_string[cmd], bank);
|
776 |
|
|
odt_en = 1;
|
777 |
|
|
tm_odt_en <= $time;
|
778 |
|
|
end else if (odt_rtt == 2'b11) begin
|
779 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d ODT Rtt = 50 Ohm", $time, cmd_string[cmd], bank);
|
780 |
|
|
odt_en = 1;
|
781 |
|
|
tm_odt_en <= $time;
|
782 |
|
|
end else begin
|
783 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal ODT Rtt = %d", $time, cmd_string[cmd], bank, odt_rtt);
|
784 |
|
|
odt_en = 0;
|
785 |
|
|
end
|
786 |
|
|
// Additive Latency
|
787 |
|
|
additive_latency = addr[5:3];
|
788 |
|
|
read_latency = cas_latency + additive_latency;
|
789 |
|
|
write_latency = read_latency - 1;
|
790 |
|
|
if ((additive_latency >= AL_MIN) && (additive_latency <= AL_MAX)) begin
|
791 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Additive Latency = %d", $time, cmd_string[cmd], bank, additive_latency);
|
792 |
|
|
end else begin
|
793 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Additive Latency = %d", $time, cmd_string[cmd], bank, additive_latency);
|
794 |
|
|
end
|
795 |
|
|
// OCD Program
|
796 |
|
|
ocd = addr[9:7];
|
797 |
|
|
if (ocd == 3'b000) begin
|
798 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d OCD Program = OCD Exit", $time, cmd_string[cmd], bank);
|
799 |
|
|
end else if (ocd == 3'b111) begin
|
800 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d OCD Program = OCD Default", $time, cmd_string[cmd], bank);
|
801 |
|
|
end else begin
|
802 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal OCD Program = %b", $time, cmd_string[cmd], bank, ocd);
|
803 |
|
|
end
|
804 |
|
|
|
805 |
|
|
// DQS_N Enable
|
806 |
|
|
dqs_n_en = !addr[10];
|
807 |
|
|
if (!dqs_n_en) begin
|
808 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d DQS_N Enable = Disabled", $time, cmd_string[cmd], bank);
|
809 |
|
|
end else if (dqs_n_en) begin
|
810 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d DQS_N Enable = Enabled", $time, cmd_string[cmd], bank);
|
811 |
|
|
end else begin
|
812 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal DQS_N Enable = %d", $time, cmd_string[cmd], bank, dqs_n_en);
|
813 |
|
|
end
|
814 |
|
|
// RDQS Enable
|
815 |
|
|
rdqs_en = addr[11];
|
816 |
|
|
if (!rdqs_en) begin
|
817 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d RDQS Enable = Disabled", $time, cmd_string[cmd], bank);
|
818 |
|
|
end else if (rdqs_en) begin
|
819 |
|
|
`ifdef x8
|
820 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d RDQS Enable = Enabled", $time, cmd_string[cmd], bank);
|
821 |
|
|
`else
|
822 |
|
|
$display ("%m: at time %t WARNING: %s %d Illegal RDQS Enable. RDQS only exists on a x8 part", $time, cmd_string[cmd], bank);
|
823 |
|
|
rdqs_en = 0;
|
824 |
|
|
`endif
|
825 |
|
|
end else begin
|
826 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal RDQS Enable = %d", $time, cmd_string[cmd], bank, rdqs_en);
|
827 |
|
|
end
|
828 |
|
|
// Output Enable
|
829 |
|
|
out_en = !addr[12];
|
830 |
|
|
if (!out_en) begin
|
831 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Enable = Disabled", $time, cmd_string[cmd], bank);
|
832 |
|
|
end else if (out_en) begin
|
833 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Enable = Enabled", $time, cmd_string[cmd], bank);
|
834 |
|
|
end else begin
|
835 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal Output Enable = %d", $time, cmd_string[cmd], bank, out_en);
|
836 |
|
|
end
|
837 |
|
|
end
|
838 |
|
|
2 : begin
|
839 |
|
|
// High Temperature Self Refresh rate
|
840 |
|
|
if (!addr[7]) begin
|
841 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d High Temperature Self Refresh rate = Disabled", $time, cmd_string[cmd], bank);
|
842 |
|
|
end else if (addr[1]) begin
|
843 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s %d High Temperature Self Refresh rate = Enabled", $time, cmd_string[cmd], bank);
|
844 |
|
|
end else begin
|
845 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal High Temperature Self Refresh rate = %d", $time, cmd_string[cmd], bank, addr[7]);
|
846 |
|
|
end
|
847 |
|
|
if ((addr & ~(1<<7)) !== 0) begin
|
848 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal value. Reserved bits must be programmed to zero", $time, cmd_string[cmd], bank);
|
849 |
|
|
end
|
850 |
|
|
end
|
851 |
|
|
3 : begin
|
852 |
|
|
if (addr !== 0) begin
|
853 |
|
|
$display ("%m: at time %t ERROR: %s %d Illegal value. Reserved bits must be programmed to zero", $time, cmd_string[cmd], bank);
|
854 |
|
|
end
|
855 |
|
|
end
|
856 |
|
|
endcase
|
857 |
|
|
init_mode_reg[bank] = 1;
|
858 |
|
|
ck_load_mode <= ck_cntr;
|
859 |
|
|
end
|
860 |
|
|
end
|
861 |
|
|
REFRESH : begin
|
862 |
|
|
if (|active_bank) begin
|
863 |
|
|
$display ("%m: at time %t ERROR: %s Failure. All banks must be Precharged.", $time, cmd_string[cmd]);
|
864 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
865 |
|
|
end else begin
|
866 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s", $time, cmd_string[cmd]);
|
867 |
|
|
er_trfc_max = 0;
|
868 |
|
|
ref_cntr = ref_cntr + 1;
|
869 |
|
|
tm_refresh <= $time;
|
870 |
|
|
end
|
871 |
|
|
end
|
872 |
|
|
PRECHARGE : begin
|
873 |
|
|
if (addr[AP]) begin
|
874 |
|
|
// tRPA timing applies when the PRECHARGE (ALL) command is issued, regardless of
|
875 |
|
|
// the number of banks already open or closed.
|
876 |
|
|
for (i=0; i<`BANKS; i=i+1) begin
|
877 |
|
|
for (j=0; j<NOP; j=j+1) begin
|
878 |
|
|
chk_err(1'b0, i, j, cmd);
|
879 |
|
|
chk_err(1'b1, i, j, cmd);
|
880 |
|
|
end
|
881 |
|
|
chk_err(1'b0, i, PWR_DOWN, cmd);
|
882 |
|
|
chk_err(1'b0, i, SELF_REF, cmd);
|
883 |
|
|
end
|
884 |
|
|
if (|auto_precharge_bank) begin
|
885 |
|
|
$display ("%m: at time %t ERROR: %s All Failure. Auto Precharge is scheduled.", $time, cmd_string[cmd]);
|
886 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
887 |
|
|
end else begin
|
888 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s All", $time, cmd_string[cmd]);
|
889 |
|
|
active_bank = 0;
|
890 |
|
|
tm_precharge_all <= $time;
|
891 |
|
|
end
|
892 |
|
|
end else begin
|
893 |
|
|
// A PRECHARGE command is allowed if there is no open row in that bank (idle state)
|
894 |
|
|
// or if the previously open row is already in the process of precharging.
|
895 |
|
|
// However, the precharge period will be determined by the last PRECHARGE command issued to the bank.
|
896 |
|
|
if (auto_precharge_bank[bank]) begin
|
897 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Auto Precharge is scheduled to bank %d.", $time, cmd_string[cmd], bank);
|
898 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
899 |
|
|
end else begin
|
900 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s bank %d", $time, cmd_string[cmd], bank);
|
901 |
|
|
active_bank[bank] = 1'b0;
|
902 |
|
|
tm_bank_precharge[bank] <= $time;
|
903 |
|
|
tm_precharge <= $time;
|
904 |
|
|
end
|
905 |
|
|
end
|
906 |
|
|
end
|
907 |
|
|
ACTIVATE : begin
|
908 |
|
|
if (`BANKS == 8) begin
|
909 |
|
|
tfaw_cntr = 0;
|
910 |
|
|
for (i=0; i<`BANKS; i=i+1) begin
|
911 |
|
|
if ($time - tm_bank_activate[i] < TFAW) begin
|
912 |
|
|
tfaw_cntr = tfaw_cntr + 1;
|
913 |
|
|
end
|
914 |
|
|
end
|
915 |
|
|
if (tfaw_cntr > 3) begin
|
916 |
|
|
$display ("%m: at time %t ERROR: tFAW violation during %s to bank %d", $time, cmd_string[cmd], bank);
|
917 |
|
|
end
|
918 |
|
|
end
|
919 |
|
|
|
920 |
|
|
if (!init_done) begin
|
921 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Initialization sequence is not complete.", $time, cmd_string[cmd]);
|
922 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
923 |
|
|
end else if (active_bank[bank]) begin
|
924 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Bank %d must be Precharged.", $time, cmd_string[cmd], bank);
|
925 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
926 |
|
|
end else begin
|
927 |
|
|
if (addr >= 1<<ROW_BITS) begin
|
928 |
|
|
$display ("%m: at time %t WARNING: row = %h does not exist. Maximum row = %h", $time, addr, (1<<ROW_BITS)-1);
|
929 |
|
|
end
|
930 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s bank %d row %h", $time, cmd_string[cmd], bank, addr);
|
931 |
|
|
active_bank[bank] = 1'b1;
|
932 |
|
|
active_row[bank] = addr;
|
933 |
|
|
tm_bank_activate[bank] <= $time;
|
934 |
|
|
tm_activate <= $time;
|
935 |
|
|
end
|
936 |
|
|
|
937 |
|
|
end
|
938 |
|
|
WRITE : begin
|
939 |
|
|
if (!init_done) begin
|
940 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Initialization sequence is not complete.", $time, cmd_string[cmd]);
|
941 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
942 |
|
|
end else if (!active_bank[bank]) begin
|
943 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Bank %d must be Activated.", $time, cmd_string[cmd], bank);
|
944 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
945 |
|
|
end else if (auto_precharge_bank[bank]) begin
|
946 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Auto Precharge is scheduled to bank %d.", $time, cmd_string[cmd], bank);
|
947 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
948 |
|
|
end else if ((ck_cntr - ck_write < burst_length/2) && (ck_cntr - ck_write)%2) begin
|
949 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Illegal burst interruption.", $time, cmd_string[cmd]);
|
950 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
951 |
|
|
end else begin
|
952 |
|
|
if (addr[AP]) begin
|
953 |
|
|
auto_precharge_bank[bank] = 1'b1;
|
954 |
|
|
write_precharge_bank[bank] = 1'b1;
|
955 |
|
|
end
|
956 |
|
|
col = ((addr>>1) & -1*(1<<AP)) | (addr & {AP{1'b1}});
|
957 |
|
|
if (col >= 1<<COL_BITS) begin
|
958 |
|
|
$display ("%m: at time %t WARNING: col = %h does not exist. Maximum col = %h", $time, col, (1<<COL_BITS)-1);
|
959 |
|
|
end
|
960 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s bank %d col %h, auto precharge %d", $time, cmd_string[cmd], bank, col, addr[AP]);
|
961 |
|
|
wr_pipeline[2*write_latency + 1] = 1;
|
962 |
|
|
ba_pipeline[2*write_latency + 1] = bank;
|
963 |
|
|
row_pipeline[2*write_latency + 1] = active_row[bank];
|
964 |
|
|
col_pipeline[2*write_latency + 1] = col;
|
965 |
|
|
ck_bank_write[bank] <= ck_cntr;
|
966 |
|
|
ck_write <= ck_cntr;
|
967 |
|
|
end
|
968 |
|
|
end
|
969 |
|
|
READ : begin
|
970 |
|
|
if (!dll_locked)
|
971 |
|
|
$display ("%m: at time %t WARNING: %s prior to DLL locked. Failing to wait for synchronization to occur may result in a violation of the tAC or tDQSCK parameters.", $time, cmd_string[cmd]);
|
972 |
|
|
if (!init_done) begin
|
973 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Initialization sequence is not complete.", $time, cmd_string[cmd]);
|
974 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
975 |
|
|
end else if (!active_bank[bank]) begin
|
976 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Bank %d must be Activated.", $time, cmd_string[cmd], bank);
|
977 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
978 |
|
|
end else if (auto_precharge_bank[bank]) begin
|
979 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Auto Precharge is scheduled to bank %d.", $time, cmd_string[cmd], bank);
|
980 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
981 |
|
|
end else if ((ck_cntr - ck_read < burst_length/2) && (ck_cntr - ck_read)%2) begin
|
982 |
|
|
$display ("%m: at time %t ERROR: %s Failure. Illegal burst interruption.", $time, cmd_string[cmd]);
|
983 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
984 |
|
|
end else begin
|
985 |
|
|
if (addr[AP]) begin
|
986 |
|
|
auto_precharge_bank[bank] = 1'b1;
|
987 |
|
|
read_precharge_bank[bank] = 1'b1;
|
988 |
|
|
end
|
989 |
|
|
col = ((addr>>1) & -1*(1<<AP)) | (addr & {AP{1'b1}});
|
990 |
|
|
if (col >= 1<<COL_BITS) begin
|
991 |
|
|
$display ("%m: at time %t WARNING: col = %h does not exist. Maximum col = %h", $time, col, (1<<COL_BITS)-1);
|
992 |
|
|
end
|
993 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: %s bank %d col %h, auto precharge %d", $time, cmd_string[cmd], bank, col, addr[AP]);
|
994 |
|
|
rd_pipeline[2*read_latency - 1] = 1;
|
995 |
|
|
ba_pipeline[2*read_latency - 1] = bank;
|
996 |
|
|
row_pipeline[2*read_latency - 1] = active_row[bank];
|
997 |
|
|
col_pipeline[2*read_latency - 1] = col;
|
998 |
|
|
ck_bank_read[bank] <= ck_cntr;
|
999 |
|
|
ck_read <= ck_cntr;
|
1000 |
|
|
end
|
1001 |
|
|
end
|
1002 |
|
|
NOP: begin
|
1003 |
|
|
if (in_power_down) begin
|
1004 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Power Down Exit", $time);
|
1005 |
|
|
in_power_down = 0;
|
1006 |
|
|
if (|active_bank & low_power) begin // slow exit active power down
|
1007 |
|
|
ck_slow_exit_pd <= ck_cntr;
|
1008 |
|
|
end
|
1009 |
|
|
ck_power_down <= ck_cntr;
|
1010 |
|
|
end
|
1011 |
|
|
if (in_self_refresh) begin
|
1012 |
|
|
if ($time - tm_cke < TISXR)
|
1013 |
|
|
$display ("%m: at time %t ERROR: tISXR violation during Self Refresh Exit", $time);
|
1014 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Self Refresh Exit", $time);
|
1015 |
|
|
in_self_refresh = 0;
|
1016 |
|
|
ck_dll_reset <= ck_cntr;
|
1017 |
|
|
ck_self_refresh <= ck_cntr;
|
1018 |
|
|
tm_self_refresh <= $time;
|
1019 |
|
|
tm_refresh <= $time;
|
1020 |
|
|
end
|
1021 |
|
|
end
|
1022 |
|
|
endcase
|
1023 |
|
|
if ((prev_cke !== 1) && (cmd !== NOP)) begin
|
1024 |
|
|
$display ("%m: at time %t ERROR: NOP or Deselect is required when CKE goes active.", $time);
|
1025 |
|
|
end
|
1026 |
|
|
if (!init_done) begin
|
1027 |
|
|
case (init_step)
|
1028 |
|
|
|
1029 |
|
|
if ($time < 200000000)
|
1030 |
|
|
$display ("%m: at time %t WARNING: 200 us is required before CKE goes active.", $time);
|
1031 |
|
|
// if (cmd_chk + 200000000 > $time)
|
1032 |
|
|
// $display("%m: at time %t WARNING: NOP or DESELECT is required for 200 us before CKE is brought high", $time);
|
1033 |
|
|
init_step = init_step + 1;
|
1034 |
|
|
end
|
1035 |
|
|
1 : if (dll_en) init_step = init_step + 1;
|
1036 |
|
|
2 : begin
|
1037 |
|
|
if (&init_mode_reg && dll_reset) begin
|
1038 |
|
|
active_bank = {`BANKS{1'b1}}; // require Precharge All or bank Precharges
|
1039 |
|
|
ref_cntr = 0; // require refresh
|
1040 |
|
|
init_step = init_step + 1;
|
1041 |
|
|
end
|
1042 |
|
|
end
|
1043 |
|
|
3 : if (ref_cntr == 2) begin
|
1044 |
|
|
init_step = init_step + 1;
|
1045 |
|
|
end
|
1046 |
|
|
4 : if (!dll_reset) init_step = init_step + 1;
|
1047 |
|
|
5 : if (ocd == 3'b111) init_step = init_step + 1;
|
1048 |
|
|
6 : begin
|
1049 |
|
|
if (ocd == 3'b000) begin
|
1050 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Initialization Sequence is complete", $time);
|
1051 |
|
|
init_done = 1;
|
1052 |
|
|
end
|
1053 |
|
|
end
|
1054 |
|
|
endcase
|
1055 |
|
|
end
|
1056 |
|
|
end else if (prev_cke) begin
|
1057 |
|
|
if ((!init_done) && (init_step > 1)) begin
|
1058 |
|
|
$display ("%m: at time %t ERROR: CKE must remain active until the initialization sequence is complete.", $time);
|
1059 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
1060 |
|
|
end
|
1061 |
|
|
case (cmd)
|
1062 |
|
|
REFRESH : begin
|
1063 |
|
|
for (j=0; j<NOP; j=j+1) begin
|
1064 |
|
|
chk_err(1'b0, bank, j, SELF_REF);
|
1065 |
|
|
end
|
1066 |
|
|
chk_err(1'b0, bank, PWR_DOWN, SELF_REF);
|
1067 |
|
|
chk_err(1'b0, bank, SELF_REF, SELF_REF);
|
1068 |
|
|
if (|active_bank) begin
|
1069 |
|
|
$display ("%m: at time %t ERROR: Self Refresh Failure. All banks must be Precharged.", $time);
|
1070 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
1071 |
|
|
init_done = 0;
|
1072 |
|
|
end else if (odt_en && odt_state) begin
|
1073 |
|
|
$display ("%m: at time %t ERROR: ODT must be off prior to entering Self Refresh", $time);
|
1074 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
1075 |
|
|
init_done = 0;
|
1076 |
|
|
end else if (!init_done) begin
|
1077 |
|
|
$display ("%m: at time %t ERROR: Self Refresh Failure. Initialization sequence is not complete.", $time);
|
1078 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
1079 |
|
|
end else begin
|
1080 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Self Refresh Enter", $time);
|
1081 |
|
|
in_self_refresh = 1;
|
1082 |
|
|
dll_locked = 0;
|
1083 |
|
|
end
|
1084 |
|
|
end
|
1085 |
|
|
NOP : begin
|
1086 |
|
|
// entering slow_exit or precharge power down and tANPD has not been satisfied
|
1087 |
|
|
if ((low_power || (active_bank == 0)) && (ck_cntr - ck_odt < TANPD))
|
1088 |
|
|
$display ("%m: at time %t WARNING: tANPD violation during %s. Synchronous or asynchronous change in termination resistance is possible.", $time, cmd_string[PWR_DOWN]);
|
1089 |
|
|
for (j=0; j<NOP; j=j+1) begin
|
1090 |
|
|
chk_err(1'b0, bank, j, PWR_DOWN);
|
1091 |
|
|
end
|
1092 |
|
|
chk_err(1'b0, bank, PWR_DOWN, PWR_DOWN);
|
1093 |
|
|
chk_err(1'b0, bank, SELF_REF, PWR_DOWN);
|
1094 |
|
|
|
1095 |
|
|
if (!init_done) begin
|
1096 |
|
|
$display ("%m: at time %t ERROR: Power Down Failure. Initialization sequence is not complete.", $time);
|
1097 |
|
|
if (STOP_ON_ERROR) $stop(0);
|
1098 |
|
|
end else begin
|
1099 |
|
|
if (DEBUG) begin
|
1100 |
|
|
if (|active_bank) begin
|
1101 |
|
|
$display ("%m: at time %t INFO: Active Power Down Enter", $time);
|
1102 |
|
|
end else begin
|
1103 |
|
|
$display ("%m: at time %t INFO: Precharge Power Down Enter", $time);
|
1104 |
|
|
end
|
1105 |
|
|
end
|
1106 |
|
|
in_power_down = 1;
|
1107 |
|
|
end
|
1108 |
|
|
end
|
1109 |
|
|
default : begin
|
1110 |
|
|
$display ("%m: at time %t ERROR: NOP, Deselect, or Refresh is required when CKE goes inactive.", $time);
|
1111 |
|
|
init_done = 0;
|
1112 |
|
|
end
|
1113 |
|
|
endcase
|
1114 |
|
|
if (!init_done) begin
|
1115 |
|
|
if (DEBUG) $display ("%m: at time %t WARNING: Reset has occurred. Device must be re-initialized.", $time);
|
1116 |
|
|
reset_task;
|
1117 |
|
|
end
|
1118 |
|
|
end
|
1119 |
|
|
prev_cke = cke;
|
1120 |
|
|
end
|
1121 |
|
|
endtask
|
1122 |
|
|
|
1123 |
|
|
task data_task;
|
1124 |
|
|
reg [BA_BITS-1:0] bank;
|
1125 |
|
|
reg [ROW_BITS-1:0] row;
|
1126 |
|
|
reg [COL_BITS-1:0] col;
|
1127 |
|
|
integer i;
|
1128 |
|
|
integer j;
|
1129 |
|
|
begin
|
1130 |
|
|
|
1131 |
|
|
if (diff_ck) begin
|
1132 |
|
|
for (i=0; i<36; i=i+1) begin
|
1133 |
|
|
if (dq_in_valid && dll_locked && ($time - tm_dqs_neg[i] < $rtoi(TDSS*tck_avg)))
|
1134 |
|
|
$display ("%m: at time %t ERROR: tDSS violation on %s bit %d", $time, dqs_string[i/18], i%18);
|
1135 |
|
|
if (check_write_dqs_high[i])
|
1136 |
|
|
$display ("%m: at time %t ERROR: %s bit %d latching edge required during the preceding clock period.", $time, dqs_string[i/18], i%18);
|
1137 |
|
|
end
|
1138 |
|
|
check_write_dqs_high <= 0;
|
1139 |
|
|
end else begin
|
1140 |
|
|
for (i=0; i<36; i=i+1) begin
|
1141 |
|
|
if (dll_locked && dq_in_valid) begin
|
1142 |
|
|
tm_tdqss = abs_value(1.0*tm_ck_pos - tm_dqss_pos[i]);
|
1143 |
|
|
if ((tm_tdqss < tck_avg/2.0) && (tm_tdqss > TDQSS*tck_avg))
|
1144 |
|
|
$display ("%m: at time %t ERROR: tDQSS violation on %s bit %d", $time, dqs_string[i/18], i%18);
|
1145 |
|
|
end
|
1146 |
|
|
if (check_write_dqs_low[i])
|
1147 |
|
|
$display ("%m: at time %t ERROR: %s bit %d latching edge required during the preceding clock period", $time, dqs_string[i/18], i%18);
|
1148 |
|
|
end
|
1149 |
|
|
check_write_preamble <= 0;
|
1150 |
|
|
check_write_postamble <= 0;
|
1151 |
|
|
check_write_dqs_low <= 0;
|
1152 |
|
|
end
|
1153 |
|
|
|
1154 |
|
|
if (wr_pipeline[0] || rd_pipeline[0]) begin
|
1155 |
|
|
bank = ba_pipeline[0];
|
1156 |
|
|
row = row_pipeline[0];
|
1157 |
|
|
col = col_pipeline[0];
|
1158 |
|
|
burst_cntr = 0;
|
1159 |
|
|
memory_read(bank, row, col, memory_data);
|
1160 |
|
|
end
|
1161 |
|
|
|
1162 |
|
|
// burst counter
|
1163 |
|
|
if (burst_cntr < burst_length) begin
|
1164 |
|
|
burst_position = col ^ burst_cntr;
|
1165 |
|
|
if (!burst_order) begin
|
1166 |
|
|
burst_position[BO_BITS-1:0] = col + burst_cntr;
|
1167 |
|
|
end
|
1168 |
|
|
burst_cntr = burst_cntr + 1;
|
1169 |
|
|
end
|
1170 |
|
|
|
1171 |
|
|
// write dqs counter
|
1172 |
|
|
if (wr_pipeline[WDQS_PRE + 1]) begin
|
1173 |
|
|
wdqs_cntr = WDQS_PRE + burst_length + WDQS_PST - 1;
|
1174 |
|
|
end
|
1175 |
|
|
// write dqs
|
1176 |
|
|
if ((wdqs_cntr == burst_length + WDQS_PST) && (wdq_cntr == 0)) begin //write preamble
|
1177 |
|
|
check_write_preamble <= ({DQS_BITS{dqs_n_en}}<<18) | {DQS_BITS{1'b1}};
|
1178 |
|
|
end
|
1179 |
|
|
if (wdqs_cntr > 1) begin // write data
|
1180 |
|
|
if ((wdqs_cntr - WDQS_PST)%2) begin
|
1181 |
|
|
check_write_dqs_high <= ({DQS_BITS{dqs_n_en}}<<18) | {DQS_BITS{1'b1}};
|
1182 |
|
|
end else begin
|
1183 |
|
|
check_write_dqs_low <= ({DQS_BITS{dqs_n_en}}<<18) | {DQS_BITS{1'b1}};
|
1184 |
|
|
end
|
1185 |
|
|
end
|
1186 |
|
|
if (wdqs_cntr == WDQS_PST) begin // write postamble
|
1187 |
|
|
check_write_postamble <= ({DQS_BITS{dqs_n_en}}<<18) | {DQS_BITS{1'b1}};
|
1188 |
|
|
end
|
1189 |
|
|
if (wdqs_cntr > 0) begin
|
1190 |
|
|
wdqs_cntr = wdqs_cntr - 1;
|
1191 |
|
|
end
|
1192 |
|
|
|
1193 |
|
|
// write dq
|
1194 |
|
|
if (dq_in_valid) begin // write data
|
1195 |
|
|
bit_mask = 0;
|
1196 |
|
|
if (diff_ck) begin
|
1197 |
|
|
for (i=0; i<DM_BITS; i=i+1) begin
|
1198 |
|
|
bit_mask = bit_mask | ({`DQ_PER_DQS{~dm_in_neg[i]}}<<(burst_position*DQ_BITS + i*`DQ_PER_DQS));
|
1199 |
|
|
end
|
1200 |
|
|
memory_data = (dq_in_neg<<(burst_position*DQ_BITS) & bit_mask) | (memory_data & ~bit_mask);
|
1201 |
|
|
end else begin
|
1202 |
|
|
for (i=0; i<DM_BITS; i=i+1) begin
|
1203 |
|
|
bit_mask = bit_mask | ({`DQ_PER_DQS{~dm_in_pos[i]}}<<(burst_position*DQ_BITS + i*`DQ_PER_DQS));
|
1204 |
|
|
end
|
1205 |
|
|
memory_data = (dq_in_pos<<(burst_position*DQ_BITS) & bit_mask) | (memory_data & ~bit_mask);
|
1206 |
|
|
end
|
1207 |
|
|
dq_temp = memory_data>>(burst_position*DQ_BITS);
|
1208 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: WRITE @ DQS= bank = %h row = %h col = %h data = %h",$time, bank, row, (-1*BL_MAX & col) + burst_position, dq_temp);
|
1209 |
|
|
if (burst_cntr%BL_MIN == 0) begin
|
1210 |
|
|
memory_write(bank, row, col, memory_data);
|
1211 |
|
|
end
|
1212 |
|
|
end
|
1213 |
|
|
if (wr_pipeline[1]) begin
|
1214 |
|
|
wdq_cntr = burst_length;
|
1215 |
|
|
end
|
1216 |
|
|
if (wdq_cntr > 0) begin
|
1217 |
|
|
wdq_cntr = wdq_cntr - 1;
|
1218 |
|
|
dq_in_valid = 1'b1;
|
1219 |
|
|
end else begin
|
1220 |
|
|
dq_in_valid = 1'b0;
|
1221 |
|
|
dqs_in_valid <= 1'b0;
|
1222 |
|
|
for (i=0; i<36; i=i+1) begin
|
1223 |
|
|
wdqs_pos_cntr[i] <= 0;
|
1224 |
|
|
end
|
1225 |
|
|
end
|
1226 |
|
|
if (wr_pipeline[0]) begin
|
1227 |
|
|
b2b_write <= 1'b0;
|
1228 |
|
|
end
|
1229 |
|
|
if (wr_pipeline[2]) begin
|
1230 |
|
|
if (dqs_in_valid) begin
|
1231 |
|
|
b2b_write <= 1'b1;
|
1232 |
|
|
end
|
1233 |
|
|
dqs_in_valid <= 1'b1;
|
1234 |
|
|
end
|
1235 |
|
|
// read dqs enable counter
|
1236 |
|
|
if (rd_pipeline[RDQSEN_PRE]) begin
|
1237 |
|
|
rdqsen_cntr = RDQSEN_PRE + burst_length + RDQSEN_PST - 1;
|
1238 |
|
|
end
|
1239 |
|
|
if (rdqsen_cntr > 0) begin
|
1240 |
|
|
rdqsen_cntr = rdqsen_cntr - 1;
|
1241 |
|
|
dqs_out_en = 1'b1;
|
1242 |
|
|
end else begin
|
1243 |
|
|
dqs_out_en = 1'b0;
|
1244 |
|
|
end
|
1245 |
|
|
|
1246 |
|
|
// read dqs counter
|
1247 |
|
|
if (rd_pipeline[RDQS_PRE]) begin
|
1248 |
|
|
rdqs_cntr = RDQS_PRE + burst_length + RDQS_PST - 1;
|
1249 |
|
|
end
|
1250 |
|
|
// read dqs
|
1251 |
|
|
if ((rdqs_cntr >= burst_length + RDQS_PST) && (rdq_cntr == 0)) begin //read preamble
|
1252 |
|
|
dqs_out = 1'b0;
|
1253 |
|
|
end else if (rdqs_cntr > RDQS_PST) begin // read data
|
1254 |
|
|
dqs_out = rdqs_cntr - RDQS_PST;
|
1255 |
|
|
end else if (rdqs_cntr > 0) begin // read postamble
|
1256 |
|
|
dqs_out = 1'b0;
|
1257 |
|
|
end else begin
|
1258 |
|
|
dqs_out = 1'b1;
|
1259 |
|
|
end
|
1260 |
|
|
if (rdqs_cntr > 0) begin
|
1261 |
|
|
rdqs_cntr = rdqs_cntr - 1;
|
1262 |
|
|
end
|
1263 |
|
|
|
1264 |
|
|
// read dq enable counter
|
1265 |
|
|
if (rd_pipeline[RDQEN_PRE]) begin
|
1266 |
|
|
rdqen_cntr = RDQEN_PRE + burst_length + RDQEN_PST;
|
1267 |
|
|
end
|
1268 |
|
|
if (rdqen_cntr > 0) begin
|
1269 |
|
|
rdqen_cntr = rdqen_cntr - 1;
|
1270 |
|
|
dq_out_en = 1'b1;
|
1271 |
|
|
end else begin
|
1272 |
|
|
dq_out_en = 1'b0;
|
1273 |
|
|
end
|
1274 |
|
|
// read dq
|
1275 |
|
|
if (rd_pipeline[0]) begin
|
1276 |
|
|
rdq_cntr = burst_length;
|
1277 |
|
|
end
|
1278 |
|
|
if (rdq_cntr > 0) begin // read data
|
1279 |
|
|
dq_temp = memory_data>>(burst_position*DQ_BITS);
|
1280 |
|
|
dq_out = dq_temp;
|
1281 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: READ @ DQS= bank = %h row = %h col = %h data = %h",$time, bank, row, (-1*BL_MAX & col) + burst_position, dq_temp);
|
1282 |
|
|
rdq_cntr = rdq_cntr - 1;
|
1283 |
|
|
end else begin
|
1284 |
|
|
dq_out = {DQ_BITS{1'b1}};
|
1285 |
|
|
end
|
1286 |
|
|
|
1287 |
|
|
// delay signals prior to output
|
1288 |
|
|
if (RANDOM_OUT_DELAY && (dqs_out_en || |dqs_out_en_dly || dq_out_en || |dq_out_en_dly)) begin
|
1289 |
|
|
for (i=0; i<DQS_BITS; i=i+1) begin
|
1290 |
|
|
// DQSCK requirements
|
1291 |
|
|
// 1.) less than tDQSCK
|
1292 |
|
|
// 2.) greater than -tDQSCK
|
1293 |
|
|
// 3.) cannot change more than tQHS + tDQSQ from previous DQS edge
|
1294 |
|
|
dqsck_max = TDQSCK;
|
1295 |
|
|
if (dqsck_max > dqsck[i] + TQHS + TDQSQ) begin
|
1296 |
|
|
dqsck_max = dqsck[i] + TQHS + TDQSQ;
|
1297 |
|
|
end
|
1298 |
|
|
dqsck_min = -1*TDQSCK;
|
1299 |
|
|
if (dqsck_min < dqsck[i] - TQHS - TDQSQ) begin
|
1300 |
|
|
dqsck_min = dqsck[i] - TQHS - TDQSQ;
|
1301 |
|
|
end
|
1302 |
|
|
|
1303 |
|
|
// DQSQ requirements
|
1304 |
|
|
// 1.) less than tAC - DQSCK
|
1305 |
|
|
// 2.) less than tDQSQ
|
1306 |
|
|
// 3.) greater than -tAC
|
1307 |
|
|
// 4.) greater than tQH from previous DQS edge
|
1308 |
|
|
dqsq_min = -1*TAC;
|
1309 |
|
|
if (dqsq_min < dqsck[i] - TQHS) begin
|
1310 |
|
|
dqsq_min = dqsck[i] - TQHS;
|
1311 |
|
|
end
|
1312 |
|
|
if (dqsck_min == dqsck_max) begin
|
1313 |
|
|
dqsck[i] = dqsck_min;
|
1314 |
|
|
end else begin
|
1315 |
|
|
dqsck[i] = $dist_uniform(seed, dqsck_min, dqsck_max);
|
1316 |
|
|
end
|
1317 |
|
|
dqsq_max = TAC;
|
1318 |
|
|
if (dqsq_max > TDQSQ + dqsck[i]) begin
|
1319 |
|
|
dqsq_max = TDQSQ + dqsck[i];
|
1320 |
|
|
end
|
1321 |
|
|
|
1322 |
|
|
dqs_out_en_dly[i] <= #(tck_avg/2.0 + ($random % TAC)) dqs_out_en;
|
1323 |
|
|
dqs_out_dly[i] <= #(tck_avg/2.0 + dqsck[i]) dqs_out;
|
1324 |
|
|
for (j=0; j<`DQ_PER_DQS; j=j+1) begin
|
1325 |
|
|
if (dq_out_en) begin // tLZ2
|
1326 |
|
|
dq_out_en_dly[i*`DQ_PER_DQS + j] <= #(tck_avg/2.0 + $dist_uniform(seed, -2*TAC, dqsq_max)) dq_out_en;
|
1327 |
|
|
end else begin // tHZ
|
1328 |
|
|
dq_out_en_dly[i*`DQ_PER_DQS + j] <= #(tck_avg/2.0 + ($random % TAC)) dq_out_en;
|
1329 |
|
|
end
|
1330 |
|
|
if (dqsq_min == dqsq_max) begin
|
1331 |
|
|
dq_out_dly [i*`DQ_PER_DQS + j] <= #(tck_avg/2.0 + dqsq_min) dq_out[i*`DQ_PER_DQS + j];
|
1332 |
|
|
end else begin
|
1333 |
|
|
dq_out_dly [i*`DQ_PER_DQS + j] <= #(tck_avg/2.0 + $dist_uniform(seed, dqsq_min, dqsq_max)) dq_out[i*`DQ_PER_DQS + j];
|
1334 |
|
|
end
|
1335 |
|
|
end
|
1336 |
|
|
end
|
1337 |
|
|
end else begin
|
1338 |
|
|
out_delay = tck_avg/2.0;
|
1339 |
|
|
dqs_out_en_dly <= #(out_delay) {DQS_BITS{dqs_out_en}};
|
1340 |
|
|
dqs_out_dly <= #(out_delay) {DQS_BITS{dqs_out }};
|
1341 |
|
|
dq_out_en_dly <= #(out_delay) {DQ_BITS {dq_out_en }};
|
1342 |
|
|
dq_out_dly <= #(out_delay) {DQ_BITS {dq_out }};
|
1343 |
|
|
end
|
1344 |
|
|
end
|
1345 |
|
|
endtask
|
1346 |
|
|
|
1347 |
|
|
always @(diff_ck) begin : main
|
1348 |
|
|
integer i;
|
1349 |
|
|
|
1350 |
|
|
if (!in_self_refresh && (diff_ck !== 1'b0) && (diff_ck !== 1'b1))
|
1351 |
|
|
$display ("%m: at time %t ERROR: CK and CK_N are not allowed to go to an unknown state.", $time);
|
1352 |
|
|
data_task;
|
1353 |
|
|
if (diff_ck) begin
|
1354 |
|
|
// check setup of command signals
|
1355 |
|
|
if ($time > TIS) begin
|
1356 |
|
|
if ($time - tm_cke < TIS)
|
1357 |
|
|
$display ("%m: at time %t ERROR: tIS violation on CKE by %t", $time, tm_cke + TIS - $time);
|
1358 |
|
|
if (cke_in) begin
|
1359 |
|
|
for (i=0; i<22; i=i+1) begin
|
1360 |
|
|
if ($time - tm_cmd_addr[i] < TIS)
|
1361 |
|
|
$display ("%m: at time %t ERROR: tIS violation on %s by %t", $time, cmd_addr_string[i], tm_cmd_addr[i] + TIS - $time);
|
1362 |
|
|
end
|
1363 |
|
|
end
|
1364 |
|
|
end
|
1365 |
|
|
|
1366 |
|
|
// update current state
|
1367 |
|
|
if (!dll_locked && !in_self_refresh && (ck_cntr - ck_dll_reset == TDLLK)) begin
|
1368 |
|
|
// check CL value against the clock frequency
|
1369 |
|
|
if (cas_latency*tck_avg < CL_TIME)
|
1370 |
|
|
$display ("%m: at time %t ERROR: CAS Latency = %d is illegal @tCK(avg) = %f", $time, cas_latency, tck_avg);
|
1371 |
|
|
// check WR value against the clock frequency
|
1372 |
|
|
if (write_recovery*tck_avg < TWR)
|
1373 |
|
|
$display ("%m: at time %t ERROR: Write Recovery = %d is illegal @tCK(avg) = %f", $time, write_recovery, tck_avg);
|
1374 |
|
|
dll_locked = 1;
|
1375 |
|
|
end
|
1376 |
|
|
if (|auto_precharge_bank) begin
|
1377 |
|
|
for (i=0; i<`BANKS; i=i+1) begin
|
1378 |
|
|
// Write with Auto Precharge Calculation
|
1379 |
|
|
// 1. Meet minimum tRAS requirement
|
1380 |
|
|
// 2. Write Latency PLUS BL/2 cycles PLUS WR after Write command
|
1381 |
|
|
if (write_precharge_bank[i]
|
1382 |
|
|
&& ($time - tm_bank_activate[i] >= TRAS_MIN)
|
1383 |
|
|
&& (ck_cntr - ck_bank_write[i] >= write_latency + burst_length/2 + write_recovery)) begin
|
1384 |
|
|
|
1385 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Auto Precharge bank %d", $time, i);
|
1386 |
|
|
write_precharge_bank[i] = 0;
|
1387 |
|
|
active_bank[i] = 0;
|
1388 |
|
|
auto_precharge_bank[i] = 0;
|
1389 |
|
|
ck_write_ap = ck_cntr;
|
1390 |
|
|
tm_bank_precharge[i] = $time;
|
1391 |
|
|
tm_precharge = $time;
|
1392 |
|
|
end
|
1393 |
|
|
// Read with Auto Precharge Calculation
|
1394 |
|
|
// 1. Meet minimum tRAS requirement
|
1395 |
|
|
// 2. Additive Latency plus BL/2 cycles after Read command
|
1396 |
|
|
// 3. tRTP after the last 4-bit prefetch
|
1397 |
|
|
if (read_precharge_bank[i]
|
1398 |
|
|
&& ($time - tm_bank_activate[i] >= TRAS_MIN)
|
1399 |
|
|
&& (ck_cntr - ck_bank_read[i] >= additive_latency + burst_length/2)) begin
|
1400 |
|
|
|
1401 |
|
|
read_precharge_bank[i] = 0;
|
1402 |
|
|
// In case the internal precharge is pushed out by tRTP, tRP starts at the point where
|
1403 |
|
|
// the internal precharge happens (not at the next rising clock edge after this event).
|
1404 |
|
|
if ($time - tm_bank_read_end[i] < TRTP) begin
|
1405 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Auto Precharge bank %d", tm_bank_read_end[i] + TRTP, i);
|
1406 |
|
|
active_bank[i] <= #(tm_bank_read_end[i] + TRTP - $time) 0;
|
1407 |
|
|
auto_precharge_bank[i] <= #(tm_bank_read_end[i] + TRTP - $time) 0;
|
1408 |
|
|
tm_bank_precharge[i] <= #(tm_bank_read_end[i] + TRTP - $time) tm_bank_read_end[i] + TRTP;
|
1409 |
|
|
tm_precharge <= #(tm_bank_read_end[i] + TRTP - $time) tm_bank_read_end[i] + TRTP;
|
1410 |
|
|
end else begin
|
1411 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Auto Precharge bank %d", $time, i);
|
1412 |
|
|
active_bank[i] = 0;
|
1413 |
|
|
auto_precharge_bank[i] = 0;
|
1414 |
|
|
tm_bank_precharge[i] = $time;
|
1415 |
|
|
tm_precharge = $time;
|
1416 |
|
|
end
|
1417 |
|
|
end
|
1418 |
|
|
end
|
1419 |
|
|
end
|
1420 |
|
|
|
1421 |
|
|
// respond to incoming command
|
1422 |
|
|
if (cke_in ^ prev_cke) begin
|
1423 |
|
|
ck_cke <= ck_cntr;
|
1424 |
|
|
end
|
1425 |
|
|
|
1426 |
|
|
cmd_task(cke_in, cmd_n_in, ba_in, addr_in);
|
1427 |
|
|
if ((cmd_n_in == WRITE) || (cmd_n_in == READ)) begin
|
1428 |
|
|
al_pipeline[2*additive_latency] = 1'b1;
|
1429 |
|
|
end
|
1430 |
|
|
if (al_pipeline[0]) begin
|
1431 |
|
|
// check tRCD after additive latency
|
1432 |
|
|
if ($time - tm_bank_activate[ba_pipeline[2*cas_latency - 1]] < TRCD) begin
|
1433 |
|
|
if (rd_pipeline[2*cas_latency - 1]) begin
|
1434 |
|
|
$display ("%m: at time %t ERROR: tRCD violation during %s", $time, cmd_string[READ]);
|
1435 |
|
|
end else begin
|
1436 |
|
|
$display ("%m: at time %t ERROR: tRCD violation during %s", $time, cmd_string[WRITE]);
|
1437 |
|
|
end
|
1438 |
|
|
end
|
1439 |
|
|
// check tWTR after additive latency
|
1440 |
|
|
if (rd_pipeline[2*cas_latency - 1]) begin
|
1441 |
|
|
if ($time - tm_write_end < TWTR)
|
1442 |
|
|
$display ("%m: at time %t ERROR: tWTR violation during %s", $time, cmd_string[READ]);
|
1443 |
|
|
end
|
1444 |
|
|
end
|
1445 |
|
|
if (rd_pipeline[2*(cas_latency - burst_length/2 + 2) - 1]) begin
|
1446 |
|
|
tm_bank_read_end[ba_pipeline[2*(cas_latency - burst_length/2 + 2) - 1]] <= $time;
|
1447 |
|
|
end
|
1448 |
|
|
for (i=0; i<`BANKS; i=i+1) begin
|
1449 |
|
|
if ((ck_cntr - ck_bank_write[i] > write_latency) && (ck_cntr - ck_bank_write[i] <= write_latency + burst_length/2)) begin
|
1450 |
|
|
tm_bank_write_end[i] <= $time;
|
1451 |
|
|
tm_write_end <= $time;
|
1452 |
|
|
end
|
1453 |
|
|
end
|
1454 |
|
|
|
1455 |
|
|
// clk pin is disabled during self refresh
|
1456 |
|
|
if (!in_self_refresh) begin
|
1457 |
|
|
tjit_cc_time = $time - tm_ck_pos - tck_i;
|
1458 |
|
|
tck_i = $time - tm_ck_pos;
|
1459 |
|
|
tck_avg = tck_avg - tck_sample[ck_cntr%TDLLK]/$itor(TDLLK);
|
1460 |
|
|
tck_avg = tck_avg + tck_i/$itor(TDLLK);
|
1461 |
|
|
tck_sample[ck_cntr%TDLLK] = tck_i;
|
1462 |
|
|
tjit_per_rtime = tck_i - tck_avg;
|
1463 |
|
|
|
1464 |
|
|
if (dll_locked) begin
|
1465 |
|
|
// check accumulated error
|
1466 |
|
|
terr_nper_rtime = 0;
|
1467 |
|
|
for (i=0; i<50; i=i+1) begin
|
1468 |
|
|
terr_nper_rtime = terr_nper_rtime + tck_sample[i] - tck_avg;
|
1469 |
|
|
terr_nper_rtime = abs_value(terr_nper_rtime);
|
1470 |
|
|
case (i)
|
1471 |
|
|
|
1472 |
|
|
1 : if (terr_nper_rtime - TERR_2PER >= 1.0) $display ("%m: at time %t ERROR: tERR(2per) violation by %f ps.", $time, terr_nper_rtime - TERR_2PER);
|
1473 |
|
|
2 : if (terr_nper_rtime - TERR_3PER >= 1.0) $display ("%m: at time %t ERROR: tERR(3per) violation by %f ps.", $time, terr_nper_rtime - TERR_3PER);
|
1474 |
|
|
3 : if (terr_nper_rtime - TERR_4PER >= 1.0) $display ("%m: at time %t ERROR: tERR(4per) violation by %f ps.", $time, terr_nper_rtime - TERR_4PER);
|
1475 |
|
|
4 : if (terr_nper_rtime - TERR_5PER >= 1.0) $display ("%m: at time %t ERROR: tERR(5per) violation by %f ps.", $time, terr_nper_rtime - TERR_5PER);
|
1476 |
|
|
5,6,7,8,9 : if (terr_nper_rtime - TERR_N1PER >= 1.0) $display ("%m: at time %t ERROR: tERR(n1per) violation by %f ps.", $time, terr_nper_rtime - TERR_N1PER);
|
1477 |
|
|
default : if (terr_nper_rtime - TERR_N2PER >= 1.0) $display ("%m: at time %t ERROR: tERR(n2per) violation by %f ps.", $time, terr_nper_rtime - TERR_N2PER);
|
1478 |
|
|
endcase
|
1479 |
|
|
end
|
1480 |
|
|
|
1481 |
|
|
// check tCK min/max/jitter
|
1482 |
|
|
if (abs_value(tjit_per_rtime) - TJIT_PER >= 1.0)
|
1483 |
|
|
$display ("%m: at time %t ERROR: tJIT(per) violation by %f ps.", $time, abs_value(tjit_per_rtime) - TJIT_PER);
|
1484 |
|
|
if (abs_value(tjit_cc_time) - TJIT_CC >= 1.0)
|
1485 |
|
|
$display ("%m: at time %t ERROR: tJIT(cc) violation by %f ps.", $time, abs_value(tjit_cc_time) - TJIT_CC);
|
1486 |
|
|
if (TCK_MIN - tck_avg >= 1.0)
|
1487 |
|
|
$display ("%m: at time %t ERROR: tCK(avg) minimum violation by %f ps.", $time, TCK_MIN - tck_avg);
|
1488 |
|
|
if (tck_avg - TCK_MAX >= 1.0)
|
1489 |
|
|
$display ("%m: at time %t ERROR: tCK(avg) maximum violation by %f ps.", $time, tck_avg - TCK_MAX);
|
1490 |
|
|
if (tm_ck_pos + TCK_MIN - TJIT_PER > $time)
|
1491 |
|
|
$display ("%m: at time %t ERROR: tCK(abs) minimum violation by %t", $time, tm_ck_pos + TCK_MIN - TJIT_PER - $time);
|
1492 |
|
|
if (tm_ck_pos + TCK_MAX + TJIT_PER < $time)
|
1493 |
|
|
$display ("%m: at time %t ERROR: tCK(abs) maximum violation by %t", $time, $time - tm_ck_pos - TCK_MAX - TJIT_PER);
|
1494 |
|
|
|
1495 |
|
|
// check tCL
|
1496 |
|
|
if (tm_ck_neg + TCL_MIN*tck_avg - TJIT_DUTY > $time)
|
1497 |
|
|
$display ("%m: at time %t ERROR: tCL(abs) minimum violation on CLK by %t", $time, tm_ck_neg + TCL_MIN*tck_avg - TJIT_DUTY - $time);
|
1498 |
|
|
if (tm_ck_neg + TCL_MAX*tck_avg + TJIT_DUTY < $time)
|
1499 |
|
|
$display ("%m: at time %t ERROR: tCL(abs) maximum violation on CLK by %t", $time, $time - tm_ck_neg - TCL_MAX*tck_avg - TJIT_DUTY);
|
1500 |
|
|
if (tcl_avg < TCL_MIN*tck_avg)
|
1501 |
|
|
$display ("%m: at time %t ERROR: tCL(avg) minimum violation on CLK by %t", $time, TCL_MIN*tck_avg - tcl_avg);
|
1502 |
|
|
if (tcl_avg > TCL_MAX*tck_avg)
|
1503 |
|
|
$display ("%m: at time %t ERROR: tCL(avg) maximum violation on CLK by %t", $time, tcl_avg - TCL_MAX*tck_avg);
|
1504 |
|
|
end
|
1505 |
|
|
|
1506 |
|
|
// calculate the tch avg jitter
|
1507 |
|
|
tch_avg = tch_avg - tch_sample[ck_cntr%TDLLK]/$itor(TDLLK);
|
1508 |
|
|
tch_avg = tch_avg + tch_i/$itor(TDLLK);
|
1509 |
|
|
tch_sample[ck_cntr%TDLLK] = tch_i;
|
1510 |
|
|
|
1511 |
|
|
// update timers/counters
|
1512 |
|
|
tcl_i <= $time - tm_ck_neg;
|
1513 |
|
|
end
|
1514 |
|
|
|
1515 |
|
|
prev_odt <= odt_in;
|
1516 |
|
|
// update timers/counters
|
1517 |
|
|
ck_cntr <= ck_cntr + 1;
|
1518 |
|
|
tm_ck_pos <= $time;
|
1519 |
|
|
end else begin
|
1520 |
|
|
// clk pin is disabled during self refresh
|
1521 |
|
|
if (!in_self_refresh) begin
|
1522 |
|
|
if (dll_locked) begin
|
1523 |
|
|
if (tm_ck_pos + TCH_MIN*tck_avg - TJIT_DUTY > $time)
|
1524 |
|
|
$display ("%m: at time %t ERROR: tCH(abs) minimum violation on CLK by %t", $time, tm_ck_pos + TCH_MIN*tck_avg - TJIT_DUTY + $time);
|
1525 |
|
|
if (tm_ck_pos + TCH_MAX*tck_avg + TJIT_DUTY < $time)
|
1526 |
|
|
$display ("%m: at time %t ERROR: tCH(abs) maximum violation on CLK by %t", $time, $time - tm_ck_pos - TCH_MAX*tck_avg - TJIT_DUTY);
|
1527 |
|
|
if (tch_avg < TCH_MIN*tck_avg)
|
1528 |
|
|
$display ("%m: at time %t ERROR: tCH(avg) minimum violation on CLK by %t", $time, TCH_MIN*tck_avg - tch_avg);
|
1529 |
|
|
if (tch_avg > TCH_MAX*tck_avg)
|
1530 |
|
|
$display ("%m: at time %t ERROR: tCH(avg) maximum violation on CLK by %t", $time, tch_avg - TCH_MAX*tck_avg);
|
1531 |
|
|
end
|
1532 |
|
|
|
1533 |
|
|
// calculate the tcl avg jitter
|
1534 |
|
|
tcl_avg = tcl_avg - tcl_sample[ck_cntr%TDLLK]/$itor(TDLLK);
|
1535 |
|
|
tcl_avg = tcl_avg + tcl_i/$itor(TDLLK);
|
1536 |
|
|
tcl_sample[ck_cntr%TDLLK] = tcl_i;
|
1537 |
|
|
|
1538 |
|
|
// update timers/counters
|
1539 |
|
|
tch_i <= $time - tm_ck_pos;
|
1540 |
|
|
end
|
1541 |
|
|
tm_ck_neg <= $time;
|
1542 |
|
|
end
|
1543 |
|
|
|
1544 |
|
|
// on die termination
|
1545 |
|
|
if (odt_en) begin
|
1546 |
|
|
// clk pin is disabled during self refresh
|
1547 |
|
|
if (!in_self_refresh && diff_ck) begin
|
1548 |
|
|
if ($time - tm_odt < TIS) begin
|
1549 |
|
|
$display ("%m: at time %t ERROR: tIS violation on ODT by %t", $time, tm_odt + TIS - $time);
|
1550 |
|
|
end
|
1551 |
|
|
if (prev_odt ^ odt_in) begin
|
1552 |
|
|
if (!dll_locked)
|
1553 |
|
|
$display ("%m: at time %t WARNING: tDLLK violation during ODT transition.", $time);
|
1554 |
|
|
if (odt_in && ($time - tm_odt_en < TMOD))
|
1555 |
|
|
$display ("%m: at time %t ERROR: tMOD violation during ODT transition", $time);
|
1556 |
|
|
if ($time - tm_self_refresh < TXSNR)
|
1557 |
|
|
$display ("%m: at time %t ERROR: tXSNR violation during ODT transition", $time);
|
1558 |
|
|
if (in_self_refresh)
|
1559 |
|
|
$display ("%m: at time %t ERROR: Illegal ODT transition during Self Refresh.", $time);
|
1560 |
|
|
|
1561 |
|
|
// async ODT mode applies:
|
1562 |
|
|
// 1.) during active power down with slow exit
|
1563 |
|
|
// 2.) during precharge power down
|
1564 |
|
|
// 3.) if tANPD has not been satisfied
|
1565 |
|
|
// 4.) until tAXPD has been satisfied
|
1566 |
|
|
if ((in_power_down && (low_power || (active_bank == 0))) || (ck_cntr - ck_slow_exit_pd < TAXPD)) begin
|
1567 |
|
|
if (ck_cntr - ck_slow_exit_pd < TAXPD)
|
1568 |
|
|
$display ("%m: at time %t WARNING: tAXPD violation during ODT transition. Synchronous or asynchronous change in termination resistance is possible.", $time);
|
1569 |
|
|
if (odt_in) begin
|
1570 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Async On Die Termination = %d", $time + TAONPD, 1'b1);
|
1571 |
|
|
odt_state <= #(TAONPD) 1'b1;
|
1572 |
|
|
end else begin
|
1573 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Async On Die Termination = %d", $time + TAOFPD, 1'b0);
|
1574 |
|
|
odt_state <= #(TAOFPD) 1'b0;
|
1575 |
|
|
end
|
1576 |
|
|
// sync ODT mode applies:
|
1577 |
|
|
// 1.) during normal operation
|
1578 |
|
|
// 2.) during active power down with fast exit
|
1579 |
|
|
end else begin
|
1580 |
|
|
if (odt_in) begin
|
1581 |
|
|
i = TAOND*2;
|
1582 |
|
|
odt_pipeline[i] = 1'b1;
|
1583 |
|
|
end else begin
|
1584 |
|
|
i = TAOFD*2;
|
1585 |
|
|
odt_pipeline[i] = 1'b1;
|
1586 |
|
|
end
|
1587 |
|
|
end
|
1588 |
|
|
ck_odt <= ck_cntr;
|
1589 |
|
|
end
|
1590 |
|
|
end
|
1591 |
|
|
if (odt_pipeline[0]) begin
|
1592 |
|
|
odt_state = ~odt_state;
|
1593 |
|
|
if (DEBUG) $display ("%m: at time %t INFO: Sync On Die Termination = %d", $time, odt_state);
|
1594 |
|
|
end
|
1595 |
|
|
end
|
1596 |
|
|
|
1597 |
|
|
// shift pipelines
|
1598 |
|
|
if (|wr_pipeline || |rd_pipeline || |al_pipeline) begin
|
1599 |
|
|
al_pipeline = al_pipeline>>1;
|
1600 |
|
|
wr_pipeline = wr_pipeline>>1;
|
1601 |
|
|
rd_pipeline = rd_pipeline>>1;
|
1602 |
|
|
for (i=0; i<`MAX_PIPE; i=i+1) begin
|
1603 |
|
|
ba_pipeline[i] = ba_pipeline[i+1];
|
1604 |
|
|
row_pipeline[i] = row_pipeline[i+1];
|
1605 |
|
|
col_pipeline[i] = col_pipeline[i+1];
|
1606 |
|
|
end
|
1607 |
|
|
end
|
1608 |
|
|
if (|odt_pipeline) begin
|
1609 |
|
|
odt_pipeline = odt_pipeline>>1;
|
1610 |
|
|
end
|
1611 |
|
|
end
|
1612 |
|
|
|
1613 |
|
|
// receiver(s)
|
1614 |
|
|
task dqs_even_receiver;
|
1615 |
|
|
input [4:0] i;
|
1616 |
|
|
reg [71:0] bit_mask;
|
1617 |
|
|
begin
|
1618 |
|
|
bit_mask = {`DQ_PER_DQS{1'b1}}<<(i*`DQ_PER_DQS);
|
1619 |
|
|
if (dqs_even[i]) begin
|
1620 |
|
|
if (rdqs_en) begin // rdqs disables dm
|
1621 |
|
|
dm_in_pos[i] = 1'b0;
|
1622 |
|
|
end else begin
|
1623 |
|
|
dm_in_pos[i] = dm_in[i];
|
1624 |
|
|
end
|
1625 |
|
|
dq_in_pos = (dq_in & bit_mask) | (dq_in_pos & ~bit_mask);
|
1626 |
|
|
end
|
1627 |
|
|
end
|
1628 |
|
|
endtask
|
1629 |
|
|
|
1630 |
|
|
always @(posedge dqs_even[ 0]) dqs_even_receiver( 0);
|
1631 |
|
|
always @(posedge dqs_even[ 1]) dqs_even_receiver( 1);
|
1632 |
|
|
always @(posedge dqs_even[ 2]) dqs_even_receiver( 2);
|
1633 |
|
|
always @(posedge dqs_even[ 3]) dqs_even_receiver( 3);
|
1634 |
|
|
always @(posedge dqs_even[ 4]) dqs_even_receiver( 4);
|
1635 |
|
|
always @(posedge dqs_even[ 5]) dqs_even_receiver( 5);
|
1636 |
|
|
always @(posedge dqs_even[ 6]) dqs_even_receiver( 6);
|
1637 |
|
|
always @(posedge dqs_even[ 7]) dqs_even_receiver( 7);
|
1638 |
|
|
always @(posedge dqs_even[ 8]) dqs_even_receiver( 8);
|
1639 |
|
|
always @(posedge dqs_even[ 9]) dqs_even_receiver( 9);
|
1640 |
|
|
always @(posedge dqs_even[10]) dqs_even_receiver(10);
|
1641 |
|
|
always @(posedge dqs_even[11]) dqs_even_receiver(11);
|
1642 |
|
|
always @(posedge dqs_even[12]) dqs_even_receiver(12);
|
1643 |
|
|
always @(posedge dqs_even[13]) dqs_even_receiver(13);
|
1644 |
|
|
always @(posedge dqs_even[14]) dqs_even_receiver(14);
|
1645 |
|
|
always @(posedge dqs_even[15]) dqs_even_receiver(15);
|
1646 |
|
|
always @(posedge dqs_even[16]) dqs_even_receiver(16);
|
1647 |
|
|
always @(posedge dqs_even[17]) dqs_even_receiver(17);
|
1648 |
|
|
|
1649 |
|
|
task dqs_odd_receiver;
|
1650 |
|
|
input [4:0] i;
|
1651 |
|
|
reg [71:0] bit_mask;
|
1652 |
|
|
begin
|
1653 |
|
|
bit_mask = {`DQ_PER_DQS{1'b1}}<<(i*`DQ_PER_DQS);
|
1654 |
|
|
if (dqs_odd[i]) begin
|
1655 |
|
|
if (rdqs_en) begin // rdqs disables dm
|
1656 |
|
|
dm_in_neg[i] = 1'b0;
|
1657 |
|
|
end else begin
|
1658 |
|
|
dm_in_neg[i] = dm_in[i];
|
1659 |
|
|
end
|
1660 |
|
|
dq_in_neg = (dq_in & bit_mask) | (dq_in_neg & ~bit_mask);
|
1661 |
|
|
end
|
1662 |
|
|
end
|
1663 |
|
|
endtask
|
1664 |
|
|
|
1665 |
|
|
always @(posedge dqs_odd[ 0]) dqs_odd_receiver( 0);
|
1666 |
|
|
always @(posedge dqs_odd[ 1]) dqs_odd_receiver( 1);
|
1667 |
|
|
always @(posedge dqs_odd[ 2]) dqs_odd_receiver( 2);
|
1668 |
|
|
always @(posedge dqs_odd[ 3]) dqs_odd_receiver( 3);
|
1669 |
|
|
always @(posedge dqs_odd[ 4]) dqs_odd_receiver( 4);
|
1670 |
|
|
always @(posedge dqs_odd[ 5]) dqs_odd_receiver( 5);
|
1671 |
|
|
always @(posedge dqs_odd[ 6]) dqs_odd_receiver( 6);
|
1672 |
|
|
always @(posedge dqs_odd[ 7]) dqs_odd_receiver( 7);
|
1673 |
|
|
always @(posedge dqs_odd[ 8]) dqs_odd_receiver( 8);
|
1674 |
|
|
always @(posedge dqs_odd[ 9]) dqs_odd_receiver( 9);
|
1675 |
|
|
always @(posedge dqs_odd[10]) dqs_odd_receiver(10);
|
1676 |
|
|
always @(posedge dqs_odd[11]) dqs_odd_receiver(11);
|
1677 |
|
|
always @(posedge dqs_odd[12]) dqs_odd_receiver(12);
|
1678 |
|
|
always @(posedge dqs_odd[13]) dqs_odd_receiver(13);
|
1679 |
|
|
always @(posedge dqs_odd[14]) dqs_odd_receiver(14);
|
1680 |
|
|
always @(posedge dqs_odd[15]) dqs_odd_receiver(15);
|
1681 |
|
|
always @(posedge dqs_odd[16]) dqs_odd_receiver(16);
|
1682 |
|
|
always @(posedge dqs_odd[17]) dqs_odd_receiver(17);
|
1683 |
|
|
|
1684 |
|
|
// Processes to check hold and pulse width of control signals
|
1685 |
|
|
always @(cke_in) begin
|
1686 |
|
|
if ($time > TIH) begin
|
1687 |
|
|
if ($time - tm_ck_pos < TIH)
|
1688 |
|
|
$display ("%m: at time %t ERROR: tIH violation on CKE by %t", $time, tm_ck_pos + TIH - $time);
|
1689 |
|
|
end
|
1690 |
|
|
if (dll_locked && ($time - tm_cke < $rtoi(TIPW*tck_avg)))
|
1691 |
|
|
$display ("%m: at time %t ERROR: tIPW violation on CKE by %t", $time, tm_cke + TIPW*tck_avg - $time);
|
1692 |
|
|
tm_cke = $time;
|
1693 |
|
|
end
|
1694 |
|
|
always @(odt_in) begin
|
1695 |
|
|
if (odt_en && !in_self_refresh) begin
|
1696 |
|
|
if ($time - tm_ck_pos < TIH)
|
1697 |
|
|
$display ("%m: at time %t ERROR: tIH violation on ODT by %t", $time, tm_ck_pos + TIH - $time);
|
1698 |
|
|
if (dll_locked && ($time - tm_odt < $rtoi(TIPW*tck_avg)))
|
1699 |
|
|
$display ("%m: at time %t ERROR: tIPW violation on ODT by %t", $time, tm_odt + TIPW*tck_avg - $time);
|
1700 |
|
|
end
|
1701 |
|
|
tm_odt = $time;
|
1702 |
|
|
end
|
1703 |
|
|
|
1704 |
|
|
task cmd_addr_timing_check;
|
1705 |
|
|
input i;
|
1706 |
|
|
reg [4:0] i;
|
1707 |
|
|
begin
|
1708 |
|
|
if (prev_cke) begin
|
1709 |
|
|
if ($time - tm_ck_pos < TIH)
|
1710 |
|
|
$display ("%m: at time %t ERROR: tIH violation on %s by %t", $time, cmd_addr_string[i], tm_ck_pos + TIH - $time);
|
1711 |
|
|
if (dll_locked && ($time - tm_cmd_addr[i] < $rtoi(TIPW*tck_avg)))
|
1712 |
|
|
$display ("%m: at time %t ERROR: tIPW violation on %s by %t", $time, cmd_addr_string[i], tm_cmd_addr[i] + TIPW*tck_avg - $time);
|
1713 |
|
|
end
|
1714 |
|
|
tm_cmd_addr[i] = $time;
|
1715 |
|
|
end
|
1716 |
|
|
endtask
|
1717 |
|
|
|
1718 |
|
|
always @(cs_n_in ) cmd_addr_timing_check( 0);
|
1719 |
|
|
always @(ras_n_in ) cmd_addr_timing_check( 1);
|
1720 |
|
|
always @(cas_n_in ) cmd_addr_timing_check( 2);
|
1721 |
|
|
always @(we_n_in ) cmd_addr_timing_check( 3);
|
1722 |
|
|
always @(ba_in [ 0]) cmd_addr_timing_check( 4);
|
1723 |
|
|
always @(ba_in [ 1]) cmd_addr_timing_check( 5);
|
1724 |
|
|
always @(ba_in [ 2]) cmd_addr_timing_check( 6);
|
1725 |
|
|
always @(addr_in[ 0]) cmd_addr_timing_check( 7);
|
1726 |
|
|
always @(addr_in[ 1]) cmd_addr_timing_check( 8);
|
1727 |
|
|
always @(addr_in[ 2]) cmd_addr_timing_check( 9);
|
1728 |
|
|
always @(addr_in[ 3]) cmd_addr_timing_check(10);
|
1729 |
|
|
always @(addr_in[ 4]) cmd_addr_timing_check(11);
|
1730 |
|
|
always @(addr_in[ 5]) cmd_addr_timing_check(12);
|
1731 |
|
|
always @(addr_in[ 6]) cmd_addr_timing_check(13);
|
1732 |
|
|
always @(addr_in[ 7]) cmd_addr_timing_check(14);
|
1733 |
|
|
always @(addr_in[ 8]) cmd_addr_timing_check(15);
|
1734 |
|
|
always @(addr_in[ 9]) cmd_addr_timing_check(16);
|
1735 |
|
|
always @(addr_in[10]) cmd_addr_timing_check(17);
|
1736 |
|
|
always @(addr_in[11]) cmd_addr_timing_check(18);
|
1737 |
|
|
always @(addr_in[12]) cmd_addr_timing_check(19);
|
1738 |
|
|
always @(addr_in[13]) cmd_addr_timing_check(20);
|
1739 |
|
|
always @(addr_in[14]) cmd_addr_timing_check(21);
|
1740 |
|
|
always @(addr_in[15]) cmd_addr_timing_check(22);
|
1741 |
|
|
|
1742 |
|
|
// Processes to check setup and hold of data signals
|
1743 |
|
|
task dm_timing_check;
|
1744 |
|
|
input i;
|
1745 |
|
|
reg [4:0] i;
|
1746 |
|
|
begin
|
1747 |
|
|
if (dqs_in_valid) begin
|
1748 |
|
|
if ($time - tm_dqs[i] < TDH)
|
1749 |
|
|
$display ("%m: at time %t ERROR: tDH violation on DM bit %d by %t", $time, i, tm_dqs[i] + TDH - $time);
|
1750 |
|
|
if (check_dm_tdipw[i]) begin
|
1751 |
|
|
if (dll_locked && ($time - tm_dm[i] < $rtoi(TDIPW*tck_avg)))
|
1752 |
|
|
$display ("%m: at time %t ERROR: tDIPW violation on DM bit %d by %t", $time, i, tm_dm[i] + TDIPW*tck_avg - $time);
|
1753 |
|
|
end
|
1754 |
|
|
end
|
1755 |
|
|
check_dm_tdipw[i] <= 1'b0;
|
1756 |
|
|
tm_dm[i] = $time;
|
1757 |
|
|
end
|
1758 |
|
|
endtask
|
1759 |
|
|
|
1760 |
|
|
always @(dm_in[ 0]) dm_timing_check( 0);
|
1761 |
|
|
always @(dm_in[ 1]) dm_timing_check( 1);
|
1762 |
|
|
always @(dm_in[ 2]) dm_timing_check( 2);
|
1763 |
|
|
always @(dm_in[ 3]) dm_timing_check( 3);
|
1764 |
|
|
always @(dm_in[ 4]) dm_timing_check( 4);
|
1765 |
|
|
always @(dm_in[ 5]) dm_timing_check( 5);
|
1766 |
|
|
always @(dm_in[ 6]) dm_timing_check( 6);
|
1767 |
|
|
always @(dm_in[ 7]) dm_timing_check( 7);
|
1768 |
|
|
always @(dm_in[ 8]) dm_timing_check( 8);
|
1769 |
|
|
always @(dm_in[ 9]) dm_timing_check( 9);
|
1770 |
|
|
always @(dm_in[10]) dm_timing_check(10);
|
1771 |
|
|
always @(dm_in[11]) dm_timing_check(11);
|
1772 |
|
|
always @(dm_in[12]) dm_timing_check(12);
|
1773 |
|
|
always @(dm_in[13]) dm_timing_check(13);
|
1774 |
|
|
always @(dm_in[14]) dm_timing_check(14);
|
1775 |
|
|
always @(dm_in[15]) dm_timing_check(15);
|
1776 |
|
|
always @(dm_in[16]) dm_timing_check(16);
|
1777 |
|
|
always @(dm_in[17]) dm_timing_check(17);
|
1778 |
|
|
|
1779 |
|
|
task dq_timing_check;
|
1780 |
|
|
input i;
|
1781 |
|
|
reg [6:0] i;
|
1782 |
|
|
begin
|
1783 |
|
|
if (dqs_in_valid) begin
|
1784 |
|
|
if ($time - tm_dqs[i/`DQ_PER_DQS] < TDH)
|
1785 |
|
|
$display ("%m: at time %t ERROR: tDH violation on DQ bit %d by %t", $time, i, tm_dqs[i/`DQ_PER_DQS] + TDH - $time);
|
1786 |
|
|
if (check_dq_tdipw[i]) begin
|
1787 |
|
|
if (dll_locked && ($time - tm_dq[i] < $rtoi(TDIPW*tck_avg)))
|
1788 |
|
|
$display ("%m: at time %t ERROR: tDIPW violation on DQ bit %d by %t", $time, i, tm_dq[i] + TDIPW*tck_avg - $time);
|
1789 |
|
|
end
|
1790 |
|
|
end
|
1791 |
|
|
check_dq_tdipw[i] <= 1'b0;
|
1792 |
|
|
tm_dq[i] = $time;
|
1793 |
|
|
end
|
1794 |
|
|
endtask
|
1795 |
|
|
|
1796 |
|
|
always @(dq_in[ 0]) dq_timing_check( 0);
|
1797 |
|
|
always @(dq_in[ 1]) dq_timing_check( 1);
|
1798 |
|
|
always @(dq_in[ 2]) dq_timing_check( 2);
|
1799 |
|
|
always @(dq_in[ 3]) dq_timing_check( 3);
|
1800 |
|
|
always @(dq_in[ 4]) dq_timing_check( 4);
|
1801 |
|
|
always @(dq_in[ 5]) dq_timing_check( 5);
|
1802 |
|
|
always @(dq_in[ 6]) dq_timing_check( 6);
|
1803 |
|
|
always @(dq_in[ 7]) dq_timing_check( 7);
|
1804 |
|
|
always @(dq_in[ 8]) dq_timing_check( 8);
|
1805 |
|
|
always @(dq_in[ 9]) dq_timing_check( 9);
|
1806 |
|
|
always @(dq_in[10]) dq_timing_check(10);
|
1807 |
|
|
always @(dq_in[11]) dq_timing_check(11);
|
1808 |
|
|
always @(dq_in[12]) dq_timing_check(12);
|
1809 |
|
|
always @(dq_in[13]) dq_timing_check(13);
|
1810 |
|
|
always @(dq_in[14]) dq_timing_check(14);
|
1811 |
|
|
always @(dq_in[15]) dq_timing_check(15);
|
1812 |
|
|
always @(dq_in[16]) dq_timing_check(16);
|
1813 |
|
|
always @(dq_in[17]) dq_timing_check(17);
|
1814 |
|
|
always @(dq_in[18]) dq_timing_check(18);
|
1815 |
|
|
always @(dq_in[19]) dq_timing_check(19);
|
1816 |
|
|
always @(dq_in[20]) dq_timing_check(20);
|
1817 |
|
|
always @(dq_in[21]) dq_timing_check(21);
|
1818 |
|
|
always @(dq_in[22]) dq_timing_check(22);
|
1819 |
|
|
always @(dq_in[23]) dq_timing_check(23);
|
1820 |
|
|
always @(dq_in[24]) dq_timing_check(24);
|
1821 |
|
|
always @(dq_in[25]) dq_timing_check(25);
|
1822 |
|
|
always @(dq_in[26]) dq_timing_check(26);
|
1823 |
|
|
always @(dq_in[27]) dq_timing_check(27);
|
1824 |
|
|
always @(dq_in[28]) dq_timing_check(28);
|
1825 |
|
|
always @(dq_in[29]) dq_timing_check(29);
|
1826 |
|
|
always @(dq_in[30]) dq_timing_check(30);
|
1827 |
|
|
always @(dq_in[31]) dq_timing_check(31);
|
1828 |
|
|
always @(dq_in[32]) dq_timing_check(32);
|
1829 |
|
|
always @(dq_in[33]) dq_timing_check(33);
|
1830 |
|
|
always @(dq_in[34]) dq_timing_check(34);
|
1831 |
|
|
always @(dq_in[35]) dq_timing_check(35);
|
1832 |
|
|
always @(dq_in[36]) dq_timing_check(36);
|
1833 |
|
|
always @(dq_in[37]) dq_timing_check(37);
|
1834 |
|
|
always @(dq_in[38]) dq_timing_check(38);
|
1835 |
|
|
always @(dq_in[39]) dq_timing_check(39);
|
1836 |
|
|
always @(dq_in[40]) dq_timing_check(40);
|
1837 |
|
|
always @(dq_in[41]) dq_timing_check(41);
|
1838 |
|
|
always @(dq_in[42]) dq_timing_check(42);
|
1839 |
|
|
always @(dq_in[43]) dq_timing_check(43);
|
1840 |
|
|
always @(dq_in[44]) dq_timing_check(44);
|
1841 |
|
|
always @(dq_in[45]) dq_timing_check(45);
|
1842 |
|
|
always @(dq_in[46]) dq_timing_check(46);
|
1843 |
|
|
always @(dq_in[47]) dq_timing_check(47);
|
1844 |
|
|
always @(dq_in[48]) dq_timing_check(48);
|
1845 |
|
|
always @(dq_in[49]) dq_timing_check(49);
|
1846 |
|
|
always @(dq_in[50]) dq_timing_check(50);
|
1847 |
|
|
always @(dq_in[51]) dq_timing_check(51);
|
1848 |
|
|
always @(dq_in[52]) dq_timing_check(52);
|
1849 |
|
|
always @(dq_in[53]) dq_timing_check(53);
|
1850 |
|
|
always @(dq_in[54]) dq_timing_check(54);
|
1851 |
|
|
always @(dq_in[55]) dq_timing_check(55);
|
1852 |
|
|
always @(dq_in[56]) dq_timing_check(56);
|
1853 |
|
|
always @(dq_in[57]) dq_timing_check(57);
|
1854 |
|
|
always @(dq_in[58]) dq_timing_check(58);
|
1855 |
|
|
always @(dq_in[59]) dq_timing_check(59);
|
1856 |
|
|
always @(dq_in[60]) dq_timing_check(60);
|
1857 |
|
|
always @(dq_in[61]) dq_timing_check(61);
|
1858 |
|
|
always @(dq_in[62]) dq_timing_check(62);
|
1859 |
|
|
always @(dq_in[63]) dq_timing_check(63);
|
1860 |
|
|
always @(dq_in[64]) dq_timing_check(64);
|
1861 |
|
|
always @(dq_in[65]) dq_timing_check(65);
|
1862 |
|
|
always @(dq_in[66]) dq_timing_check(66);
|
1863 |
|
|
always @(dq_in[67]) dq_timing_check(67);
|
1864 |
|
|
always @(dq_in[68]) dq_timing_check(68);
|
1865 |
|
|
always @(dq_in[69]) dq_timing_check(69);
|
1866 |
|
|
always @(dq_in[70]) dq_timing_check(70);
|
1867 |
|
|
always @(dq_in[71]) dq_timing_check(71);
|
1868 |
|
|
|
1869 |
|
|
task dqs_pos_timing_check;
|
1870 |
|
|
input i;
|
1871 |
|
|
reg [5:0] i;
|
1872 |
|
|
reg [3:0] j;
|
1873 |
|
|
begin
|
1874 |
|
|
if (dqs_in_valid && ((wdqs_pos_cntr[i] < burst_length/2) || b2b_write) && (dqs_n_en || i<18)) begin
|
1875 |
|
|
if (dqs_in[i] ^ prev_dqs_in[i]) begin
|
1876 |
|
|
if (dll_locked) begin
|
1877 |
|
|
if (check_write_preamble[i]) begin
|
1878 |
|
|
if ($time - tm_dqs_neg[i] < $rtoi(TWPRE*tck_avg))
|
1879 |
|
|
$display ("%m: at time %t ERROR: tWPRE violation on &s bit %d", $time, dqs_string[i/18], i%18);
|
1880 |
|
|
end else if (check_write_postamble[i]) begin
|
1881 |
|
|
if ($time - tm_dqs_neg[i] < $rtoi(TWPST*tck_avg))
|
1882 |
|
|
$display ("%m: at time %t ERROR: tWPST violation on %s bit %d", $time, dqs_string[i/18], i%18);
|
1883 |
|
|
end else begin
|
1884 |
|
|
if ($time - tm_dqs_neg[i] < $rtoi(TDQSL*tck_avg))
|
1885 |
|
|
$display ("%m: at time %t ERROR: tDQSL violation on %s bit %d", $time, dqs_string[i/18], i%18);
|
1886 |
|
|
end
|
1887 |
|
|
end
|
1888 |
|
|
if ($time - tm_dm[i%18] < TDS)
|
1889 |
|
|
$display ("%m: at time %t ERROR: tDS violation on DM bit %d by %t", $time, i, tm_dm[i%18] + TDS - $time);
|
1890 |
|
|
if (!dq_out_en) begin
|
1891 |
|
|
for (j=0; j<`DQ_PER_DQS; j=j+1) begin
|
1892 |
|
|
if ($time - tm_dq[i*`DQ_PER_DQS+j] < TDS)
|
1893 |
|
|
$display ("%m: at time %t ERROR: tDS violation on DQ bit %d by %t", $time, i*`DQ_PER_DQS+j, tm_dq[i*`DQ_PER_DQS+j] + TDS - $time);
|
1894 |
|
|
check_dq_tdipw[i*`DQ_PER_DQS+j] <= 1'b1;
|
1895 |
|
|
end
|
1896 |
|
|
end
|
1897 |
|
|
if ((wdqs_pos_cntr[i] < burst_length/2) && !b2b_write) begin
|
1898 |
|
|
wdqs_pos_cntr[i] <= wdqs_pos_cntr[i] + 1;
|
1899 |
|
|
end else begin
|
1900 |
|
|
wdqs_pos_cntr[i] <= 1;
|
1901 |
|
|
end
|
1902 |
|
|
check_dm_tdipw[i%18] <= 1'b1;
|
1903 |
|
|
check_write_preamble[i] <= 1'b0;
|
1904 |
|
|
check_write_postamble[i] <= 1'b0;
|
1905 |
|
|
check_write_dqs_low[i] <= 1'b0;
|
1906 |
|
|
tm_dqs[i%18] <= $time;
|
1907 |
|
|
end else begin
|
1908 |
|
|
$display ("%m: at time %t ERROR: Invalid latching edge on %s bit %d", $time, dqs_string[i/18], i%18);
|
1909 |
|
|
end
|
1910 |
|
|
end
|
1911 |
|
|
tm_dqss_pos[i] <= $time;
|
1912 |
|
|
tm_dqs_pos[i] = $time;
|
1913 |
|
|
prev_dqs_in[i] <= dqs_in[i];
|
1914 |
|
|
end
|
1915 |
|
|
endtask
|
1916 |
|
|
|
1917 |
|
|
always @(posedge dqs_in[ 0]) dqs_pos_timing_check( 0);
|
1918 |
|
|
always @(posedge dqs_in[ 1]) dqs_pos_timing_check( 1);
|
1919 |
|
|
always @(posedge dqs_in[ 2]) dqs_pos_timing_check( 2);
|
1920 |
|
|
always @(posedge dqs_in[ 3]) dqs_pos_timing_check( 3);
|
1921 |
|
|
always @(posedge dqs_in[ 4]) dqs_pos_timing_check( 4);
|
1922 |
|
|
always @(posedge dqs_in[ 5]) dqs_pos_timing_check( 5);
|
1923 |
|
|
always @(posedge dqs_in[ 6]) dqs_pos_timing_check( 6);
|
1924 |
|
|
always @(posedge dqs_in[ 7]) dqs_pos_timing_check( 7);
|
1925 |
|
|
always @(posedge dqs_in[ 8]) dqs_pos_timing_check( 8);
|
1926 |
|
|
always @(posedge dqs_in[ 9]) dqs_pos_timing_check( 9);
|
1927 |
|
|
always @(posedge dqs_in[10]) dqs_pos_timing_check(10);
|
1928 |
|
|
always @(posedge dqs_in[11]) dqs_pos_timing_check(11);
|
1929 |
|
|
always @(posedge dqs_in[12]) dqs_pos_timing_check(12);
|
1930 |
|
|
always @(posedge dqs_in[13]) dqs_pos_timing_check(13);
|
1931 |
|
|
always @(posedge dqs_in[14]) dqs_pos_timing_check(14);
|
1932 |
|
|
always @(posedge dqs_in[15]) dqs_pos_timing_check(15);
|
1933 |
|
|
always @(posedge dqs_in[16]) dqs_pos_timing_check(16);
|
1934 |
|
|
always @(posedge dqs_in[17]) dqs_pos_timing_check(17);
|
1935 |
|
|
always @(negedge dqs_in[18]) dqs_pos_timing_check(18);
|
1936 |
|
|
always @(negedge dqs_in[19]) dqs_pos_timing_check(19);
|
1937 |
|
|
always @(negedge dqs_in[20]) dqs_pos_timing_check(20);
|
1938 |
|
|
always @(negedge dqs_in[21]) dqs_pos_timing_check(21);
|
1939 |
|
|
always @(negedge dqs_in[22]) dqs_pos_timing_check(22);
|
1940 |
|
|
always @(negedge dqs_in[23]) dqs_pos_timing_check(23);
|
1941 |
|
|
always @(negedge dqs_in[24]) dqs_pos_timing_check(24);
|
1942 |
|
|
always @(negedge dqs_in[25]) dqs_pos_timing_check(25);
|
1943 |
|
|
always @(negedge dqs_in[26]) dqs_pos_timing_check(26);
|
1944 |
|
|
always @(negedge dqs_in[27]) dqs_pos_timing_check(27);
|
1945 |
|
|
always @(negedge dqs_in[28]) dqs_pos_timing_check(28);
|
1946 |
|
|
always @(negedge dqs_in[29]) dqs_pos_timing_check(29);
|
1947 |
|
|
always @(negedge dqs_in[30]) dqs_pos_timing_check(30);
|
1948 |
|
|
always @(negedge dqs_in[31]) dqs_pos_timing_check(31);
|
1949 |
|
|
always @(negedge dqs_in[32]) dqs_neg_timing_check(32);
|
1950 |
|
|
always @(negedge dqs_in[33]) dqs_neg_timing_check(33);
|
1951 |
|
|
always @(negedge dqs_in[34]) dqs_neg_timing_check(34);
|
1952 |
|
|
always @(negedge dqs_in[35]) dqs_neg_timing_check(35);
|
1953 |
|
|
|
1954 |
|
|
task dqs_neg_timing_check;
|
1955 |
|
|
input i;
|
1956 |
|
|
reg [5:0] i;
|
1957 |
|
|
reg [3:0] j;
|
1958 |
|
|
begin
|
1959 |
|
|
if (dqs_in_valid && (wdqs_pos_cntr[i] > 0) && check_write_dqs_high[i] && (dqs_n_en || i < 18)) begin
|
1960 |
|
|
if (dqs_in[i] ^ prev_dqs_in[i]) begin
|
1961 |
|
|
if (dll_locked) begin
|
1962 |
|
|
if ($time - tm_dqs_pos[i] < $rtoi(TDQSH*tck_avg))
|
1963 |
|
|
$display ("%m: at time %t ERROR: tDQSH violation on %s bit %d", $time, dqs_string[i/18], i%18);
|
1964 |
|
|
if ($time - tm_ck_pos < $rtoi(TDSH*tck_avg))
|
1965 |
|
|
$display ("%m: at time %t ERROR: tDSH violation on %s bit %d", $time, dqs_string[i/18], i%18);
|
1966 |
|
|
end
|
1967 |
|
|
if ($time - tm_dm[i%18] < TDS)
|
1968 |
|
|
$display ("%m: at time %t ERROR: tDS violation on DM bit %d by %t", $time, i, tm_dm[i%18] + TDS - $time);
|
1969 |
|
|
if (!dq_out_en) begin
|
1970 |
|
|
for (j=0; j<`DQ_PER_DQS; j=j+1) begin
|
1971 |
|
|
if ($time - tm_dq[i*`DQ_PER_DQS+j] < TDS)
|
1972 |
|
|
$display ("%m: at time %t ERROR: tDS violation on DQ bit %d by %t", $time, i*`DQ_PER_DQS+j, tm_dq[i*`DQ_PER_DQS+j] + TDS - $time);
|
1973 |
|
|
check_dq_tdipw[i*`DQ_PER_DQS+j] <= 1'b1;
|
1974 |
|
|
end
|
1975 |
|
|
end
|
1976 |
|
|
check_dm_tdipw[i%18] <= 1'b1;
|
1977 |
|
|
check_write_dqs_high[i] <= 1'b0;
|
1978 |
|
|
tm_dqs[i%18] <= $time;
|
1979 |
|
|
end else begin
|
1980 |
|
|
$display ("%m: at time %t ERROR: Invalid latching edge on %s bit %d", $time, dqs_string[i/18], i%18);
|
1981 |
|
|
end
|
1982 |
|
|
end
|
1983 |
|
|
tm_dqs_neg[i] = $time;
|
1984 |
|
|
prev_dqs_in[i] <= dqs_in[i];
|
1985 |
|
|
end
|
1986 |
|
|
endtask
|
1987 |
|
|
|
1988 |
|
|
always @(negedge dqs_in[ 0]) dqs_neg_timing_check( 0);
|
1989 |
|
|
always @(negedge dqs_in[ 1]) dqs_neg_timing_check( 1);
|
1990 |
|
|
always @(negedge dqs_in[ 2]) dqs_neg_timing_check( 2);
|
1991 |
|
|
always @(negedge dqs_in[ 3]) dqs_neg_timing_check( 3);
|
1992 |
|
|
always @(negedge dqs_in[ 4]) dqs_neg_timing_check( 4);
|
1993 |
|
|
always @(negedge dqs_in[ 5]) dqs_neg_timing_check( 5);
|
1994 |
|
|
always @(negedge dqs_in[ 6]) dqs_neg_timing_check( 6);
|
1995 |
|
|
always @(negedge dqs_in[ 7]) dqs_neg_timing_check( 7);
|
1996 |
|
|
always @(negedge dqs_in[ 8]) dqs_neg_timing_check( 8);
|
1997 |
|
|
always @(negedge dqs_in[ 9]) dqs_neg_timing_check( 9);
|
1998 |
|
|
always @(negedge dqs_in[10]) dqs_neg_timing_check(10);
|
1999 |
|
|
always @(negedge dqs_in[11]) dqs_neg_timing_check(11);
|
2000 |
|
|
always @(negedge dqs_in[12]) dqs_neg_timing_check(12);
|
2001 |
|
|
always @(negedge dqs_in[13]) dqs_neg_timing_check(13);
|
2002 |
|
|
always @(negedge dqs_in[14]) dqs_neg_timing_check(14);
|
2003 |
|
|
always @(negedge dqs_in[15]) dqs_neg_timing_check(15);
|
2004 |
|
|
always @(negedge dqs_in[16]) dqs_neg_timing_check(16);
|
2005 |
|
|
always @(negedge dqs_in[17]) dqs_neg_timing_check(17);
|
2006 |
|
|
always @(posedge dqs_in[18]) dqs_neg_timing_check(18);
|
2007 |
|
|
always @(posedge dqs_in[19]) dqs_neg_timing_check(19);
|
2008 |
|
|
always @(posedge dqs_in[20]) dqs_neg_timing_check(20);
|
2009 |
|
|
always @(posedge dqs_in[21]) dqs_neg_timing_check(21);
|
2010 |
|
|
always @(posedge dqs_in[22]) dqs_neg_timing_check(22);
|
2011 |
|
|
always @(posedge dqs_in[23]) dqs_neg_timing_check(23);
|
2012 |
|
|
always @(posedge dqs_in[24]) dqs_neg_timing_check(24);
|
2013 |
|
|
always @(posedge dqs_in[25]) dqs_neg_timing_check(25);
|
2014 |
|
|
always @(posedge dqs_in[26]) dqs_neg_timing_check(26);
|
2015 |
|
|
always @(posedge dqs_in[27]) dqs_neg_timing_check(27);
|
2016 |
|
|
always @(posedge dqs_in[28]) dqs_neg_timing_check(28);
|
2017 |
|
|
always @(posedge dqs_in[29]) dqs_neg_timing_check(29);
|
2018 |
|
|
always @(posedge dqs_in[30]) dqs_neg_timing_check(30);
|
2019 |
|
|
always @(posedge dqs_in[31]) dqs_neg_timing_check(31);
|
2020 |
|
|
always @(posedge dqs_in[32]) dqs_neg_timing_check(32);
|
2021 |
|
|
always @(posedge dqs_in[33]) dqs_neg_timing_check(33);
|
2022 |
|
|
always @(posedge dqs_in[34]) dqs_neg_timing_check(34);
|
2023 |
|
|
always @(posedge dqs_in[35]) dqs_neg_timing_check(35);
|
2024 |
|
|
|
2025 |
|
|
endmodule
|