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

Dividing array in parts.

Altera_Forum
Honored Contributor II
2,266 Views

Hi, I'm having a problem when I try to take just one part of an array, for example: 

I have a 512x512 array, and want just the first 8x8 samples. 

I'm having the following error: 

"slice of object cannot be specified for object that has an array type of more than one dimension" 

 

Here's part of the code: 

 

 

Type array_t IS ARRAY (0 to 7, 0 to 7) OF STD_LOGIC_VECTOR(0 to 7); 

Type array_t2 IS ARRAY (0 to 511, 0 to 511) OF STD_LOGIC_VECTOR(0 to 7); 

 

SIGNAL input: array_t 

SIGNAL output: array_t2 

 

input<=output(0 to 7, 0 to 7); 

 

Thank you!!
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
761 Views

you cannot do that with a 2d array, you can only access one entry at a time.  

 

for this, you would need a loop (ps. I think you means to assign output, not input!) 

 

for i in input'range(1) loop for j in input'range(2) loop output(i,j) <= input(i,j); end loop; end loop;
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

Thanks Tricky. You are always saving my life.  

As soon as possible I will teste and reply. 

Thanks again!
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

 

--- Quote Start ---  

you cannot do that with a 2d array, you can only access one entry at a time. 

--- Quote End ---  

 

Respectively a row slice at once. Keep in mind, that a 2D array isn't but a mapping scheme to represent data structures, that are 1D arrays by nature.
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

It didn't worked, I get an error: 

"indexed name returns a value whose type does not match "array_t", the type of the target expression." 

 

Type array_t IS ARRAY (0 to 7, 0 to 7) OF STD_LOGIC_VECTOR(0 to 7); 

Type array_t2 IS ARRAY (0 to 511, 0 to 511) OF STD_LOGIC_VECTOR(0 to 7); 

 

SIGNAL output: array_t 

SIGNAL input: array_t2 

 

process(clk) 

begin 

for i in 0 to 7 loop 

for j in 0 to 7 loop 

output<=input(i, j); 

end loop; 

end loop; 

end process; 

 

Thank You!
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

you need to change it to 

 

output(i, j) <= input(i,j);
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

Oh...Ok, 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

The code worked fine if I want to do something using the same index: 

 

output(0, 0) <= input(0, 0); 

 

but how about 

 

output(0, 0) <= input(8, 8); 

output(0, 1) <= input(8, 9); 

 

How can be done that? 

Thank You!
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

I have tried this before and didn't worked. But the error was somewhere else. 

 

This works. 

output(i, j) <= input(i, j+8);
0 Kudos
Reply