THE WATCH WINDOW

Adding Items to the Watch Window

Whereas the variables, memory and register windows belonging to processor models are only displayed when the simulation is paused, the Watch Window provides a means to display values that are updated in real time. Each item can be given a name of your own choosing as it is added, which is a good deal more manageable than hunting for the address again in a memory window; the Add Items (By Address)... dialogue has a Name field for exactly that purpose.

To add an item to the Watch Window:

  1. Press CTRL+F12 to start debugging, or pause the simulation if it is already running.
  2. Display the memory window containing the item to be watched, and the watch window itself, using the numbered options on the Debug menu.

    The Debug menu listing the memory windows and the watch window against their ordinal numbers


    If you are working with the VSM Studio IDE the Watch Window is (by default) a docked tab at the bottom of the IDE. If you are working directly the watch window will launch as a floating window which you can then dock at the bottom of the schematic window if you prefer.

    The memory window behaves the same way, appearing either inside the IDE or over the schematic according to where you are debugging.
  3. Mark a memory location or range of memory locations using the left mouse button. The selected range should appear in inverted colours.

    A range of memory locations selected in a memory window
  4. Drag the selected item(s) from the memory window to the watch window.

    Memory locations dragged from a memory window into the watch window

You can also add items to the Watch Window by using the Add Items (By Name)... or Add Items (By Address)... commands on its right mouse button context menu. Both open a dialogue form titled Add Memory Item. Adding by name is particularly useful for the SFRs in microcontrollers, which can be expanded to monitor individual bitfields; every microcontroller model registers its special function registers this way.

The Watch Window monitoring the CMCON register of a PIC18, expanded to show its individual bitfields

Watch Window monitoring the CMCON register of the PIC18

Add Memory Item (By Name)

Add Memory Item (By Address)

Modifying Items in the Watch Window

Having got an item or items into the window, you can select an item with the left mouse button and then use the right mouse button context menu to change how it is interpreted and how it is displayed.

The Data Type sub-menu offers ASCIIZ String, Byte, Word, Double Word, Quad Word, IEEE Float (4 bytes), IEEE Double (8 bytes), HiTech Float (3 bytes) and Microchip Float (4 bytes). For a type that comprises several bytes, the second and subsequent bytes are taken from the addresses following the item address, so to display a multi-byte word or a string you only need to drag in the first byte from the memory window. Below the types is a Big Endian option, available on any type larger than a byte, which reverses that order for targets that store the most significant byte first.

The HiTech Float and Microchip Float types are the answer to the floating point ambiguity in the COF format described under Supported Debug Formats. If a float from a PIC compiler reads as nonsense, add it to the watch window and try the other float type.

The Display Format sub-menu controls how the value is written out and offers Binary, Octal, Hexadecimal, Signed Integer, Unsigned Integer, Floating Point and ASCII Text. The two decimal renderings are Signed Integer and Unsigned Integer.

The rest of the menu covers presentation and housekeeping: Show Addresses?, Show Types?, Show Previous Values?, Show Watch Expressions? and Show Gridlines? control what the window displays, Set Font... and Set Colours... control how it looks, and Select All, Copy To Clipboard, Find Item and Delete Item do what their names suggest.

Watchpoint Conditions

The Watch Window provides a facility to suspend the simulation when a particular condition arises in the values of the items. At the simplest level this is the On Change condition, which fires whenever the value of a particular item changes, but you can also specify more complex conditions if necessary.

To specify a Watchpoint Condition

  1. Press CTRL+F12 to start debugging, or pause the simulation if it is already running.
  2. Display the watch window itself using the option on the Debug menu.

    The Debug menu with the watch window listed among the numbered popup windows
  3. Add the items on which the watchpoint condition will depend to the watch window as described in the previous section.
  4. Select the Watchpoint Condition... command from the right mouse button context menu.

    The Watchpoint Condition command on the watch window context menu
  5. Choose a Global Break Condition. There are three settings: turn watch points off altogether, suspend the simulation if any expression is true, or stop it only when all the expressions are true. The first of these is how you switch a set of watchpoints off without deleting them.
  6. Specify one or more item break expressions. An item break expression consists of the watch item on which it operates, an operator and a mask value, a condition and a value to test against.

The Watchpoint Condition dialogue form, showing the global break condition and an item break expression

The Watchpoint Condition dialogue form

Two points about the expression are easy to miss. The mask has an operator of its own, sitting immediately to its left and offering None, AND, OR and XOR: a mask value alone does nothing until that operator is set, and the combination is what lets you watch particular bits of a register rather than the whole of it. The condition itself offers None, On Change, Equals, Not Equals, Greater Than, Greater or Equal To, Less Than and Less or Equal To.

Watchpoint Condition

Activating a watchpoint condition will impose a modest overhead on the simulator since ProSPICE must re-test the condition at every time-point in the simulation (that is, at or above the machine cycle rate in a microcontroller application). However, the facility can be a god-send when looking for obscure bugs and the fact that the simulation may take a few extra minutes to reach the point of interest is not normally an issue.

See Also:

Variables Window

Breakpoint Triggers

Popup Windows