GNAT Pro User Day: QGen: Simulink® static verification and code generation
QGen: Simulink® static verification 
and code generation 
Presented by 
Matteo Bordin 
bordin@adacore.com
What is QGen? 
A qualifiable and customizable code generator from 
Simulink® and Stateflow® to SPARK and MISRA C 
A formal model verifier for runtime errors and functional properties 
An extendable framework to integrate heterogeneous models
Main features 1/2 
Support for a large subset of Simulink® 
Around 120 blocks, optional checks for MISRA Simulink® 
Stateflow® support expected in Spring 2015 
Code generation for SPARK and MISRA C 
Readable and traceable code, no performance penalty 
Ships with static model verifier 
Run-time errors (divisions by zero, overflows, …) 
Logical errors (dead execution paths) 
Functional properties (Simulink® assertions blocks)
Main features 2/2 
Off-the-shelf qualification material 
Including validation against Simulink® simulation 
DO-178C, EN 50128, ISO-26262 TCL3 
Highly tunable thanks to visible intermediate representation 
“Plug-and-play” transformations using Eclipse tools or XML manipulation 
Optimized code generation 
Generation of additional artifacts: Makefiles, docs, metrics, … 
Integrating with UML/SysML/AADL or in house DSLs
Product development history 1/2 
France and EU -funded collaborative R&D project 
From October 2011 to October 2015 
10M Euros total budget 
19 Partners 
Leader: Continental Automotive France
Product development history 2/2
How does QGen work? 1/2 
Simulink® model 
importer 
QGen intermediate representation (EMF metamodel) 
SPARK & MISRA C 
code generator 
model verifier
How does QGen work? 2/2 
Integrated in Matlab® (ideal for everyday use) 
From command line (does not require Matlab®, ideal for regression testing) 
qgenc MyModel.mdl [code-generation-options]
QGen and DO-178 
DO-330 (Tool Qualification Document) 
Precise identification of certification credit for code generator qualification 
Identification of credit w.r.t qualification strategy (TQL1 vs TQL5)
Using QGen - Verification 
Simulink® model 
QGen intermediate representation 
Verification 
Formalism 
importer 
model verifier 
Verification results 
round-trip 
Advanced 
+ 
traceability data 
*already qualified as part of a DO-178 Verification Tool / TQL5 
Verification 
Engine*
Using QGen - finding bugs 
No defensive modeling against division by zero
GNAT Pro User Day: QGen: Simulink® static verification and code generation
Using QGen - verifying functional properties 
ON OFF 
TRUE ERROR OK 
FALSE OK OK 
Brake OR 
Clutch 
Cruise Control 
The Cruise Control shall never be ON after 
the driver pushed the Brake or clutch pedal
Using QGen - verifying functional properties 
Formalization of safety property 
System implementation 
The Cruise Control shall never be ON after 
the driver pushed the Brake or clutch pedal
GNAT Pro User Day: QGen: Simulink® static verification and code generation
Using QGen - mixing proof & test 
Integration of legacy code via S-Function blocks 
How to prove the complete system (model + legacy code) is safe? 
How to extract model-relevant properties from legacy code? 
S-Functions written in C 
Difficult to automatically extract information 
Source code may not be available 
Rely on design-by-contact 
Wrap C code in automatically generated Ada stubs 
Decorate Ada stubs using pre/post conditions 
Rely on pre/post conditions for model verification 
Test C code against pre/post conditions
Using QGen - mixing proof & test 
S-Function written in C
GNAT Pro User Day: QGen: Simulink® static verification and code generation
Using QGen - mixing proof & test 
Availability of Static Analysis 
C S-Function Incomplete Model Static Analys 
C S-Function with Ada 2012 wrapper 
(design by contract) 
Static Analysis for Model 
Test for S-Function 
Ada S-Function 
Static Analysis on both Model 
and Source code 
Static Analysis holds for both 
C and Ada code generation!
Using QGen - Code Generation
Using QGen - Code Generation 
Standard code generation 
One file for every atomic subsystem 
Variables are global (in .adb/.c files) 
Full inlining, to increase performances 
A single file for the entire system 
All function calls are inlined 
Less memory consumption, less memory copy, more optimization 
Wrapping to reuse code with different I/O 
Corresponds to Simulink “generate reusable code” 
Pass persistent state and I/O as formal parameters 
Allows reusing the same code for multiple I/O data
GNAT Pro User Day: QGen: Simulink® static verification and code generation
QGen - an open and extensible framework 
Simulink Model 
Black Box 
Source Code 
Source Code 
Traditional Code Generators 
Simulink Model 
Access to intermediate representations 
Makefile 
generation 
Processor 
customization 
Modeling standard 
checking 
Additional 
verification 
Integration with UML 
Extract traceability 
data
Customizing QGen: use case 1 
A new processor is adopted, which provides intrinsic optimized functions 
Ex.: saturated sum 
How to reuse existing models? 
While benefitting from new processor functionalities? 
Relying on S-Functions requires changing them 
And potentially re-execute some verification activities! 
We rather change the code generator!
Customizing QGen: use case 1 
Exploit process-specific instructions 
… 
-- inlined code for saturated sum 
Int32 tmp := a + b; 
if tmp > Int16’Last then 
out := Int16’Last; 
elsif tmp < Int16’First then 
out := Int16’First; 
else 
out := tmp; 
end if; 
… 
… 
-- use processor-specific lib 
out := zaddwss (a, b); 
…
Customizing QGen: use case 1 
Intermediate 
representation 1 
Intermediate 
representation 2 
Intermediate 
representation 3 
Intermediate 
representation 4 
Intermediate 
representation 5 
Intermediate 
representation 6 
Source Code 
>> qgenc myModel.mdl —steps psgdxe 
>> python custom_saturate.py myModel_x.xmi 
>> qgenc myModel_x.xmi —language ada 
ECore-compliant XMI 
Python Script 
(150 SLOC)
Customizing QGen: use case 2 
Communication between control engineers and software architects 
Simulink models hide information relevant for software architecture 
Execution rates, data flow constraints, … 
How can this information be communicated to a software architect? 
Extraction of architectural concerns from Simulink model 
Extract AADL model out of Simulink 
Can be used to produce allocation models 
Can be used to execute real-time analysis
Customizing QGen: use case 2 
Intermediate 
representation 1 
ECore-compliant XMI 
Acceleo / ATL 
transformation 
>> qgen myModel.mdl —steps pe 
Extraction of real-time architectural constraints 
by generating an AADL model
QGen: roadmap 
2013 - 2014 
End of 2014 
February 2015 
Spring 2015 
Q4 2015 
evaluation by project P partners 
first selected customer pre-release 
QGen 1.0 available 
Stateflow® support 
full qualification material 
In the pipeline: static stack analysis, AUTOSAR, …
QGEN is the open, tunable and qualifiable 
model verifier and code generator 
for Simulink® and Stateflow® 
pre-release for selected customers: Q4 2014 
version 1.0: February 2015
QGen: Simulink® static verification 
and code generation 
Presented by 
Matteo Bordin 
bordin@adacore.com

