1 |
3 |
mgeng |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- Test pattern generator for the ----
|
4 |
|
|
---- Synchronous static RAM ("Zero Bus Turnaround" RAM, ZBT RAM) ----
|
5 |
|
|
---- simulation model. ----
|
6 |
|
|
---- ----
|
7 |
|
|
---- This file is part of the simu_mem project. ----
|
8 |
|
|
---- ----
|
9 |
|
|
---- Description ----
|
10 |
|
|
---- This architecture generates a random pattern. ----
|
11 |
|
|
---- ----
|
12 |
|
|
---- Authors: ----
|
13 |
|
|
---- - Michael Geng, vhdl@MichaelGeng.de ----
|
14 |
|
|
---- ----
|
15 |
|
|
----------------------------------------------------------------------
|
16 |
|
|
---- ----
|
17 |
|
|
---- Copyright (C) 2008 Authors ----
|
18 |
|
|
---- ----
|
19 |
|
|
---- This source file may be used and distributed without ----
|
20 |
|
|
---- restriction provided that this copyright statement is not ----
|
21 |
|
|
---- removed from the file and that any derivative work contains ----
|
22 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
23 |
|
|
---- ----
|
24 |
|
|
---- This source file is free software; you can redistribute it ----
|
25 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
26 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
27 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
28 |
|
|
---- later version. ----
|
29 |
|
|
---- ----
|
30 |
|
|
---- This source is distributed in the hope that it will be ----
|
31 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
32 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
33 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
34 |
|
|
---- details. ----
|
35 |
|
|
---- ----
|
36 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
37 |
|
|
---- Public License along with this source; if not, download it ----
|
38 |
|
|
---- from http://www.gnu.org/licenses/lgpl.html ----
|
39 |
|
|
---- ----
|
40 |
|
|
----------------------------------------------------------------------
|
41 |
|
|
-- CVS Revision History
|
42 |
|
|
--
|
43 |
|
|
-- $Log: not supported by cvs2svn $
|
44 |
|
|
--
|
45 |
|
|
ARCHITECTURE random OF patgen IS
|
46 |
|
|
CONSTANT D_width : INTEGER := D'LENGTH;
|
47 |
|
|
CONSTANT A_width : INTEGER := A'LENGTH;
|
48 |
|
|
|
49 |
|
|
SIGNAL next_state : state_type;
|
50 |
|
|
SIGNAL state : state_type;
|
51 |
|
|
SIGNAL last_state : state_type;
|
52 |
|
|
SIGNAL next_operation : state_type;
|
53 |
|
|
SIGNAL operation : state_type;
|
54 |
|
|
SIGNAL want_sleep : STD_LOGIC;
|
55 |
|
|
SIGNAL want_sleep_delayed_1 : STD_LOGIC;
|
56 |
|
|
SIGNAL want_sleep_delayed_2 : STD_LOGIC;
|
57 |
|
|
SIGNAL ZZ_delayed_1 : STD_LOGIC;
|
58 |
|
|
BEGIN
|
59 |
|
|
ASSERT A_width >= 5
|
60 |
|
|
REPORT "Error: Address widths < 5 bits not supported by the test pattern generator"
|
61 |
|
|
SEVERITY FAILURE;
|
62 |
|
|
|
63 |
|
|
D <= (D_width - 1 DOWNTO 0 => 'L');
|
64 |
|
|
|
65 |
|
|
next_state <= calc_state (CS1_n, CS2, CS2_n, WE_n, BW_n, OE_n, ADV, ZZ, operation) WHEN (CKE_n = '0');
|
66 |
|
|
next_operation <= calc_operation (next_state, operation);
|
67 |
|
|
|
68 |
|
|
pPatternGenerator : PROCESS (Clk, Rst) IS
|
69 |
|
|
VARIABLE random : NATURAL;
|
70 |
|
|
VARIABLE random_u : unsigned (31 DOWNTO 0);
|
71 |
|
|
VARIABLE OE_n_v : STD_LOGIC;
|
72 |
|
|
VARIABLE WE_n_v : STD_LOGIC;
|
73 |
|
|
VARIABLE nWE_next_rising_edge : STD_LOGIC;
|
74 |
|
|
VARIABLE ADV_v : STD_LOGIC;
|
75 |
|
|
VARIABLE CKE_n_v : STD_LOGIC;
|
76 |
|
|
VARIABLE nBW_v : STD_LOGIC_VECTOR (D_width / 9 - 1 DOWNTO 0);
|
77 |
|
|
VARIABLE nCS1_v : STD_LOGIC;
|
78 |
|
|
VARIABLE CS2_v : STD_LOGIC;
|
79 |
|
|
VARIABLE nCS2_v : STD_LOGIC;
|
80 |
|
|
VARIABLE ZZ_v : STD_LOGIC;
|
81 |
|
|
VARIABLE State_v : state_type;
|
82 |
|
|
BEGIN
|
83 |
|
|
IF (Rst = '1') THEN
|
84 |
|
|
random := 1;
|
85 |
|
|
WE_n_v := '0';
|
86 |
|
|
D <= (D_width - 1 DOWNTO 0 => '0');
|
87 |
|
|
A <= (A_width - 1 DOWNTO 0 => '0');
|
88 |
|
|
ADV <= '0';
|
89 |
|
|
WE_n <= '0';
|
90 |
|
|
CKE_n <= '0';
|
91 |
|
|
CS1_n <= '0';
|
92 |
|
|
CS2 <= '0';
|
93 |
|
|
CS2_n <= '0';
|
94 |
|
|
CKE_n <= '0';
|
95 |
|
|
OE_n <= '0';
|
96 |
|
|
ZZ <= '0';
|
97 |
|
|
ZZ_delayed_1 <= '0';
|
98 |
|
|
LBO_n <= '0';
|
99 |
|
|
BW_n <= (D_width / 9 - 1 DOWNTO 0 => '0');
|
100 |
|
|
last_state <= Deselect;
|
101 |
|
|
want_sleep <= '0';
|
102 |
|
|
want_sleep_delayed_1 <= '0';
|
103 |
|
|
want_sleep_delayed_2 <= '0';
|
104 |
|
|
ELSIF RISING_EDGE (Clk) THEN
|
105 |
|
|
state <= next_state;
|
106 |
|
|
operation <= next_operation;
|
107 |
|
|
|
108 |
|
|
IF ((WE_n_v = '1') OR (next_state = sleep) OR (state = sleep)) THEN
|
109 |
|
|
WE_n <= '1' AFTER tWH;
|
110 |
|
|
END IF;
|
111 |
|
|
|
112 |
|
|
IF ((state = write) OR (state = write_continue)) THEN
|
113 |
|
|
OE_n_v := '1';
|
114 |
|
|
ELSE
|
115 |
|
|
random := lcg (random);
|
116 |
|
|
OE_n_v := TO_UNSIGNED (random, 32)(0);
|
117 |
|
|
END IF;
|
118 |
|
|
OE_n <= OE_n_v AFTER clk_periode - tOE;
|
119 |
|
|
ELSIF FALLING_EDGE (Clk) THEN
|
120 |
|
|
IF (Ena = '1') THEN
|
121 |
|
|
random := lcg (random);
|
122 |
|
|
IF ((state = sleep) OR (last_state = sleep)) THEN
|
123 |
|
|
ADV_v := '0';
|
124 |
|
|
ELSE
|
125 |
|
|
ADV_v := TO_UNSIGNED (random, 32)(0);
|
126 |
|
|
END IF;
|
127 |
|
|
WE_n_v := TO_UNSIGNED (random, 32)(1);
|
128 |
|
|
CKE_n_v := TO_UNSIGNED (random, 32)(2);
|
129 |
|
|
LBO_n <= TO_UNSIGNED (random, 32)(3);
|
130 |
|
|
nBW_v := STD_LOGIC_VECTOR (TO_UNSIGNED (random, 32)(D_width / 9 + 3 DOWNTO 4));
|
131 |
|
|
A <= TO_UNSIGNED (random, 32)(8) & (A_width - 5 DOWNTO 0 => '0') &
|
132 |
|
|
TO_UNSIGNED (random, 32)(9) & "00";
|
133 |
|
|
|
134 |
|
|
IF (last_state = write) OR (last_state = write_continue) THEN
|
135 |
|
|
random_vector (D, random);
|
136 |
|
|
ELSE
|
137 |
|
|
D <= (D_width - 1 DOWNTO 0 => 'Z');
|
138 |
|
|
END IF;
|
139 |
|
|
|
140 |
|
|
-- disable clock only about every 1024 cycles
|
141 |
|
|
random := lcg (random);
|
142 |
|
|
random_u := TO_UNSIGNED (random, 32);
|
143 |
|
|
CKE_n_v := random_u (0) AND random_u (1) AND random_u (2) AND random_u (3) AND random_u (4) AND
|
144 |
|
|
random_u (5) AND random_u (6) AND random_u (7) AND random_u (8) AND random_u (9);
|
145 |
|
|
|
146 |
|
|
-- deassert CS1_n only about every 1024 cycles
|
147 |
|
|
random := lcg (random);
|
148 |
|
|
random_u := TO_UNSIGNED (random, 32);
|
149 |
|
|
nCS1_v := random_u (0) AND random_u (1) AND random_u (2) AND random_u (3) AND random_u (4) AND
|
150 |
|
|
random_u (5) AND random_u (6) AND random_u (7) AND random_u (8) AND random_u (9);
|
151 |
|
|
|
152 |
|
|
-- deassert CS2 only about every 1024 cycles
|
153 |
|
|
random := lcg (random);
|
154 |
|
|
random_u := TO_UNSIGNED (random, 32);
|
155 |
|
|
CS2_v := random_u (0) OR random_u (1) OR random_u (2) OR random_u (3) OR random_u (4) OR
|
156 |
|
|
random_u (5) OR random_u (6) OR random_u (7) OR random_u (8) OR random_u (9);
|
157 |
|
|
|
158 |
|
|
-- deassert CS2_n only about every 1024 cycles
|
159 |
|
|
random := lcg (random);
|
160 |
|
|
random_u := TO_UNSIGNED (random, 32);
|
161 |
|
|
nCS2_v := random_u (0) AND random_u (1) AND random_u (2) AND random_u (3) AND random_u (4) AND
|
162 |
|
|
random_u (5) AND random_u (6) AND random_u (7) AND random_u (8) AND random_u (9);
|
163 |
|
|
|
164 |
|
|
-- put RAM in sleep mode only about every 1024 cycles
|
165 |
|
|
random := lcg (random);
|
166 |
|
|
random_u := TO_UNSIGNED (random, 32);
|
167 |
|
|
want_sleep <= random_u (0) AND random_u (1) AND random_u (2) AND random_u (3) AND random_u (4) AND
|
168 |
|
|
random_u (5) AND random_u (6) AND random_u (7) AND random_u (8) AND random_u (9);
|
169 |
|
|
want_sleep_delayed_1 <= want_sleep;
|
170 |
|
|
want_sleep_delayed_2 <= want_sleep_delayed_1;
|
171 |
|
|
ZZ_v := want_sleep_delayed_2;
|
172 |
|
|
ZZ_delayed_1 <= ZZ;
|
173 |
|
|
|
174 |
|
|
IF (WE_n = '0') AND (WE_n_v = '1') THEN
|
175 |
|
|
nWE_next_rising_edge := '0';
|
176 |
|
|
ELSE
|
177 |
|
|
nWE_next_rising_edge := WE_n_v;
|
178 |
|
|
END IF;
|
179 |
|
|
|
180 |
|
|
State_v := calc_state (nCS1_v, CS2_v, nCS2_v, nWE_next_rising_edge, nBW_v, OE_n, ADV_v,
|
181 |
|
|
ZZ_v, operation);
|
182 |
|
|
IF (State_v = invalid_state) THEN
|
183 |
|
|
ADV_v := '0';
|
184 |
|
|
END IF;
|
185 |
|
|
|
186 |
|
|
State_v := calc_state (nCS1_v, CS2_v, nCS2_v, nWE_next_rising_edge, nBW_v, OE_n, ADV_v,
|
187 |
|
|
ZZ_v, operation);
|
188 |
|
|
IF (State_v = invalid_state) THEN
|
189 |
|
|
nBW_v (0) := '0';
|
190 |
|
|
END IF;
|
191 |
|
|
|
192 |
|
|
State_v := calc_state (nCS1_v, CS2_v, nCS2_v, nWE_next_rising_edge, nBW_v, OE_n, ADV_v,
|
193 |
|
|
ZZ_v, operation);
|
194 |
|
|
IF (((want_sleep = '1') OR (want_sleep_delayed_1 = '1') OR (want_sleep_delayed_2 = '1')) AND
|
195 |
|
|
((State_v = write) OR (State_v = write_continue))) THEN
|
196 |
|
|
nCS1_v := '1';
|
197 |
|
|
ADV_v := '0';
|
198 |
|
|
END IF;
|
199 |
|
|
|
200 |
|
|
IF (((ZZ = '1') OR (ZZ_delayed_1 = '1')) AND
|
201 |
|
|
((State_v = write))) THEN
|
202 |
|
|
nCS1_v := '0';
|
203 |
|
|
CS2_v := '1';
|
204 |
|
|
nCS2_v := '0';
|
205 |
|
|
WE_n_v := '1';
|
206 |
|
|
ADV_v := '0';
|
207 |
|
|
OE_n_v := '0';
|
208 |
|
|
CKE_n_v := '0';
|
209 |
|
|
END IF;
|
210 |
|
|
|
211 |
|
|
ADV <= ADV_v;
|
212 |
|
|
CKE_n <= CKE_n_v;
|
213 |
|
|
BW_n <= nBW_v;
|
214 |
|
|
CKE_n <= CKE_n_v;
|
215 |
|
|
CS1_n <= nCS1_v;
|
216 |
|
|
CS2 <= CS2_v;
|
217 |
|
|
CS2_n <= nCS2_v;
|
218 |
|
|
ZZ <= ZZ_v;
|
219 |
|
|
|
220 |
|
|
IF (WE_n_v = '0') THEN
|
221 |
|
|
WE_n <= '0' AFTER clk_periode * 0.5 - tWS;
|
222 |
|
|
END IF;
|
223 |
|
|
|
224 |
|
|
IF (CKE_n = '0') THEN
|
225 |
|
|
last_state <= state;
|
226 |
|
|
END IF;
|
227 |
|
|
END IF;
|
228 |
|
|
END IF;
|
229 |
|
|
END PROCESS pPatternGenerator;
|
230 |
|
|
END ARCHITECTURE random;
|