Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

Reading a file content with quartus

Hi everybody,

I need to read a value from an external file at compilation time and I don´t achieve to do it with quartus. The same code works for Xilinx Ise but I´m not able to do it with Quartus.

The code also works fine with Modelsim.

I have made many changes at code and search solutions on the web but nothing.

This is the begining of the function I use to read the content of the file

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

use std.textio.all;

-------------------------------------------------------------------------------

-- function to get version from 'version.txt' file

impure function get_version return std_logic_vector is

file data_file: text open READ_MODE is "version.txt";

variable rd_line : line;

begin

-- check that file is not empty

assert(not endfile(data_file))

report "*** ERROR: File is empty" severity error;

-- read 1st line and convert it to string

readline(vers_file, rd_line);

.................................................

.................................................

.................................................

.................................................

end get_version;

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

The problem is that I don´t get to read or locate the file. At compilation time it doesn't give me the report error but I know that it does't correctly read the file because if I put a file name it doesn´t exist, It seems to do the same (nothing).

I have been searching for any example, but I didn´t found it. Can anyone help me?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Quartus does not support textio during synthesis whilst Xilinx does. I opened an enhancement request for this about 8 years ago, but still no Textio.

    You can get quartus to read in text files using TCL and output a VHDL package that contains the version number.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Quartus does not support textio during synthesis whilst Xilinx does. I opened an enhancement request for this about 8 years ago, but still no Textio.

    You can get quartus to read in text files using TCL and output a VHDL package that contains the version number.

    --- Quote End ---

    Thank you for your answer. I will try to do what you said but I need to do it automatically, so I will try to do a script that firstly generates the VHDL pakage and then compiles and generates all the quartus Project. I hope it is posible.