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

Subversion Repositories marca

[/] [marca/] [tags/] [INITIAL/] [vhdl/] [marca.vht] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jeunes2
-- Copyright (C) 1991-2006 Altera Corporation
2
-- Your use of Altera Corporation's design tools, logic functions
3
-- and other software and tools, and its AMPP partner logic
4
-- functions, and any output files any of the foregoing
5
-- (including device programming or simulation files), and any
6
-- associated documentation or information are expressly subject
7
-- to the terms and conditions of the Altera Program License
8
-- Subscription Agreement, Altera MegaCore Function License
9
-- Agreement, or other applicable license agreement, including,
10
-- without limitation, that your use is for the sole purpose of
11
-- programming logic devices manufactured by Altera and sold by
12
-- Altera or its authorized distributors.  Please refer to the
13
-- applicable agreement for further details.
14
 
15
-- *****************************************************************************
16
-- This file contains a Vhdl test bench with test vectors .The test vectors
17
-- are exported from a vector file in the Quartus Waveform Editor and apply to
18
-- the top level entity of the current Quartus project .The user can use this
19
-- testbench to simulate his design using a third-party simulation tool .
20
-- *****************************************************************************
21
-- Generated on "12/14/2006 19:48:14"
22
 
23
-- Vhdl Self-Checking Test Bench (with test vectors) for design :       marca
24
--
25
-- Simulation tool : 3rd Party
26
--
27
 
28
LIBRARY ieee;
29
USE ieee.std_logic_1164.all;
30
 
31
LIBRARY STD;
32
USE STD.textio.ALL;
33
 
34
PACKAGE marca_vhd_tb_types IS
35
-- input port types
36
SUBTYPE i1_type IS STD_LOGIC;
37
SUBTYPE i2_type IS STD_LOGIC_VECTOR(1 DOWNTO 0);
38
SUBTYPE i3_type IS STD_LOGIC;
39
-- output port types
40
SUBTYPE o1_type IS STD_LOGIC_VECTOR(1 DOWNTO 0);
41
-- output port names
42
CONSTANT o1_name : STRING (1 TO 7) := "ext_out";
43
-- n(outputs)
44
CONSTANT o_num : INTEGER := 1;
45
-- mismatches vector type
46
TYPE mmvec IS ARRAY (0 to (o_num - 1)) OF INTEGER;
47
-- exp o/ first change track vector type
48
TYPE trackvec IS ARRAY (1 to o_num) OF BIT;
49
-- sampler type
50
SUBTYPE sample_type IS STD_LOGIC;
51
-- utility functions
52
FUNCTION std_logic_to_char (a: STD_LOGIC) RETURN CHARACTER;
53
FUNCTION std_logic_vector_to_string (a: STD_LOGIC_VECTOR) RETURN STRING;
54
PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC; justified: IN SIDE:= RIGHT; field:IN WIDTH:=0);
55
PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC_VECTOR; justified: IN SIDE:= RIGHT; field:IN WIDTH:=0);
56
PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC; real_value : IN STD_LOGIC);
57
PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC_VECTOR; real_value : IN STD_LOGIC_VECTOR);
58
 
59
END marca_vhd_tb_types;
60
 
61
PACKAGE BODY marca_vhd_tb_types IS
62
        FUNCTION std_logic_to_char (a: STD_LOGIC)
63
                RETURN CHARACTER IS
64
        BEGIN
65
        CASE a IS
66
         WHEN 'U' =>
67
          RETURN 'U';
68
         WHEN 'X' =>
69
          RETURN 'X';
70
         WHEN '0' =>
71
          RETURN '0';
72
         WHEN '1' =>
73
          RETURN '1';
74
         WHEN 'Z' =>
75
          RETURN 'Z';
76
         WHEN 'W' =>
77
          RETURN 'W';
78
         WHEN 'L' =>
79
          RETURN 'L';
80
         WHEN 'H' =>
81
          RETURN 'H';
82
         WHEN '-' =>
83
          RETURN 'D';
84
        END CASE;
85
        END;
86
 
87
        FUNCTION std_logic_vector_to_string (a: STD_LOGIC_VECTOR)
88
                RETURN STRING IS