More Related Content

PPTX
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
PDF
GNAT Pro User Day: AdaCore Insights
PDF
GNAT Pro User Day: GNATdashboard - Tracking and Improving Software Quality
PDF
GNAT Pro User Day: Ada at Ansaldo STS
PPTX
GNAT Pro User Day: Ada Factory
PPTX
GNATdashboard
PDF
OpenDataPlane Project
PPTX
THE STATE OF OPENTELEMETRY, DOTAN HOROVITS, Logz.io
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
GNAT Pro User Day: AdaCore Insights
GNAT Pro User Day: GNATdashboard - Tracking and Improving Software Quality
GNAT Pro User Day: Ada at Ansaldo STS
GNAT Pro User Day: Ada Factory
GNATdashboard
OpenDataPlane Project
THE STATE OF OPENTELEMETRY, DOTAN HOROVITS, Logz.io

What's hot (20)

PPTX
Tech Days 2015: Ada 2012 and Spark Crazyflie and Railway Demo
PPTX
Project P Open Workshop
PDF
LCA14: LCA14-209: ODP Project Update
PPTX
Tech Days 2015: Static Analysis CodePeer
PDF
AdaCore Paris Tech Day 2016: Cyrille Comar - Looking Ahead
PDF
ODP Presentation LinuxCon NA 2014
PPTX
Tech Days 2015: CodePeer - Introduction and Examples of Use
PPTX
Værktøjer udviklet på AAU til analyse af SCJ programmer
PDF
ScilabTEC 2015 - Evidence
PPT
Sci scada toolbox
PPTX
Advanced technologies and techniques for debugging HPC applications
PPTX
IE WebGL and Babylon.js (Web3D 2014)
PDF
ScilabTEC 2015 - Noesis Solutions
PDF
ScilabTEC 2015 - Embedded Solutions
PDF
Composable infrastructure try valence
PPTX
PhD SDN Projects
PPTX
Strel streaming
PDF
Toward a Methodology to turn Smalltak code into FPGA
PDF
Tools and Methods for Continuously Expanding Software Applications
Tech Days 2015: Ada 2012 and Spark Crazyflie and Railway Demo
Project P Open Workshop
LCA14: LCA14-209: ODP Project Update
Tech Days 2015: Static Analysis CodePeer
AdaCore Paris Tech Day 2016: Cyrille Comar - Looking Ahead
ODP Presentation LinuxCon NA 2014
Tech Days 2015: CodePeer - Introduction and Examples of Use
Værktøjer udviklet på AAU til analyse af SCJ programmer
ScilabTEC 2015 - Evidence
Sci scada toolbox
Advanced technologies and techniques for debugging HPC applications
IE WebGL and Babylon.js (Web3D 2014)
ScilabTEC 2015 - Noesis Solutions
ScilabTEC 2015 - Embedded Solutions
Composable infrastructure try valence
PhD SDN Projects
Strel streaming
Toward a Methodology to turn Smalltak code into FPGA
Tools and Methods for Continuously Expanding Software Applications
Ad

