Nios® II Processor Reference Guide

ID 683836
Date 8/28/2023
Public
Document Table of Contents

5.2.2.1. Multiply and Divide Performance

The Nios II/f core provides the following hardware multiplier options:

  • DSP Block—Includes DSP block multipliers available on the target device. This option is available only on Intel FPGAs that have a hardware multiplier that supports 32-bit multiplication.
  • Embedded Multipliers—Includes dedicated embedded multipliers available on the target device. This option is available only on Intel FPGAs that have embedded multipliers.
  • Logic Elements—Includes hardware multipliers built from logic element (LE) resources.
  • None—Does not include multiply hardware. In this case, multiply operations are emulated in software.

The Nios II/f core also provides a hardware divide option that includes LE-based divide circuitry in the ALU.

Including an ALU option improves the performance of one or more arithmetic instructions.

Note: The performance of the embedded multipliers differ, depending on the target FPGA family.
Table 59.  Hardware Multiply and Divide Details for the Nios II/f Core
ALU Option Hardware Details Cycles per Instruction Result Latency Cycles Supported Instructions
No hardware multiply or divide Multiply and divide instructions generate an exception None
Logic elements ALU includes 32 x 4-bit multiplier 11 +2 mul, muli
32-bit multiplier ALU includes 32 x 32-bit multiplier 1 +2 mul, muli, mulxss, mulxsu, mulxuu
16-bit multiplier ALU includes 3 16 x 16-bit multiplier 1 +2 mul, muli
16-bit multiplier ALU includes 4 16 x 16-bit multiplier 2 +2 mul, muli, mulxss, mulxsu, mulxuu
Hardware divide ALU includes SRT Radix-2 divide circuit 35 +2 div, divu

The cycles per instruction value determines the maximum rate at which the ALU can dispatch instructions and produce each result. The latency value determines when the result becomes available. If there is no data dependency between the results and operands for back-to-back instructions, then the latency does not affect throughput. However, if an instruction depends on the result of an earlier instruction, then the processor stalls through any result latency cycles until the result is ready.

In the following code example, a multiply operation (with 1 instruction cycle and 2 result latency cycles) is followed immediately by an add operation that uses the result of the multiply. On the Nios II/f core, the addi instruction, like most ALU instructions, executes in a single cycle. However, in this code example, execution of the addi instruction is delayed by two additional cycles until the multiply operation completes.

mul r1, r2, r3        ; r1 = r2 * r3
addi r1, r1, 100      ; r1 = r1 + 100 (Depends on result of mul)

In contrast, the following code does not stall the processor.

mul r1, r2, r3        ; r1 = r2 * r3
or r5, r5, r6         ; No dependency on previous results
or r7, r7, r8         ; No dependency on previous results
addi r1, r1, 100      ; r1 = r1 + 100 (Depends on result of mul)