The Nios II Instruction Set Simulator (ISS) is a program that allows you to simulate the operation of a Nios II processor, except for the operation of hardware peripherals (such as the PIO).
To follow this example, download cprog1.zip for a sample C source file.
One way of working, without generating multiple projects, is to create a blank project and change the source files to generate variations on the basic project. Just move the old source files out to another folder and move the new source files in.
The following steps create a blank project based on a current system library.
Select File -- New -- Nios II C/C++ Application to obtain the project dialog box shown below. Select your nios2lab1 hardware PTF file and Blank Project as the project template. Then press Next.
On the second page of the wizard, shown below, select the second radio button and then your existing hello_world_small system library. Then press Finish.
Once your project folders have been created, you can download your source file, e.g. cprog1.c, into the project folder.
Right click on the project name and select Debug As -- Nios II Instruction Set Simulator or highlight the project name and select Run -- Debug As -- Nios II ISS from the top level menu.
After the debug project make process has completed, you may get the following message:
Let the system change perspective. You can select Window -- Change Perspective -- Nios II C/C++ to change the perspective back again.
The debug perspective, shown below, collects a number of views applicable to debugging operations.
One exploration of these windows, from the screen image above, is shown in the following sequence.
The Debug window shows that the active thread is suspended at line 9 of cprog1.c, address 0x8094.
The source browser for cprog1.c highlights line 9
The disassembly screen shows that we have stopped at address 0x8094.
The Variables view shows we have already set values for na and nb, and that we changed the format of nb from decimal to hexadecimal.
The variables in main are defined on the stack, indexed through the frame pointer (fp). They are listed in the Variables according to their position on the stack:
Load/Store instructions are used to access the stack:
stw r2,0(fp)stores the contents of register r2 to the stack location corresponding to na.
ldw r3,0(fp)loads the contents of the stack location corresponding to na into register r3.
The toolbar collection shown below is used to step through a program:
The active buttons are
|Instruction Stepping Mode|
The actions are defined for functions - step into a function, over a function, or out of a function. Usually, going from instruction to instruction, just use Step Into. For serious stepping, use the F5 key shortcut to single step.
The Instruction Stepping Mode toggles between single C statements at a step and single assembly code instructions at a step.
Maintained by John Loomis, last updated 9 September 2008