AN 977: Nios® V Processor Custom Instruction

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

3.3. Custom Instruction Word Format

The Nios® V processor custom instructions are based on the R-type instruction format. The instruction word specifies the selector index, extension index, immediate, ALU switch and register usage. The ctrl port delivers the 32-bit custom instruction word to the custom logic blocks.

Besides the opcode (hardcoded in Platform Designer), rs2, rs1, and rd fields (allocated during software compilation), you can assign funct7 and funct3 fields to serve different purposes. You can either hardcode the funct7 and funct3 fields in Platform Designer or translate the fields as input arguments in the software C-macro.

Table 6.  32-bit Custom Instruction Word Format
32-bit Custom Instruction Bit Field
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
funct7[6:0] rs2 rs1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rs1 funct3[2:0] rd opcode

Each of the bit field serves the following purposes:

Table 7.  Bits Description
Bits Function
funct7[6:4]
  • Optional selector index
  • User-defined immediate
funct7[3:0]
  • Extension index
  • User-defined immediate
rs2 Source register of data1
rs1 Source register of data0
funct3[2:0]
  • Extension index
  • ALU switch
  • User-defined immediate
rd Destination register for result
opcode Required selector index