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_19_sink-b.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
|
23
|
-- $Revision: 1.2 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
library math;
|
28
|
|
29
|
architecture behavior of sink is
|
30
|
|
31
|
begin
|
32
|
|
33
|
token_consumer : process is
|
34
|
|
35
|
variable number_of_tokens_consumed : natural := 0;
|
36
|
variable life_time : real; -- in time_unit
|
37
|
variable sum_of_life_times : real := 0.0; -- in time_unit
|
38
|
variable sum_of_squares_of_life_times : real := 0.0; --in time_unit**2
|
39
|
|
40
|
use std.textio.all;
|
41
|
file info_file : text;
|
42
|
variable L : line;
|
43
|
|
44
|
use math.math_real.sqrt;
|
45
|
|
46
|
procedure write_summary is
|
47
|
variable mean_life_time : real
|
48
|
:= sum_of_life_times / real(number_of_tokens_consumed);
|
49
|
variable std_dev_of_life_times : real
|
50
|
:= sqrt ( ( sum_of_squares_of_life_times
|
51
|
- sum_of_life_times**2 / real(number_of_tokens_consumed) )
|
52
|
/ real( number_of_tokens_consumed - 1 ) );
|
53
|
begin
|
54
|
write(L, string'("Summary information for sink "));
|
55
|
write(L, name);
|
56
|
write(L, string'(" up to time "));
|
57
|
write(L, now, unit => time_unit);
|
58
|
writeline(info_file, L);
|
59
|
write(L, string'(" Number of tokens consumed = "));
|
60
|
write(L, natural(number_of_tokens_consumed));
|
61
|
writeline(info_file, L);
|
62
|
write(L, string'(" Mean life_time = "));
|
63
|
write(L, mean_life_time * time_unit, unit => time_unit);
|
64
|
writeline(info_file, L);
|
65
|
write(L, string'(" Standard deviation of life_times = "));
|
66
|
write(L, std_dev_of_life_times * time_unit, unit => time_unit);
|
67
|
writeline(info_file, L);
|
68
|
writeline(info_file, L);
|
69
|
end procedure write_summary;
|
70
|
|
71
|
procedure write_trace is
|
72
|
begin
|
73
|
write(L, string'("Sink "));
|
74
|
write(L, name);
|
75
|
write(L, string'(": at "));
|
76
|
write(L, now, unit => time_unit);
|
77
|
write(L, string'(" consumed "));
|
78
|
write(L, in_arc.token, time_unit);
|
79
|
writeline(info_file, L);
|
80
|
end procedure write_trace;
|
81
|
|
82
|
begin
|
83
|
file_open(info_file, info_file_name, write_mode);
|
84
|
loop
|
85
|
wait on info_detail'transaction, in_arc;
|
86
|
if info_detail'active and info_detail = summary then
|
87
|
write_summary;
|
88
|
end if;
|
89
|
if in_arc'event then
|
90
|
number_of_tokens_consumed := number_of_tokens_consumed + 1;
|
91
|
life_time := real( (now - in_arc.token.creation_time) / time_unit );
|
92
|
sum_of_life_times := sum_of_life_times + life_time;
|
93
|
sum_of_squares_of_life_times := sum_of_squares_of_life_times + life_time ** 2;
|
94
|
if info_detail = trace then
|
95
|
write_trace;
|
96
|
end if;
|
97
|
end if;
|
98
|
end loop;
|
99
|
end process token_consumer;
|
100
|
|
101
|
end architecture behavior;
|