QP Frameworks and QM Modeling Tool


In this article, we explore quantum platform (QP) frameworks and modelling tool. The framework can be used to produce highly-responsive and modular-embedded system applications. Design and implementation of real-time embedded software is so easy with the help of the QP modelling- and code-generation tool

Jai Sachith Paul

QP, from Quantum Leaps, is a family of open source frameworks that helps a user build efficient real-time embedded applications. The framework can completely replace the need for a traditional real-time operating system (RTOS) on a bare-metal single-chip microcontroller that controls the entire embedded system. The QP family consists of three frameworks: QP/C and QP-nano (written in C) and QP/C++ (written in C++).

Fig. 1: QM graphical modelling tool

Why quantum platform

Fig. 2: Components of quantum platform

The QP reveals itself before us as a better alternative to the RTOS in a single-chip microcontroller, controlling the embedded system application. Let us try to figure out the reasons for this.

Explore Circuits and Projects Explore Videos and Tutorials

No blocking. In an RTOS, we have counters, flags and other blocking mechanisms that are time-consuming in the sense that, when a program is blocked, it is not doing any work while waiting for an event. This also consumes a lot of memory space. In order to keep things simple, active objects are introduced into the QP framework by behavioural modelling specified by hierarchical state machine (UML state chart).The QP framework provides the active objects with the execution thread, queuing of events and event based timing services.

The elimination of blocks helps the program to have a smaller footprint in RAM (data space) as well as in ROM (code space). The scalability and efficiency is thereby increased considerably in a resource-constrained embedded system.

A8Z_boxHigh-efficiency and better resource utilisation. The flow of program is controlled by asynchronous events initiated by user actions, such as a mouse click, sensor outputs or messages from other threads. This event-driven approach helps the programmer to express his event more directly, which, in turn, improves the efficiency of his work. Another advantage of using this scheme is that the CPU needs to be busy at the occurrence of the event only. This means, that, we have a better resource-utilisation and power-efficiency. No wonder the event-driven, quantum platform is ideal for single-chip microcontrollers in embedded system design.

CAPture VDAS Evaluation Software

Graphical modelling using QM
By knowing the advantages of decomposing the software into event-driven actors, a developer might wonder how the quantum platform could be used to implement real-time embedded software. In order to help them, the package comes with a really cool graphical modelling tool, QP modeler (abbreviated as QM). The QM helps you elaborate graphically UML state charts associated with active objects. While using this tool, you need not re-invent the software architecture from scratch. The modeller helps you reuse the active object framework provided by QP. This will, in turn, increase your productivity dramatically.

QM also features automatic generation of C/C++ code, depending upon the framework used. Automatic model verification is also done during code generation. The tool provides mechanisms to quickly switch between the code and model, so as to apply required changes to the model than to the code. The QP/C and QP-nano frameworks comply with most of motor industry software reliability association’s MISRA-C:2004 rules, while the QP/C++ framework complies with most of MISRA-C++:2008 rules.

Feature highlights
Pre-emptive multitasking kernel. Users can go for the traditional RTOS for running the active-object model. But the QP framework provides a simple, superfast, non-blocking, run-to-completion (RTC) kernel. The kernel provides fully-pre-emptive multitasking using a single stack for all actor threads.

The pre-emptive kernel determines the scheduling policy where an RTC step can be pre-empted in order to execute another thread in the same processor. The suspended RTC step can later be resumed. There will be no concurrency issues as long as the pre-empting and pre-empted threads do not share the same resources.

Encapsulation for enhancing concurrency. Encapsulation involves packaging of data with operations into classes. It includes a mechanism for restricting access to some of the object’s components as well as a language construct that facilitates bundling of data with the methods (or other functions) operating on that data.

Even without any mutual exclusion mechanism, all private attributes of the active objects can be accessed only by its own thread. In order to ensure proper encapsulation, the resources are not shared. A dedicated active object becomes the manager and access of the resources by the rest of the system is by the events posted to this manager-active object.

DoCircuits Circuit Simulator

Highly-responsive event-driven architecture. There is an event queue associated with every active object. It helps them receive all the events exclusively through this queue. Whenever there are events like user actions, such as a mouse click, sensor outputs or messages from other threads, an event will be posted to the event queue asynchronously. The event producer need not wait in line for the actual processing of event. The QP framework takes up the responsibility of safely delivering and queuing of events in the queue to the thread of recipient active object where the processing takes place. In the event-driven approach, the processor is busy only at the occurrence of the event. There is a better utilisation of resources and saving of power.

Fig. 3: Code generation in QM

The event-driven approach seen in QP modeler is quite different from that seen in the traditional graphical user interface (GUI) development tools and architectures. Here, the actors not only make use of the nature of the event but also the context (state) of the system. All relevant aspects of the system’s history are very efficiently captured by the state.

Using the tool
A wide range of products in various domains that include consumer electronics, telecommunications, industrial automation, transportation, medical devices, aerospace and robotics already make use of this highly-efficient tool.

The software is licensed under dual-licensing model. If you are developing and distributing open source applications under GNU general public licence (GPL), as published by the free software foundation, then you are free to use Quantum Leaps software under GPL version 3 of the licence, or any later version.

If you are developing and distributing traditional closed source applications, you must purchase one of Quantum Leaps’ commercial licences, which are specifically designed for users interested in retaining the proprietary status of their code.

What to expect

Deeds: One-Stop Solution for All Your Digital Electronics Design Needs

268_activeBefore going for any tool, it is important to know what the current users feel about it. A user who reviewed the product on the company website says, “The QP implementation is very compact and efficient, yet provides you with lots of features for such a small package. The QP framework code is well-organised and the port files allowed us to easily make any customisations that we needed. All of this has allowed us to focus on our design and functionality instead of reinventing the wheel with another custom-state machine. One of the best parts about this model is that the maintenance code can be easily added, without adding lots of spaghetti code to add in something new. Without using QF, I do not believe we could have delivered on our given schedule dates with the same level of quality.”

Another user feels, “Early versions, of what is today QP, were developed and used by IntegriNautics (now Novariant) in its core GPS receiver technology. A GPS receiver is an ideal test bed for the concepts of QP, having significant domain complexity and requiring hard real-time determinism, small footprint and low power. Subsequently, QP has been adopted across the company and is used in all products on a variety of OS platforms.”

Some users also have a different view on CPU utilisation by using QP. They feel, “Ideally, when QP is used with an operating system, it should have lower CPU utilisation rates and more efficiency. But, in some practical case studies we see, it proves to be just the opposite. We also feel complexities in porting and implementation.”

Most users have given high ratings for the product and found the product to be very useful. But, some users feel that the product did not meet their expectation in certain aspects. The decision on whether the user should go for QP framework should be based on case study, taking into consideration the unique constraints of the system being built.

Download latest version of the software: click here

The author works at EFY