E
Eli Bendersky
Guest
Hello all,
In an effort to read and process non-trivial command files for a
transactor in a testbench, I came upon a couple of questions regarding
text / string processing in VHDL:
1) It seems to be impossible to pass "line" variables into functions,
therefore making it difficult to implement such useful functions as
is_whitespace_only(line) and is_comment(line). For the meantime I made
them accept strings and read the line into a string. Isn't there a way
around this ? How do you prefer to work with "line" type vars ?
2) VHDL's strong typedness makes it difficult to work with strings in
a flexible way. For instance, the following "would be" code doesn't
really work:
var msg := string;
....
....
if (something) then
msg := "hello";
else
msg := "bye";
end if;
Because "msg" can't be declared as an unconstrained string. However,
to give it length would mean to constrain all strings assignable to it
to this length. If I say:
vsr msg := string(1 to 5);
Then I can assign "hello" to it (length 5) but not "bye". This is
quite painful. How can I solve this problem ?
In general, could you post useful code snippets for string / text
processing, and / or point to non-standard libraries you use ? I found
txt_util (http://www.stefanvhdl.com/vhdl/vhdl/txt_util.vhd) pretty
helpful for making some operations less painful.
TIA
Eli
In an effort to read and process non-trivial command files for a
transactor in a testbench, I came upon a couple of questions regarding
text / string processing in VHDL:
1) It seems to be impossible to pass "line" variables into functions,
therefore making it difficult to implement such useful functions as
is_whitespace_only(line) and is_comment(line). For the meantime I made
them accept strings and read the line into a string. Isn't there a way
around this ? How do you prefer to work with "line" type vars ?
2) VHDL's strong typedness makes it difficult to work with strings in
a flexible way. For instance, the following "would be" code doesn't
really work:
var msg := string;
....
....
if (something) then
msg := "hello";
else
msg := "bye";
end if;
Because "msg" can't be declared as an unconstrained string. However,
to give it length would mean to constrain all strings assignable to it
to this length. If I say:
vsr msg := string(1 to 5);
Then I can assign "hello" to it (length 5) but not "bye". This is
quite painful. How can I solve this problem ?
In general, could you post useful code snippets for string / text
processing, and / or point to non-standard libraries you use ? I found
txt_util (http://www.stefanvhdl.com/vhdl/vhdl/txt_util.vhd) pretty
helpful for making some operations less painful.
TIA
Eli