Embedded Design Handbook

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

7.2.2.2.1. Increasing Processor Efficiency

An easy way to increase the software application's performance is to increase the rate at which the Nios® II processor fetches and processes instructions, while decreasing the number of instructions the application requires. The following techniques can increase processor efficiency in running your application:

  • Processor clock frequency—Modify the processor clock frequency using Platform Designer. The faster the execution speed of the processor, the more quickly it is able to process instructions.
  • Nios® II processor improvements—Select the most efficient version of the Nios® II processor and parameterize it properly. The following processor settings can be modified using Platform Designer:
    • Processor type—Select the fastest Nios® II processor core possible. In order of performance, from fastest to slowest, the processors are the Nios® II/f and Nios® II/e cores.
    • Instruction and data cache—Include an instruction or data cache, especially if the memory you select for code execution—where the application image and the data are stored—has high access time or latency.
    • Multipliers—Use hardware multipliers to increase the efficiency of relevant mathematical operations.

      For more information about the processor configuration options, refer to the Instantiating the Nios® II Processor chapter of the Nios® II Gen2 Processor Reference Handbook.

  • Nios® II instruction and data memory speed—Select memory with low access time and latency for the main program execution. The memory you select for main program execution impacts overall performance, especially if the Nios® II caches are not enabled. The Nios® II processor stalls while it fetches program instructions and data.
  • Tightly coupled memories—Select a tightly coupled memory for the main program execution. A tightly coupled memory is a fast general purpose memory that is connected directly to the Nios® II processor's instruction or data paths, or both, and bypasses any caches. Access to tightly coupled memory has the same speed as access to cache memory. A tightly coupled memory must guarantee a single-cycle access time. Therefore, it is usually implemented in an FPGA memory block.

    For more information about tightly coupled memories, refer to the Using Tightly Coupled Memory with the Nios® II Processor Tutorial and to the Cache and Tightly-Coupled Memory chapter of the Nios II Gen2 Software Developer's Handbook.

  • Compiler Settings—More efficient code execution can be attained with the use of compiler optimizations. Increase the compiler optimization setting to -03, the fastest compiler optimization setting, to attain more efficient code execution. You set the C-compiler optimization settings for the BSP project independently of the optimization settings for the application. For information about configuring the compiler optimization level for the BSP project, refer to the hal.make.bsp_cflags_optimization BSP setting in the Nios® II Software Build Tools Reference chapter of the Nios® II Gen2 Software Developer’s Handbook.