Cascading the attributes

V

valtih1978

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?
 
V

valtih1978

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.
 
A

Andy

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
 
V

valtih1978

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.
 
A

Andy

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top