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_20_ch_20_06.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
|
23
|
-- $Revision: 1.2 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
entity ch_20_06 is
|
28
|
|
29
|
end entity ch_20_06;
|
30
|
|
31
|
|
32
|
----------------------------------------------------------------
|
33
|
|
34
|
use std.textio.all;
|
35
|
|
36
|
architecture test of ch_20_06 is
|
37
|
|
38
|
subtype encoding_type is bit_vector(1 downto 0);
|
39
|
attribute encoding : encoding_type;
|
40
|
|
41
|
begin
|
42
|
|
43
|
|
44
|
process1 : process is
|
45
|
|
46
|
-- code from book:
|
47
|
|
48
|
type controller_state is (idle, active, fail_safe);
|
49
|
type load_level is (idle, busy, overloaded);
|
50
|
|
51
|
attribute encoding of idle [ return controller_state ] : literal is b"00";
|
52
|
attribute encoding of active [ return controller_state ] : literal is b"01";
|
53
|
attribute encoding of fail_safe [ return controller_state ] : literal is b"10";
|
54
|
|
55
|
-- end of code from book
|
56
|
|
57
|
variable L : line;
|
58
|
|
59
|
begin
|
60
|
write(L, string'("process1"));
|
61
|
writeline(output, L);
|
62
|
write(L, idle [ return controller_state ] ' encoding);
|
63
|
writeline(output, L);
|
64
|
write(L, active [ return controller_state ] ' encoding);
|
65
|
writeline(output, L);
|
66
|
write(L, fail_safe [ return controller_state ] ' encoding);
|
67
|
writeline(output, L);
|
68
|
wait;
|
69
|
end process process1;
|
70
|
|
71
|
|
72
|
process2 : process is
|
73
|
|
74
|
type controller_state is (idle, active, fail_safe);
|
75
|
type load_level is (idle, busy, overloaded);
|
76
|
|
77
|
attribute encoding of idle : literal is b"11";
|
78
|
|
79
|
variable L : line;
|
80
|
|
81
|
begin
|
82
|
write(L, string'("process2"));
|
83
|
writeline(output, L);
|
84
|
write(L, idle [ return controller_state ] ' encoding);
|
85
|
writeline(output, L);
|
86
|
write(L, idle [ return load_level ] ' encoding);
|
87
|
writeline(output, L);
|
88
|
wait;
|
89
|
end process process2;
|
90
|
|
91
|
|
92
|
end architecture test;
|