%s format question in $display

From: Ryan, Ray (Ray_Ryan@mentorg.com)
Date: Mon Feb 23 2004 - 15:15:21 PST

  • Next message: Stefen Boyd: "Re: (POSTED) Minutes of the February 23, 2004 IEEE 1364 WG meeting"

    We have received a customer question about differences between
    the 1364 LRM and verilog simulators.

    The LRM seems to specify that leading 0's in a string should not
    be printed (using %s in $display), however the major simulators
    convert leading 0's to blanks and then print these blanks.

    Is there an errata on this? (I can't find one).

    Further info:

    The 1364 LRM, 2.6.2 String Manipulation, contains the following
    example:

      module string_test;
      reg [8*14:1] stringvar;
      initial begin
        stringvar = "Hello world";
        $display("%s is stored as %h", stringvar,stringvar);
        stringvar = {stringvar,"!!!"};
        $display("%s is stored as %h", stringvar,stringvar);
      end
      endmodule

    For which the expected output is listed as:

    Hello world is stored as 00000048656c6c6f20776f726c64
    Hello world!!! is stored as 48656c6c6f20776f726c64212121

    The leading 0's of 'stringvar' in the first call to
    $display are NOT printed (also not convered to blanks).

    However, the simulation result seen is:
       Hello world is stored as 00000048656c6c6f20776f726c64
    Hello world!!! is stored as 48656c6c6f20776f726c64212121

    Also in 17.1.1.7 String format, at the end of the section it
    state:
    "... No termination character or value is required at the end
    of a string, and leading zeros are never printed."

    Help in identifying the correct behavior would be appreciated.

    Thanks,
    Ray Ryan



    This archive was generated by hypermail 2.1.4 : Mon Feb 23 2004 - 15:27:04 PST and
    sponsored by Boyd Technology, Inc.