Forum Discussion
Altera_Forum
Honored Contributor
13 years agoThe definition of __builtin_custom_ini() is in the gcc sources, there isn't anything 'special' about it you could write it yourself. It expends to a single nios instruction.
I've a very similar one:__attribute__((always_inline))
static __inline__ unsigned int
custom_inic(const unsigned int op, unsigned int a, const unsigned int b)
{
uint32_t result;
__asm__ ( "custom\t%1, %0, %2, c%3"
: "=r" (result) : "n" (op), "r" (a), "n" (b));
return result;
} for custom instructions where I use the 'regb' field as a sub-opcode (In particular for supporting all the byte and bit swaps in a single instruction). The custom instruction number is allocated by sopc builder/qsys when you add the instruction, unfortunately you don't seem to be able to choose your own number [1]. The instruction number is then written to one of the generated .h files. [1] This is a problem if you are trying to define multiple nios cpu with different (overlapping) sets of custom instructions. Or want to be able to compile code without the sopc/qsys generated header file.