AN 985: Nios® V Processor Tutorial

ID 784468
Date 7/24/2024
Public
Document Table of Contents

1.3.4. Running System Simulation

The msim_setup.tcl script in the package generated creates alias commands for each step. For the list of commands, refer to the following table:
Macros Description
dev_com Compile device library files.
com Compiles the design files in correct order.
elab Elaborates the top-level design.
elab_debug Elaborates the top-level design with the novopt option.
ld Compiles all the design files and elaborates the top-level design.
ld_debug
Compiles all the design files and elaborates the top-level design with the vopt option.
Note: The vopt option is to run optimization before elaborating the top-level design in the simulator.

You can run the simulation in the Questa simulator by performing the following steps,

  1. Launch the Nios V Command Shell.
  2. Open the Questa for Intel FPGA simulator using the command vsim.
  3. In the Questa Transcript window, change your working directory to the mentor folder.
    cd <Working directory>/niosv_top_tb/niosv_top_tb/sim/mentor
  4. Copy the memory initialization file into the mentor folder.
    file copy -force \
    <Working directory>/software/app/build/Default/hello.hex ./
  5. Run the msim_setup.tcl.
    do msim_setup.tcl
  6. Compiles all the design files and elaborates the top-level design with vopt option.
    ld_debug
  7. Run the simulation for more than 5 milliseconds.
    run 10ms
At the end of the simulation, you can find the following message prints in the Questa Transcript window: Hello world, this is the Nios V/m cpu checking in <loop number>.
Figure 75. Questa Transcript Window Message

You can observe the simulation results from the waveform viewer:

  1. In Questa for Intel FPGA simulator, navigate to the Instance window.
  2. Unroll niosv_top_tb.
  3. Select niosv_top_inst, and the simulator populates a list of signals in the Objects window.
  4. Right-click any of the signals, and click Add Waves to add them into the Wave window.
  5. Restart and run the simulation for more than 5 milliseconds.
    restart
    run 10ms
  6. Wait for the simulator to complete the given time.
Figure 76. Questa Instance and Objects Windows

The following figure shows the simulated wave result.

  • 1st signal: Clock Input
  • 2nd signal: Reset Input
  • Other signals: Any one or more signals within the niosv_top_inst
Figure 77. Waveform Viewer