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
    1. Advertising

  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
    #2
    1. Advertising

  3. valtih1978

    valtih1978 Guest

    arr : string (5 downto 3);

    Should arr'range'rightof(5) evaluate to 6 or 4?
    valtih1978, May 29, 2013
    #3
  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
    Andy, Jun 3, 2013
    #4
  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
    #5
  6. valtih1978

    Andy Guest

    Alan,

    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
    Andy, Jun 3, 2013
    #6
    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. Max
    Replies:
    1
    Views:
    476
    Joe Kesselman
    Sep 22, 2006
  2. P4trykx
    Replies:
    2
    Views:
    1,804
    bruce barker
    Jan 31, 2007
  3. james_027

    class attributes & data attributes

    james_027, Jun 20, 2007, in forum: Python
    Replies:
    2
    Views:
    369
    Bruno Desthuilliers
    Jun 20, 2007
  4. Kyle Schmitt
    Replies:
    3
    Views:
    185
    Kyle Schmitt
    Jul 24, 2007
  5. Jayden
    Replies:
    16
    Views:
    510
    Steven D'Aprano
    Sep 29, 2012
Loading...

Share This Page