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_09_ch_09_04.vhd,v 1.2 2001-10-24 23:31:00 paw Exp $
|
23
|
-- $Revision: 1.2 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
package arithmetic_ops is
|
28
|
|
29
|
-- code from book
|
30
|
|
31
|
procedure increment ( bv : inout bit_vector; by : in integer := 1 );
|
32
|
|
33
|
procedure increment ( int : inout integer; by : in integer := 1 );
|
34
|
|
35
|
-- end code from book
|
36
|
|
37
|
end package arithmetic_ops;
|
38
|
|
39
|
package body arithmetic_ops is
|
40
|
|
41
|
procedure increment ( bv : inout bit_vector; by : in integer := 1 ) is
|
42
|
begin
|
43
|
end procedure increment;
|
44
|
|
45
|
procedure increment ( int : inout integer; by : in integer := 1 ) is
|
46
|
begin
|
47
|
end procedure increment;
|
48
|
|
49
|
end package body arithmetic_ops;
|
50
|
|
51
|
|
52
|
entity ch_09_04 is
|
53
|
|
54
|
end entity ch_09_04;
|
55
|
|
56
|
library stimulus;
|
57
|
use stimulus.stimulus_generators.all;
|
58
|
|
59
|
architecture test of ch_09_04 is
|
60
|
|
61
|
-- code from book
|
62
|
|
63
|
-- MTI bug mt017
|
64
|
-- alias bv_increment is work.arithmetic_ops.increment [ bit_vector, integer ];
|
65
|
|
66
|
alias int_increment is work.arithmetic_ops.increment [ integer, integer ];
|
67
|
|
68
|
-- workaround to avoid MTI bug mt018
|
69
|
-- alias "*" is "and" [ bit, bit return bit ];
|
70
|
|
71
|
alias "*" is std.standard."and" [ bit, bit return bit ];
|
72
|
|
73
|
-- alias "+" is "or" [ bit, bit return bit ];
|
74
|
|
75
|
alias "+" is std.standard."or" [ bit, bit return bit ];
|
76
|
|
77
|
-- alias "-" is "not" [ bit return bit ];
|
78
|
|
79
|
alias "-" is std.standard."not" [ bit return bit ];
|
80
|
|
81
|
-- end workaround
|
82
|
|
83
|
alias high is std.standard.'1' [ return bit ];
|
84
|
|
85
|
-- end code from book
|
86
|
|
87
|
signal a, b, c, s : bit := '0';
|
88
|
signal test_vector : bit_vector(1 to 3);
|
89
|
signal test_high : bit := high;
|
90
|
|
91
|
begin
|
92
|
|
93
|
-- code from book
|
94
|
|
95
|
-- workaround to avoid MTI bug mt018
|
96
|
-- s <= a * b + (-a) * c;
|
97
|
|
98
|
s <= (a and b) or ((not a) and c);
|
99
|
|
100
|
-- end workaround
|
101
|
|
102
|
-- end code from book
|
103
|
|
104
|
stimulus : all_possible_values ( bv => test_vector,
|
105
|
delay_between_values => 10 ns );
|
106
|
|
107
|
(a, b, c) <= test_vector;
|
108
|
|
109
|
end architecture test;
|