std.textio.read strange behaviour?!

Discussion in 'VHDL' started by James Unterburger, Jun 26, 2008.

  1. Here is a repeat of what I said in my post of 06/24/2008 01:28 PM
    since (apparently) some interested parties have not been able to
    see it:



    If the out-of-range value is allowed, it is a bug.

    See (1993 LRM) [2.1.1.1 Constant and variable parameters], line62:
    After completion of the subprogram body, if the mode is INOUT or OUT,
    the value of the formal parameter is copied back into the associated
    actual parameter; it is similarly an error if, after applying any
    conversion function or type conversion present in the formal part of
    the applicable association element, the value of the formal parameter
    does not belong to the subtype denoted by the subtype indication of
    the actual.

    Note that no "body" of the textio READ functions exist, but we do have
    the functionality requirements described in [14.3 Package TEXTIO].
    If we were to implement the READ functions in VHDL, there would be no way to
    know the (scalar) subtype range of any actual associated with a mode OUT
    formal inside the subprogram body, so it's safe to say that [2.1.1.1] does
    apply, and not some internal (or external, if the GOOD formal is present)
    mechanism, for catching out-of-range errors. Thus the range check must
    occur after the value has been placed into the (variable) actual associated
    with the VALUE formal for these READ subprograms. The value of the actual
    associated with the GOOD formal (when present) does not reflect this
    out-of-range error.

    The reason the "b2 := byte" line does not error is that both sides of the
    assignment are of the same subtype so no checking is needed (save the
    case, say, when a bug causes the value of "byte" to be illegal).

    The reason the "b2 := byte+0" line does fail is that the "+" operator
    for (base) type INTEGER is used, and its return value can be (and will
    be, in this case) outside the legal range for the target of the assignment,
    so the necessary checking code is emitted as part of the compilation process.

    If you change the WRITE(to_stdout...) call to use u8'image(byte) instead
    of integer'image(byte), this too will error out (as it should) for illegal
    value of "byte".
     
    James Unterburger, Jun 26, 2008
    #1
    1. Advertising

  2. James Unterburger wrote:
    > Here is a repeat of what I said in my post of 06/24/2008 01:28 PM
    > since (apparently) some interested parties have not been able to
    > see it:


    Thanks for resending. I did not see the previous version.

    > Note that no "body" of the textio READ functions exist, but we do have
    > the functionality requirements described in [14.3 Package TEXTIO].


    Interesting.
    A vhdl library function that
    cannot be implemented in vhdl.
    I can see where a sim vendor might miss this point.
    Thanks for the clarification.

    -- Mike Treseler
     
    Mike Treseler, Jun 26, 2008
    #2
    1. Advertising

  3. James Unterburger

    Guest

    Thanks for your extensive answer. I don't have a copy of the LRM,
    but it seems to be very precise about what to expect from the return
    of procedure calls.

    I have filed a service request to both modelsim/mentor and aldec.
    Mentor acknowledges this as a bug, aldec didn't reply before I left
    work.


    Thank you all,
    Regards -- Pontus
     
    , Jun 26, 2008
    #3
  4. Actually, I don't know if a body for textio can be written in VHDL or not,
    but the LRM certainly does not specify one, it specifies only how the
    subprograms must behave. The copy out rules in 2.1.1.1 apply nonetheless,
    else we end up with untenable situations as shown in the testcase.


    Mike Treseler wrote:
    > James Unterburger wrote:
    >
    >>Here is a repeat of what I said in my post of 06/24/2008 01:28 PM
    >>since (apparently) some interested parties have not been able to
    >>see it:

    >
    >
    > Thanks for resending. I did not see the previous version.
    >
    >
    >>Note that no "body" of the textio READ functions exist, but we do have
    >>the functionality requirements described in [14.3 Package TEXTIO].

    >
    >
    > Interesting.
    > A vhdl library function that
    > cannot be implemented in vhdl.
    > I can see where a sim vendor might miss this point.
    > Thanks for the clarification.
    >
    > -- Mike Treseler
     
    James Unterburger, Jun 26, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Magne Munkejord
    Replies:
    1
    Views:
    3,747
    Magne Munkejord
    Aug 23, 2006
  2. Nicolas Matringe

    std.textio, readline and memory deallocation

    Nicolas Matringe, Sep 1, 2006, in forum: VHDL
    Replies:
    9
    Views:
    2,188
    Paul Uiterlinden
    Sep 4, 2006
  3. westkite
    Replies:
    1
    Views:
    845
    scottcarl
    Nov 5, 2007
  4. Replies:
    13
    Views:
    1,088
  5. Zhane
    Replies:
    0
    Views:
    625
    Zhane
    Apr 25, 2009
Loading...

Share This Page