Get value from a text file (newbie)

S

smu

Hello,

I have a question about the possibility to read some informations in a text
file.

For example, I have a entity 'scaler'. Can I do something like

architecture Behavioral of scaler0 is
component scaler
generic ( ???)
port ( clr : in std_logic; clk : in std_logic; d : in
std_logic_vector(15 downto 0);
q : out std_logic_vector(15 downto 0));
end component;
begin
scaler0_c : scaler
generic map ( ??? => 'filename of file containing initialisation
data')
port map (......
......
end Behavioral;


Thank you in advance

smu
 
R

Renaud Pacalet

smu a écrit :
Hello,

I have a question about the possibility to read some informations in a text
file.

Yes you can. Here is a simple exemple:

entity A is
generic(FILENAME: String := "foo.dat");
port(K: out Integer);
end entity A;

use STD.TEXTIO.all;

architecture ARC of A is
file INITFILE: Text open READ_MODE is FILENAME;
begin
INITP: process
variable L: Line;
variable V: Integer;
begin
K <= 0;
wait for 1 ns;
READLINE(INITFILE, L);
READ(L, V);
K <= V;
wait;
end process INITP;
end architecture ARC;

entity ATB is
end entity ATB;

use STD.TEXTIO.all;

architecture SIM of ATB is
signal K: Integer;
begin
IA: entity WORK.A(ARC)
generic map(FILENAME => "bar.txt")
port map(K => K);
MONITOR: process(K)
variable L: Line;
begin
WRITE(L, K);
WRITE(L, String'(" @ "));
WRITE(L, NOW);
WRITELINE(OUTPUT, L);
end process MONITOR;
end architecture SIM;

Best regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top