VHDLStarter
Newbie level 6
Hello, I am trying to read a single line from a text file and then output it to another text file.
Here is my current code:
I have a text file that has "abcd" in it. However, after I simulate it my output.txt file reads "bcdd".
I have had trouble finding a basic example of inputting and outputting. I used this code here: **broken link removed**
My questions are:
1- Am inputting the line correctly? Do I have the right type of variable for what I want to do?
2- Do I have the output statements in the right position? As I previously stated, the output is not in the proper order.
3- I am interested in trying to use a string and call to specific bits instead of a character. Is this possible?
Thanks.
Here is my current code:
Code:
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.numeric_std.all;
use Ieee.std_logic_unsigned.all;
use std.textio.all;
entity tb_project is
end tb_project;
architecture tb_project_arch of tb_project is
begin
read_input_file:process
--ouput variables
variable OUTLINE : LINE;
file FILEOUT : TEXT is OUT "ouput.TXT";
--
--Input variables
variable inline:line;
variable character_variable:character; --should this be a string?
variable end_of_line:boolean;
file myfile:text is "input.txt";
begin
while not endfile(myfile) loop
readline(myfile,inline);
read(inline,character_variable,end_of_line);
--end_of_line is EOLN boolean flag
while end_of_line loop
read(inline,character_variable,end_of_line);
WRITE(OUTLINE,character_variable); --add variable to outline variable for output.
end loop;
end loop;
WRITELINE(FILEOUT, OUTLINE); --writes outline variable to file.
wait; --Do nothing when finished
end process read_input_file;
end tb_project_arch;
I have a text file that has "abcd" in it. However, after I simulate it my output.txt file reads "bcdd".
I have had trouble finding a basic example of inputting and outputting. I used this code here: **broken link removed**
My questions are:
1- Am inputting the line correctly? Do I have the right type of variable for what I want to do?
2- Do I have the output statements in the right position? As I previously stated, the output is not in the proper order.
3- I am interested in trying to use a string and call to specific bits instead of a character. Is this possible?
Thanks.