Using a Custom Bitfile in C Code: Difference between revisions

From Cpre584
Jump to navigation Jump to search
No edit summary
Line 26: Line 26:
=== Making a Coprocessor Call ===
=== Making a Coprocessor Call ===
The vector adder example uses:
The vector adder example uses:
  act_sum = l_copcall_fmt(sig, cpVadd, "AAAA", a1, a2, a3, size);
  act_sum = l_copcall_fmt(sig1, 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.
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.

Revision as of 21:02, 15 February 2012

In the simplest form, 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 (bitfile) you created
  • A coprocessor funcation call (ex: l_copcall_fmt, d_copcall_fmt, etc)

If you want to pass parameters to your function call, you use an assembly file to marshal registers back and forth between the processor's registers (starting at A8) and the coprocessor's AEG registers. If you must pass a lot of data, it's better to pass a pointer to the data and allocate memory on the coprocessor board.

Getting the Signature

The standard way to get a signature is using:

 char * personality_name = "yourpersonalityname";
 cny_image_t sig1, sig2;
 int stat;
 if (cny_get_signature)
   cny_get_signature(personality, &sig1, &sig2, &stat);
 else 
   fprintf(stderr, "ERROR:  cny_get_signature not found\n");
  • stat returns 0 on success
  • sig1 is required, and contains a 64 bit signature for your custom bitfile/personality/AE.
  • sig2 is not used, but may have use in the future.

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 are used to allocate memory on the coprocessor.

See: Convey Programmers Guide (.pdf) - Chapter 9

Making a Coprocessor Call

The vector adder example uses:

act_sum = l_copcall_fmt(sig1, 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.

References