multidimensional array

  • Thread starter vijayant.rutgers
  • Start date
V

vijayant.rutgers

Hi,
My basic requirement is to have a set of commands for a block. This
has been declared as :

TYPE command IS ARRAY (NATURAL range <>) OF NATURAL;

CONSTANT block1_command :command:=
(
-- ('1','0','1',X"0F_0F"),
(16#1F#),
(16#11#),
(16#12#),
(16#15#)
);...follows...

Now I have 5-6 blocks as :

TYPE blocks IS (block1, block2....block5);

I wish to link block1 with block1_command ; block2 with
block2_command.....etc.....i.e. if I pass 'block1' to my entity, it
should get associated with block1_command.

One way of doing this is :
type command_table is array (blocks, command) of blocks; but this
doesnt work since command is not discrete....

Can anyone help me with some other method ?

Help appreciated.

Thanks,
Vijayant
 
K

KJ

Hi,
My basic requirement is to have a set of commands for a block. This
has been declared as :

TYPE command IS ARRAY (NATURAL range <>) OF NATURAL;

CONSTANT block1_command :command:=
(
-- ('1','0','1',X"0F_0F"),
(16#1F#),
(16#11#),
(16#12#),
(16#15#)
);...follows...

Now I have 5-6 blocks as :

TYPE blocks IS (block1, block2....block5);

I wish to link block1 with block1_command ; block2 with
block2_command.....etc.....i.e. if I pass 'block1' to my entity, it
should get associated with block1_command.

One way of doing this is :
type command_table is array (blocks, command) of blocks; but this
doesnt work since command is not discrete....

Can anyone help me with some other method ?

You don't so much want a multi-dimensional array in this case, what you
would like is an array of an array which is declared as...

type Array_Of_Commands is array (natural range <>) of command;

Then declare a signal, variable or constant of that type...

constant My_List_Of_Commands: Array_Of_Commands(1 to 5) := (block1,
block2....block5);

My_List_Of_Commands(3) will then equal block3.

Kevin Jennings
 
V

vijayant.rutgers

Hi Kevin,
I would like to thank you for your help. But since my 'command' is
unconstrained , I am getting compile time error.

Error : "Array element type can not be unconstrained array type
command."


This is the line where I am getting an errror :
type Array_Of_Commands is array (natural range <>) of command;

Is there any way out for this ?

Any help is appreciated.

Thanks,
Vijayant Bhatnagar.
 
B

Brian Drummond

You don't so much want a multi-dimensional array in this case, what you
would like is an array of an array which is declared as...

type Array_Of_Commands is array (natural range <>) of command;

I may be misunderstanding the problem, but what's wrong with

type Array_Of_Commands is array (blocks) of command;

and use block1 etc as index values?

- Brian
 
K

KJ

Hi Kevin,
I would like to thank you for your help. But since my 'command' is
unconstrained , I am getting compile time error.

It appeared to me from the original post that the actual 'commands'
were all going to be 4 element arrays (or at least that each of the
commands are of the same length). If that's the case then you simply
constrain the length of the command, either by modifying the type
definition or when you define the array of commands

type Array_Of_Commands is array (natural range <>) of command(0 to 3);

If each command is potentially a different size command array then I
suggest you go back and take a fresh look at the overall problem that
you're trying to solve because trying to represent the command set as
being an unknown size of variable sized arrays might not be a very
good approach to the problem, 'specially if it needs to be
synthesizable (not clear if that is your goal or not). Check out
Mike's post and examples for a possibly clearer formulation of how to
view the problem in a different light.

If it doesn't need to be synthesizable, and is strictly for a
simulation or testbench then you have several other alternatives that
would center around using pointers and dynamically allocating memory
instead...but I'm guessing that might not be the case here.

Kevin Jennings
 
K

KJ

I may be misunderstanding the problem, but what's wrong with

type Array_Of_Commands is array (blocks) of command;

and use block1 etc as index values?

Nothing 'wrong' with it...as long as 'command' is constrained at some
point.

I'm guessing from the OP that each command 'should' be the same number
of bytes (i.e. command would be a fixed sized array) but I'm not
totally sure.

Kevin Jennings
 
V

Vijayant

Hi,
I actually realized about this after running google search. There was
a fault in our architecture. Now we have changed this and it is
working well. The basic flaw was in the unconstrained array.

Thanks to all for the help.

Regards,
Vijayant Bhatnagar
Rutgers Univ.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top