Project

General

Profile

Download (6.68 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
-- Copyright (C) 2001 Bill Billowitch.
3

    
4
-- Some of the work to develop this test suite was done with Air Force
5
-- support.  The Air Force and Bill Billowitch assume no
6
-- responsibilities for this software.
7

    
8
-- This file is part of VESTs (Vhdl tESTs).
9

    
10
-- VESTs is free software; you can redistribute it and/or modify it
11
-- under the terms of the GNU General Public License as published by the
12
-- Free Software Foundation; either version 2 of the License, or (at
13
-- your option) any later version. 
14

    
15
-- VESTs is distributed in the hope that it will be useful, but WITHOUT
16
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18
-- for more details. 
19

    
20
-- You should have received a copy of the GNU General Public License
21
-- along with VESTs; if not, write to the Free Software Foundation,
22
-- Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
23

    
24
-- ---------------------------------------------------------------------
25
--
26
-- $Id: tc1637.vhd,v 1.2 2001-10-26 16:29:42 paw Exp $
27
-- $Revision: 1.2 $
28
--
29
-- ---------------------------------------------------------------------
30

    
31
package c08s12b00x00p05n01i01637pkg is
32

    
33
  -- type declarations
34
  type ENUM is ( E1, E2, E3 );
35
  type DISTANCE is range 0 to 1E9
36
    units
37
      -- Base units.
38
      A;                    -- angstrom
39

    
40
      -- Metric lengths.
41
      nm       = 10 A;      -- nanometer
42
      um       = 1000 nm;   -- micrometer (or micron)
43
      mm       = 1000 um;   -- millimeter
44
      cm       = 10 mm;     -- centimeter
45

    
46
      -- English lengths.
47
      mil      = 254000 A;  -- mil
48
      inch     = 1000 mil;  -- inch
49
    end units;
50
  type ANARRAY is ARRAY( 0 to 1 ) of REAL;
51
  type ARECORD is
52
    RECORD
53
      Field1      : INTEGER;
54
      Field2      : BOOLEAN;
55
    end record;
56

    
57
  -- constant declarations
58
  CONSTANT CONSTI     : INTEGER  := 47;
59
  CONSTANT CONSTR     : REAL     := 47.0;
60
  CONSTANT CONSTE     : ENUM     := E1;
61
  CONSTANT CONSTD     : DISTANCE := 1 A;
62
  CONSTANT CONSTT     : TIME     := 1 hr;
63
  CONSTANT CONSTB     : BIT      := '1';
64
  CONSTANT CONSTS     : SEVERITY_LEVEL := WARNING;
65
  CONSTANT CONSTBO    : BOOLEAN  := FALSE;
66
  CONSTANT CONSTA     : ANARRAY  := ( 3.1415926, 4.0 );
67
  CONSTANT CONSTRE    : ARECORD  := ( Field1 => 2, Field2 => TRUE );
68
  
69
  -- function declarations.
70
  function funcI return INTEGER;
71
  function funcR return REAL;
72
  function funcE return ENUM;
73
  function funcD return DISTANCE;
74
  function funcT return TIME;
75
  function funcB return BIT;
76
  function funcS return SEVERITY_LEVEL;
77
  function funcBO return BOOLEAN;
78
  function funcA return ANARRAY;
79
  function funcRE return ARECORD;
80
  
81
end c08s12b00x00p05n01i01637pkg;
82

    
83
package body c08s12b00x00p05n01i01637pkg is
84
  
85
  function funcI return INTEGER is
86
  begin
87
    return( CONSTI );
88
  end;
89
  
90
  function funcR return REAL is
91
  begin
92
    return( CONSTR );
93
  end;
94
  
95
  function funcE return ENUM is
96
  begin
97
    return( CONSTE );
98
  end;
99
  
100
  function funcD return DISTANCE is
101
  begin
102
    return( CONSTD );
103
  end;
104
  
105
  function funcT return TIME is
106
  begin
107
    return( CONSTT );
108
  end;
109
  
110
  function funcB return BIT is
111
  begin
112
    return( CONSTB );
113
  end;
114
  
115
  function funcS return SEVERITY_LEVEL is
116
  begin
117
    return( CONSTS );
118
  end;
119
  
120
  function funcBO return BOOLEAN is
121
  begin
122
    return( CONSTBO );
123
  end;
124
  
125
  function funcA return ANARRAY is
126
  begin
127
    return( CONSTA );
128
  end;
129
  
130
  function funcRE return ARECORD is
131
  begin
132
    return( CONSTRE );
133
  end;
134
  
135
end c08s12b00x00p05n01i01637pkg;
136

    
137
use work.c08s12b00x00p05n01i01637pkg.all;
138
ENTITY c08s12b00x00p05n01i01637ent IS
139
END c08s12b00x00p05n01i01637ent;
140

    
141
ARCHITECTURE c08s12b00x00p05n01i01637arch OF c08s12b00x00p05n01i01637ent IS
142

    
143
BEGIN
144
  TESTING: PROCESS
145
    -- variable declarations.
146
    VARIABLE VARI     : INTEGER;
147
    VARIABLE VARR     : REAL;
148
    VARIABLE VARE     : ENUM;
149
    VARIABLE VARD     : DISTANCE;
150
    VARIABLE VART     : TIME;
151
    VARIABLE VARB     : BIT;
152
    VARIABLE VARS     : SEVERITY_LEVEL;
153
    VARIABLE VARBO    : BOOLEAN;
154
    VARIABLE VARA     : ANARRAY;
155
    VARIABLE VARRE    : ARECORD;
156
  BEGIN
157
    -- Call each function, verify that it returns the proper value.
158
    assert (funcI = CONSTI);
159
    assert (funcR = CONSTR);
160
    assert (funcE = CONSTE);
161
    assert (funcD = CONSTD);
162
    assert (funcT = CONSTT);
163
    assert (funcB = CONSTB);
164
    assert (funcS = CONSTS);
165
    assert (funcBO = CONSTBO);
166
    assert (funcA = CONSTA);
167
    assert (funcRE = CONSTRE);
168
    
169
    -- Assign function values to variables, make sure they're OK.
170
    VARI  := funcI;
171
    VARR  := funcR;
172
    VARE  := funcE;
173
    VARD  := funcD;
174
    VART  := funcT;
175
    VARB  := funcB;
176
    VARS  := funcS;
177
    VARBO := funcBO;
178
    VARA  := funcA;
179
    VARRE := funcRE;
180
    assert (VARI = CONSTI);
181
    assert (VARR = CONSTR);
182
    assert (VARE = CONSTE);
183
    assert (VARD = CONSTD);
184
    assert (VART = CONSTT);
185
    assert (VARB = CONSTB);
186
    assert (VARS = CONSTS);
187
    assert (VARBO = CONSTBO);
188
    assert (VARA = CONSTA);
189
    assert (VARRE = CONSTRE);
190

    
191
    assert NOT((funcI = CONSTI)   and
192
               (funcR = CONSTR)   and
193
               (funcE = CONSTE)   and
194
               (funcD = CONSTD)   and
195
               (funcT = CONSTT)   and
196
               (funcB = CONSTB)   and
197
               (funcS = CONSTS)   and
198
               (funcBO = CONSTBO)   and
199
               (funcA = CONSTA)   and
200
               (funcRE = CONSTRE)   and
201
               (VARI = CONSTI)   and
202
               (VARR = CONSTR)   and
203
               (VARE = CONSTE)   and
204
               (VARD = CONSTD)   and
205
               (VART = CONSTT)   and
206
               (VARB = CONSTB)   and
207
               (VARS = CONSTS)   and
208
               (VARBO = CONSTBO)   and
209
               (VARA = CONSTA)   and
210
               (VARRE = CONSTRE))   
211
      report "***PASSED TEST: c08s12b00x00p05n01i01637"
212
      severity NOTE;
213
    assert   ((funcI = CONSTI)   and
214
              (funcR = CONSTR)   and
215
              (funcE = CONSTE)   and
216
              (funcD = CONSTD)   and
217
              (funcT = CONSTT)   and
218
              (funcB = CONSTB)   and
219
              (funcS = CONSTS)   and
220
              (funcBO = CONSTBO)   and
221
              (funcA = CONSTA)   and
222
              (funcRE = CONSTRE)   and
223
              (VARI = CONSTI)   and
224
              (VARR = CONSTR)   and
225
              (VARE = CONSTE)   and
226
              (VARD = CONSTD)   and
227
              (VART = CONSTT)   and
228
              (VARB = CONSTB)   and
229
              (VARS = CONSTS)   and
230
              (VARBO = CONSTBO)   and
231
              (VARA = CONSTA)   and
232
              (VARRE = CONSTRE))   
233
      report "***FAILED TEST: c08s12b00x00p05n01i01637 - The value of the expression defines the result returned by the function."
234
      severity ERROR;
235
    wait;
236
  END PROCESS TESTING;
237

    
238
END c08s12b00x00p05n01i01637arch;
(262-262/2088)