8

i need to declared the values that the counter is to take in a 2D array. Also, how do i select elements from the array and use them (say assign them to another variable) how do i declare the elements of this 2D array ?

type lutable is array (0 to 4, 0 to 63) of integer range 0 to 4000; 

1 Answer 1

13

in a 2D array e.g.:

type lutable is array (0 to 4, 0 to 2) of integer range 0 to 4000; signal sample_array: lutable; 

you can assign elements to another signal as follows:

out_signal<=sample_array(in_a, in_b); 

the contents of the array can be declared e.g. as defaults (caution, this is not supported by all synthesis-tools!):

signal sample_array: lutable:=( (1000, 2000, 3000), (4000, 3000, 2000), (100, 200, 300), (1,2,3), (5,6,7)); 

or over a constant-array, e.g.:

signal sample_array: lutable; constant sample_array_init: lutable:=( (1000, 2000, 3000), (4000, 3000, 2000), (100, 200, 300), (1,2,3), (5,6,7)); ... sample_array<=sample_array_init; ... 

or, of course, element by element:

 sample_array(1,1)<=1000; ... 
Sign up to request clarification or add additional context in comments.

2 Comments

thanks so much. Just one more thing. Can I access these elements say row-wise or column-wise?
@user2481101: No you can't, they can only be accessed individually based on the two value index.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.