Accessing Text files

Discussion in 'VHDL' started by strykaar, Aug 28, 2006.

  1. strykaar

    strykaar

    Joined:
    Aug 28, 2006
    Messages:
    3
    Hi All,

    I am trying to access text files with binary data in it using the TEXTIO package, but i get errors saying cant access files or file does not exist...below is the copy of the program i am using, please correct me if i am doing anything wrong:

    USE WORK.TEXTIO.ALL;
    ENTITY square IS
    PORT( go : IN std_logic);
    END square;
    ARCHITECTURE simple OF square IS
    BEGIN
    PROCESS(go)
    FILE infile : TEXT IS IN "/1.txt";
    FILE outfile : TEXT IS OUT "/2.txt";
    VARIABLE out_line, my_line : LINE;
    VARIABLE int_val : INTEGER;
    BEGIN
    WHILE NOT( ENDFILE(infile)) LOOP
    -- read a line from the input file
    READLINE( infile, my_line);
    -- read a value from the line
    READ( my_line, int_val);
    if(int_val='0')
    THEN int_val := '1';
    elsif(int_val='1')
    THEN int_val := '0';
    else
    int_val := '0';

    end if;
    -- write the changed value to the line
    WRITE( out_line, int_val);
    -- write the line to the output file
    WRITELINE( outfile, out_line);
    END LOOP;
    END PROCESS;
    END simple;
    strykaar, Aug 28, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. crazyprakash
    Replies:
    4
    Views:
    3,362
    adrian
    Oct 30, 2005
  2. googlinggoogler@hotmail.com
    Replies:
    4
    Views:
    936
    M.E.Farmer
    Feb 13, 2005
  3. Blake Essing
    Replies:
    1
    Views:
    608
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Sep 11, 2006
  4. utab
    Replies:
    3
    Views:
    827
    ionut.neicu@gmail.com
    Nov 28, 2006
  5. yinglcs@gmail.com
    Replies:
    3
    Views:
    1,431
    Rolf Magnus
    Jan 18, 2009
Loading...

Share This Page