Tutorial: Creating a Custom Bitfile
This page covers the creation and installation of a custom personality/bitfile (a modification of the vector adder sample project).
Building a Bitfile
Copy rev 2011_11_22 of the example project and set your environment variables if you have not done so already. You can make a small modification to the verilog code if you wish.
cd ~/pdk_sample/cae_vadd/phys make
The bitfile will take a long time to create (while the Reference Manual states 2 to 4 hours; mine took 18 hours to finish). Be patient.
Packaging the Bitfile
cd ~/pdk_sample/cae_vadd/phys make release
This will create a new directory (~/pdk_sample/cae_vadd.release/). The important file that is created is named cae_fpga.tgz.
Installing the Bitfile
Follow the instructions from section 9.4.7 to install the packaged bitfile.
- Rename ~/pdk_sample/cae_vadd.released/#DATE#/cae_fpga.tgz to ae_fpga.tgz
- Determine what your bitfile's signature should be
- Copy the ae_fpga.tgz file to /opt/convey/personalities/#signature#
Any ideas? We need higher privilledges add files to the /opt/convey/personalities/ folder.
Finally, flush the MP cache:
/opt/convey/sbin/mpcache –f
Using the Bitfile in C Code
My current understanding is that running a routine on the coprocessor requires two parts:
- A call to the cny_get_signature function to get the signature of the custom personality you created
- A cny coprocessor funcation call (ex: l_copcall_fmt, d_copcall_fmt, etc)
If you want to pass parameters to your function call, the vector adder set the standard of using an assembly file to marshal registers back and forth between the processor / coprocessor, though there may be other ways.
Getting the Signature
cny_image_t sig2; cny_image_t sig; int stat; if (cny_get_signature) cny_get_signature("your custom personality name", &sig, &sig2, &stat); else fprintf(stderr,"ERROR: cny_get_signature not found\n");
Allocated Memory on the Coprocessor Board
System memory and memory used for the coprocessor are physically separate. In the example C file, function calls such as cny_cp_malloc and ny_cp_posix_memalign.
See: Convey Programmers Guide (.pdf) - Chapter 9
Making a Coprocessor Call
The vector adder example uses:
act_sum = l_copcall_fmt(sig, cpVadd, "AAAA", a1, a2, a3, size);
In this case, the l at the beginning of l_copcall_fmt means the return type is a long (64 bits). The first two arguments are always (1) the bitfile signature and (2) a assembly function name. The third argument lists the type and number of optional arguments that are passed (starting at register A8). For example, "AAAA" means there are 4 long variables passed to the coprocessor call.
See: Convey Programmers Guide (.pdf) - Appendix G
References
- Convey PDK Reference Manual (.pdf) - Sections 9.4.6, 9.4.7, 10 and Appendix D
- Convey Programmers Guide (.pdf) - Chapter 9 and Appendix G