From: Steven Sharp (sharp@cadence.com)
Date: Mon Nov 03 2003 - 18:24:15 PST
I had another thought on the form of the system function.
While trying to explain why $strcat was different from the C strcat, I
was thinking that it was sort of like a combination of the C strcat with
a C itoa function. Except that there isn't actually a C itoa function
(integer to ASCII), only a C atoi function (ASCII to integer), which does
the reverse.
Then Adam started discussing the use of Verilog vector concatenation to
do the string concatenation part, with a 1-character-long conversion
to string that only handles values between 0 and 9. Again, it is the
conversion function that is missing, not the concatenation capability.
So instead of a $strcat that does the conversion and concatenation both,
perhaps it would be better to have a $itoa or $itos (integer to string)
function, and use the existing concatenation operator for the concatenation
part. This would fit in with the existing $itor and $rtoi conversion
functions. The naming convention could be extended by having a family
of functions with a base specifier at the end of the name, like the
$display family of tasks (and $readmemb and $readmemh). I must admit
that a name like $itosb is pretty ugly though.
One reason I find this attractive is that the existing system functions
that could be allowed in constant expressions are all classified as
conversion functions. Having this new system function be a conversion
function also would keep things neat and make it easy to describe what
system functions were allowed in constant expressions.
Note that this does not help with the width problem at all. This new
system function would still need to be defined in a way that ensured
that the result had a constant width known at compile time. It would
still require some kind of padding. And if the padding were with NUL
characters, and the result were used in a concatenation, the NULs would
end up in the middle of the resulting vector. This might be even less
convenient to deal with.
Steven Sharp
sharp@cadence.com
This archive was generated by hypermail 2.1.4
: Mon Nov 03 2003 - 18:17:20 PST
and
sponsored by Boyd Technology, Inc.