Hallo,
ich habe mal einen neuen Thread erstellt, weil er thematisch nicht mehr
wirklich in meinen anderen Thread passt.
Ich habe die folgende Datei von stefanvhdl.com etwas modifiziert.
http://www.stefanvhdl.com/vhdl/html/file_read.html
Ziel soll es sein ohne Takt, direkt sequentuell, alle Zeilen in ein
Array zu schreiben, damit ich es von dort zu meinen Stimuli Registern
mappen kann.
So wie ich es verstanden habe, wird die Variable l : line automtaisch
mit jedem loop-Durchlauf hochgezählt, bis end-of-file erreicht ist. Das
wollte ich ausnutzen um die line-Variable als Index für mein Array zu
verwenden.
Ein Index kann natürlich nur integer sein. (siehe markierte Zeile 33)
Wie also kann ich line => integer umwandeln und somit mein Vorhaben
übersichtlich gestalten?
1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use std.textio.all;
|
4 | use work.txt_util.all;
|
5 |
|
6 | entity FILE_READ is
|
7 | generic ( stim_file: string := "sim.dat" );
|
8 | port(CLK : in std_logic;
|
9 | RST : in std_logic;
|
10 | ...
|
11 | EOG : out std_logic);
|
12 | end FILE_READ;
|
13 |
|
14 | architecture read_from_file of FILE_READ is
|
15 |
|
16 | file stimulus: TEXT open read_mode is stim_file;
|
17 |
|
18 | type text_array is array (0 to 5) of std_logic_vector(4 downto 0);
|
19 | signal sim_text : text_array;
|
20 |
|
21 | begin
|
22 | -- read data and control information from a file
|
23 | receive_data: process
|
24 | variable l: line;
|
25 | variable s: string(y'range);
|
26 | begin
|
27 | EOG <= '0';
|
28 | wait until RST='1'; -- wait for Reset to complete
|
29 | wait until RST='0';
|
30 | while not endfile(stimulus) loop -- read digital data from input file
|
31 | readline(stimulus, l);
|
32 | read(l, s);
|
33 | ---------------------------------------
|
34 | sim_text(l) <= to_std_logic_vector(s); -- Zeile 33
|
35 | ---------------------------------------
|
36 | end loop;
|
37 | print("I@FILE_READ: reached end of "& stim_file);
|
38 | EOG <= '1';
|
39 | wait;
|
40 | end process receive_data;
|
41 |
|
42 | end read_from_file;
|
Vielen Dank!
Alex