Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multidimensional array

Status
Not open for further replies.

sresam89

Member level 2
Joined
Sep 9, 2009
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,576
hello all
can somebody help in accessing and manipulating multidimensional array in vhdl.
any help will be lot appreciated as am finiding it difficult to manipulate the values in my 2 dimensional array as declared

type arr is array (6 downto 0) of std_logic_vector(6 downto 0);
signal and_1:arr;

when i can store values to the array why cant i read them or assign them a variable of same type?

thanks in advance
 

you can access them via:

and_1(3) <= "0010010";
and_1 <= (others => (others => '0'));

or something like that.

Please post your code.
 

i can store values using the following loop

for i in 0 to 3 loop
for j in 0 to 3 loop
and_1(i,j)<=(x(i) and y(j));
end loop;
end loop;

while i cant retrieve the values using

temp<=and_1(i,(j downto 0));

why is that?
 

what you talked about in your origional post, and your new post, are different things.

What you posted:
type arr is array (6 downto 0) of std_logic_vector(6 downto 0);

is not a 2D array. It is a 1d array of a 1d array type. This you can access with:

my_array(a)(b).

But what you can also do is access ranges. You can only access ranges in 1d arrays:

output <= my_array(a)(3 downto 0);

in your next post, you have a 2d array:
type arr is arrray(natural range<>, natural range <>) of integer;

which you access like this:

output <= my_array(i,j);

Each dimension is separated with a comma. You cannot access ranges inside the index, every element has to be accessed individuall, so (j downto 0) is illegal here.

what you will have to do is:

for k in j downto 0 loop
temp(k) <= and_1(i, k);
end loop;
 
  • Like
Reactions: j_andr

    j_andr

    Points: 2
    Helpful Answer Positive Rating
Try

temp<=and_1(i)(j downto 0);

that will be only valid if the array declaration was lyk

type arr is array (6 downto 0) of std_logic_vector(6 downto 0);
signal and_1:arr;

but then for that too if i use temp<=and_1(i)(j downto 0);
the temp variable is not getting any values during program run

---------- Post added at 16:07 ---------- Previous post was at 15:53 ----------

what you talked about in your origional post, and your new post, are different things.

What you posted:
type arr is array (6 downto 0) of std_logic_vector(6 downto 0);

is not a 2D array. It is a 1d array of a 1d array type. This you can access with:

my_array(a)(b).

But what you can also do is access ranges. You can only access ranges in 1d arrays:

output <= my_array(a)(3 downto 0);

in your next post, you have a 2d array:
type arr is arrray(natural range<>, natural range <>) of integer;

which you access like this:

output <= my_array(i,j);

Each dimension is separated with a comma. You cannot access ranges inside the index, every element has to be accessed individuall, so (j downto 0) is illegal here.

what you will have to do is:

for k in j downto 0 loop
temp(k) <= and_1(i, k);
end loop;

sorry that i confused a bit

when i use

type arr is array (6 downto 0,6 downto 0) of std_logic;
signal and_1:arr;

i use

and_1(i,j)<=(x(i) and y(j));//to store values to 2d array
temp(j)<=and_1(i,j);//to retrieve value.

and while using

type arr is array (6 downto 0) of std_logic_vector(6 downto 0);
signal and_1:arr;

i use

and_1(i)(j)<=(x(i) and y(j));//to store values
temp<=and_1(i)(j);//to retrieve values

on both times am able to store values to array perfectly but unable retrieve them back

---------- Post added at 16:22 ---------- Previous post was at 16:07 ----------

output <= my_array(i,j);
[/QUOTE=TrickyDicky;940491]

what should be the type of output where u mentioned
 

whatever the base type of the array is. In your case, probably std_logic.

I really suggest you do NOT create arrays of std_logic. It makes things annoying.
 

whatever the base type of the array is. In your case, probably std_logic.

I really suggest you do NOT create arrays of std_logic. It makes things annoying.

i know its killing my time.still i need a piece of a code to retrieve the array values as mentioned above
please advice...

thanks.. in advance..
 

Code:
for k in j downto 0 loop
  output(k) <= and_1(i, k);
end loop;

or if its not inside a process, use a generate loop
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top