Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

reading image data stored in text file using vhdl in xilinx

Status
Not open for further replies.

kakarala

Member level 1
Joined
Jun 22, 2010
Messages
40
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,801
Hii,

I want to read a grayscale image using VHDL, so i stored it in a text file using matlab and now i want to read pixel values from txt file.can anyone help me?
 

you could create a memory with the values of the text file, generate it through IP wizard and read it. Every time that you want to read a image you have to modify your memory and recompile the entire project. This is like and "offline" solution.

Or, if you want to read "online" the text file, you could send the values through serial (rs232) conection.
 

Re: reading image data stored in text file using vhdl in xil

If you would like to read the file for your simulation purposes using VHDL then you can follow what is given in the below link

**broken link removed**
 

Re: reading image data stored in text file using vhdl in xil

I followed this tutorial and i tried to execute code file_read.vhd and its giving me following error
ERROR:HDLParsers:3369 - "C:/Documents and Settings/ak0227/Desktop/Motionestimation/image.vhd" Line 69. 0 is not included in the index range, 1 to 2147483647, of array STRING.
ERROR:HDLParsers:3312 - "C:/Documents and Settings/ak0227/Desktop/Motionestimation/image.vhd" Line 84. Undefined symbol 's'.
ERROR:HDLParsers:1209 - "C:/Documents and Settings/ak0227/Desktop/Motionestimation/image.vhd" Line 84. s: Undefined symbol (last report in this block)

**broken link removed**
 

tehre is an error too, when i run it
 

strings have to be declared with natural ranges, and always ascending.

so you have to declare:

variable s : string(1 to 10);
NOT string(0 to 9);

And I suspect the error is in image.vhd, not file_read.vhd
 

Re: reading image data stored in text file using vhdl in xil

I stored the image gray scale pixel values in a text (.txt) document. I want to read the values from the values and store them in a matrix with size of image. Text file is attached below. can anyone pls help me
 

I see you have an image of a table tennis bat/ball..

to read in the image, try the following code that I used to find out exactly what your image was (which I then wrote into a bitmap file):

Code:
type img_array_t is array(natural range <>, natural range <>) of natural;
signal img_array   : img_array_t(0 to X_SIZE-1, 0 to Y_SIZE-1);


.....
--inside a process/function/procedure
file img_file : text open read_mode is "text.txt";
variable l : line;


for y in 0 to Y_SIZE-1 loop   
  readline(img_file, l);     --gets 1 line at a time
  
  for x in 0 to X_SIZE-1 loop
    read(l, img_array(x,y));   --read in each pixel
  end loop;
end loop;
 

Re: reading image data stored in text file using vhdl in xil

can you pls post the complete vhdl code here?
 

Re: reading image data stored in text file using vhdl in xil

I mean declaration of variables ( X_size) and signals.
 

replace X_size is whatever the image size is.
There are no more varaibles/signals to see - they are already in the code. You just need to adapt it to your needs.
 

Re: reading image data stored in text file using vhdl in xil

i executed the following code :

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;

entity read is


end read;

architecture Behavioral of read is

type img_array_t is array(natural range <>, natural range <>) of natural;
signal img_array : img_array_t(0 to 239, 0 to 351);

begin

recievedata: process

file img_file : text open read_mode is "stennis1.txt";
variable l : line;

begin


for y in 0 to 351 loop
readline(img_file, l); --gets 1 line at a time

for x in 0 to 239 loop
read(l, img_array(x,y)); --read in each pixel
end loop;
end loop;

end process;

end Behavioral;

It gave me following error :
ERROR:HDLParsers:1300 - "C:/Documents and Settings/ak0227/Desktop/Motionestimation/read.vhd" Line 55. Entity 'read' read is not an array index prefix.

In this code i just renamed the text file, pls tell me whats wrong here.
 

rename the entity to something other than read.
 

Re: reading image data stored in text file using vhdl in xil

i figured that error now i am getting another error for the following code.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;


---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity image_read is

--port(
--type img_array_t is array(natural range <>, natural range <>) of natural;
--signal img_array : img_array_t(0 to 239, 0 to 351));

end image_read;

architecture Behavioral of image_read is

type img_array_t is array(natural range <>, natural range <>) of natural;
signal img_array : img_array_t(0 to 239, 0 to 351);

begin

recievedata: process
--variable img_array : img_array_t(0 to 239, 0 to 351);
file img_file : text open read_mode is "stennis1.txt";
variable l : line;
variable temp : natural;

begin


for y in 0 to 351 loop

readline(img_file, l); --gets 1 line at a time

for x in 0 to 239 loop
read(l,temp); --read in each pixel
img_array(x,y) <= temp;
end loop;
end loop;

end process;

end Behavioral;

ERROR:Xst:842 - "C:/Documents and Settings/ak0227/Desktop/Motionestimation/test.vhd" line 73: Same wait conditions expected in all Multiple Waits.

but test.vhd is another code , i dont know why is it giving error even i deleted the test.vhd file
 

you need to add wait at the end of the process, else it will loop forever. Im guessing you only want it to run once.

process
begin
.....
wait;
end process;
 

Re: reading image data stored in text file using vhdl in xil

after i wrote wait; statement it gives me the following error.

ERROR:Xst:841 - "C:/Documents and Settings/ak0227/Desktop/sample/test.vhd" line 47: Bad condition in wait statement, or only one clock per process.
 

you cannot synthesise this code. You can only simulate it. This is NOT code you can use on an FPGA. You will need modelsim, activeHDL, GHDL or some other simulator to see this working.

File IO is intended for testing and behavioural models only.
 

Re: reading image data stored in text file using vhdl in xil

ok,can i simulate using ISIM?
 

I Dont know - I dont have any experience with it. If it is similar to the quartus simulator, probably not, as you need to compile the project first.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top