AN 977: Nios® V Processor Custom Instruction

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

1.1. Implementing Custom Instruction

Nios® V processor custom instructions are custom logic blocks adjacent to the arithmetic logic unit (ALU) in the processor’s datapath.

Nios® V processor custom instructions are based on the RISC-V R-type instruction format, and provides support for four unique opcodes. Leveraging the funct7[6:4] in the custom instruction, each opcode is further associated with eight custom logic blocks. In total, you can have up to 32 custom logic blocks connected to a single Nios® V processor. Logic block connections on the Nios® V processor are exposed as Nios V Custom Instruction Manager interfaces, and are defined using the Custom Instructions Hardware Interfaces Table in the Nios® V processor IP parameterization.

Figure 2. Custom Logic Blocks
The following steps show how you can implement and use custom instructions with the Nios® V processor:
  1. When you implement the custom instructions in the Nios® V processor system, each custom operation must associate with its unique selector index (opcode and funct7[6:4]).
  2. The selector index allows the software to specify the desired operation from among up to 32 custom logic blocks.
  3. In the Platform Designer, you can define one or more selector index using the Custom Instructions Hardware Interfaces Table. Each defined selector index would be presented as a Nios V Custom Instruction Manager interface on the Nios® V processor.
  4. You can define custom instruction software C macros for software deployment in system.h using the Custom Instructions Hardware Interfaces Table in the Nios V IP parameterization. An accompanying GDB debug memonics file for the defined software C macros is generated by Platform Designer for use by the Ashling* RiscFree* IDE for Intel® FPGAs.
Note: You can have up to 128 custom instructions in a single custom logic block using the extended custom instructions. For example, if you instantiate all 32 logic blocks, you can have a maximum of 4096 custom instructions connected to a single Nios® V processor.