Re: [sv-bc] hex number in string literal

From: Krishanu Debnath <krishanu_at_.....>
Date: Thu Mar 23 2006 - 22:51:36 PST
[Context and attribution lines restored manually once again]

Brad Pierce wrote:
> Krishanu Debnath wrote:
>> [Context and attribute lines restored manually]
>>
>> Brad Pierce wrote:
>>  > Krishanu Debnath wrote:
>>  >> Hello,
>>  >>
>>  >> This has been discussed 
>> before(http://www.eda.org/sv-bc/hm/1539.html),
>>  >> But I
>>  >> still don't find the normative answer. Lets try again.
>>  >>
>>  >> Here is the Chapter & Verse(CV) from standard about special string
>>  >> character -
>>  >> hex number.
>>  >>
>>  >> 3.6 String literals
>>  >> [...]  SystemVerilog adds the following special string characters:
>>  >> \v vertical tab
>>  >> \f form feed
>>  >> \a bell
>>  >> \x02 hex number
>>  >>
>>  >> Sec 4.7 String data type shows an example of hex number in string
>>  >> literal.
>>  >>
>>  >> [page 20]
>>  >>
>>  >> bit [10:0] a = "\x41"; // assigns to a 'b000_0100_0001
>>  >>
>>  >> But It does not mandate about the number of hex digits required. 
>> is it 2?
>>  >>
>>  >> Please note that Verilog 2005 draft is very clear about how many
>>  >> characters
>>  >> are required to specify octal digits in string literal. Here is 
>> the CV
>>  >> from
>>  >> Verilog 2005 draft ...
>>  >>
>>  >> Sec 3.6.3 Special characters in strings
>>  >>
>>  >> \ddd A character specified in 1--3 octal digits (0 ? d ? 7).
>>  >>
>>  >> If less than three characters are used, the following character shall
>>  >> not be an
>>  >> octal digit. Implementations may issue an error if the character
>>  >> represented is
>>  >> greater than \377.
>>  >>
>>  >> Now consider this example: (note the embedded comments)
>>  >>
>>  >> module sample;
>>  >>
>>  >>     string s;
>>  >>
>>  >>     initial
>>  >>     begin
>>  >>         s = "\x41";  // this means now s is "A". ASCII value of A is
>>  >> 0x41.
>>  >>         $display("value of s %s \n", s);
>>  >>
>>  >>         s = "\x4142"; // does this mean s is "A42" ?
>>  >>         $display("value of s %s \n", s);
>>  >>
>>  >>         s = "\x41\x42"; // does this mean s is "AB" ?
>>  >>         $display("value of s %s \n", s);
>>  >>
>>  >>         s = "\x4"; // less than two characters followed by x, so it
>>  >> will be not
>>  >>                    // treated as hex number.
>>  >>         $display("value of s %s \n", s);
>>  >>     end
>>  >> endmodule
>>  >>
>>  >> Does the above make sense?
>>  >>
>>  >> Krishanu
>>  >
>>> For background on the V2005 clarification about octal escape sequences,
>>> see
>>>
>>>    http://www.boyd.com/1364_btf/report/full_pr/119.html
>>>
>>> -- Brad
>>>
>>
>> Umm, I just read it. But does it *answer* my question?
>>
>> Krishanu
>>
>>
> 
> Did I claim it did?
> 
> -- Brad

Nope. Did you read my issue with SV hex escape sequence? Do you agree
with my comments I put in the example? If yes, then I would like to see this
issue filed in problem reporting database, and further processing of this issue.

Thanks,
Krishanu
Received on Thu Mar 23 22:50:37 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 23 2006 - 22:50:43 PST