Forum Discussion
Altera_Forum
Honored Contributor
19 years ago1) Yes just leave it disconnected, C2H will connect it automatically assuming you have the pragma statement setup properly (see# 2).
2) # pragma altera_accelerate connect_variable <function_name>/<variable_name> to <memory_name>/<port name> ex. # pragma altera_accelerate connect_variable foo/a_ptr to tcm/s2 void foo(int * a_ptr) { int i; *a_ptr = 0; for(i = 0; i < 1024; i++) { *a_prt += i; // dereference pointer "a_prt" and accumulate "i" into it (doesn't make sense to access main memory to accumulate variable i) } return *a_prt; } Not that this does anything useful but this example tells the C2H compiler that "a_ptr" points to data located in a memory called "tcm" and connect to the memory port named "s2" (port of tcm). By default without this pragma, C2H connects to all slave ports (ports not just memories) that the Nios II data master connects to. This pragma is important for controlling the number of slave ports C2H will connect variables to. You can reuse the pragma statement on the same variable but different memory ports as well. So if you want to connect a variable in a C2H accelerator to 2 out of 10 memory ports in your system, this pragma gives you this control (use it twice). With that said, if you use this pragma statement be sure that the data being accessed indeed resides in memory you use in the connection pragma. As a rule of thumb I recommend leaving the pragma statements out of your code while prototyping your algorithm (reduce your clock frequency), then add in the pragma statements to optimize your master:slave connections when you are finalizing the design (then increase your clock frequency). These documents will go into more details (read them in this order to get the most out of them): http://www.altera.com/literature/ug/ug_nio...2h_compiler.pdf (http://www.altera.com/literature/ug/ug_nios2_c2h_compiler.pdf) (user guide) http://www.altera.com/literature/an/an420.pdf (http://www.altera.com/literature/an/an420.pdf) (optimization guide) http://www.altera.com/literature/an/an417.pdf (http://www.altera.com/literature/an/an417.pdf) (SG-DMA example) http://www.altera.com/literature/tt/tt_nio...ng_tutorial.pdf (http://www.altera.com/literature/tt/tt_nios2_c2h_accelerating_tutorial.pdf) (FFT example) These are located here: http://www.altera.com/literature/lit-nio2.jsp (http://www.altera.com/literature/lit-nio2.jsp) There are also two other examples currently (image rotate, and FIR) located here: http://www.altera.com/support/examples/nios2/exm-nios2.html (http://www.altera.com/support/examples/nios2/exm-nios2.html) I hope that helps.