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.

help with reading a hex file in vhdl

Status
Not open for further replies.

haneet

Full Member level 3
Joined
Nov 7, 2006
Messages
160
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Activity points
2,219
Hi Frndz,

I have a text file with hex data which needs to be read using VHDL. Can someone help me with this??

thanks
 

Hi,

The package std_logic_textio has functions (HREAD) to read hex values from a file.

Devas
 
or if your std_logic_vector is not a multuple of 4 bits, write a string to integer function:

function string_to_int( x_str : string; radix : positive range 2 to 36 := 10) return integer;
 

hey devas,
can you give me a sample code on how to use as i havn't ever used file handling in VHDL.

thanks

Added after 55 minutes:

hey Devas,

I tried using the HREAD somehow... but it says "no feasible entries for hread"

do you want me to upload the code i wrote??

thanks
 

Hi Haneet,

Something like:

library ieee;
use ieee.std_logic_textio.all;
library std;
use std.textio.all;

architecture xxxx of yyyy is
file fin : text open read_mode is "<path to your hex file>";

process(zzzz)
variable rdline : line
variable hex : std_logic_vector(3 downto 0);
begin
while not endfile(fin) loop
readline(fin, rdline);
hread(rdline, hex);
end loop;
end process;


I guess google will also find some examples of reading files.

Devas
 

    haneet

    Points: 2
    Helpful Answer Positive Rating
Please dont expect to compile this code - this is for simulation and verification only.
 

Thanks Devas.. Its working.

@Tricky.. yea i just want to use this for testing.

thanks guys...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top