niosii instruction set simulator
TRANSCRIPT
-
8/6/2019 NiosII Instruction Set Simulator
1/8
NiosII Instruction Set Simulator
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.
Creating a Blank Project
One way of working, without generating multiple projects, is to create a blank project andchange 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 yournios2lab1 hardware PTF file andBlank Projectas the project template. Then pressNext.
-
8/6/2019 NiosII Instruction Set Simulator
2/8
On the second page of the wizard, shown below, select the second radio button and then yourexisting hello_world_smallsystem library. Then press Finish.
-
8/6/2019 NiosII Instruction Set Simulator
3/8
Once your project folders have been created, you can download your source file, e.g. cprog1.c,into the project folder.
Running a Simulation
Right click on the project name and select Debug As -- Nios II Instruction Set Simulator orhighlight 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:
-
8/6/2019 NiosII Instruction Set Simulator
4/8
Let the system change perspective. You can select Window -- Change Perspective -- Nios IIC/C++ to change the perspective back again.
Debug Operations
The debug perspective, shown below, collects a number of views applicable to debugging
operations.
-
8/6/2019 NiosII Instruction Set Simulator
5/8
One exploration of these windows, from the screen image above, is shown in the followingsequence.
The Debug window shows that the active thread is suspended at line 9 ofcprog1.c, address0x8094.
-
8/6/2019 NiosII Instruction Set Simulator
6/8
The source browser forcprog1.c highlights line 9
The disassembly screen shows that we have stopped at address 0x8094.
The Variables view shows we have already set values forna and nb, and that we changed the
format ofnb from decimal to hexadecimal.
-
8/6/2019 NiosII Instruction Set Simulator
7/8
The variables in main are defined on thestack, indexed through theframe pointer(fp). They arelisted in the Variables according to their position on the stack:
Address Name
0(fp) na
4(fp) nb
8(fp) nc
12(fp) nd
16(fp) ne
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.
Stepping through the code
The toolbar collection shown below is used to step through a program:
The active buttons are
Step Into
Step Over
Step Return
Instruction Stepping Mode
-
8/6/2019 NiosII Instruction Set Simulator
8/8
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.