Viewers also liked (7)

PPTX
GNAT Pro User Day: AdaCore University
PPTX
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
PDF
GNAT Pro User Day: Leveraging AdaCore Tool to Support Rigorous Software Devel...
PPTX
GNAT Pro User Day: VISIUM™ and Ada
PPTX
GNAT Pro User Day: GNATdoc: Automatic Documentation Generator
PDF
GNAT Pro User Day: New and Upcoming Developments in the AdaCore Technology
PPTX
Ada 2012
GNAT Pro User Day: AdaCore University
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
GNAT Pro User Day: Leveraging AdaCore Tool to Support Rigorous Software Devel...
GNAT Pro User Day: VISIUM™ and Ada
GNAT Pro User Day: GNATdoc: Automatic Documentation Generator
GNAT Pro User Day: New and Upcoming Developments in the AdaCore Technology
Ada 2012
Ad

Similar to GNAT Pro User Day: QGen: Simulink® static verification and code generation (20)

PPTX
Tech Days 2015: Model Based Development with QGen
PPTX
Automated Requirements-Based Testing for Medical Device Software
PPTX
Automated requirements based testing for ISO 26262
PDF
“A Practical Guide to Getting the DNN Accuracy You Need and the Performance Y...
PPTX
Automated Low Level Requirements Testing for DO-178C
PPSX
Automated Requirements-Based Testing for Medical Device Software.ppsx
PDF
PyData Berlin 2023 - Mythical ML Pipeline.pdf
PDF
Incquery Suite Models 2020 Conference by István Ráth, CEO of IncQuery Labs
PPTX
Controller Software Verification Using AVM Meta and HybridSAL
PDF
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
PDF
Presentation Verification & Validation
PPTX
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
PPTX
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
PPT
Code Generation with MDA and xUML
PDF
Bounded Model Checking for C Programs in an Enterprise Environment
PDF
Tools for Test-Driven Product Modeling
PPTX
Incremental Queries and Transformations for Engineering Critical Systems
PPT
Rhapsody Software
PDF
Universal Chip Interconnect Verification
PDF
Universal Chip interconnect Verification
Tech Days 2015: Model Based Development with QGen
Automated Requirements-Based Testing for Medical Device Software
Automated requirements based testing for ISO 26262
“A Practical Guide to Getting the DNN Accuracy You Need and the Performance Y...
Automated Low Level Requirements Testing for DO-178C
Automated Requirements-Based Testing for Medical Device Software.ppsx
PyData Berlin 2023 - Mythical ML Pipeline.pdf
Incquery Suite Models 2020 Conference by István Ráth, CEO of IncQuery Labs
Controller Software Verification Using AVM Meta and HybridSAL
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
Presentation Verification & Validation
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
Code Generation with MDA and xUML
Bounded Model Checking for C Programs in an Enterprise Environment
Tools for Test-Driven Product Modeling
Incremental Queries and Transformations for Engineering Critical Systems
Rhapsody Software
Universal Chip Interconnect Verification
Universal Chip interconnect Verification

More from AdaCore (20)

