UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor gopal.maste
Visitor
3,265 Views
Registered: ‎03-22-2011

storing .txt file in an array..

hi all !
i have made a program to read a text file from a specified location , and i want to store it an array .. i don't know how to do this...please help me..

here is my code for reading a file..

 

 

 

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use STD.textio.all;
ENTITY read_file IS
END read_file;

ARCHITECTURE beha OF read_file IS

    signal  bin_value : std_logic_vector(3 downto 0):="0000";
   
BEGIN
   
   --Read process
    process
      file file_pointer : text;
        variable line_content : string(1 to 4);
      variable line_num : line;
        variable j : integer := 0;
        variable char : character:='0';
   begin
       
      file_open(file_pointer,"C:\read.txt",READ_MODE);   
      while not endfile(file_pointer) loop  
      readline (file_pointer,line_num);   
     
      READ (line_num,line_content);
      
        for j in 1 to 4 loop       
            char := line_content(j);
            if(char = '0') then
                bin_value(4-j) <= '0';
            else
                bin_value(4-j) <= '1';
            end if;
        end loop;  
        wait for 10 ns; 
      end loop;
      file_close(file_pointer);
        wait;
    end process;

end beha;
0 Kudos
3 Replies
Teacher rcingham
Teacher
3,244 Views
Registered: ‎09-09-2010

Re: storing .txt file in an array..

Is what you are trying to do is send a text file from the hard-disk of your PC to an FPGA on some sort of development board that is connected to the PC by some sort of interface?

------------------------------------------
"If it don't work in simulation, it won't work on the board."
0 Kudos
Visitor gopal.maste
Visitor
3,182 Views
Registered: ‎03-22-2011

Re: storing .txt file in an array..

i want to take the contents from that file store it in an array and see the reult of stored data in the simulation window.

0 Kudos
Teacher rcingham
Teacher
3,165 Views
Registered: ‎09-09-2010

Re: storing .txt file in an array..

So, what doesn't work with the above code when you simulate it?

------------------------------------------
"If it don't work in simulation, it won't work on the board."
0 Kudos