Project

General

Profile

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

    
2
-- Copyright (C) 1996 Morgan Kaufmann Publishers, Inc
3

    
4
-- This file is part of VESTs (Vhdl tESTs).
5

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

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

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

    
20
-- ---------------------------------------------------------------------
21
--
22
-- $Id: ch_18_fg_18_10.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
entity fg_18_10 is
28
end entity fg_18_10;
29

    
30

    
31
architecture test of fg_18_10 is
32

    
33
  signal temperature, setting : integer;
34
  signal enable, heater_fail : bit;
35

    
36
begin
37

    
38
-- code from book
39

    
40
  stimulus_interpreter : process is
41

    
42
                                   use std.textio.all;
43

    
44
                                 file control : text open read_mode is "control";
45

    
46
                                 variable command : line;
47
                                 variable read_ok : boolean;
48
                                 variable next_time : time;
49
                                 variable whitespace : character;
50
                                 variable signal_id : string(1 to 4);
51
                                 variable temp_value, set_value : integer;
52
                                 variable on_value, fail_value : bit;
53

    
54
  begin
55

    
56
    command_loop : while not endfile(control) loop
57

    
58
      readline ( control, command );
59

    
60
      -- read next stimulus time, and suspend until then
61
      read ( command, next_time, read_ok );
62
      if not read_ok then
63
        report "error reading time from line: " & command.all
64
          severity warning;
65
        next command_loop;
66
      end if;
67
      wait for next_time - now;
68

    
69
      -- skip whitespace
70
      while command'length > 0
71
        and ( command(command'left) = ' '    -- ordinary space
72
              or command(command'left) = ' '  -- non-breaking space
73
              or command(command'left) = HT ) loop
74
        read ( command, whitespace );
75
      end loop;
76

    
77
      -- read signal identifier string
78
      read ( command, signal_id, read_ok );
79
      if not read_ok then
80
        report "error reading signal id from line: " & command.all
81
          severity warning;
82
        next command_loop;
83
      end if;
84
      -- dispatch based on signal id
85
      case signal_id is
86

    
87
        when "temp" =>
88
          read ( command, temp_value, read_ok );
89
          if not read_ok then
90
            report "error reading temperature value from line: "
91
              & command.all
92
              severity warning;
93
            next command_loop;
94
          end if;
95
          temperature <= temp_value;
96

    
97
        when "set " =>
98
          -- . . .    -- similar to "temp"
99

    
100
          -- not in book
101
          read ( command, set_value, read_ok );
102
          if not read_ok then
103
            report "error reading setting value from line: "
104
              & command.all
105
              severity warning;
106
            next command_loop;
107
          end if;
108
          setting <= set_value;
109
          -- end not in book
110

    
111
        when "on  " =>
112
          read ( command, on_value, read_ok );
113
          if not read_ok then
114
            report "error reading on value from line: "
115
              & command.all
116
              severity warning;
117
            next command_loop;
118
          end if;
119
          enable <= on_value;
120

    
121
        when "fail" =>
122
          -- . . .    -- similar to "on  "
123

    
124
          -- not in book
125
          read ( command, fail_value, read_ok );
126
          if not read_ok then
127
            report "error reading fail value from line: "
128
              & command.all
129
              severity warning;
130
            next command_loop;
131
          end if;
132
          heater_fail <= fail_value;
133
          -- end not in book
134

    
135
        when others =>
136
          report "invalid signal id in line: " & signal_id
137
            severity warning;
138
          next command_loop;
139

    
140
      end case;
141

    
142
    end loop command_loop;
143

    
144
    wait;
145

    
146
  end process stimulus_interpreter;
147

    
148
-- end code from book
149

    
150
end architecture test;
(141-141/171)