In this article, we explore the features and advantages of gpsim by analysing the step-by-step procedure to simulate PIC microcontroller using this tool.
gpsim is a free software simulation tool for PIC microcontrollers from Microchip, which has been designed to be fast enough to simulate PICs at a speed of about 20MHz. Its accurate design makes it comparable to using a real PIC microcontroller from the core to the I/O pins and even all the internal peripherals.
Why it is noteworthy
It is mostly written in C++, which enables it to easily implement a hierarchical model of a PIC. This in turn enables it to use the inheritance property of C++, which allows the various models of PIC to share a relationship. By being designed to support all the three families of PIC (12-bit core, 14-bit core and 16-bit core), this tool eliminates the need of a different simulator for a different core. gpsim’s accuracy allows it to test the PIC in the same way as it would be in a real world.
Why use this tool
Currently, there are so many software simulators available for PIC that it becomes obvious for engineers to ask: Why use gpsim? A simple answer to this is that, being a free and open source software, unlike most of its serious competition, gpsim enjoys the FOSS community support.
gpsim has the following benefits that make it superior to all the other simulators available in the market:
Easy debugging with three-control option. gpsim is capable of being controlled from either a graphical user interface (GUI) by a remote process or by a command line interface (CLI). Although the tool is by default configured for GUI, it can also be configured for CLI and remote process later.
No hardware requirements. gpsim does not require any minimum hardware specification and so can be built and run on any popular Linux distribution. Moreover, it is not limited to Linux and has also been ported to other operating systems like Microsoft Windows, BSD, MAC and Solaris.
Supports loadable modules. This feature enables gpsim to add all other devices that are totally separate from this tool. It allows users to customise a simulation environment.
Allows easy inspection. At times, a history or a trace of the work helps inspect its current status and to analyse the cause of the bugs. gpsim helps diagnose the bugs providing that history.
Additional benefits through supportive tools
gpsim has the following supportive tools that help it in simulation:
Register reviewer. gpsim has two similar register windows that provide data for RAM and EEPROM. It allows you to see all registers in the current processor, with their display names and values. The register viewer provides the following functions:
1. One can not only set read, write and break point values but also clear each break point on the registers
2. Writes and reads of specific data can be logged in
3. Cells can be copied just by dragging the borders of the selected cells
4. The content of one cell can be copied to another cell
5. ‘Add watch’ allows one to watch the register values
Source browser. gpsim has two source browsers: .asm and .obj. The .asm is a colour-coded display of the PIC source whereas the .obj provides an opcode view. The opcode view has memory cell on one line and information related to disassembly, address and hexadecimal value on the other.
Breadboard. It not only allows one to create/modify and examine the PIC environment but also helps to instantiate PIC processor from the command line or from .stc file. In simple language, it helps in creating a correct configuration to test the source code. You can create code just by a click and also connect to those nodes for a better configuration just with the help of gpsim’s breadboard.
Scope window. gpsim also has a scope window that provides a graphical view of the I/O pin states in the same way as a logic analyser. It can be controlled either from the GUI or from the command line.
What users have to say
We realise that a journalist’s conclusion might not be as accurate as that of an actual user. Therefore we are reproducing below some reviews on this tool from the sourceforge.net and edaboard.com communities:
1. “Step debugging of assembly code with virtual breadboard, watch, scope, and supports stimulus files and graphical peripheral module simulation. Wow! This is worth money!”
2. “Made my transition from High Level development to embedded development world much easier. Works great with 16F series. Waiting for the kinks to unwind in the 18F series. Great job, developers and maintainers!!”
3. “I found to manage the nice free and open source PIC simulator gpsim. It has GUI and animation also. Earlier I tried it, but it crashed after ‘Add library’ (libgpsim_modules.dll on windows). I used the latest version—0.25.1. But the good news is, earlier version 0.24.0 works perfectly. I was also having problem in using USART module correctly (on Linux). This is also solved.”
Download latest version of the software: click here
The author is a technical journalist at EFY. The article is based on the gpsim document from Sourceforge.net