Example 6–5 – Altera Nios II C2H Compiler User Manual
Page 124

6–6
9.1
Altera Corporation
Nios II C2H Compiler User Guide
November 2009
Unshare Pointer Pragma
Example 6–5. Automatically Shared Master Port
#pragma altera_accelerate connect_variable ptr_a to onchip_memory_0
#pragma altera_accelerate connect_variable ptr_a to onchip_memory_1
#pragma altera_accelerate connect_variable ptr_b to onchip_memory_0
#pragma altera_accelerate connect_variable ptr_b to onchip_memory_1
if (x)
{
ptr_a = ONCHIP_MEMORY_1_BASE;
ptr_b = ONCHIP_MEMORY_2_BASE;
}
else
{
ptr_a = ONCHIP_MEMORY_2_BASE;
ptr_b = ONCHIP_MEMORY_1_BASE;
}
/* ... perform some dereference operations with ptr_a and ptr_b ... */
To overcome this problem, use the
unshare_pointer
pragma, which
instructs the compiler to always optimize for speed, and never defer
operations for the purposes of resource scheduling. The syntax is as
follows, for a pointer
my_ptr
in function
my_func
:
#pragma altera_accelerate unshare_pointer my_func/my_ptr