Project

General

Profile

Download (2.48 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_07_fg_07_16.vhd,v 1.2 2001-10-26 16:29:34 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
entity fg_07_16 is
28
end entity fg_07_16;
29

    
30

    
31

    
32
architecture test of fg_07_16 is
33

    
34
  -- code from book
35

    
36
  function limit ( value, min, max : integer ) return integer is
37
  begin
38
    if value > max then
39
      return max;
40
    elsif value < min then
41
      return min;
42
    else
43
      return value;
44
    end if;
45
  end function limit;
46

    
47
  -- end code from book
48

    
49
begin
50

    
51
  tester : process is
52

    
53
                     variable new_temperature, current_temperature, increment : integer;
54
                   variable new_motor_speed, old_motor_speed,
55
                     scale_factor, error : integer;
56

    
57
  begin
58

    
59
    current_temperature := 75;
60
    increment := 10;
61

    
62
    -- code from book (in text)
63

    
64
    new_temperature := limit ( current_temperature + increment, 10, 100 );
65

    
66
    -- end code from book
67

    
68
    increment := 60;
69
    new_temperature := limit ( current_temperature + increment, 10, 100 );
70
    increment := -100;
71
    new_temperature := limit ( current_temperature + increment, 10, 100 );
72

    
73
    old_motor_speed := 1000;
74
    scale_factor := 5;
75
    error := 5;
76

    
77
    -- code from book (in text)
78

    
79
    new_motor_speed := old_motor_speed
80
                       + scale_factor * limit ( error, -10, +10 );
81

    
82
    -- end code from book
83

    
84
    error := 15;
85
    new_motor_speed := old_motor_speed
86
                       + scale_factor * limit ( error, -10, +10 );
87

    
88
    error := -20;
89
    new_motor_speed := old_motor_speed
90
                       + scale_factor * limit ( error, -10, +10 );
91

    
92
    wait;
93
  end process tester;
94

    
95
end architecture test;
(307-307/534)