Simulating ALTERA NIOS II Embedded Processor Designs in Active-HDL

This application note describes how to simulate ALTERA NIOS II Embedded Processor Designs in Active-HDL. This is based on the “Board Diagnostics” sample design taken from Eclipse IDE for C/C++ Developers software, but basic flow should remain the same for other designs as well.

Tool Requirements

This application note assumes that users have installed the following software and have prior experience using them. Altera Quartus II 10.1 or later

  1. Altera Quartus II 10.1 or later

  2. NIOS II EDS 9.0 or later

  3. Active-HDL 8.3 or later

Setting up the design

  1. Create an empty folder “TEMP” in the “C:\” root directory, go to “computer >properties> advanced system settings”, and click on the Environment Variables button and set the System variables TEMP and TMP to the empty folder as shown.

    Figure 1: Environment setup

  2. Click on the path System variable as shown below, check it for double semi-colons “;;” and replace all “;;” with a single semi-colon“;” in the path statement. Reboot or restart the computer.

    Figure 2: Path Integrity Check

  3. Open Quartus II software

  4. From the File menu, select Open project

  5. Select the appropriate “.qpf” file from the project directory and click Open, a design sample is shown below.

    Figure 3: Quartus II Configuration Controller Project

    SOPC Builder simulation settings

  6. After the project is loaded in to Quartus II Software, go to menu Tools and click on SOPC Builder and check all connections in the chosen design. See the sample screen below.

    Figure 4: clk_0 clk_reset connection

  7. Check to ensure that no errors exist as the example shown below. Read all Warnings and Information items to determine their overall affect on the chosen design.

    Figure 5: Design Status Window

    Simulation File Generation

  8. Click Next to enable the simulation file generation

  9. On the System Generation tab, turn on the Simulation. Create project simulator files option

    Figure 6: System generation settings

  10. Click Generate. Click Save when prompted to save changes

    Figure 7: Generate simulation files tab

    Figure 8: Generation Complete

    Building software tools and generating memory initialization file

    To create and build the software project in Eclipse perform the following steps:

  11. Open NIOS II Software Build Tools for Eclipse

  12. Go to File>New>>Project>

  13. Select NIOS II Application and BSP from Template and click on Next

    Figure 9: Create new project in NIOS II IDE

  14. In the next window, use the browser to find the SOPC Information File Name and click Open.

    Figure 10: Select SOPC Info File

  15. Select the Board Diagnostics Project template and name the project “BD_big_stack”. Click “Next”. Alert: The HAL BSP does not support a Memory Management Unit (MMU), therefore to use one of the Eclipse NIOS II Software Examples the MMU needs to be eliminated from the design.

    Figure 11: New project settings

  16. Select the Create a new BSP project based ......and match the settings below. Click “Finish”. Wait for the status window to complete.

    Figure 12: BSP Creation

  17. Observe the project creation and status window output shown below.

  18. *** Clean-only build of configuration Nios II for project BD_big_stack ****

    make clean

    [BD_big_stack clean complete]

  19. Select the project and right click>select Properties>>Project References and match the settings shown below. Click OK.

    Figure 13: Project References

  20. Select the “BD_big_stack” project and right click>select Build Project and execute it, observe the output window. Building the software project takes some time. When the compilation is complete, the .dat files in the <project directory> are updated.

    --quartus_project_dir "C:/Users/TerryT/workspace/niosII_stratixII_2s60"

    Info: (BD_big_stack.elf) 89 KBytes program size (code + initialized data).

    Info: 31 KBytes free for stack + heap.

    Info: Creating BD_big_stack.objdump

    nios2-elf-objdump --disassemble --syms --all-header --source BD_big_stack.elf >BD_big_stack.objdump

    [BD_big_stack build complete]

    After creating and building the software project, follow these steps in Active-HDL in order to run the simulation.

    Running simulation in Active-HDL

    Please follow these steps once the simulation files generation in both SOPC and Eclipse are complete.

  21. Start Active-HDL, or if Active-HDL is already opened then close any opened workspace.

  22. Go to menu File>>Import>>Altera>>SOPC Simulation Script

  23. Browse to setup_sim.do file, select it and click on Open [setup_sim.do file can be found inside the project directory. This file is generated by SOPC builder]

    Figure 14: setup_sim.do file

  24. Altera SOPC Simulation Script importing wizard will create the workspace and will create and add the necessary do files to the workspace. Below is the typical output of the console after importing setup_sim.do file. The workspace is shown below as a result of importing the simulation script to Active-HDL.

    # ELBREAD: Elaboration time 2.5 [s].

    # Reading "setup_sim.do" ...

    # Creating "setup_sim_altera.do" ...

    # Creating "comp_altera.do" ...

    # Creating "comp_mem_altera.do" ...

    # Creating "init_sim_altera.do" ...

    # Creating "wave_presets_altera.do" ...

    # Creating "list_presets_altera.do" ...

    # Creating "help_altera.do" ...

    # Creating "aliases_altera.do" ...

    # Creating "jtag_uart_0_log_altera.do" ...

    # Import process successfully finished, etc.

    Figure 15: Workspace after importing the setup_sim.do file

  25. Execute the comp_altera.do file to map and compile the required libraries. To execute the macro file, you can right click on the comp_altera.do file and click on execute.

    # Compile Architecture "europa" of Entity "onchip_memory2_0_s1_arbitrator"

    # Compile Entity "sysid_control_slave_arbitrator"

    # Compile Architecture "europa" of Entity "sysid_control_slave_arbitrator"

    # Compile Entity "timer_0_s1_arbitrator"

    # Compile Architecture "europa" of Entity "timer_0_s1_arbitrator"

    # Compile Entity "VME_HW_SOPC_BUILD_reset_clk_0_domain_synch_module"

    # Compile Architecture "europa" of Entity "VME_HW_SOPC_BUILD_reset_clk_0_domain_synch_module"

    # Compile Entity "VME_HW_SOPC_BUILD_reset_altpll_0_c0_out_domain_synch_module"

    # Compile Architecture "europa" of Entity "VME_HW_SOPC_BUILD_reset_altpll_0_c0_out_domain_synch_module"

    # Compile Entity "VME_HW_SOPC_BUILD"

    # Compile Architecture "europa" of Entity "VME_HW_SOPC_BUILD"

    # Compile Entity "test_bench"

    # Compile Architecture "europa" of Entity "test_bench"

    # Compile success 0 Errors 0 Warnings Analysis time : 0.8 [s]

  26. Execute the init_sim_altera.do file to initialize the simulation. Following messages will be printed on the console.

    # ELAB2: Elaboration final pass...

    # ELAB2: Create instances ...

    # ELAB2: Create instances complete.

    # SLP: Started

    # SLP: Elaboration phase ...

    # SLP: Elaboration phase ... skipped, nothing to simulate in SLP mode : 0.0 [s]

    # SLP: Finished : 0.0 [s]

    # ELAB2: Elaboration final pass complete - time: 1.2 [s].

    # KERNEL: Kernel process initialization done.

    # Allocation: Simulator allocated 25170 kB (elbread=6156 elab2=16989 kernel=2025 sdf=0)

    # KERNEL: ASDB file was created in location C:\Users\TerryT\workspace\niosII_stratixII_2s60\VME_HW_SOPC_BUILD_sim\src\wave.asdb

    # 11:36 AM, Wednesday, February 02, 2011

    # Simulation has been initialized

    # Selected Top-Level: test_bench (europa)

  27. Execute the wave_presets_altera.do file to add the signals to the waveform. You can execute the macro to add the signals or you can print w in the console and hit enter.

  28. Now run the simulation from the simulation menu or type run 1000 us in the console and hit enter. Console should display the following messages.

    # # Displays virtual signals

    # 6 signal(s) traced.

    run 1000 us

    # EXECUTION:: NOTE : Stratix II GX PLL is enabled

    # EXECUTION:: Time: 0 ps, Iteration: 2, Instance: /DUT/the_altpll_0/altpll_0_altpll_sd1_183/STRATIXII_ALTPLL/M1, Process: SCHEDULE.

    # EXECUTION:: NOTE : Stratix II GX PLL locked to incoming clock

    # EXECUTION:: Time: 110 ns, Iteration: 4, Instance: /DUT/the_altpll_0/altpll_0_altpll_sd1_183/STRATIXII_ALTPLL/M1, Process: SCHEDULE.

    # KERNEL: stopped at time: 1 ms

  29. The image below shows an example of a successful simulation run for 1msec.

    Figure 16: AHDL Simulation Run

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.