Custom Instruction
The Custom Instruction interface allows you to write your own ALU-type
operation to be performed in hardware. You simply write the Verilog code for
any 2-operand operation and can then use it in your assembly program using the
instruction "custom 0,rZ,rX,rY".
Notes
To add your own custom instruction do the following:
- Download the Hardware Development Kit for your DE2/DE1 board.
- Open the Quartus Project File (.qpf) found inside it.
- Implement your operation in the studentcustom0.v file in Verilog.
- Compile the design (Ctrl-L) to generate a new .sof file for programming the FPGA.
- Program the .sof onto the board using the Quartus II programmer, or the following command in the Nios II Shell: nios2-configure-sof --cable USB-Blaster[USB-0] nameofyour.sof
- In your assembly program use the instruction "custom 0,rZ,rX,rY" to perform the custom instruction, where rZ is the destination register, and rX and rY are your dataa and datab inputs respectively.
Example: To perform (x>>7)+(y>>13)
In Verilog (studentcustom0.v):
assign result = dataa[31:7] + datab[31:13];
In Assembly:
custom 0,r4,r3,r2