AN 977: Nios® V Processor Custom Instruction

ID 773194
Date 4/14/2023
Public
Document Table of Contents

3.3.3. User-defined Immediate

You can apply the funct7 or funct3 field as a user-defined immediate by assigning “x” in the Software C-Macro, in the Platform Designer. Assigning the logic translates the fields into input arguments in the Software C-Macro.

Note: Platform Designer translates the bit field to the user-defined immediate when assigning the logic "x" in Software C-Macro only.

Software C Macros with funct3 and funct7 fields assigned with "x"

#define CUSTOM_OPERATION(VAL_1, VAL_2, F3, F7) ({ \
 int output; \
 asm volatile (".insn r 0x2B, %[FUNCT3], (0x0 | (%[FUNCT7]<<0)), %[out], %[input1], %[input2]" \
    : [out] "=r" (output) \
    : [input1] "r" (VAL_1), [input2] "r" (VAL_2), [FUNCT3] "i" (F3), [FUNCT7] "i" (F7)); \
    output;  \
})