Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Reading hex data from file

 
Thread Tools Search this Thread
Old 06-23-2005, 06:44 PM   #1
Default Reading hex data from file


Hi!

I have got text file with data wrote in this manner:

.........
01 04 A2 FC 10 D0 E4 C2
0A C3 FF 9A D2 E1 00 00
.........


each 2-sign value is a hex value of std_logic_vector(7 downto 0), and it
should be connected with data vector in my project like this:

data(7 downto 0) <= (2-sign value from text file);


how can I do that?
have you got a similiar vhdl example witch I can use?

Thanks for any help

Paul




magik
  Reply With Quote
Old 06-23-2005, 07:42 PM   #2
info_
 
Posts: n/a
Default Re: Reading hex data from file
Hi,

Simple;
OTOMH (not tested, so you have a little work left

use std.textio.all;
use ieee.std_logic_textio.all; -- Synopsys

readline(L, File_handle);
for i in 1 to 8 loop
hread (L, vData); -- variable vData : std_logic_vector(Data'range);
Data <= vData;
-- wait some etc...
end loop;


and do this while you've not reached the end of file.
Voilà


magik wrote:
> Hi!
>
> I have got text file with data wrote in this manner:
>
> ........
> 01 04 A2 FC 10 D0 E4 C2
> 0A C3 FF 9A D2 E1 00 00
> ........
>
>
> each 2-sign value is a hex value of std_logic_vector(7 downto 0), and it
> should be connected with data vector in my project like this:
>
> data(7 downto 0) <= (2-sign value from text file);
>
>
> how can I do that?
> have you got a similiar vhdl example witch I can use?
>
> Thanks for any help
>
> Paul
>
>



info_
  Reply With Quote
Old 06-23-2005, 08:17 PM   #3
info_
 
Posts: n/a
Default Re: Reading hex data from file
info_ wrote:

> Hi,
>
> Simple;
> OTOMH (not tested, so you have a little work left
>
> use std.textio.all;
> use ieee.std_logic_textio.all; -- Synopsys
>
> readline(L, File_handle);

Ooops !
readline (File_handle,L); -- indeed


Bert Cuzeau


info_
  Reply With Quote
Old 06-23-2005, 09:17 PM   #4
magik
 
Posts: n/a
Default Re: Reading hex data from file
Thanx Bert!!

What if some of my lines are not exactly with 8 2-hex ??

ok, in real the file looks like this:

---------------------------------
COMAND_A
01 04 A2 FC 10 D0 E4 C2
0A C3 FF 9A D2 E1 00 00
(empty line or comment)
COMAND_B
01 04 A2
---------------------------------

I will start from checking first line witch should cover string and I will
decide what to do. Of course at this moment I will use read(L, string_var);
where string_var is STRING type. After this I will read data... how can I
assume that there is no more data in present line or the line is empty or
has no-hex (0-9, A-F) objects??


Paul




magik
  Reply With Quote
Old 06-23-2005, 10:18 PM   #5
info_
 
Posts: n/a
Default Re: Reading hex data from file
magik wrote:

> Thanx Bert!!
>
> What if some of my lines are not exactly with 8 2-hex ??
>
> ok, in real the file looks like this:
>
> ---------------------------------
> COMAND_A
> 01 04 A2 FC 10 D0 E4 C2
> 0A C3 FF 9A D2 E1 00 00
> (empty line or comment)
> COMAND_B
> 01 04 A2
> ---------------------------------
>
> I will start from checking first line witch should cover string and I will
> decide what to do. Of course at this moment I will use read(L, string_var);
> where string_var is STRING type. After this I will read data... how can I
> assume that there is no more data in present line or the line is empty or
> has no-hex (0-9, A-F) objects??
>
>
> Paul
>
>


Can test L(1), but your example is quite unfriendly as "C" is a
valid hex character
Why not use a semicolumn for non-data (& comments) lines ?

Testing L'length is recommended. Less than 2 is hopeless
for hreading a byte. (it gets easily rid of blank lines too)

Could use the "safe" version of read & test the boolean to see if the
extraction went okay or not.

Writing a robust data parser in VHDL isn't terribly exciting,
but it isn't very difficult either.
Once you'll have yours, keep it : it's very useful and resusable code.

Bert Cuzeau


info_
  Reply With Quote
Old 06-24-2005, 08:32 PM   #6
magik
 
Posts: n/a
Default Re: Reading hex data from file
Thanx again !!

OK my test model is working, but how can I finish testing ?
For now, when the end of the input text file is reached my AHDL is crashing
down...


Paul




magik
  Reply With Quote
Old 06-25-2005, 10:52 AM   #7
Bert Cuzeau
 
Posts: n/a
Default Re: Reading hex data from file
magik wrote:
> Thanx again !!
>
> OK my test model is working, but how can I finish testing ?
> For now, when the end of the input text file is reached my AHDL is crashing
> down...

AHDL ? ! you mean VHDL ?

while not ENDFILE(F) loop
-- process the file
end loop;
should do the trick.


Bert Cuzeau


Bert Cuzeau
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SONY DVD RW DW-G120A SOMETIMES FAILS...... atlantic965 DVD Video 0 06-18-2006 10:36 PM
problems backing up dvds Lawrence Traub DVD Video 11 09-27-2005 07:34 PM
Re: Ripping DVDs. Please answer the attached question. - Question.txt Stan Brown DVD Video 19 02-09-2005 11:19 PM
Burn process failed - help! Log file posted for help troubleshooting Michael Mason DVD Video 1 08-16-2004 09:24 PM
Pioneer A05 Problems Bill Stock DVD Video 8 11-28-2003 05:03 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46