Simulating Nios® II Designs in Riviera-PRO

Introduction

This application note describes the steps to produce an RTL simulation environment with the NIOS® II example design (Hello World), Qsys, and the NIOS II software build tools for Eclipse. This document also provides step by step instructions on RTL simulation in Riviera-PRO.

Requirements

This application note assumes following:

  1. You have the following software installed and licensed:

    • Altera Quartus® II version 13.0.0 or later and all devices from Altera

    • Riviera-PRO 2013.06 or later

  2. You have experience using Qsys and have familiarity with the Riviera-PRO simulator.

  3. You have downloaded the example design used in this application note (an351_design.zip). You can download this example design from http://www.altera.com/support/examples/nios2/exm-simulating-niosii.html

  4. You have extracted the example design.

    NOTE: The location where you extract the file will be referred to as <project_directory>

Setting and Generating the simulation environment in Qsys

  1. Start the Quartus II Software. Click File | Open Project.

  2. Browse to <project_directory>/an351_design, select an351_project.qpf and click Open.

    Figure 1: Opening example design

  3. Now open Qsys by clicking Tools | Qsys. Once Qsys is opened it will ask you to open the system file.

  4. Select the niosii_system.qsys file and click Open. This file is located in the <project_direcoty>/an351_design directory.

    Figure 2: Opening Qsys system file

  5. Click on the Generation tab. Set the following parameters to these values:

    • Create simulation model – None

    • Create testbench Qsys system – Simple, BFMs for clocks and resets

      NOTE: If you system has exported ports other than clock and reset, choose Standard, BFMs for standard Avalon interfaces

    • Create testbench simulation model – Verilog

    • Create HDL design files for synthesis – none

    • Create block symbol file (.bsf) – Uncheck

  6. Click Generate. Save the system by clicking File | Save once Generation is done.

    NOTE: The example design is a complete Qsys system. Make sure that your Qsys system is completed before generating simulation models.

    Generated files include:

    • rivierapro_setup.tcl (<project_directory>/an351_design/niosii_system/testbench/aldec)

    • Qsys system testbench file and Memory initialization files (.mif) (<project_directory>/an351_design/niosii_system/testbench/niossii_system_tb/simulation)

    Creating Nios II software

  7. Open Nios II Software Build Tools for Eclipse version Indigo Service Release 2 (13.0 or later)

  8. Click File | New and select Nios II Application and BSP from Template.

    Figure 3: Creating new application

  9. Select the SOPC Information (.sopcinfo) file name by browsing to <project_directory>/an351_design, and then select niosii_system.sopcinfo.

  10. Specify hello_world_an351 as the project name.

  11. Select Hello World from the Templates option and click Finish.

    Figure 4: Selecting template

  12. Right-click on hello_world_an351 in the Project Explorer and select Build Project. This step builds the hello_world project and creates all necessary files for simulation.

    Figure 5: Building Project

    Running Simulation in Riviera-PRO

  13. Once the build project is done, right-click on hello_world_an351 in the Project Explorer and select Run As | Run Configurations….

    Figure 6: Setting Configuration

  14. In the Run Configuration window, right-click on Nios II ModelSim and select New. This will create a New_configuration sub-tab under Nios II Modelsim.

    NOTE: Steps 14 and 15 are required if you are using Nios II SBT for the first time and have never setup a configuration for Riviera-PRO before. Once the configuration is setup for Riviera-PRO, you can run simulation by directly selecting Nios II Mosdelsim from Run As.

    Figure 7: Creating new configuration

  15. In New_configuration, provide the Riviera-PRO executable path. Select Apply and Run.

    Figure 8: Setting Configuration

  16. The above action will invoke Riviera-PRO and start executing the script. This will result in errors in Riviera-PRO. By default, Nios II SBT starts Riviera-PRO in the wrong directory. The correct directory should be …sim/aldec. It generates simulation scripts for Aldec. Click on the Change Directory button from the Filesystem tab of Riviera-PRO.

    NOTE: Because of wrong directory it automatically starts executing script which was created for mentor, this results in error.

    Figure 9: Changing directory

  17. Select the aldec folder as the current directory from the Select a Directory window.

    Figure 10: Selecting aldec as current directory

  18. This will set aldec as a current directory. Open the rivierapro_setup.tcl script file and execute it. This will set all necessary variables and will copy all memory files to current directory.

    NOTE: Click the Execute button from script editor tool bar.

    Figure 11: Executing tcl script

  19. Script execution will set aliases which can be run as a command in the Riviera-Pro console for creating libraries (both device and work), compiling libraries, compiling the hello world example source files (Qsys tb system), and initializing simulation (elaboration).

    Figure 12: Setting variables and aliases through script

  20. Now let’s start simulation process by compiling device library files. Type dev_com in the Riviera-PRO Console and hit Enter.

    NOTE: If the small circle is spinning in top right corner of riviera-PRO that means Riviera-PRO is executing some process.

    Figure 13: Compiling Device Libraries

  21. Once device libraries compilation is done, type com in the Riviera-PRO Console and hit Enter. This will compile all of your Qsys system tb in different work libraries.

    NOTE: You can observe components compiled into libraries by expanding the respective library from the Library Manager in Riviera-PRO.

    Figure 14: Compiling Qsys tb system

  22. Once compilation of tb system is done, you can start the elaboration of the system using the top level module. This can be done using elab alias command. Type elab in the Riviera-PRO Console and hit Enter.

    igure 15: Elaborating Design

  23. Once elaboration is done you will see message: ASDB was creates in location…. This means you can now run simulation.

    Figure 16: Message showing Elaboration complete

  24. To run the simulation, type run 2ms in the Riviera-PRO Console. This will print the “Hello from Nios II!” message in the Riviera-PRO Console.

    Figure 17: Hello from Nios II

Conclusion

Altera Nios II Embedded Processor Designs can be simulated in Riviera-PRO. Please refer to http://www.altera.com/literature/an/an351.pdf for more detailed information about the hello world example and memory initialization files. Please contact Aldec support if you have any questions or difficulty following this application note.

You can observe waveforms in the above simulation. Please refer to http://www.aldec.com/en/support/resources for more detailed information on the Riviera-PRO waveform and other debugging tools.

Ask Us a Question
x
Ask Us a Question
x
Captcha ImageReload Captcha
Incorrect data entered.
Thank you! Your question has been submitted. Please allow 1-3 business days for someone to respond to your question.
Internal error occurred. Your question was not submitted. Please contact us using Feedback form.
We use cookies to ensure we give you the best user experience and to provide you with content we believe will be of relevance to you. If you continue to use our site, you consent to our use of cookies. A detailed overview on the use of cookies and other website information is located in our Privacy Policy.