OpenCores
URL https://opencores.org/ocsvn/t400/t400/trunk

Subversion Repositories t400

[/] [t400/] [trunk/] [bench/] [vhdl/] [tb_prod.vhd] - Blame information for rev 179

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 125 arniml
-------------------------------------------------------------------------------
2
--
3
-- Testbench for the production test as proposed by
4
--   "Testing of COP400 Familiy Devices"
5
--   National Semiconductor
6
--   COP Note 7
7
--   April 1991
8
--
9 179 arniml
-- $Id: tb_prod.vhd 179 2009-04-01 19:48:38Z arniml $
10 125 arniml
--
11
-- Copyright (c) 2006 Arnim Laeuger (arniml@opencores.org)
12
--
13
-- All rights reserved
14
--
15
-- Redistribution and use in source and synthezised forms, with or without
16
-- modification, are permitted provided that the following conditions are met:
17
--
18
-- Redistributions of source code must retain the above copyright notice,
19
-- this list of conditions and the following disclaimer.
20
--
21
-- Redistributions in synthesized form must reproduce the above copyright
22
-- notice, this list of conditions and the following disclaimer in the
23
-- documentation and/or other materials provided with the distribution.
24
--
25
-- Neither the name of the author nor the names of other contributors may
26
-- be used to endorse or promote products derived from this software without
27
-- specific prior written permission.
28
--
29
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
31
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
33
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39
-- POSSIBILITY OF SUCH DAMAGE.
40
--
41
-- Please report bugs to the author, but before you do so, please
42
-- make sure that this is not a derivative work and that
43
-- you have the latest version of this file.
44
--
45
-- The latest version of this file can be found at:
46
--      http://www.opencores.org/cvsweb.shtml/t400/
47
--
48
-------------------------------------------------------------------------------
49
 
50
entity tb_prod is
51
 
52
end tb_prod;
53
 
54
 
55
library ieee;
56
use ieee.std_logic_1164.all;
57
use ieee.numeric_std.all;
58
 
59
use work.t400_system_comp_pack.t420;
60
use work.tb_pack.all;
61
use work.t400_opt_pack.all;
62
 
63
architecture behav of tb_prod is
64
 
65
  -- 5 MHz clock
66
  constant period_c : time := 200 ns;
67
  signal   ck_s     : std_logic;
68
  signal   en_ck_s  : std_logic := '0';
69
 
70
  signal reset_n_s  : std_logic;
71
 
72
  signal io_l_s     : std_logic_vector(7 downto 0);
73
  signal io_d_s,
74
         d_s        : std_logic_vector(3 downto 0);
75
  signal exp_d_s    : std_logic_vector(3 downto 0) := "0000";
76
  signal io_g_s,
77
         g_s        : std_logic_vector(3 downto 0);
78
  signal exp_g_s    : std_logic_vector(3 downto 0) := "0000";
79
  signal io_in_s    : std_logic_vector(3 downto 0);
80
 
81
  signal si_s,
82
         so_s,
83
         sk_s       : std_logic;
84
 
85
  signal cs_n_s,
86
         rd_n_s,
87
         wr_n_s     : std_logic;
88
 
89
  signal tb_io_l_s  : std_logic_vector(7 downto 0);
90
  signal disable_s  : boolean   := true;
91
  signal pass_s     : std_logic := 'L';
92
  signal fail_s     : std_logic := 'L';
93
 
94
  signal vdd4_s     : std_logic_vector(3 downto 0);
95
 
96
begin
97
 
98
  vdd4_s    <= (others => '1');
99
  reset_n_s <= '1';
100
 
101
  -----------------------------------------------------------------------------
102
  -- DUT
103
  -----------------------------------------------------------------------------
104
  t420_b : t420
105
    generic map (
106
      opt_ck_div_g   => t400_opt_ck_div_4_c
107
    )
108
    port map (
109
      ck_i      => ck_s,
110
      ck_en_i   => en_ck_s,
111
      reset_n_i => reset_n_s,
112
      cko_i     => io_in_s(2),
113
      si_i      => si_s,
114
      so_o      => so_s,
115
      sk_o      => sk_s,
116
      io_l_b    => io_l_s,
117
      io_d_o    => io_d_s,
118
      io_g_b    => io_g_s,
119
      io_in_i   => io_in_s
120
    );
121
 
122
  io_l_s  <= (others => 'H');
123
  io_d_s  <= (others => 'L');
124
  io_g_s  <= (others => 'L');
125
  io_in_s <= (others => 'H');
126
 
