Cascading the attributes

Discussion in 'VHDL' started by valtih1978, May 25, 2013.

  1. valtih1978

    valtih1978 Guest

    What is supposed to happen when one invokes
    boolean'base'base'image(true)'base'base'val(1) or E'SIMPLE_NAME'length
    or S'transaction'transaction?
    valtih1978, May 25, 2013
    1. Advertisements

  2. valtih1978

    valtih1978 Guest

    and, the most intriguing,

    val := a'range'high

    It seems that there is internal range type in VHDL. Although it is not
    exposed explicitly and, therefore you cannot instantiate objects of this
    type, I see no rule that forbids testing its attributes this way.

    Similarly to OOP, where you write object.method(arg), where methods are
    just functions, tied to the object, I consider the attribute as a
    function (operators are the other kind of fancy functions). It takes an
    object and produces a result. I see no objection against cascading
    function calls.
    valtih1978, May 28, 2013
    1. Advertisements

  3. valtih1978

    valtih1978 Guest

    arr : string (5 downto 3);

    Should arr'range'rightof(5) evaluate to 6 or 4?
    valtih1978, May 29, 2013
  4. valtih1978

    Andy Guest

    Actually, the string type's index is positive (which is an integer subtype), so

    arr'range is integer range 5 downto 3;

    Therefore arr'range'rightof(5) evaluates to an integer value of 4.

    Andy, Jun 3, 2013
  5. valtih1978

    valtih1978 Guest

    Thanks for your answers. You is the first one who almost explicitly says
    that cascading is not prohibited in the LRM and "should just work". I
    asked this question just because our de-facto standard implementaion,
    called Modelsim, does not think so. Particularly, he produces
    compilation error

    | Prefix (attribute name "range") for attribute "rightof"
    | is not a type mark

    for arr'range'rightof(5) whose syntax you have approved.

    Might be somebody can comment on Modelsim behaviour.
    valtih1978, Jun 3, 2013
  6. valtih1978

    Andy Guest


    Per LRM (2008) 16.2 Predefined attributes, A'range is of kind "range", whereas T'base is of kind "type". Also, the result of A'range is defined as a range of the index type of A, which is not a type itself.

    So arr'range is just "5 downto 3", not "integer range 5 downto 3".

    Accordingly, you would not be able to use A'range as follows:

    variable arr_ndx : arr'range;

    But you could use:

    variable arr_ndx : integer range arr'range;

    To get what was apparently desired from arr'range'rightof(5), you'd probably need to write a function.

    Andy, Jun 3, 2013
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.