StateTable'LENGTH(2)

J

JohnSmith

Guest
Hi,

What does the (2) here?

StateTable'LENGTH(2)

Thanks
 
JohnSmith wrote:

What does the (2) here?
StateTable'LENGTH(2)
I expect that it would cause a syntax error.
StateTable'LENGTH = 2 would be a valid boolean.

-- Mike Treseler
 
On Nov 2, 11:25 am, Mike Treseler <mtrese...@gmail.com> wrote:
JohnSmith wrote:
What does the (2) here?
StateTable'LENGTH(2)

I expect that it would cause a syntax error.
StateTable'LENGTH = 2 would be a valid boolean.

   -- Mike Treseler
Actually, a legal interpretation would exist if StateTable is an array
with 2 or more dimensions. Then this would return the length of the
second index range. For example, if StateTable were of a type like:

array(1 to 3, 100 to 199, 16 to 66) of BIT;

then the above subterm would evaluate to 100.

- Kenn
 
On 2 Nov, 17:37, kennheinr...@sympatico.ca wrote:
On Nov 2, 11:25 am, Mike Treseler <mtrese...@gmail.com> wrote:

JohnSmith wrote:
What does the (2) here?
StateTable'LENGTH(2)

I expect that it would cause a syntax error.
StateTable'LENGTH = 2 would be a valid boolean.

   -- Mike Treseler

Actually, a legal interpretation would exist if StateTable is an array
with 2 or more dimensions. Then this would return the length of the
second index range.  For example, if StateTable were of a type like:

 array(1 to 3, 100 to 199, 16 to 66) of BIT;

then the above subterm would evaluate to 100.

 - Kenn
But why would the above work?
Shouldnt it be StateTable(2)'length ?
 
On Nov 3, 4:24 am, Tricky <Trickyh...@gmail.com> wrote:

But why would the above work?
Because that is the syntax for getting the length of the 2nd element
of a multi-dimensional array.

Shouldnt it be StateTable(2)'length ?
No, StateTable(2)'length would get you the length of the second
element of StateTable.

An array of arrays is not the same thing as a 2d array. Below is an
example that defines an array of an array as well as a 2d array and
the syntax differences you come across when using these things.

type t_array_of_array is array(1 to 10) of std_logic_vector(7 downto
0);
type t_2darray is array(1 to 10, 7 downto 0) of std_logic;
signal Arr_arr: t_array_of_array;
signal Arr2d: t_2darray;

Arr_arr(2)(3) returns bit 3 of Arr_arr(2).
Arr2d(2,3) returns element (2,3) of Arr2d.

Arr_arr(2) returns a std_logic_vector(7 downto 0)
Arr2d(2) is a syntax error.

Arr_arr'length = Arr_arr'length(1) = 10
Arr2d'length(1) also = 10.

Arr_arr'length(2) = syntax error because Arr_arr is only a one-
dimensional array. But Arr_arr(xx)'length = 8 (where 'xx' is any
number in the range from 1 to 10)
Arr2d'length(2) = 8

Kevin Jennings
 
On Nov 2, 6:37 pm, kennheinr...@sympatico.ca wrote:
On Nov 2, 11:25 am, Mike Treseler <mtrese...@gmail.com> wrote:

JohnSmith wrote:
What does the (2) here?
StateTable'LENGTH(2)

I expect that it would cause a syntax error.
StateTable'LENGTH = 2 would be a valid boolean.

-- Mike Treseler

Actually, a legal interpretation would exist if StateTable is an array
with 2 or more dimensions. Then this would return the length of the
second index range. For example, if StateTable were of a type like:

array(1 to 3, 100 to 199, 16 to 66) of BIT;

then the above subterm would evaluate to 100.

- Kenn
....
TYPE VitalStateTableType IS ARRAY ( NATURAL RANGE <>, NATURAL
RANGE <> )
OF VitalStateSymbolType;


begin

process
variable X_FF_O_tab : VitalStateTableType;
begin

......

What about open arrays?
 
On Nov 4, 4:06 pm, JohnSmith <csnew...@gmail.com> wrote:
On Nov 2, 6:37 pm, kennheinr...@sympatico.ca wrote:



On Nov 2, 11:25 am, Mike Treseler <mtrese...@gmail.com> wrote:

