Project

General

Profile

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

    
27
entity cache is
28
  generic ( cache_size, block_size, associativity : positive;
29
            benchmark_name : string(1 to 10) );
30
  port ( halt : in bit );
31
end entity cache;
32

    
33

    
34

    
35
architecture instrumented of cache is
36

    
37
begin
38

    
39
  -- code from book
40

    
41
  cache_monitor : process is
42

    
43
                            type measurement_record is
44
                          record
45
                            cache_size, block_size, associativity : positive;
46
                            benchmark_name : string(1 to 10);
47
                            miss_rate : real;
48
                            ave_access_time : delay_length;
49
                          end record;
50
                          type measurement_file is file of measurement_record;
51
                          file measurements : measurement_file
52
                            open append_mode is "cache-measurements";
53
                          -- . . .
54

    
55
                          -- not in book
56
                          constant miss_count : natural := 100;
57
                          constant total_accesses : natural := 1000;
58
                          constant total_delay : delay_length := 2400 ns;
59
                          -- end not in book
60

    
61
  begin
62
    -- . . .
63
    loop
64
      -- . . .
65
      -- not in book
66
      wait on halt;
67
      -- end not in book
68
      exit when halt = '1';
69
      -- . . .
70
    end loop;
71

    
72
    write ( measurements,
73
            measurement_record'(
74
              -- write values of generics for this run
75
              cache_size, block_size, associativity, benchmark_name,
76
              -- calculate performance metrics
77
              miss_rate => real(miss_count) / real(total_accesses),
78
              ave_access_time => total_delay / total_accesses ) );
79
    wait;
80

    
81
  end process cache_monitor;
82

    
83
  -- end code from book
84

    
85
end architecture instrumented;
86

    
87

    
88

    
89
entity fg_18_04 is
90
end entity fg_18_04;
91

    
92

    
93

    
94
architecture test of fg_18_04 is
95

    
96
  signal halt : bit := '0';
97

    
98
begin
99

    
100
  dut : entity work.cache(instrumented)
101
    generic map ( cache_size => 128*1024, block_size => 16,
102
                  associativity => 2, benchmark_name => "dhrystone " )
103
    port map ( halt => halt );
104

    
105
  halt <= '1' after 10 ns;
106

    
107
end architecture test;
108

    
109

    
110

    
111
entity fg_18_04_a is
112
end entity fg_18_04_a;
113

    
114

    
115
architecture reader of fg_18_04_a is
116
begin
117

    
118
  process is
119

    
120
            type measurement_record is
121
          record
122
            cache_size, block_size, associativity : positive;
123
            benchmark_name : string(1 to 10);
124
            miss_rate : real;
125
            ave_access_time : delay_length;
126
          end record;
127
          type measurement_file is file of measurement_record;
128
          file measurements : measurement_file open read_mode is "cache-measurements";
129
          variable measurement : measurement_record;
130

    
131
          use std.textio.all;
132
          variable L : line;
133

    
134
  begin
135
    while not endfile(measurements) loop
136
      read(measurements, measurement);
137
      write(L, measurement.cache_size);
138
      write(L, ' ');
139
      write(L, measurement.block_size);
140
      write(L, ' ');
141
      write(L, measurement.associativity);
142
      write(L, ' ');
143
      write(L, measurement.benchmark_name);
144
      write(L, ' ');
145
      write(L, measurement.miss_rate);
146
      write(L, ' ');
147
      write(L, measurement.ave_access_time);
148
      writeline(output, L);
149

    
150
    end loop;
151

    
152
    wait;
153
  end process;
154

    
155
end architecture reader;
(135-135/171)