- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the FPGA resource allocation will be different if the variable declaration in different place?
//declare the variable i, j, k not in the loop int i; int j; int k; for (...) { for (...) { //declare the variable i, j, k in loop int i; int j; int k; } } ThanksLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It certainly does, please read "Intel FPGA SDK for OpenCL Best Practices Guide, Section 1.6.3, Declare Variables in the Deepest Scope Possible".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Variables declared outside the loops become Global and are visible to the entire code/project. This will mean the memory allocated for the variable will not be released once it is not used. Global variables will tend to keep their memory allocations as long as the project / program is active in memory this taking up a lot of memory space. This is bad design for Embedded designs as Embedded systems have limited RAM.
Its always best to declare variables locally where they tend to be used and then free them once they are out of scope. Only use global variables if needed. This way your code will take up the least memory footprint and can fit into the program memory or the on-chip ROM/flash.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page