Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > stdio_h.vhd modules for string/file processing

Reply
Thread Tools

stdio_h.vhd modules for string/file processing

 
 
Eli Bendersky
Guest
Posts: n/a
 
      10-07-2008
Hello,

Is anyone using the stdio_h/strings_h and kin libraries from
http://bear.ces.cwru.edu/VHDL/index.html ?

I find their implementation of C-like strings (Nul terminated) on top
of VHDL strings quite robust, but some things are missing. For
instance, there seems to be no easy way to sscanf several consecutive
tokens from a string.

Have you had experience with this library you can share ? Any useful
utilities you've added to it ? Are you aware of more complete
versions ?

Thanks in advance
 
Reply With Quote
 
 
 
 
Tricky
Guest
Posts: n/a
 
      10-07-2008
On 7 Oct, 05:43, Eli Bendersky <(E-Mail Removed)> wrote:
> Hello,
>
> Is anyone using the stdio_h/strings_h and kin libraries fromhttp://bear.ces.cwru.edu/VHDL/index.html?
>
> I find their implementation of C-like strings (Nul terminated) on top
> of VHDL strings quite robust, but some things are missing. For
> instance, there seems to be no easy way to sscanf several consecutive
> tokens from a string.


Aslong as the tokens are separated by spaces, read(l: line; i:
integer) works well enough for me.

> Have you had experience with this library you can share ? Any useful
> utilities you've added to it ? Are you aware of more complete
> versions ?
>
> Thanks in advance


I dont get the point of what these packages are trying to do, other
than make code look more C-like and ease software programmers into
VHDL by giving them familiar functions. Functioanlly, Im pretty sure
anything you can do in these packages can be done via the std.textio
package. Reading data files is a bit of a workaround, as you can only
read 1 byte at a time, but it can be done quite easily.

I worry that packages like this bring more software programmers into
VHDL without understanding the unlying principals of digital
electronics.
 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      10-07-2008
Eli Bendersky wrote:

> Is anyone using the stdio_h/strings_h and kin libraries from
> http://bear.ces.cwru.edu/VHDL/index.html ?
>
> I find their implementation of C-like strings (Nul terminated) on top
> of VHDL strings quite robust, but some things are missing. For
> instance, there seems to be no easy way to sscanf several consecutive
> tokens from a string.


When I want to do string or file processing,
I use python or shell script. When I want
to make hardware models for synthesis
or simulation, I use vhdl, modelsim, and quartus.

-- Mike Treseler
 
Reply With Quote
 
Eli Bendersky
Guest
Posts: n/a
 
      10-08-2008
> I dont get the point of what these packages are trying to do, other
> than make code look more C-like and ease software programmers into
> VHDL by giving them familiar functions. Functioanlly, Im pretty sure
> anything you can do in these packages can be done via the std.textio
> package. Reading data files is a bit of a workaround, as you can only
> read 1 byte at a time, but it can be done quite easily.
>
> I worry that packages like this bring more software programmers into
> VHDL without understanding the unlying principals of digital
> electronics.


No.

This package actually tries to combat the brain-dead VHDL string
processing. One of the biggest cons of VHDL string processing is
needing to declare strings with known length. This is solved in the
package by emulating C strings ending with NUL. As long as you use
functions / procedures from the package, you can really beautifully
handle variable-length strings.

Eli

 
Reply With Quote
 
Eli Bendersky
Guest
Posts: n/a
 
      10-08-2008

> When I want to do string or file processing,
> I use python or shell script. When I want
> to make hardware models for synthesis
> or simulation, I use vhdl, modelsim, and quartus.
>
> * * * -- Mike Treseler


I agree in general, but sometimes it does make sense to read a file in
VHDL for a sophisticated testbench. In these cases, it is nice to have
a powerful library of functions to make the process less painful.

Eli
 
Reply With Quote
 
Tricky
Guest
Posts: n/a
 
      10-08-2008

> No.
>
> This package actually tries to combat the brain-dead VHDL string
> processing. One of the biggest cons of VHDL string processing is
> needing to declare strings with known length. This is solved in the
> package by emulating C strings ending with NUL. As long as you use
> functions / procedures from the package, you can really beautifully
> handle variable-length strings.
>
> Eli


Then use a line type instead. The read/write functions all resize the
string dynamically. If you need access to the actual string you can
just dereference the pointer with something like:
report myline.all;
DEALLOCATE(myline); --to clear the string
 
Reply With Quote
 
Eli Bendersky
Guest
Posts: n/a
 
      10-08-2008
