Altera_Forum
Honored Contributor
18 years agoLoading file from working folder
Hi guys,
I am currently using the Altera UP2 Educational Kit to perform convolution on images. I was hoping to write a program which allow my board to load a binary file (.bin) from my current working folder. The binary file contains the pixel values which i have converted from a normal JPEG picture (.jpg) using MATLAB. I have been using the following lines: read_from_file: process(clk)variable indata_line: line;
variable indata: integer;
file input_data_file: text open read_mode is "c:/altera/72sp1/qdesigns/conv_3x3/noise2.bin";
begin
if rising_edge(clk) then
readline(input_data_file,indata_line);
read(indata_line,indata);
d <= conv_std_logic_vector(indata,8);
if endfile(input_data_file) then
report "end of file -- looping back to start of file";
file_close(input_data_file);
file_open(input_data_file,"c:/altera/72sp1/qdesigns/conv_3x3/noise2.bin");
end if;
end if;
end process; However, during simulation, I faced an error reporting "warning: invalid vector source file type specified".
"error: no valid vector source file specified and default file "c:/altera/72sp1/qdesigns/conv_3x3/conv_3x3.cvwf" does not exist" My enquiries are: 1) What are the limitation to the vector source file type? Does text open read_mode support other file types? For example, text (.txt) or binary file (.bin)? 2) Can i use the following lines to get the processed output in my current working folder? write_to_file: process(clk)
variable outdata_line: line;
variable outdata: integer:=0;
file output_data_file: text open write_mode is "c:/altera/72sp1/qdesigns/conv_3x3/noise2_output.bin";
begin
if rising_edge(clk) then
outdata := conv_integer(unsigned(dout));
if dv = '1' then
write(outdata_line,outdata);
writeline(output_data_file,outdata_line);
end if;
end if;
end process; 3) If not, any suggestion for me to cope with this problem? Or any references i can refer to?