Forum Discussion
Altera_Forum
Honored Contributor
16 years agoGet stack top/bottom pointers at run time?
Hi folks- I want to write a stack test function to detemine stack usage during run time testing. For that I need to be able to get stack top and bottom pointers at run time. Can anyone p...
Altera_Forum
Honored Contributor
16 years agoOk, here's the solution from me, the OP.
First some background. The NIOS stack is shared with the heap at all remaining RAM starting at the top of block RAM allocated for NIOS. At least that's true for onchip block memory. If I'm wrong, somebody please correct me. As a donation to karma, my solution is attached, free for anyone to use. Note that you can't use it if the heap is ever used. Call the zero function as early as possible after main starts. If you use the heap, you'll need to change the get function to somehow find the highest address of the heap that is in use. JJS