RE: %s format question in $display

From: Michael McNamara (mac@verisity.com)
Date: Mon Feb 23 2004 - 19:19:36 PST

  • Next message: Shalom Bresticker: "enhancement/548: support SDF RETAIN?"

    Thinking about this further, it may be that there is indeed an errata,
    as the new formatted IO section 17.1.1.3 specified that unsized format
    size speficiation auto sizes the output space to hold the largest
    possible value; but that one could get the minimum needed size by
    using inserting a 0 after the % character.

    It seems the error was not updating the example in section 2.6.2 to
    reflect this change.

    It would make sense to me to replace the %s with a %0s in the example.
    %s. It may also make sense to refrain from partially specifing the
    effect of format characters in section 2, and consolidate all of that
    to section 17.1.1

    -mac

    -- On Feb 23 2004 at 18:57, Michael McNamara sent a message:
    > To: Ray_Ryan@mentorg.com, etf@boyd.com
    > Subject: "RE: %s format question in $display"
    >
    > It is my personal view that the standard is clear on this, and that
    > the customer should decide whether to insist that their vendor comply
    > with the standard.
    >
    > Note that this forum (etf@boyd.com) does not pass judgement on the
    > adhereance to the standard of any implementation.
    >
    > If you (or anyone else) would like to propose a change in the standard
    > because you feel the standard is in error, this would be the place to
    > send in your request. If your proposal is an enhancement, than
    > btf@boyd.com would likely be the place.
    >
    > -mac
    >
    > -- On Feb 23 2004 at 15:15, Ryan, Ray sent a message:
    > > To: etf@boyd.com
    > > Subject: "%s format question in $display"
    > >
    > > 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 - 19:05:03 PST and
    sponsored by Boyd Technology, Inc.