Re: [sv-bc] question on str.putc()

From: Neil Korpusik <Neil.Korpusik@sun.com>
Date: Fri Oct 15 2004 - 13:32:12 PDT

Hi Surrendra,

It is my understanding that the note for str[j]=x is referring to both of

   task putc(int i, string s)
   task putc(int i, byte c)

The following example is shown right before table 3-2 in section 3.7

   a[0]="h"; // OK same as a[0]="hi";

Note: there is actually a typo in the text here
                // OK same as a[0] = "hi" ) <--- ) should be ;

This example is showing the assignment of a string to a single character of
a. The "first" character of the string is assigned.

In the example pointed to by Shalom

   bit[1:4][7:0] h = "hello"; //assigns to h "ello"

The reason that the 'h' is dropped is due to the following paragraph in section
3.7 that describes truncation rules when the lengths of strings are unequal.

"A string literal can be assigned to a string or an integral type. If their
size differs the literal is right justified and either truncated on the left
or zero filled on the left, as necessary."

Neil

Surrendra Dudani wrote:
> Hi Shalom,
> I think the note str[j] = x is referring to
> task putc(int i, byte c)
> and not to
> task putc(int i, string s)
> Although the rules of assignment are not explicitly specified in this
> section, it seems to me that a string cannot be assigned to a character
> of another string.
> str[j] = x, when x is a string variable.
>
> Surrendra
>
> At 02:11 PM 10/15/2004 +0200, you wrote:
>
>> I apologize if this was already brought up.
>>
>> 3.7.2 putc() says that
>>
>> str.putc(i,s) replaces the i'th character in str with the first
>> character in s.
>>
>> Then it says,
>>
>> Note: str.putc(j,x) is semantically equivalent to str[j] = x.
>>
>> My question, I would think that str[j] = x takes the LAST, not FIRST,
>> character if x is a string, as in the example
>>
>> bit[1:4][7:0] h = "hello"; //assigns to h "ello"
>>
>> Thanks,
>> Shalom
>>
>> --
>> 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 Proprietary
>
>
>
> **********************************************
> Surrendra A. Dudani
> Synopsys, Inc.
> 377 Simarano Drive, Suite 300
> Marlboro, MA 01752
>
> Tel: 508-263-8072
> Fax: 508-263-8123
> email: Surrendra.Dudani@synopsys.com
> **********************************************
>

-- 
---------------------------------------------------------------------
Neil Korpusik                                     Tel: 408-720-4852
Member of Technical Staff                         Fax: 408-720-4850
Frontend Technologies - ASICs & Processors (FTAP)
Sun Microsystems
email: neil.korpusik@sun.com
---------------------------------------------------------------------
Received on Fri Oct 15 13:32:17 2004

This archive was generated by hypermail 2.1.8 : Fri Oct 15 2004 - 13:32:34 PDT