aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1392/file15.vhdl
blob: cd71f209315843544e81a85cd95bc48f161c0f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- Code your testbench here
library IEEE;
use IEEE.std_logic_1164.all;
--use std.textio.all;
--use work.proc_pkg.all;


entity file15 is

end entity file15;

architecture rtl of file15 is

  type char_array_t is array(natural range <>) of character;
  type char_arr_file is file of char_array_t;
  
begin
  process
    
    file cr : char_arr_file;
    
    variable mcrr : char_array_t(12 downto 0);
    variable small_mcrr : char_array_t(2 downto 0);
    variable c : character := 'a';
    variable len : natural;
    
  begin
    
    file_open(cr, "./char_arr_file.txt", WRITE_MODE);
    for i in 0 to 12 loop
      mcrr(i) := c;
      c := character'succ(c);
    end loop;
    write(cr, mcrr);
    file_close(cr);
    
    -- small container
    file_open(cr, "./char_arr_file.txt", READ_MODE);
    read(cr, small_mcrr,len);
    
    for i in 0 to 2 loop
      report "" & small_mcrr(i);
    end loop;
    file_close(cr);
    
    
    wait;
  end process;
    
end rtl;