Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12454 Discussions

best look up table implementation in C

Altera_Forum
Honored Contributor II
1,022 Views

Hello all, 

 

I am doing a project that required to have a look up table for my C programming coding, i read there are several tutorial that i could refer but wish to seek for the best code efficient usage, any tips?  

 

BR, Ray
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
145 Views

Hey, you can implement this with a set of arrays...just make this simple as possible. 

 

check this out  

"http://www.edaboard.com/thread178540.html"
Altera_Forum
Honored Contributor II
145 Views

did you manage to try out? you can either just print out the data for checking or use a debug to view those variable create..

Altera_Forum
Honored Contributor II
145 Views

Yeap, initial testing looks good.... any way to optimize this to use lower memory? I'm using a MAX 10 here,,, limited resources.

Altera_Forum
Honored Contributor II
145 Views

how huge is your looks up table? I believe still able to fit in your MAX10.

Altera_Forum
Honored Contributor II
145 Views

You may check this 

 

Code: 

# define NUMBER_OF_ROWS 5 # define NUMBER_OF_COLS 4 static int myArray = { {5, 10, 15, 20}, {12, 10, 8, 8}, {24, 22, 20, 18}, {34, 32, 30, 29}, {46, 43, 43, 43} }; void main(void) { int i, j; printf("\n The contents of myArray are:\n"); for (i = 0; i < NUMBER_OF_ROWS; i++) { for(j = 0; j < NUMBER_OF_COLS; j++) printf("%5d", myArray); printf("\n"); } }  

But, since your rows and colums are not in sequence, so you may have either full lookup table (10 rows, 20 colums) or you need to divide your X and Y by specific value (rows divide by 2, colums divide by 5) to access the table
Reply