89
        VARIABLE result : STRING(1 TO a'LENGTH);
90
        VARIABLE j : NATURAL := 1;
91
        BEGIN
92
                FOR i IN a'RANGE LOOP
93
                        result(j) := std_logic_to_char(a(i));
94
                        j := j + 1;
95
                END LOOP;
96
                RETURN result;
97
        END;
98
 
99
        PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC; justified: IN SIDE:=RIGHT; field:IN WIDTH:=0) IS
100
        BEGIN
101
                write(L,std_logic_to_char(VALUE),JUSTIFIED,field);
102
        END;
103
 
104
        PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC_VECTOR; justified: IN SIDE:= RIGHT; field:IN WIDTH:=0) IS
105
        BEGIN
106
                write(L,std_logic_vector_to_string(VALUE),JUSTIFIED,field);
107
        END;
108
 
109
        PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC; real_value : IN STD_LOGIC) IS
110
        VARIABLE txt : LINE;
111
        BEGIN
112
        write(txt,string'("ERROR! Vector Mismatch for output port "));
113
        write(txt,output_port_name);
114
        write(txt,string'(" :: @time = "));
115
        write(txt,NOW);
116
        write(txt,string'(", Expected value = "));
117
        write(txt,expected_value);
118
        write(txt,string'(", Real value = "));
119
        write(txt,real_value);
120
        writeline(output,txt);
121
        END;
122
 
123
        PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC_VECTOR; real_value : IN STD_LOGIC_VECTOR) IS
124
        VARIABLE txt : LINE;
125
        BEGIN
126
        write(txt,string'("ERROR! Vector Mismatch for output port "));
127
        write(txt,output_port_name);
128
        write(txt,string'(" :: @time = "));
129
        write(txt,NOW);
130
        write(txt,string'(", Expected value = "));
131
        write(txt,expected_value);
132
        write(txt,string'(", Real value = "));
133
        write(txt,real_value);
134
        writeline(output,txt);
135
        END;
136
 
137
END marca_vhd_tb_types;
138
 
139
LIBRARY ieee;
140
USE ieee.std_logic_1164.all;
141
 
142
USE WORK.marca_vhd_tb_types.ALL;
143
 
144
ENTITY marca_vhd_sample_tst IS
145
PORT (
146
        s1 : IN i1_type;
147
        s2 : IN i2_type;
148
        s3 : IN i3_type;
149
        sampler : OUT sample_type
150
        );
151
END marca_vhd_sample_tst;
152
 
153
ARCHITECTURE sample_arch OF marca_vhd_sample_tst IS
154
SIGNAL clk : sample_type := '1';
155
BEGIN
156
t_prcs_sample : PROCESS ( s1 , s2 , s3 )
157
BEGIN
158
        IF (NOW > 0 ps) AND (NOW < 850000000 ps) THEN
159
                clk <= NOT clk ;
160
        END IF;
161
END PROCESS t_prcs_sample;
162
sampler <= clk;
163
END sample_arch;
164
 
165
LIBRARY ieee;
166
USE ieee.std_logic_1164.all;
167
 
168
LIBRARY STD;
169
USE STD.textio.ALL;
170
 
171
USE WORK.marca_vhd_tb_types.ALL;
172
 
173
ENTITY marca_vhd_check_tst IS
174
GENERIC (
175
        debug_tbench : BIT := '0'
176
);
177
PORT (
178
        o1 : IN o1_type;
179
        sampler : IN sample_type
180
);
181
END marca_vhd_check_tst;
182
ARCHITECTURE ovec_arch OF marca_vhd_check_tst IS
183
SIGNAL t_sig_o1_expected,t_sig_o1_expected_prev,t_sig_o1_prev : o1_type;
184
 
185
SIGNAL trigger : BIT := '0';
186
SIGNAL trigger_e : BIT := '0';
187
SIGNAL trigger_r : BIT := '0';
188
SIGNAL trigger_i : BIT := '0';
189
SIGNAL num_mismatches : mmvec := (OTHERS => 0);
190
 
191
BEGIN
192
 
193
-- Update history buffers  expected /o
194
t_prcs_update_o_expected_hist : PROCESS (trigger)
195
BEGIN
196
        t_sig_o1_expected_prev <= t_sig_o1_expected;
197
END PROCESS t_prcs_update_o_expected_hist;
198
 
199
 
200
-- Update history buffers  real /o
201
t_prcs_update_o_real_hist : PROCESS (trigger)
202
BEGIN
203
        t_sig_o1_prev <= o1;
204
END PROCESS t_prcs_update_o_real_hist;
205
 
206
 
207
-- expected ext_out[1]
208
t_prcs_ext_out_1: PROCESS
209
BEGIN
210
        t_sig_o1_expected(1) <= '0';
211
        WAIT FOR 93383521 ps;
212
        t_sig_o1_expected(1) <= '1';
213
        WAIT FOR 100000 ps;
214
        t_sig_o1_expected(1) <= '0';
215
        WAIT FOR 95600000 ps;
216
        t_sig_o1_expected(1) <= '1';
217
        WAIT FOR 100000 ps;
218
        t_sig_o1_expected(1) <= '0';
219
        WAIT FOR 95050000 ps;
220
        t_sig_o1_expected(1) <= '1';
221
        WAIT FOR 100000 ps;
222
        t_sig_o1_expected(1) <= '0';
223
        WAIT FOR 95600000 ps;
224
        t_sig_o1_expected(1) <= '1';
225
        WAIT FOR 100000 ps;
226
        t_sig_o1_expected(1) <= '0';
227
WAIT;
228
END PROCESS t_prcs_ext_out_1;
229
-- expected ext_out[0]
230
t_prcs_ext_out_0: PROCESS
231
BEGIN
232
        t_sig_o1_expected(0) <= '1';
233
        WAIT FOR 387433530 ps;
234
        t_sig_o1_expected(0) <= '0';
235
        WAIT FOR 8800000 ps;
236
        FOR i IN 1 TO 3
237
        LOOP
238
                t_sig_o1_expected(0) <= '1';
239
                WAIT FOR 17600000 ps;
240
                t_sig_o1_expected(0) <= '0';
241
                WAIT FOR 17600000 ps;
242
        END LOOP;
243
        t_sig_o1_expected(0) <= '1';
244
        WAIT FOR 8800000 ps;
245
        FOR i IN 1 TO 2
246
        LOOP
247
                t_sig_o1_expected(0) <= '0';
248
                WAIT FOR 17600000 ps;
249
                t_sig_o1_expected(0) <= '1';
250
                WAIT FOR 17600000 ps;
251
        END LOOP;
252
        t_sig_o1_expected(0) <= '0';
253
        WAIT FOR 8800000 ps;
254
        t_sig_o1_expected(0) <= '1';
255
        WAIT FOR 8800000 ps;
256
        t_sig_o1_expected(0) <= '0';
257
        WAIT FOR 26400000 ps;
258
        FOR i IN 1 TO 2
259
        LOOP
260
                t_sig_o1_expected(0) <= '1';
261
                WAIT FOR 17600000 ps;
262
                t_sig_o1_expected(0) <= '0';
263
                WAIT FOR 17600000 ps;
264
        END LOOP;
265
        t_sig_o1_expected(0) <= '1';
266
        WAIT FOR 8800000 ps;
267
        t_sig_o1_expected(0) <= '0';
268
        WAIT FOR 8800000 ps;
269
        t_sig_o1_expected(0) <= '1';
270
        WAIT FOR 8800000 ps;
271
        t_sig_o1_expected(0) <= '0';
272
        WAIT FOR 35200000 ps;
273
        t_sig_o1_expected(0) <= '1';
274
WAIT;
275
END PROCESS t_prcs_ext_out_0;
276
 
277
-- Set trigger on real/expected o/ pattern changes
278
 
279
t_prcs_trigger_e : PROCESS(t_sig_o1_expected)
280
BEGIN
281
        trigger_e <= NOT trigger_e;
282
END PROCESS t_prcs_trigger_e;
283
 
284
t_prcs_trigger_r : PROCESS(o1)
285
BEGIN
286
        trigger_r <= NOT trigger_r;
287
END PROCESS t_prcs_trigger_r;
288
 
289
 
290
t_prcs_selfcheck : PROCESS
291
VARIABLE i : INTEGER := 1;
292
VARIABLE txt : LINE;
293
 
294
VARIABLE last_o1_exp : o1_type := (OTHERS => 'U');
295
 
296
VARIABLE on_first_change : trackvec := "1";
297
BEGIN
298
 
299
WAIT UNTIL (sampler'LAST_VALUE = '1'OR sampler'LAST_VALUE = '0')
300
        AND sampler'EVENT;
301
IF (debug_tbench = '1') THEN
302
        write(txt,string'("Scanning pattern "));
303
        write(txt,i);
304
        writeline(output,txt);
305
        write(txt,string'("| expected "));write(txt,o1_name);write(txt,string'(" = "));write(txt,t_sig_o1_expected_prev);
306
        writeline(output,txt);
307
        write(txt,string'("| real "));write(txt,o1_name);write(txt,string'(" = "));write(txt,t_sig_o1_prev);
308
        writeline(output,txt);
309
        i := i + 1;
310
END IF;
311
IF ( t_sig_o1_expected_prev /= "XX" ) AND (t_sig_o1_expected_prev /= "UU" ) AND (t_sig_o1_prev /= t_sig_o1_expected_prev) AND (
312
        (t_sig_o1_expected_prev /= last_o1_exp) OR
313
        (on_first_change(1) = '1')
314
                ) THEN
315
        throw_error("ext_out",t_sig_o1_expected_prev,t_sig_o1_prev);
316
        num_mismatches(0) <= num_mismatches(0) + 1;
317
        on_first_change(1) := '0';
318
        last_o1_exp := t_sig_o1_expected_prev;
319
END IF;
320
    trigger_i <= NOT trigger_i;
321
END PROCESS t_prcs_selfcheck;
322
 
323
 
324
t_prcs_trigger_res : PROCESS(trigger_e,trigger_i,trigger_r)
325
BEGIN
326
        trigger <= trigger_i XOR trigger_e XOR trigger_r;
327
END PROCESS t_prcs_trigger_res;
328
 
329
t_prcs_endsim : PROCESS
330
VARIABLE txt : LINE;
331
VARIABLE total_mismatches : INTEGER := 0;
332
BEGIN
333
WAIT FOR 850000000 ps;
334
total_mismatches := num_mismatches(0);
335
IF (total_mismatches = 0) THEN
336
        write(txt,string'("Simulation passed !"));
337
        writeline(output,txt);
338
ELSE
339
        write(txt,total_mismatches);
340
        write(txt,string'(" mismatched vectors : Simulation failed !"));
341
        writeline(output,txt);
342
END IF;
343
WAIT;
344
END PROCESS t_prcs_endsim;
345
 
346
END ovec_arch;
347
 
348
LIBRARY ieee;
349
USE ieee.std_logic_1164.all;
350
 
351
LIBRARY STD;
352
USE STD.textio.ALL;
353
 
354
USE WORK.marca_vhd_tb_types.ALL;
355
 
356
ENTITY marca_vhd_vec_tst IS
357
END marca_vhd_vec_tst;
358
ARCHITECTURE marca_arch OF marca_vhd_vec_tst IS
359
-- constants
360
-- signals
361
SIGNAL t_sig_clock : STD_LOGIC;
362
SIGNAL t_sig_ext_in : STD_LOGIC_VECTOR(1 DOWNTO 0);
363
SIGNAL t_sig_ext_out : STD_LOGIC_VECTOR(1 DOWNTO 0);
364
SIGNAL t_sig_ext_reset : STD_LOGIC;
365
SIGNAL t_sig_sampler : sample_type;
366
 
367
COMPONENT marca
368
        PORT (
369
        clock : IN STD_LOGIC;
370
        ext_in : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
371
        ext_out : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
372
        ext_reset : IN STD_LOGIC
373
        );
374
END COMPONENT;
375
COMPONENT marca_vhd_check_tst
376
PORT (
377
        o1 : IN o1_type;
378
        sampler : IN sample_type
379
);
380
END COMPONENT;
381
COMPONENT marca_vhd_sample_tst
382
PORT (
383
        s1 : IN i1_type;
384
        s2 : IN i2_type;
385
        s3 : IN i3_type;
386
        sampler : OUT sample_type
387
        );
388
END COMPONENT;
389
BEGIN
390
        i1 : marca
391
        PORT MAP (
392
-- list connections between master ports and signals
393
        clock => t_sig_clock,
394
        ext_in => t_sig_ext_in,
395
        ext_out => t_sig_ext_out,
396
        ext_reset => t_sig_ext_reset
397
        );
398
 
399
-- clock
400
t_prcs_clock: PROCESS
401
BEGIN
402
LOOP
403
        t_sig_clock <= '0';
404
        WAIT FOR 25000 ps;
405
        t_sig_clock <= '1';
406
        WAIT FOR 25000 ps;
407
        IF (NOW >= 850000000 ps) THEN WAIT; END IF;
408
END LOOP;
409
END PROCESS t_prcs_clock;
410
 
411
-- ext_reset
412
t_prcs_ext_reset: PROCESS
413
BEGIN
414
        t_sig_ext_reset <= '0';
415
        WAIT FOR 100000 ps;
416
        t_sig_ext_reset <= '1';
417
WAIT;
418
END PROCESS t_prcs_ext_reset;
419
-- ext_in[1]
420
t_prcs_ext_in_1: PROCESS
421
BEGIN
422
        t_sig_ext_in(1) <= '0';
423
WAIT;
424
END PROCESS t_prcs_ext_in_1;
425
-- ext_in[0]
426
t_prcs_ext_in_0: PROCESS
427
BEGIN
428
        t_sig_ext_in(0) <= '1';
429
        WAIT FOR 8680000 ps;
430
        t_sig_ext_in(0) <= '0';
431
        WAIT FOR 8680000 ps;
432
        t_sig_ext_in(0) <= '1';
433
        WAIT FOR 8680000 ps;
434
        t_sig_ext_in(0) <= '0';
435
        WAIT FOR 26040000 ps;
436
        t_sig_ext_in(0) <= '1';
437
        WAIT FOR 17360000 ps;
438
        t_sig_ext_in(0) <= '0';
439
        WAIT FOR 17360000 ps;
440
        t_sig_ext_in(0) <= '1';
441
        WAIT FOR 17360000 ps;
442
        t_sig_ext_in(0) <= '0';
443
        WAIT FOR 17360000 ps;
444
        t_sig_ext_in(0) <= '1';
445
        WAIT FOR 8680000 ps;
446
        t_sig_ext_in(0) <= '0';
447
        WAIT FOR 17360000 ps;
448
        t_sig_ext_in(0) <= '1';
449
        WAIT FOR 17360000 ps;
450
        t_sig_ext_in(0) <= '0';
451
        WAIT FOR 17360000 ps;
452
        t_sig_ext_in(0) <= '1';
453
        WAIT FOR 17360000 ps;
454
        t_sig_ext_in(0) <= '0';
455
        WAIT FOR 8680000 ps;
456
        t_sig_ext_in(0) <= '1';
457
        WAIT FOR 17360000 ps;
458
        t_sig_ext_in(0) <= '0';
459
        WAIT FOR 17360000 ps;
460
        t_sig_ext_in(0) <= '1';
461
        WAIT FOR 17360000 ps;
462
        t_sig_ext_in(0) <= '0';
463
        WAIT FOR 17360000 ps;
464
        t_sig_ext_in(0) <= '1';
465
        WAIT FOR 17360000 ps;
466
        t_sig_ext_in(0) <= '0';
467
        WAIT FOR 17360000 ps;
468
        t_sig_ext_in(0) <= '1';
469
        WAIT FOR 8680000 ps;
470
        t_sig_ext_in(0) <= '0';
471
        WAIT FOR 8680000 ps;
472
        t_sig_ext_in(0) <= '1';
473
        WAIT FOR 8680000 ps;
474
        t_sig_ext_in(0) <= '0';
475
        WAIT FOR 34720000 ps;
476
        t_sig_ext_in(0) <= '1';
477
WAIT;
478
END PROCESS t_prcs_ext_in_0;
479
tb_sample : marca_vhd_sample_tst
480
PORT MAP (
481
        s1 => t_sig_clock,
482
        s2 => t_sig_ext_in,
483
        s3 => t_sig_ext_reset,
484
        sampler => t_sig_sampler
485
        );
486
 
487
tb_out : marca_vhd_check_tst
488
PORT MAP (
489
        o1 => t_sig_ext_out,
490
        sampler => t_sig_sampler
491
        );
492
END marca_arch;

powered by: WebSVN 2.1.0

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