multidimensional array

Discussion in 'VHDL' started by vijayant.rutgers@gmail.com, Feb 8, 2008.

  1. 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
    , Feb 8, 2008
    #1
    1. Advertising

  2. KJ Guest

    <> wrote in message
    news:...
    > 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
    KJ, Feb 9, 2008
    #2
    1. Advertising

  3. Guest

    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" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > 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
    , Feb 10, 2008
    #3
  4. On Sat, 09 Feb 2008 03:03:45 GMT, "KJ" <> wrote:

    >
    ><> wrote in message
    >news:...
    >> 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
    Brian Drummond, Feb 10, 2008
    #4
  5. 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
    Mike Treseler, Feb 10, 2008
    #5
  6. KJ Guest

    On Feb 9, 10:14 pm, ""
    <> 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
    KJ, Feb 11, 2008
    #6
  7. KJ Guest

    On Feb 10, 9:07 am, Brian Drummond <>
    wrote:
    > On Sat, 09 Feb 2008 03:03:45 GMT, "KJ" <> wrote:
    >
    > ><> wrote in message
    > >news:...
    > >> 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
    KJ, Feb 11, 2008
    #7
  8. Vijayant Guest

    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 <> wrote:
    > On Feb 10, 9:07 am, Brian Drummond <>
    > wrote:
    >
    >
    >
    > > On Sat, 09 Feb 2008 03:03:45 GMT, "KJ" <> wrote:

    >
    > > ><> wrote in message
    > > >news:...
    > > >> 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
    Vijayant, Mar 14, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Bazell

    slice of multidimensional array

    Dave Bazell, Jul 23, 2003, in forum: Perl
    Replies:
    2
    Views:
    4,067
  2. epigram
    Replies:
    1
    Views:
    10,781
    =?Utf-8?B?c29jaWV0b3BpYS5uZXQ=?=
    Jul 16, 2005
  3. Ben
    Replies:
    8
    Views:
    12,570
    Eki Y. Baskoro
    Dec 18, 2003
  4. Huub
    Replies:
    6
    Views:
    597
  5. geletine
    Replies:
    12
    Views:
    21,645
    Fred Kleinschmidt
    May 5, 2006
Loading...

Share This Page