multidimensional array

  • Thread starter vijayant.rutgers@gmail.co
  • Start date
V

vijayant.rutgers@gmail.co

Guest
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
 
<vijayant.rutgers@gmail.com> wrote in message
news:a931504d-d0c4-43e0-9147-1feacd564838@e6g2000prf.googlegroups.com...
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
 
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.

On Feb 8, 10:03 pm, "KJ" <kkjenni...@sbcglobal.net> wrote:
vijayant.rutg...@gmail.com> wrote in message

news:a931504d-d0c4-43e0-9147-1feacd564838@e6g2000prf.googlegroups.com...



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
 
On Sat, 09 Feb 2008 03:03:45 GMT, "KJ" <kkjennings@sbcglobal.net> wrote:

vijayant.rutgers@gmail.com> wrote in message
news:a931504d-d0c4-43e0-9147-1feacd564838@e6g2000prf.googlegroups.com...
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;
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
 
vijayant.rutgers@gmail.com wrote:

Can anyone help me with some other method ?
I don't understand what you are trying to do,
but I sometimes declare a type for commands.
Example:
type op_t is (idle, get, put);

Details:
http://home.comcast.net/~mike_treseler/oe_demo.vhd


-- Mike Treseler
 
On Feb 9, 10:14 pm, "vijayant.rutg...@gmail.com"
<vijayant.rutg...@gmail.com> wrote:
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
 
On Feb 10, 9:07 am, Brian Drummond <brian_drumm...@btconnect.com>
wrote:
On Sat, 09 Feb 2008 03:03:45 GMT, "KJ" <kkjenni...@sbcglobal.net> wrote:

vijayant.rutg...@gmail.com> wrote in message
news:a931504d-d0c4-43e0-9147-1feacd564838@e6g2000prf.googlegroups.com...
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;

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


On Feb 11, 8:28 am, KJ <kkjenni...@sbcglobal.net> wrote:
On Feb 10, 9:07 am, Brian Drummond <brian_drumm...@btconnect.com
wrote:



On Sat, 09 Feb 2008 03:03:45 GMT, "KJ" <kkjenni...@sbcglobal.net> wrote:

vijayant.rutg...@gmail.com> wrote in message
news:a931504d-d0c4-43e0-9147-1feacd564838@e6g2000prf.googlegroups.com...
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;

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
 

Welcome to EDABoard.com

Sponsor

Back
Top