We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for
Did you mean:
Highlighted
Visitor
767 Views
Registered: ‎05-16-2018

## Indexing in arrays

I have two 2x2 arrays that stores a byte of information. I want to use the values of one array to reference a location in another array by using 4 bits as rows identifier and another 4 bits as column identifier. How can I implement that?

1 Solution

Accepted Solutions
Scholar
708 Views
Registered: ‎08-01-2012

## Re: Indexing in arrays

You need to covert the slices of round to an integer. But you cannot use the 4 msbs as you will get an out of range error as 4 bits gives values 0 to 15. The array index is 0 to 1.

To convert to integer
To_integer( unsigned ( round(0,0)(0 downto 0)));
3 Replies
Scholar
719 Views
Registered: ‎08-01-2012

## Re: Indexing in arrays

If it's 2x2, then you only need 2 bits, one for row and one for column.

Why not post some example code and explain exactly what problems you're having?
Visitor
692 Views
Registered: ‎05-16-2018

## Re: Indexing in arrays

Here are 3 2D arrays; round, round1 and temp. What I want do do is copy the data of round 1 to temp by using the most significant 4 bits of round as row identifier and least significant 4 bits as column identifier.

type matrix is array (0 to 1, 0 to 1) of std_logic_vector(7 downto 0);

signal round: matrix := ((x"00", x"01"), (x"10", x"11") );

signal round1, temp : matrix := ((x"ac", x"19"), (x"77", x"fa") );

begin

temp(0,0) <= round1(MSB 4 bits of round(0,0), LSB 4 bits of round(0,0)); ----- This is wrong. Just to show what I want to do.

Thanks for any help.

Scholar
709 Views
Registered: ‎08-01-2012