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: 
Adventurer
Adventurer
497 Views
Registered: ‎03-13-2015

LUT logic optimization

I have this array that I use to look up data from (at II=1), and even if there is a straight simple logic, for example table(x)=bit_7_of_x between the input and output, the compiler seems to carelessly add LUTs.

 

Is there a way to make the compiler do some effort on cutting down excess LUT usage?

 

Here is an example demonstrating how ignorant the compiler is. It's a 256 byte lut that has the potential to compile down to 0 LUTs, but ends up with 1362. (The lut's complexity has been cut down to demonstrate the effect.)

#include "ap_int.h"

class luttable
{
private:
	ap_uint<8> tabledata[256];
public:
	luttable(void)
	{
		for(int i=0;i<256;i++) tabledata[i]=i;
	}
	ap_uint<8> getLUT(ap_uint<8> idx)
	{
#pragma HLS ARRAY_PARTITION variable=tabledata complete dim=0
		return tabledata[idx];
	}
};

ap_uint<8> test(ap_uint<8> lutidx)
{
#pragma HLS INTERFACE ap_none port=lutidx
#pragma HLS INTERFACE ap_ctrl_none port=return
	luttable lutinst;
	return lutinst.getLUT(lutidx);
}
0 Kudos
2 Replies
Moderator
Moderator
448 Views
Registered: ‎10-04-2011

Re: LUT logic optimization

Hello @cyviz,

 

I think what is happening here is that you are partitioning the array completely. That will create registers for each of the memory locations instead of the BlockRam they would have originally been stored in. Now, in order to return a value at an index into that original array, you need to mux the output of all those registers to select the output of the correct one. That will require quite a few LUTs for the muxing functions. I am not sure in this use example that partitioning the array affords you any benefit. 

OK, I hope this helps,
Scott

0 Kudos
Adventurer
Adventurer
423 Views
Registered: ‎03-13-2015

Re: LUT logic optimization

Scott,

This is not the issue because there is no FF's, BRAM (or DSP's) in the final result, only LUT's.

 

0 Kudos