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
 

devas

Full Member level 2
Joined
Jun 16, 2009
Messages
129
Helped
42
Reputation
84
Reaction score
11
Trophy points
1,298
Activity points
2,004
Hi,

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

Devas
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,091
Helped
2,078
Reputation
4,175
Reaction score
2,036
Trophy points
1,393
Activity points
39,386
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;
 

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
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
 

devas

Full Member level 2
Joined
Jun 16, 2009
Messages
129
Helped
42
Reputation
84
Reaction score
11
Trophy points
1,298
Activity points
2,004
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

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,091
Helped
2,078
Reputation
4,175
Reaction score
2,036
Trophy points
1,393
Activity points
39,386
Please dont expect to compile this code - this is for simulation and verification only.
 

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
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

Top