Cascading the attributes

V

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?
 
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.
 
arr : string (5 downto 3);

Should arr'range'rightof(5) evaluate to 6 or 4?
 
On 25/05/13 20:55, valtih1978 wrote:
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?
I imagine things like that should "just work". Of course the prefix to a
signal attribute must be a signal, so

S'transaction'event

works fine as s'transaction returns an implicit signal - but

s'event'event

doesn't work as s'event returns a boolean value,

Alan

--
Alan Fitch
 
On 28/05/13 14:12, valtih1978 wrote:
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.
Ranges are defined in 1076-2002 3.1 "Scalar Types".

In 14.1 it says that the result type of A'RANGE[(N)] is

"The type of the Nth index range of A."

so it makes sense that you can use 'HIGH on the result

regards
Alan

--
Alan Fitch
 
On 29/05/13 11:27, valtih1978 wrote:
arr : string (5 downto 3);

Should arr'range'rightof(5) evaluate to 6 or 4?
The standard says arr'range returns a type, i.e.

type T is 5 downto 3

For rightof, it says the return value is

"The value that is to the right of the parameter in the range of T."

so I would expect the value 4.

regards
Alan

--
Alan Fitch
 
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.
 
On 03/06/13 15:27, Andy wrote:
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

Hi Andy,

Yes, sorry I forgot the word "integer".

Luckily we both agree the answer should be 4!

Alan

--
Alan Fitch
 
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
 
On 03/06/13 16:16, valtih1978 wrote:
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.
Oh dear, perhaps I'm wrong - there are clever people writing Modelsim :)

I guess you could ask Modelsim support.

Alan

--
Alan Fitch
 
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
 

Welcome to EDABoard.com

Sponsor

Back
Top