127
  io_in_s <= io_g_s;                    -- feedthrough for production test
128
 
129
  d_s     <= to_X01(io_d_s);
130
  g_s     <= to_X01(io_g_s);
131
 
132
 
133
  -----------------------------------------------------------------------------
134
  -- Testbench elements
135
  -----------------------------------------------------------------------------
136
  tb_elems_b : tb_elems
137
    generic map (
138
      period_g  => period_c,
139
      d_width_g => 4,
140
      g_width_g => 4
141
    )
142
    port map (
143
      io_l_i  => tb_io_l_s,
144
      io_d_i  => vdd4_s,
145
      io_g_i  => vdd4_s,
146
      io_in_o => open,
147
      so_i    => so_s,
148
      si_o    => si_s,
149
      sk_i    => sk_s,
150
      ck_o    => ck_s
151
    );
152
 
153
 
154
  -----------------------------------------------------------------------------
155
  -- Process ck_div
156
  --
157
  -- Purpose:
158
  --   Generates the en_ck_s signal from the high frequency clock.
159
  --
160
  ck_div: process (ck_s)
161
    variable cnt_v : natural := 0;
162
  begin
163
    if ck_s'event and ck_s = '1' then
164
      en_ck_s <= '0';
165
 
166
      if cnt_v = 25 then
167
        cnt_v := 0;
168
        en_ck_s <= '1';
169
      else
170
        cnt_v := cnt_v + 1;
171
      end if;
172
    end if;
173
  end process ck_div;
174
  --
175
  -----------------------------------------------------------------------------
176
 
177
 
178
  -----------------------------------------------------------------------------
179
  -- Process exp
180
  --
181
  -- Purpose:
182
  --   Sets the expected values for D and G ports.
183
  --
184
  exp: process
185
    procedure w_p(signal sig : in std_logic_vector) is
186
    begin
187
      wait until sig'event;
188
    end;
189
 
190
    procedure exp_d_p(exp : in natural) is
191
    begin
192
      w_p(d_s);
193
      exp_d_s <= std_logic_vector(to_unsigned(exp, 4));
194
    end;
195
 
196
    procedure exp_g_p(exp : in natural) is
197
    begin
198
      w_p(g_s);
199
      exp_g_s <= std_logic_vector(to_unsigned(exp, 4));
200
    end;
201
 
202
  begin
203
    -- default settings
204
    pass_s  <= 'L';
205
    exp_d_s <= (others => '0');
206
    exp_g_s <= (others => '0');
207
 
208
    wait for 1 us;
209
    disable_s <= false;
210
 
211
    -- G(0 > 9)
212
    exp_g_p(9);
213
 
214
    -- G(9 > 6)
215
    exp_g_p(6);
216
 
217
    -- D(0 > 13)
218
    exp_d_p(13);
219
 
220
    -- D(13 > 3)
221
    exp_d_p(3);
222
 
223
    -- D(3 > 2)
224
    exp_d_p(2);
225
 
226
    -- D(2 > 3)
227
    exp_d_p(3);
228
 
229
    -- G(6 > 7)
230
    exp_g_p(7);
231
 
232
    -- G(7 > 8)
233
    exp_g_p(8);
234
 
235
    -- G(8 > 9)
236
    exp_g_p(9);
237
 
238
    -- G(9 > 11)
239
    exp_g_p(11);
240
 
241
    -- G(11 > 7)
242
    exp_g_p(7);
243
 
244
    -- G(7 > 1)
245
    exp_g_p(1);
246
 
247
    -- D(2 > 0)
248
    exp_d_p(0);
249
 
250
    -- G(1 > 5)
251
    exp_g_p(5);
252
 
253
    -- D(0 > 15)
254
    exp_d_p(15);
255
 
256
    -- G(5 > 9)
257
    exp_g_p(9);
258
 
259
    -- D(15 > 0)
260
    exp_d_p(0);
261
 
262
    -- G(9 > 10)
263
    exp_g_p(10);
264
 
265
    -- G(10 > 9)
266
    exp_g_p(9);
267
 
268
    -- G(9 > 1)
269
    exp_g_p(1);
270
 
271
    -- G(1 > 4)
272
    exp_g_p(4);
273
 
274
    -- G(4 > 14)
275
    exp_g_p(14);
276
 
277
    -- G(14 > 3)
278
    exp_g_p(3);
279
 
280
    -- G(3 > 14)
281
    exp_g_p(14);
282
 
283
    -- G(14 > 7)
284
    exp_g_p(7);
285
 
