UPGRADE YOUR BROWSER

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 
Search instead for 
Did you mean: 
Visitor dawnfrank
Visitor
758 Views
Registered: ‎05-16-2018

Indexing in arrays

Jump to solution

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?

0 Kudos
1 Solution

Accepted Solutions
Scholar richardhead
Scholar
699 Views
Registered: ‎08-01-2012

Re: Indexing in arrays

Jump to solution
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)));

View solution in original post

0 Kudos
3 Replies
Scholar richardhead
Scholar
710 Views
Registered: ‎08-01-2012

Re: Indexing in arrays

Jump to solution
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?
0 Kudos
Visitor dawnfrank
Visitor
683 Views
Registered: ‎05-16-2018

Re: Indexing in arrays

Jump to solution

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.

0 Kudos
Scholar richardhead
Scholar
700 Views
Registered: ‎08-01-2012

Re: Indexing in arrays

Jump to solution
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)));

View solution in original post

0 Kudos