Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17255 Discussions

can i declare a 2D array as following ?

Altera_Forum
Honored Contributor II
1,698 Views

hi every body 

can i declare a 2D array as following ? 

type dataout is array (6 downto 0,11 downto 0) of std_logic_vector(7 downto 0); 

i guess this is a 3D array not 2D. 

so how i can have a 2d array of std_logic_vector? 

thank u
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
968 Views

For a 2D array just have one range in the brackets, instead of two. 

 

type dataout is array (6 downto 0) of std_logic_vector(7 downto 0); 

 

This will result in an array of 7 std_logic_vectors of range 7 downto 0.
0 Kudos
Altera_Forum
Honored Contributor II
968 Views

 

--- Quote Start ---  

For a 2D array just have one range in the brackets, instead of two. 

 

type dataout is array (6 downto 0) of std_logic_vector(7 downto 0); 

 

--- Quote End ---  

 

 

Nope, thats not a 2d array, thats a 1d array of 1d array. So you access it like this: 

 

output <= dout(x). 

 

A 2d array is declared like the OP posted. He made a 2d array of 1d arrays. You would access it like this: 

 

output <= dout(x,y); --and then add 2nd set of brackets to get individual bits
0 Kudos
Altera_Forum
Honored Contributor II
968 Views

thanks a lot my friend! 

 

--- Quote Start ---  

Nope, thats not a 2d array, thats a 1d array of 1d array. So you access it like this: 

 

output <= dout(x). 

 

A 2d array is declared like the OP posted. He made a 2d array of 1d arrays. You would access it like this: 

 

output <= dout(x,y); --and then add 2nd set of brackets to get individual bits 

--- Quote End ---  

 

 

i wanna initialize this vector, i have a 2d matrix of std_logic_vector 

can i write like this:  

 

constant d : dataout :=( -- Content -- Address(i,j) "00111100", -- 0,0 "11110000" --0,1 "01100010" --0,2 "01100010" --0,3 ... "01100010", -- 1,0 "10011000", --1,1 "10111000" --1,2 "00111000" --1,3 ... "00111100", -- 2,0 "11110000" --2,1 "01100010" --2,2 "01100010" --2,3 ... ........
0 Kudos
Reply