Arturo,
Yes, thanks. This is better.
But maybe there is a 4th type of string.
Again, please excuse my ignorance.
Can an expression be of type string? I guess so.
A simple example would be string'(b).
It is of type string, but not itself a string variable,
wo you have to accomodate string expressions as well.
Note that a string variable is a special case of a string expression.
A string concatenation or replication would also be a string expression.
Or str.toupper().
So, for example, in the sentences,
"Reading an element of a string yields a byte. A string shall not
contain the special character \0 .",
while the first use of "string" might be relevant only to string variables,
the second might apply to all string expressions.
Similarly, in
"A string or a string literal can be assigned directly to a string
variable."
The first use of "string" might mean any expression of type string.
Finally, if you think that a[0] = "hi";
assigns "i" to a[0] , same as a[0] = "i",
then we are back to saying that the sentence
"Note: str.putc(j, x) is semantically equivalent to str[j] = x."
is wrong.
Thanks,
Shalom
On Tue, 7 Dec 2004, Arturo Salz wrote:
> Shalom,
>
> I think you raise a good point. I'll try to clarify what is meant and
> perhaps you can suggest
> improvements to the language.
>
> I believe the confusion regarding string being used as a noun or as an
> adjective
> stems from the fact that there are now three kinds of strings in the
> language:
> string literals - the traditional double-quote enclosed literal
> values denoting ASCII strings
> string types - the new variable-size type that acts as a string
> container
> string variables - variables of type string (the above type).
>
> When it refers to a string literal, the text is explicit about using the
> full term. When it refers to
> string types or string variables, the noun "type" or "variable" is often
> excluded. I think that part
> of the confusion is due to not having merged the P1800 and 1364 LRM's
> into one document.
> When that happens, we will have to reconcile the terms much better. I
> believe the SystemVerilog
> usage is consistent with the fact that a 1364 string is really a literal
> value (after all they are defined
> as part of the lexical conventions and cannot be modified). Given that
> there is now a built-in type
> whose actual name is "string", I think it would be a mistake to continue
> to refer to string literals
> as just "string". In my opinion, this has to change.
>
>
> Let me take some of the items you mention:
>
> "Reading an element of a string yields a byte. A string shall not
> contain the special character \0 ."
>
> How about:
>
> "Reading one element of a string variable yields a byte. A string
> variable shall not contain the special character \0 ."
> ----------------
>
> "A string or a string literal can be assigned directly to a string
> variable."
>
> "A string variable or a string literal may be assigned directly to a
> string variable."
> ----------------
>
> bit [11:0] b = 12'ha41;
> string s2 = string'(b); // sets s2 to 'h0a41
>
> 'h0a41 is an unsized constant and thus at least 32 bits.
> You probably mean 16'h0a41.
>
> Yes. that's better.
> -----------------
>
> - "b = string'(r) ; // OK (implicit cast, implementations can issue a
> warning)"
>
> "can" should probably be "may".
>
> Yes.
> -----------------
>
> r = {"H",""}; // yields "H\0" "" is converted to 8'b0
> b = {"H",""}; // yields "H" as "" is the empty string
>
> The comments are gramatically incorrect.
> In the first, there probably should be a period between "H\0" and "".
> I don't know about the second.
>
> Yes, I believe you're right. How about:
> r = {"H",""}; // yields "H\0". "" is converted to 8'b0
> b = {"H",""}; // yields "H". "" is the empty string
> ----------------
>
> Now I'm confused again.
> What is the result of a[0] = "hi", where a is of type string?
>
> Yes. That is still a pending errata, which I have no doubt we will
> change to
> be compatible with other assignments so that:
> a[0] = "hi";
> assigns "i" to a[0] , same as a[0] = "i"
>
> Arturo
>
>
> ----- Original Message -----
> From: < <mailto:Shalom.Bresticker@freescale.com>
> Shalom.Bresticker@freescale.com>
> To: "Arturo Salz" < <mailto:Arturo.Salz@synopsys.COM>
> Arturo.Salz@synopsys.COM>
> Cc: "sv-ec" < <mailto:sv-ec@eda.org> sv-ec@eda.org>
> Sent: Monday, December 06, 2004 10:39 PM
> Subject: Re: [sv-ec] String proposal
>
>
> Arturo,
>
> I don't understand all of this, but I still have a few comments.
>
> - The term "string" when used as a noun and not as an adjective is not
> always clear. The usage appears to be inconsistent.
>
> For example, in the sentences,
> "Reading an element of a string yields a byte. A string shall not
> contain the special character \0 ."
>
> What types of strings are meant here?
>
> Or afterward,
>
> "A string or a string literal can be assigned directly to a string
> variable."
>
> What is the difference between a string and a string literal?
>
> ("can" should probably be "may".)
>
> Note especially that for better or for worse, in 1364, the term "string"
> is defined as
> "A string is a sequence of characters enclosed by double quotes ("") and
> contained on a single line."
>
> I think the current usage of string as a noun without any adjective is
> confusing and inconsistent.
>
>
> - You have
>
> bit [11:0] b = 12'ha41;
> string s2 = string'(b); // sets s2 to 'h0a41
>
> 'h0a41 is an unsized constant and thus at least 32 bits.
> You probably mean 16'h0a41.
>
>
> - "b = string'(r) ; // OK (implicit cast, implementations can issue a
> warning)"
>
> "can" should probably be "may".
>
>
> -
> r = {"H",""}; // yields "H\0" "" is converted to 8'b0
> b = {"H",""}; // yields "H" as "" is the empty string
>
> The comments are gramatically incorrect.
> In the first, there probably should be a period between "H\0" and "".
> I don't know about the second.
>
>
> - Question:
> In:
>
> a[0] = "h"; // OK. same as a[0] = "hi")
>
> you deleted the second part of the comment (and forgot the closing
> parens).
>
> The following statements still exists:
>
> str.putc(i, s) replaces the ith character in str with the first
> character in s.
> s can be any expression that can be assigned to a string.
> Note: str.putc(j, x) is semantically equivalent to str[j] = x
>
> Now I'm confused again.
> What is the result of a[0] = "hi", where a is of type string?
>
> Thanks,
> Shalom
>
>
> On Mon, 6 Dec 2004, Arturo Salz wrote:
>
> > Plase find an attached proposal that specifies the interaction between
> string and zero characters.
> >
> > The proposal essentially disallows "\0" characters from being embedded
> in a string, and defines
> > the rules for converting string literals to strings or casting
> integral values to a string.
> >
> > My apologies for the late notice.
> >
> > Arturo
> >
> >
> >
>
>
-- Shalom Bresticker Shalom.Bresticker @freescale.com Design & Verification Methodology Tel: +972 9 9522268 Freescale Semiconductor Israel, Ltd. Fax: +972 9 9522890 POB 2208, Herzlia 46120, ISRAEL Cell: +972 50 5441478 [ ]Freescale Internal Use Only [ ]Freescale Confidential ProprietaryReceived on Tue Dec 7 02:15:13 2004
This archive was generated by hypermail 2.1.8 : Tue Dec 07 2004 - 02:17:02 PST