4.3.1. Writing the Custom Instruction HDL File
4.3.2. Opening the Component Editor
4.3.3. Specifying the Custom Instruction Component Type
4.3.4. Displaying the Custom Instruction Block Symbol
4.3.5. Adding the Custom Instruction HDL File
4.3.6. Configuring the Custom Instruction Parameter Type
4.3.7. Setting Up the Custom Instruction Interfaces
4.3.8. Saving and Adding the Custom Instruction
4.3.9. Generating and Compiling the Processor System
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.
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:
Bits | Function |
---|---|
funct7[6:4] |
|
funct7[3:0] |
|
rs2 | Source register of data1 |
rs1 | Source register of data0 |
funct3[2:0] |
|
rd | Destination register for result |
opcode | Required selector index |