1
2-- Copyright (C) 2002 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
20entity read_transform_write_data is
21end entity read_transform_write_data;
22
23
24architecture writer of read_transform_write_data is
25begin
26
27  process is
28    type transform_file is file of real;
29    file initial_transforms : transform_file open write_mode is "transforms.ini";
30  begin
31    for i in 1 to 50 loop
32      write(initial_transforms, real(i));
33    end loop;
34    wait;
35  end process;
36
37end architecture writer;
38
39
40
41
42entity read_transform is
43end entity read_transform;
44
45
46architecture test of read_transform is
47begin
48
49  process is
50
51    -- code from book (in text)
52
53    type transform_array is array (1 to 3, 1 to 3) of real;
54    variable transform1, transform2 : transform_array;
55
56    type transform_file is file of real;
57    file initial_transforms : transform_file open read_mode is "transforms.ini";
58
59    -- end code from book
60
61    -- code from book (in Figure)
62
63    procedure read_transform ( file f : transform_file;
64                               variable transform : out transform_array ) is
65    begin
66      for i in transform'range(1) loop
67        for j in transform'range(2) loop
68          if endfile(f) then
69            report "unexpected end of file in read_transform - "
70                   & "some array elements not read"
71              severity error;
72            return;
73          end if;
74          read ( f, transform(i, j) );
75        end loop;
76      end loop;
77    end procedure read_transform;
78
79    -- end code from book
80
81  begin
82
83    -- code from book (in text)
84
85    read_transform ( initial_transforms, transform1 );
86    read_transform ( initial_transforms, transform2 );
87
88    -- end code from book
89
90    wait;
91  end process;
92
93end architecture test;
94