Re: Query related to escaped character in verilog

From: Neil Korpusik (Neil.Korpusik@sun.com)
Date: Wed Feb 09 2005 - 11:15:14 PST

  • Next message: Shalom.Bresticker@freescale.com: "Re: Query related to escaped character in verilog"

    The results that Shalom is showing appear to be incorrect. The leading space
    appears to be inconsistent with what is stated in 17.1.1.7

    Even though the LRM doesn't explicitly state what character to print when
    a \0 is embedded within a string, it appears from 17.1.1.7 that the NUL
    character should not be treated like a string terminator, as shown in one of
    the outputs shown by Kausik.

    Printing a blank for an embedded NUL character seems to be the most appropriate
    thing to do. Ignoring leading NUL characters seems to be the most consistent
    with the rules for the comparison and concatenation operators (4.2.3.2).

    4.2.3.2 String value padding and potential problems

       "When strings are assigned to variables, the values stored shall be padded
       on the left with zeros."

       "The comparison and cancatenation operators shall not distinguish between
       zeros resulting from padding and the original string characters (\0, ASCII
       NUL)."

    17.1.1.7 String format

       "No termination character or value is required at the end of a string, and
       leading zeros are never printed."

    Neil

    Shalom Bresticker wrote:
    > The three simulators I have access to all print " s a", with leading space
    > before the "s".
    >
    > Shalom
    >
    >
    > Kausik Datta wrote:
    >
    >
    >>Hi,
    >>I have one query related to use of escaped character in verilog.
    >>
    >>Let's take the following example:
    >>
    >>reg [31:0] a;
    >>
    >>initil
    >>begin
    >> a = "s\0a";
    >> #5 $diaplay("%s\n", a);
    >>end
    >>
    >>Some tool print this one as "s a".
    >>and some tool print as "s"
    >>
    >>Which one is the correct output? LRM doesn't say anything about this.
    >>
    >>Thanks
    >>Kausik Datta
    >>
    >>
    >
    >
    > --
    > 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
    >
    >
    >

    -- 
    ---------------------------------------------------------------------
    Neil Korpusik                                     Tel: 408-720-4852
    Staff Engineer                                    Fax: 408-720-4850
    Frontend Technologies - ASICs & Processors (FTAP)
    Sun Microsystems
    email: neil.korpusik@sun.com
    ---------------------------------------------------------------------
    


    This archive was generated by hypermail 2.1.4 : Wed Feb 09 2005 - 10:57:21 PST and
    sponsored by Boyd Technology, Inc.