1.3 Simulator Operation and Displays

Stimulus is used for controlling the stimulation of hardware signals to the application under test. A stimulus component (window) is provided for defining and generating synchronous stimulus code, which can then be attached to the simulation session. The stimulus component (window) also supports generation of asynchronous stimulus, which may be used independently of, or in conjunction with, the synchronous stimulus.

The Oscillator setting can be changed to allow accurate timing of instructions through the Stopwatch display. It also allows computational delays required within peripherals during simulation.

The MIPS rating (Instructions Count and Execution Cycles) of the last executed code segment (not stepped code) can be displayed in the Output window. This gives the execution speed of code, based on the PC it is executed on. This may differ from the execution speed on target (target speed is dependent on Oscillator Frequency). MIPS rating for the same code may be different on different PCs.

When trace is enabled, there may be a reduction of speed with the simulator performance. Trace records all instructions as they occur with source and destination data and address. It also captures all I/O port values on each instruction for displaying under the logic analyzer.

There is printf() support in the output window for MPLAB XC C compilers. This uses file names placed in the text fields on UART1, taking priority over any stimulus, register injection or register trace files attached to UART1.

dsPIC DSCs, PIC24 MCUs

The simulator engine of 16-bit families (SIM30) supports Code Guard for flow control, data memory access, EEPROM access, Flash program/erase and security configuration bit erase.

The Program Memory window has two additional formats for supporting dsPIC devices: “PSV Data” and “PSV Mixed.” When PSV Data memory is enabled on the device, the PSV window will show 16-bit data and labels at the addresses mapped. The PSV Mixed display shows memory in both 24-bit and 16-bit, and tags data with labels and disassembles instructions. This memory can be viewed as both program memory and PSV data memory in the case where code and data share this area.

The File Registers Memory window has additional features for supporting dsPIC devices. The window format may be selected as “X/Y Memory” to allow the inspection and/or modification of this memory space. In addition a “Dual Port” format is available for dsPIC33F/PIC24H devices to show DMA accessible memory more easily. This is the RAM used by the DMA peripheral.

The simulator has no separate hardware stack. The stack is mapped into the 16-bit data memory space and can be viewed by setting a watch or opening the File Registers Memory window at the appropriate location.

Note: MPLAB X IDE has a software (call) stack window.

PIC32 MCUs

The simulator engine of 32-bit families (SIM32) supports Execution/Flash memory program/erase, data memory access, peripheral/SFR register access, CPU memory access and security configuration bit erase.

Code and data memory windows support breakpoints, stepping, trace and other execution features. You can navigate to different memory regions using the Go To option (select right click, “Go to”). Right click menu items also let you switch views between Machine code and Symbolic code.

The simulator has no separate hardware stack. The stack is mapped into the 32-bit data memory space and can be viewed by setting a watch or opening the Data Memory window at the appropriate location.

Note: MPLAB X IDE has a software (call) stack window.

When using printf in an XC32 project with the simulator as the debug tool, __XC_UART must be set prior to calling printf. Assign the number of the UART to this global variable. For example, to send printf output to UART1, set __XC_UART=1. To send printf output to UART2, set __XC_UART=2.