PDF
RCA OCORA: Safe Computing Platform using open standards
PDF
Have we a Human Ecosystem?
PDF
Rust and the coming age of high integrity languages
PDF
SPARKNaCl: A verified, fast cryptographic library
PDF
Developing Future High Integrity Processing Solutions
PDF
Taming event-driven software via formal verification
PDF
Pushing the Boundary of Mostly Automatic Program Proof
PDF
RCA OCORA: Safe Computing Platform using open standards
PDF
Product Lines and Ecosystems: from customization to configuration
PDF
Securing the Future of Safety and Security of Embedded Software
PDF
Spark / Ada for Safe and Secure Firmware Development
PDF
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
PDF
The Future of Aerospace – More Software Please!
PDF
Adaptive AUTOSAR - The New AUTOSAR Architecture
PDF
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
PDF
Software Engineering for Robotics - The RoboStar Technology
PDF
MISRA C in an ISO 26262 context
PPTX
Application of theorem proving for safety-critical vehicle software
PDF
The Application of Formal Methods to Railway Signalling Software
PDF
Multi-Core (MC) Processor Qualification for Safety Critical Systems
RCA OCORA: Safe Computing Platform using open standards
Have we a Human Ecosystem?
Rust and the coming age of high integrity languages
SPARKNaCl: A verified, fast cryptographic library
Developing Future High Integrity Processing Solutions
Taming event-driven software via formal verification
Pushing the Boundary of Mostly Automatic Program Proof
RCA OCORA: Safe Computing Platform using open standards
Product Lines and Ecosystems: from customization to configuration
Securing the Future of Safety and Security of Embedded Software
Spark / Ada for Safe and Secure Firmware Development
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
The Future of Aerospace – More Software Please!
Adaptive AUTOSAR - The New AUTOSAR Architecture
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
Software Engineering for Robotics - The RoboStar Technology
MISRA C in an ISO 26262 context
Application of theorem proving for safety-critical vehicle software
The Application of Formal Methods to Railway Signalling Software
Multi-Core (MC) Processor Qualification for Safety Critical Systems

Recently uploaded (20)

PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
Architecture types and enterprise applications.pdf
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Configure Apache Mutual Authentication
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PPTX
Build Your First AI Agent with UiPath.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
Flame analysis and combustion estimation using large language and vision assi...
DOCX
search engine optimization ppt fir known well about this
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
The influence of sentiment analysis in enhancing early warning system model f...
A proposed approach for plagiarism detection in Myanmar Unicode text
Final SEM Unit 1 for mit wpu at pune .pptx
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
Module 1.ppt Iot fundamentals and Architecture
Consumable AI The What, Why & How for Small Teams.pdf
Architecture types and enterprise applications.pdf
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Custom Battery Pack Design Considerations for Performance and Safety
Configure Apache Mutual Authentication
UiPath Agentic Automation session 1: RPA to Agents
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Build Your First AI Agent with UiPath.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
Convolutional neural network based encoder-decoder for efficient real-time ob...
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Flame analysis and combustion estimation using large language and vision assi...
search engine optimization ppt fir known well about this
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...

