Microchip's MPLAB X permits simulation from the command line. This is interesting from the perspective of teaching if we have automatically-graded programming assignments that take the student's program and runs it against a simulated chip in an LMS like Moodle.
I'm interested in how we can use the MDB in MPLAB X to simulate processors in a teaching context. Specifically, I'd like to see if we can use an instance of MDB running on a Linux computer as a backend for a learning management system (LMS) like Moodle providing exercises to students using Virtual Programming Lab (VPL). One of the interesting features of MDB is that ability to "stimulate" the chip with signals using SCL. This should allow for a VPL test script to "inject" values into the simulated chip to see if the program that the students write is working correctly.
We use MPLAB X because it supports a wide range of processors, including 8- and 32-bit processors, is free, and runs on all three major operating systems.
Here, let's see how MDB works on a regular laptop or desktop computer. I'll run some existing projects for standard processors like a PIC16F1619, an ATMEGA328PB (like an Arduino Uno), and a SAMD (Cortex M0). I'm using Microchip's MPLAB X GUI to compile the program into an executable ELF file. Then, I descend into a terminal and run MDB, as per the instructions found on the Microchip Developer Wiki site (archived link).
The PIC16 is a classic 8-bit processor by Microchip. Th 16F1619 model is a recent update and one that I've used in class before.
The ATMEGA328 processor is the one found on the ever-popular Arduino Uno. The simulator tools within MPLAB X aren't as good as they are in ATMEL Studio, but it will suffice.
SAMD Example (ARM Cortex M0+)
The SAMD line of processors are based on the ARM Cortex M series of cores. Here, we look at one of the simpler Cortex M machines, the Cortex M0+.
Testing with the ATSAMD21j18a reveals that the simulator for at least some SAMD parts is problematic. For instance, we see complaints about
- W0106-SIM: This device only has partial support for PORT_GROUP0 peripheral. ** beta mode **
- W0106-SIM: This device only has partial support for PORT_GROUP1 peripheral. ** beta mode **
- W0106-SIM: This device only has partial support for TC7 peripheral. ** beta mode **
- W0111-SIM: The selection is not supported: We don't simulate the clock selection
But the core functions look fine. So, as long as we stay away from timers and GPIO (okay in an architecture class) then it's okay.
The PIC32MX is a classic 32-bit processor based on the MIPS architecture. Simpler to use that an ARM, it's a solid option for development. Here, I've accessed MDB from the command line on one of the EECS Linux workstations. MDB is located here at /eecs/local/pkg/mplab-5.50/mplab_platform/bin.
A number of my colleagues are keen on moving from ARM or MIPS to RISCV on the 32-bit or 64-bit front. I'm on the fence right now, as I was about ARM Cortex about 15 years ago. Regardless, my focus is to see how we can integrate computer architecture tools with our LMS (i.e. VPL). I was hoping to see RISCV support appear in MPLAB X but it looks like Microchip is using a different IDE for that. Unfortunately, there doesn't appear to be either (1) a simulator or (2) macOS support in their RISCV IDE.
How to integrate with VPL?
The simulator isn't officially supported by VPL, as per this list from 2014.
James Andrew Smith is an associate professor in Electrical Engineering and Computer Science Department in York University's Lassonde School. He lived in Strasbourg, France and taught at the INSA Strasbourg and Hochschule Karlsruhe while on sabbatical in 2018-19 with his wife and kids.