Forum Discussion
Altera_Forum
Honored Contributor
14 years agoVerilog array assistance
Hello all, I'm attempting to copy a portion of a 128 byte array to a 32 byte array. I'm using one of a possible five 7-bit Addresses to determine the start and end point.
Here are my declarations: --- Quote Start --- reg [7:0] STORAGE_BUF0 [31:0]; reg [7:0] LARGE_ARRAY[127:0]; reg [6:0] ADDR [5:0]; --- Quote End --- Here's where the assignment takes place: --- Quote Start --- STORAGE_BUF0[31:0] <= LARGE_ARRAY [(ADDR[0]+7'd32): (ADDR[0]+7'd01)]; --- Quote End --- The errors I get are: Error (10133): Verilog HDL Expression error at XX: illegal part select of unpacked array "STORAGE_BUF0" Error (10734): Verilog HDL error at XX: ADDR is not a constant Error (10133): Verilog HDL Expression error at XX: illegal part select of unpacked array "LARGE_ARRAY" Can anyone tell me where I'm messing up? Thanks in advance!8 Replies
- Altera_Forum
Honored Contributor
No problem :)
- Altera_Forum
Honored Contributor
Makes sense.
I've got it implemented and everything seems happy. Thanks for your help! - Altera_Forum
Honored Contributor
That is correct. So you can't have a variable number of loops. Needs to be constant. Otherwise it would be impossible to implement in hardware.
- Altera_Forum
Honored Contributor
Ah, okay.
This means the 'i' index can't be dependent on anything else, correct? - Altera_Forum
Honored Contributor
The for loop will be unrolled and implemented. this of course means that the index variable in the for loop can't be variable.
- Altera_Forum
Honored Contributor
I'm trying that now.
Do you know how a for loop synthesizes in hardware? - Altera_Forum
Honored Contributor
Maybe you could use a for loop
- Altera_Forum
Honored Contributor
Crap, I don't know what I was thinking. I know you can't copy a 2D array like this!
So, is there a faster way than setting up a loop for 32 clock ticks and copying it one byte at a time?