> Then use a line type instead. The read/write functions all resize the
> string dynamically. If you need access to the actual string you can
> just dereference the pointer with something like:
> report myline.all;
> DEALLOCATE(myline); --to clear the string


I'm aware of the existence of lines, thanks. But they still aren't
flexible enough. Consider the following simple goal:

I want to read lines from a file, formatted:

<int> <name> <hex_int> <bin_int>

Where <name> is some identifier, up to 20 chars long. I want to read
and store all these data in variables, and later write <name> along
with other things into another file.
How do you achieve this with using regular strings and lines ?

Eli
 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      10-08-2008
Eli Bendersky wrote:
>> When I want to do string or file processing,
>> I use python or shell script. When I want
>> to make hardware models for synthesis
>> or simulation, I use vhdl, modelsim, and quartus.
>>
>> -- Mike Treseler

>
> I agree in general, but sometimes it does make sense to read a file in
> VHDL for a sophisticated testbench. In these cases, it is nice to have
> a powerful library of functions to make the process less painful.


I will agree that file IO using vhdl is painful.
Parsing text or binary files is even worse.
I prefer to convert binary or text files into
vhdl constant arrays using the best available tool.
This way, vcom can do the parsing for me.

-- Mike Treseler
 
Reply With Quote
 
Tricky
Guest
Posts: n/a
 
      10-08-2008
On 8 Oct, 14:09, Eli Bendersky <(E-Mail Removed)> wrote:
> > Then use a line type instead. The read/write functions all resize the
> > string dynamically. If you need access to the actual string you can
> > just dereference the pointer with something like:
> > report myline.all;
> > DEALLOCATE(myline); --to clear the string

>
> I'm aware of the existence of lines, thanks. But they still aren't
> flexible enough. Consider the following simple goal:
>
> I want to read lines from a file, formatted:
>
> <int> <name> <hex_int> <bin_int>
>
> Where <name> is some identifier, up to 20 chars long. I want to read
> and store all these data in variables, and later write <name> along
> with other things into another file.
> How do you achieve this with using regular strings and lines ?
>
> Eli


Ok, you got me there, but it's only the <name> bit that causes me a
problem. for <int> you can read it directly into an int, and the
<hex_int> and <bin_int> can be read using the ieee.std_logic_textio
package (I know its synopsys, but it works well), assuming the hex and
bin integers are exactly the correct lengths to fill a
std_logic_vector, which can then be cast to and integer via
numeric_std. Otherwise it's stuffed again.
 
Reply With Quote
 
Eli Bendersky
Guest
Posts: n/a
 
      10-08-2008
On Oct 8, 5:14*pm, Tricky <(E-Mail Removed)> wrote:
> On 8 Oct, 14:09, Eli Bendersky <(E-Mail Removed)> wrote:
>
>
>
> > > Then use a line type instead. The read/write functions all resize the
> > > string dynamically. If you need access to the actual string you can
> > > just dereference the pointer with something like:
> > > report myline.all;
> > > DEALLOCATE(myline); --to clear the string

>
> > I'm aware of the existence of lines, thanks. But they still aren't
> > flexible enough. Consider the following simple goal:

>
> > I want to read lines from a file, formatted:

>
> > <int> <name> <hex_int> <bin_int>

>
> > Where <name> is some identifier, up to 20 chars long. I want to read
> > and store all these data in variables, and later write <name> along
> > with other things into another file.
> > How do you achieve this with using regular strings and lines ?

>
> > Eli

>
> Ok, you got me there, but it's only the <name> bit that causes me a
> problem. for <int> you can read it directly into an int, and the
> <hex_int> and <bin_int> can be read using the ieee.std_logic_textio
> package (I know its synopsys, but it works well), assuming the hex and
> bin integers are exactly the correct lengths to fill a
> std_logic_vector, which can then be cast to and integer via
> numeric_std. Otherwise it's stuffed again.


Yep, but the <name> is a problem. There's just no sane way to read and
write it back.

The c-like string libraries allow it, because strings are inherently
variable-length, and if you only use the lib's procedures to work with
them, you'll get what you want.

Eli
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
jython lacks working xml processing modules? Jane Austine Python 14 07-18-2012 08:09 AM
Post-Processing RAW vs Post-Processing TIFF Mike Henley Digital Photography 42 01-30-2005 08:26 AM
Question: processing HTML, re-write default processing action of many tags Hubert Hung-Hsien Chang Python 2 09-17-2004 03:10 PM
Perl modules for multi hierarchical XML processing Ivan Dwyer XML 1 07-25-2004 10:01 AM



Advertisments