JohnSmith wrote:
What does the (2) here?
StateTable'LENGTH(2)

I expect that it would cause a syntax error.
StateTable'LENGTH = 2 would be a valid boolean.

   -- Mike Treseler

Actually, a legal interpretation would exist if StateTable is an array
with 2 or more dimensions. Then this would return the length of the
second index range.  For example, if StateTable were of a type like:

 array(1 to 3, 100 to 199, 16 to 66) of BIT;

then the above subterm would evaluate to 100.

 - Kenn

...
    TYPE VitalStateTableType IS ARRAY ( NATURAL RANGE <>, NATURAL
RANGE <> )
         OF VitalStateSymbolType;

begin

 process
  variable X_FF_O_tab : VitalStateTableType;
 begin

.....

What about open arrays?
According to the LRM, the LENGTH attribute is only defined for
_constrained_ array subtypes, which rules out your "open" or
unconstrained arrays. I'd expect to see an error message.

- Kenn
 
On Nov 4, 11:36 pm, kennheinr...@sympatico.ca wrote:
On Nov 4, 4:06 pm, JohnSmith <csnew...@gmail.com> wrote:





On Nov 2, 6:37 pm, kennheinr...@sympatico.ca wrote:

On Nov 2, 11:25 am, Mike Treseler <mtrese...@gmail.com> wrote:

JohnSmith wrote:
What does the (2) here?
StateTable'LENGTH(2)

I expect that it would cause a syntax error.
StateTable'LENGTH = 2 would be a valid boolean.

   -- Mike Treseler

Actually, a legal interpretation would exist if StateTable is an array
with 2 or more dimensions. Then this would return the length of the
second index range.  For example, if StateTable were of a type like:

 array(1 to 3, 100 to 199, 16 to 66) of BIT;

then the above subterm would evaluate to 100.

 - Kenn

...
    TYPE VitalStateTableType IS ARRAY ( NATURAL RANGE <>, NATURAL
RANGE <> )
         OF VitalStateSymbolType;

begin

 process
  variable X_FF_O_tab : VitalStateTableType;
 begin

.....

What about open arrays?

According to the LRM, the LENGTH attribute is only defined for
_constrained_ array subtypes, which rules out your "open" or
unconstrained arrays. I'd expect to see an error message.

 - Kenn- Hide quoted text -

- Show quoted text -
These constructs are used in VITAL packages. In VitalStateTable
procedure (prmtvs_b.vhd), VitalStateTableType is defined in
prmtvs_p.vhd
 
"JohnSmith" <csnews77@gmail.com> wrote in message
news:047bfb97-ec02-4819-a074-4dcff5a93fcf@w24g2000prd.googlegroups.com...
What about open arrays?

According to the LRM, the LENGTH attribute is only defined for
_constrained_ array subtypes, which rules out your "open" or
unconstrained arrays. I'd expect to see an error message.

These constructs are used in VITAL packages. In VitalStateTable
procedure (prmtvs_b.vhd), VitalStateTableType is defined in
prmtvs_p.vhd
But even though a type can have an unconstrained array size, an actual
variable/signal will not. You would be taking the 'length(2) of the
signal/variable not of the type.

Kevin Jennigns
 
On Nov 4, 11:00 pm, JohnSmith <csnew...@gmail.com> wrote:

These constructs are used in VITAL packages. In VitalStateTable
procedure (prmtvs_b.vhd), VitalStateTableType is defined in
prmtvs_p.vhd
Agreed, the input parameter has this unconstrained type. But the array
that actually gets passed into the procedure when the procedure is
called in a program is a constrained array, so the LENGTH(2) will not
fail out.

This is due the magic of VHDL subtyping, where you can define a type
which is "more general" in a sense (and hence reusable) than you might
actually want to pass in. Then when you create an actual object you
create it as a "subtype" of that type in which you nail down the
unconstrained indices, or limit the range in some other way.

It's the same thing as with std_logic_vector (I'll call it slv for
brevity): slv itself is an unconstrained type, but when you create a
signal as "slv(7 downto 0)" you're defining a subtype of slv with 8
elements, and it's OK to pass an object of this subtype into a
procedure which takes the more general slv.

- Kenn
 

Welcome to EDABoard.com

Sponsor

Back
Top