286
    -- G(7 > 9)
287
    exp_g_p(9);
288
 
289
    -- G(9 > 10)
290
    exp_g_p(10);
291
 
292
    -- G (10 > 7)
293
    exp_g_p(7);
294
 
295
    -- G(7 > 10)
296
    exp_g_p(10);
297
 
298
    -- G(10 > 7)
299
    exp_g_p(7);
300
 
301
    -- G(7 > 10)
302
    exp_g_p(10);
303
 
304
    -- G(10 > 0)
305
    exp_g_p(0);
306
 
307
    -- G(0 > 10)
308
    exp_g_p(10);
309
 
310
    -- G(10 > 7)
311
    exp_g_p(7);
312
 
313
    -- G(7 > 10)
314
    exp_g_p(10);
315
 
316
    -- D was at 15 before
317
--    -- D(15 > 0)
318
--    exp_d_p(0);
319
 
320
    -- G(10 > 1)
321
    exp_g_p(1);
322
 
323
    -- G(1 > 0)
324
    exp_g_p(0);
325
 
326
    -- D(0 > 11)
327
    exp_d_p(11);
328
 
329
    -- G(10 > 9)
330
    exp_g_p(9);
331
 
332
    ---------------------------------------------------------------------------
333
    -- RAM tests
334
    --
335
    for reg in 0 to 3 loop
336
      exp_g_p(7);
337
      exp_g_p(14);
338
      exp_g_p(5);
339
      exp_g_p(12);
340
      exp_g_p(3);
341
      exp_g_p(10);
342
      exp_g_p(1);
343
      exp_g_p(8);
344
      exp_g_p(15);
345
      exp_g_p(6);
346
      exp_g_p(13);
347
      exp_g_p(4);
348
      exp_g_p(11);
349
      exp_g_p(2);
350
      exp_g_p(9);
351
      exp_g_p(0);
352
    end loop;
353
 
354
    wait for 1 us;
355
    if fail_s /= '1' then
356
      pass_s  <= '1';
357
    end if;
358
    wait;
359
  end process exp;
360
  --
361
  -----------------------------------------------------------------------------
362
 
363
 
364
  -----------------------------------------------------------------------------
365
  -- Process exp_d
366
  --
367
  -- Purpose:
368
  --  Checks the expected value for the D port.
369
  --
370
  exp_d: process (ck_s)
371
  begin
372
    if disable_s then
373
      fail_s <= 'L';
374
    elsif ck_s'event and ck_s = '0' then
375
      if d_s /= exp_d_s then
376
        fail_s <= '1';
377
      end if;
378
    end if;
379
  end process exp_d;
380
  --
381
  -----------------------------------------------------------------------------
382
 
383
 
384
  -----------------------------------------------------------------------------
385
  -- Process exp_g
386
  --
387
  -- Purpose:
388
  --  Checks the expected value for the G port.
389
  --
390
  exp_g: process (ck_s)
391
  begin
392
    if disable_s then
393
      fail_s <= 'L';
394
    elsif ck_s'event and ck_s = '0' then
395
      if g_s /= exp_g_s then
396
        fail_s <= '1';
397
      end if;
398
    end if;
399
  end process exp_g;
400
  --
401
  -----------------------------------------------------------------------------
402
 
403
 
404
  -----------------------------------------------------------------------------
405
  -- Process pass_fail
406
  --
407
  -- Purpose:
408
  --   Collects the pass/fail signal and generates the respective sequence
409
  --   on tb_io_l_s.
410
  --
411
  pass_fail: process
412
    procedure tb_pass_fail(pass : in boolean) is
413
    begin
414
      tb_io_l_s <= "00000000";
415
      wait for 1 us;
416
      tb_io_l_s <= "10100000";
417
      wait for 1 us;
418
      tb_io_l_s <= "01010000";
419
      wait for 1 us;
420
 
421
      if pass then
422
        tb_io_l_s <= "00000000";
423
      else
424
        tb_io_l_s <= "11110000";
425
      end if;
426
      wait for 1 us;
427
    end;
428
 
429
  begin
430
    tb_io_l_s <= (others => '0');
431
 
432
    loop
433
      wait until pass_s'event or fail_s'event;
434
      if    fail_s = '1' then
435
        tb_pass_fail(pass => false);
436
      elsif pass_s = '1' then
437
        tb_pass_fail(pass => true);
438
      end if;
439
    end loop;
440
  end process pass_fail;
441
  --
442
  -----------------------------------------------------------------------------
443
 
444
end behav;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.