read binary file in VHDL

E

elmakhloufi assaad

Guest
I want to get access and read binary file content pixel of image from ENVI logiciel :size (100*100) pixel coded each pixel in 16 bits in vhdl.any idea or advice ?
 
On 26.02.2018 12:19, elmakhloufi assaad wrote:
I want to get access and read binary file content pixel of image from ENVI logiciel :size (100*100) pixel coded each pixel in 16 bits in vhdl.any idea or advice ?

Keep in mind that this can only work in simulation.
There are plenty of examples on how to access files with VHDL, Google is
definitely your friend here.
http://lmgtfy.com/?iie=1&q=read+binary+files+vhdl

Nicolas
 
On 26.02.2018 12:19, elmakhloufi assaad wrote:
> I want to get access and read binary file content pixel of image from ENVI logiciel :size (100*100) pixel coded each pixel in 16 bits in vhdl.any idea or advice ?

Here is my example:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity binary is
end binary;

architecture rtl of binary is

signal s : std_logic_vector (7 downto 0);

begin

process

subtype byte is character;
type binfile is file of byte;

file f : binfile;
variable b : byte;

begin
s <= (others => '0');
wait for 10 ns;

File_Open (f, "util.o", read_mode);

while (not EndFile (f)) loop
Read (f, b);
s <= std_logic_vector (to_unsigned (byte'pos(b), s'length));
wait for 10 ns;
end loop;

File_Close (f);

wait for 10 ns;
s <= (others => '0');

wait; -- forever
end process;

end rtl;
 
Le lundi 26 fÊvrier 2018 11:19:07 UTC, elmakhloufi assaad a Êcrit :
I want to get access and read binary file content pixel of image from ENVI logiciel :size (100*100) pixel coded each pixel in 16 bits in vhdl.any idea or advice ?
@andrew_b thankyou for this exemple , when i simulate this code with my binary file the message : he coldnt open file?
 
Le mardi 27 fÊvrier 2018 11:35:49 UTC, elmakhloufi assaad a Êcrit :
Le lundi 26 fÊvrier 2018 11:19:07 UTC, elmakhloufi assaad a Êcrit :
I want to get access and read binary file content pixel of image from ENVI logiciel :size (100*100) pixel coded each pixel in 16 bits in vhdl.any idea or advice ?
@andrew_b thankyou for this exemple , when i simulate this code with my binary file the message : he coldnt open file?
Could not read binary file
C:\Users\hp\Desktop\file\vhdl.txt., because it was not written by Xilinx
Simulator
Simulation stopped when executing process: binary.vhd:14
on line 26 in file "C:/Xilinx92i/ENVI_read/binary.vhd"
 
On 2018-02-27 05:43, elmakhloufi assaad wrote:
Le mardi 27 fĂŠvrier 2018 11:35:49 UTC, elmakhloufi assaad a ĂŠcrit :
Le lundi 26 fĂŠvrier 2018 11:19:07 UTC, elmakhloufi assaad a ĂŠcrit :
I want to get access and read binary file content pixel of image from ENVI logiciel :size (100*100) pixel coded each pixel in 16 bits in vhdl.any idea or advice ?
@andrew_b thankyou for this exemple , when i simulate this code with my binary file the message : he coldnt open file?
Could not read binary file
C:\Users\hp\Desktop\file\vhdl.txt., because it was not written by Xilinx
Simulator
Simulation stopped when executing process: binary.vhd:14
on line 26 in file "C:/Xilinx92i/ENVI_read/binary.vhd"

Try using vhdl-93 file_open syntax. Also, try fully qualifying the file
name. Also, make sure the vhdl is compiled with the vhdl-93 option. (Or
later. The file_open syntax was changed between vhdl-87 and vhdl-93.
Also, vhdl-87 defined only 128 values for the character data type;
vhdl-93 defined all 256 possible values for a byte.)


VARIABLE open_status : file_open_status;


File_Open (open_status, f, "fully_qualified_filename", read_mode);
 

Welcome to EDABoard.com

Sponsor

Back
Top