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_02.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
|
23
|
-- $Revision: 1.2 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
entity fg_18_02_a is
|
28
|
end entity fg_18_02_a;
|
29
|
|
30
|
|
31
|
architecture writer of fg_18_02_a is
|
32
|
begin
|
33
|
|
34
|
process is
|
35
|
type packet_file is file of bit_vector;
|
36
|
file stimulus_file : packet_file open write_mode is "test packets";
|
37
|
begin
|
38
|
write(stimulus_file, X"6C");
|
39
|
write(stimulus_file, X"05");
|
40
|
write(stimulus_file, X"3");
|
41
|
|
42
|
wait;
|
43
|
end process;
|
44
|
|
45
|
end architecture writer;
|
46
|
|
47
|
|
48
|
|
49
|
entity fg_18_02 is
|
50
|
end entity fg_18_02;
|
51
|
|
52
|
|
53
|
architecture test of fg_18_02 is
|
54
|
|
55
|
signal stimulus_network, stimulus_clock : bit;
|
56
|
|
57
|
begin
|
58
|
|
59
|
clock_gen : stimulus_clock <= not stimulus_clock after 10 ns;
|
60
|
|
61
|
-- code from book
|
62
|
|
63
|
stimulate_network : process is
|
64
|
|
65
|
type packet_file is file of bit_vector;
|
66
|
file stimulus_file : packet_file open read_mode is "test packets";
|
67
|
|
68
|
-- variable packet : bit_vector(1 to 2048);
|
69
|
-- not in book (for testing only)
|
70
|
variable packet : bit_vector(1 to 8);
|
71
|
-- end not in book
|
72
|
variable packet_length : natural;
|
73
|
|
74
|
begin
|
75
|
|
76
|
while not endfile(stimulus_file) loop
|
77
|
|
78
|
read(stimulus_file, packet, packet_length);
|
79
|
if packet_length > packet'length then
|
80
|
report "stimulus packet too long - ignored" severity warning;
|
81
|
else
|
82
|
for bit_index in 1 to packet_length loop
|
83
|
wait until stimulus_clock = '1';
|
84
|
stimulus_network <= not stimulus_network;
|
85
|
wait until stimulus_clock = '0';
|
86
|
stimulus_network <= stimulus_network xor packet(bit_index);
|
87
|
end loop;
|
88
|
end if;
|
89
|
|
90
|
end loop;
|
91
|
|
92
|
wait; -- end of stimulation: wait forever
|
93
|
|
94
|
end process stimulate_network;
|
95
|
|
96
|
-- code from book
|
97
|
|
98
|
end architecture test;
|