GNAT Pro User Day: QGen: Simulink® static verification and code generation

  • 2. QGen: Simulink® static verification and code generation Presented by Matteo Bordin bordin@adacore.com
  • 3. What is QGen? A qualifiable and customizable code generator from Simulink® and Stateflow® to SPARK and MISRA C A formal model verifier for runtime errors and functional properties An extendable framework to integrate heterogeneous models
  • 4. Main features 1/2 Support for a large subset of Simulink® Around 120 blocks, optional checks for MISRA Simulink® Stateflow® support expected in Spring 2015 Code generation for SPARK and MISRA C Readable and traceable code, no performance penalty Ships with static model verifier Run-time errors (divisions by zero, overflows, …) Logical errors (dead execution paths) Functional properties (Simulink® assertions blocks)
  • 5. Main features 2/2 Off-the-shelf qualification material Including validation against Simulink® simulation DO-178C, EN 50128, ISO-26262 TCL3 Highly tunable thanks to visible intermediate representation “Plug-and-play” transformations using Eclipse tools or XML manipulation Optimized code generation Generation of additional artifacts: Makefiles, docs, metrics, … Integrating with UML/SysML/AADL or in house DSLs
  • 6. Product development history 1/2 France and EU -funded collaborative R&D project From October 2011 to October 2015 10M Euros total budget 19 Partners Leader: Continental Automotive France
  • 8. How does QGen work? 1/2 Simulink® model importer QGen intermediate representation (EMF metamodel) SPARK & MISRA C code generator model verifier
  • 9. How does QGen work? 2/2 Integrated in Matlab® (ideal for everyday use) From command line (does not require Matlab®, ideal for regression testing) qgenc MyModel.mdl [code-generation-options]
  • 10. QGen and DO-178 DO-330 (Tool Qualification Document) Precise identification of certification credit for code generator qualification Identification of credit w.r.t qualification strategy (TQL1 vs TQL5)
  • 11. Using QGen - Verification Simulink® model QGen intermediate representation Verification Formalism importer model verifier Verification results round-trip Advanced + traceability data *already qualified as part of a DO-178 Verification Tool / TQL5 Verification Engine*
  • 12. Using QGen - finding bugs No defensive modeling against division by zero
  • 14. Using QGen - verifying functional properties ON OFF TRUE ERROR OK FALSE OK OK Brake OR Clutch Cruise Control The Cruise Control shall never be ON after the driver pushed the Brake or clutch pedal
  • 15. Using QGen - verifying functional properties Formalization of safety property System implementation The Cruise Control shall never be ON after the driver pushed the Brake or clutch pedal
  • 17. Using QGen - mixing proof & test Integration of legacy code via S-Function blocks How to prove the complete system (model + legacy code) is safe? How to extract model-relevant properties from legacy code? S-Functions written in C Difficult to automatically extract information Source code may not be available Rely on design-by-contact Wrap C code in automatically generated Ada stubs Decorate Ada stubs using pre/post conditions Rely on pre/post conditions for model verification Test C code against pre/post conditions
  • 18. Using QGen - mixing proof & test S-Function written in C
  • 20. Using QGen - mixing proof & test Availability of Static Analysis C S-Function Incomplete Model Static Analys C S-Function with Ada 2012 wrapper (design by contract) Static Analysis for Model Test for S-Function Ada S-Function Static Analysis on both Model and Source code Static Analysis holds for both C and Ada code generation!
  • 21. Using QGen - Code Generation
  • 22. Using QGen - Code Generation Standard code generation One file for every atomic subsystem Variables are global (in .adb/.c files) Full inlining, to increase performances A single file for the entire system All function calls are inlined Less memory consumption, less memory copy, more optimization Wrapping to reuse code with different I/O Corresponds to Simulink “generate reusable code” Pass persistent state and I/O as formal parameters Allows reusing the same code for multiple I/O data
  • 24. QGen - an open and extensible framework Simulink Model Black Box Source Code Source Code Traditional Code Generators Simulink Model Access to intermediate representations Makefile generation Processor customization Modeling standard checking Additional verification Integration with UML Extract traceability data
  • 25. Customizing QGen: use case 1 A new processor is adopted, which provides intrinsic optimized functions Ex.: saturated sum How to reuse existing models? While benefitting from new processor functionalities? Relying on S-Functions requires changing them And potentially re-execute some verification activities! We rather change the code generator!
  • 26. Customizing QGen: use case 1 Exploit process-specific instructions … -- inlined code for saturated sum Int32 tmp := a + b; if tmp > Int16’Last then out := Int16’Last; elsif tmp < Int16’First then out := Int16’First; else out := tmp; end if; … … -- use processor-specific lib out := zaddwss (a, b); …
  • 27. Customizing QGen: use case 1 Intermediate representation 1 Intermediate representation 2 Intermediate representation 3 Intermediate representation 4 Intermediate representation 5 Intermediate representation 6 Source Code >> qgenc myModel.mdl —steps psgdxe >> python custom_saturate.py myModel_x.xmi >> qgenc myModel_x.xmi —language ada ECore-compliant XMI Python Script (150 SLOC)
  • 28. Customizing QGen: use case 2 Communication between control engineers and software architects Simulink models hide information relevant for software architecture Execution rates, data flow constraints, … How can this information be communicated to a software architect? Extraction of architectural concerns from Simulink model Extract AADL model out of Simulink Can be used to produce allocation models Can be used to execute real-time analysis
  • 29. Customizing QGen: use case 2 Intermediate representation 1 ECore-compliant XMI Acceleo / ATL transformation >> qgen myModel.mdl —steps pe Extraction of real-time architectural constraints by generating an AADL model
  • 30. QGen: roadmap 2013 - 2014 End of 2014 February 2015 Spring 2015 Q4 2015 evaluation by project P partners first selected customer pre-release QGen 1.0 available Stateflow® support full qualification material In the pipeline: static stack analysis, AUTOSAR, …
  • 31. QGEN is the open, tunable and qualifiable model verifier and code generator for Simulink® and Stateflow® pre-release for selected customers: Q4 2014 version 1.0: February 2015
  • 32. QGen: Simulink® static verification and code generation Presented by Matteo Bordin bordin@adacore.com