An integrated framework to simulate electronic systems (including digital and analog devices) with the mechanical parts of a heterogeneous automotive system is presented. The electronic system, consisting of many electronic control units (ECUs), is modeled to simulate the mechatronic system functionality. The recently developed functional mock-up interface standard approach is used to create a model for a complex cyber-physical automotive system. The framework simulates real systems, including the hardware (HW) and the software (SW) to run on the virtual ECUs. It allows co- development of the automotive system SW and HW while the mechanical system is in the loop. Hardware and software debugging is demonstrated using the developed methodology. The development cycle for the automotive mechatronic system can be greatly shortened using the proposed framework.
Autonomous driving (AD) requires sophisticated electronic systems. The designs of today’s automotive electronic systems contain many system-on-chips (SoC).[1, 2] Deep verification is required to ensure that there are no bugs or risks of failure. The safety of advanced driver assistance systems (ADAS) can not be guaranteed without verification of the whole system, including thermal, mechanical, and electrical parts. Cars with ADAS have extensive data processing and decision making capabilities. A driver is either warned so a potentially dangerous situation can be avoided, or the systems on board take control once a dangerous situation is inevitable (e.g., by steering away from the impact point). In this article, modeling the whole automotive system is adopted to verify the operation of ADAS, including the software and hardware.
Virtual platforms (VPs) are emerging as the key technology to build virtual prototypes for real products and enable the co-design of SW and HW systems. VPs enable fast architecture exploration, early SW development, and efficient performance analysis[3-7]. A VP is the ensemble of simulation models representing HW blocks and their interconnections. VPs are usually modeled via a high-level programming language tailored for modeling and simulation, such as SystemC/TLM2. In a hybrid automotive system, synergy among different tools and models crossing domains (system of systems), including virtual platforms, plant simulators, digital simulators, HW emulators and mechanical simulators, is required. Virtual platforms model ECUs (i.e., virtual ECU or VECU), including processors, HW peripherals, and controllers to run automotive software stacks.[8-12] ADAS VECUs have multiple sensors on board, of which the readings are combined to obtain a better perception of the actual situation. In this article the presented framework is used to verify both autonomous and non-autonomous VECUs. A VECU which acts as an ADAS ECU has AUTOSAR SW that runs on top of it. The VECU is connected with many types of sensors and actuators through the functional mock-up interface (FMI) standard as shown in Figure 1.
Figure 1 - Virtual ECU interfacing with different FMUs
SystemC/TLM VPs are generated using the Vista™ tool  and is connected with sensors/actuators created by MATLAB® and TASS® Prescan. TASS gives the capability to develop dangerous scenarios that can occur in the physical surrounding of a vehicle. These simulated scenarios allow engineers to have more time to focus on real system design issues at an early design stage. Using the proposed framework, the developer can verify real code on the VECU and deal with many sensors and actuators in different scenarios and study the effects of using ADAS in such scenarios. The presented methodology integrates VECU as a functional mock-up unit (FMU) using FMI.
The work in  presents an approach to create VPs as FMUs. The VP is shipped as an FMU shared object with an FMI model description XML in the FMU file. The FMI master loads the VP DLL. The proposed mechanism in this article is different in that it depends on creating an FMU wrapper which can be loaded by the FMI master with the VP through an IPC mechanism. The I/O interconnects of the VP are controlled by FMI V.2.0 co-simulation APIs triggered by the FMI master. I/O changes are propagated in an event-driven execution mechanism that is compatible with the nature of the SystemC/TLM based VP. With this mechanism, portability is high compared to the mechanism described in , as the VP can be modified and compiled without changing the FMU part. The remainder of the article is organized as follows: the design methodology using the proposed FMU is presented in section II; a case study of a full automotive system is provided in section III; and conclusions are presented in section IV.
THE DEVELOPED METHODOLOGY
In order to wrap a SystemC virtual platform as an FMU, two wrappers are used. One is inside the VP, the internal FMU control (IFC), and the other is outside, the external FMU wrapper (EFW), as shown in Figure 2. The IFC is the TLM SystemC model responsible for communicating with the EFW and synchronizing the VP with the other FMUs (could be electrical or mechanical). The IFC is connected with the EFW through an IPC mechanism. The EFW consists of XML and DLL. It can be parsed and loaded by the external FMI master inside another simulation tool. FMUs are assumed to be compliant with the FMI V.2.0 co-simulation standard. Also, it is assumed that the FMUs are provided as a pre-compiled shared library (*.DLL on Windows or *.so on Linux systems). Runtime library dependencies are assumed to be available on the same host on which the VP is running. The EFW can be configured to have any number of input and output pins. Analog ports are represented as REAL numbers and digital pins are represented as INTEGER numbers. Each pin has a unique reference value (V_reference). EFW configuration can be set in the XML file. IFC has the same configuration of EFW.
The EFW XML has a dynamic array of S_FMU_PORT structure for each pin, as shown in Figure 2, below. The S_FMU_PORT structure defines the FMU_Container_Value, which represents the value to be sent/received from/to the VP to/from the FMI master. The FMU_Container_Type represents the data type (REAL or INTEGER). V_reference represents the reference value for the pin, which is defined in the XML file. If the pin value is updated by any side (master or slave), the updated value is set. The pin direction in the XML file identifies if the pin is input or output. C_socket represents the virtual socket, which is mapped to the pin, as shown in Figure 3, below. The default initialization value of V_reference is -1. Initialization is performed once the FMI master begins calling the FMU initialization APIs.
Figure 2 - The dynamic array of FMU ports structure
Once the FMI master sends an INTEGR value to the FMU, it calls the fmi2SetInteger API; then the EFW searches for all the S_FMU_PORTs that have the matched reference value with input direction. EFW sets the FMU_Container_Value with the value that is sent by other FMUs. If the XML V_reference does not exist, then the V_reference is set to -1. Finally, the value is sent to the corresponding virtual socket, as shown in Figure 4.
Figure 3 - The EFW transmit sequence
On the other side, IFC handles the reception and transmission of the pin values by the mapper sub-block. EFW sends a string using the IPC virtual socket. The string consists of five data values separated by a semicolon (pin value, data type, variable reference, updated flag, and direction). The mapper inside the IFC parses the string and issues a transaction on the general purpose input output (GPIO) TLM pin, which matches the V_reference in the XML, as shown in Figure 4. Each TLM pin has a unique V_reference.
Figure 4 - IFC receiving sequence
Similar behavior happens when the GPIO issues a transaction to send data on the GPIO pin. The mapper sends the data value to the EFW on the corresponding virtual socket. Once the FMI master reads data from the FMU, it calls the Fmi2getint API, and the saved value is returned to the FMI master. The exchanged data between the FMI master external tool and the VP, which is wrapped as an FMU slave, is shown in Figure 5. A case study of many VECUs communicating together (with one of them, ADAS VECU, acting as an FMU connected to a Matlab FMI master) is presented in the following section.
Figure 5 - Data exchange between the VECU pins and the FMI master in an external tool
An ADAS of an autonomous vehicle consisting of four VECUs connected to a CAN bus is used in the presented case study to demonstrate the use of VP as an FMU, as shown in Figure 6, below. A dashboard VECU is modeled using CANoe® for packet generation and monitoring. Different inputs (such as pedal/angle, brake/angle, shift, and stop engine) and outputs (monitor speed/RPM) are stimulated and observed through the dashboard. The engine control VECU is modeled as a PowerPC Virtual Platform using Vista Architect® to run the AUTOSAR stack/application. The engine control VECU reads input combinations from the dashboard and sends command/pedal/brake angle to the transmission controller VECU. The transmission controller VECU is modeled as a virtual SoC (based on the ARM® CortexM3) that runs a bare metal application. It reads pedal angle from the engine controller VECU and calculates the RPM/speed. The braking system is modeled using Simcenter Amesim® with mechatronic components, exported as a slave FMU and connected to a Vista FMI master running on the host machine. The FMU input is a brake force which comes from the digital-to-analog converter (DAC) model inside the engine control VECU, and the output is the force on the 4-wheel calipers of the vehicle.
Figure 6 - Advanced emergency braking system controlled by ADAS VECU (case study)
The scenario begins with the actor information receiver (AIR) sensor detecting a person moving across the road, modeled using PreScan.® The AIR sensor is connected to a virtual ADAS control VECU running the advanced emergency braking system (AEBS) bare-metal application and wrapped as an FMU. The ADAS VECU is integrated inside MATLAB Simulink® from MathWorks, as shown in Figure 7. The AIR sensor output is zero in case no object is detected. The analog-to-digital converter (ADC) of the VECU is connected to the AIR sensor.
Figure 7 - The ADAS VECU wrapped as an FMU connection
One driving scenario is to be chosen out of 10,000 for testing the ADAS. The simulated vehicle is driven normally on a simulated road. The AIR sensor in the car detects a person running across the road in front of the car at a distance of 20 meters. The ADAS VECU uses this sensor information and determines that a collision would occur with the person unless avoidance action is taken. The ADAS sends a signal to the braking system to stop the car.Each VECU has a unique CAN ID. The communication between the VECUs is done by CAN frames, as shown in Figure 8.
Figure 8 - CAN frames data flow on virtual CAN bus
The ADAS VECU is wrapped as an FMU and imported into MATLAB Simulink. It receives the speed/RPM CAN packet from the transmission controller VECU and controls the car animation in PreScan. Once a human appears in front of the car, the sensor detects the object and the ADAS VECU automatically sends a CAN packet (ID =0x70) with data containing the brake angle. The transmission controller VECU sends a force to the mechanical brake system in Simcenter Amesim and the car stops. The natural decreasing slope of the car speed is generated by road friction. Once the AIR sensor detects the object at a distance of 20 meters, the ADAS control VECU sends brake signal frames automatically, resulting in a sharp decrease in the car speed with the car stopping at a distance of 14 meters. The simulated scenario is shown in Figure 10, below. The car speed decreases from 20 km/s to 0 km/s during 1 sec.
Figure 9 - (a) The AIR sensor distance (m) and car speed (km/hr) (b) The ADAS VECU stops the car once it detects the human in front of it
In another scenario, the car's speed decreases from 90 km/s to 40 km/s during 971 ms, as shown in Figure 10, below. In this case the collision between the vehicle and the human will happen as a result of driving at high speed and suddenly encountering the pedestrian. Many scenarios can be verified with different speeds. AUTOSAR SW analysis for each scenario can be generated and verified, as shown in Figure 11.
Figure 10 - Collision occurs as a result of car running at high speed. The AIR sensor distance (m) and car speed (km/hr)
Figure 11 - AUTOSAR SW analysis for ADAS VECU
As shown in this article, simulating a full hetero-geneous automotive system is becoming feasible using virtual platforms for the target VECUs and FMI standard. Not only electrical systems but also mechanical systems can be simulated and verified using the presented methodology. Virtualization is efficiently used to run AUTOSAR SW on a functional simulation. An ADAS, including electrical (digital and analog) and mechanical subsystems is modeled and simulated in a short time (with high performance). Integrating the heterogeneous parts of a system of systems is becoming essential for automotive system development. In this article, the FMI standard is used to model full SoC platforms as FMUs. FMI allows simulating digital, analog, and mechanical parts using an integrated framework. Real software runs efficiently on the modeled system, allowing the verification of the system operation. ADAS is validated on the developed virtual system. Debugging the software with the hardware is made easier with the presented methodology.
 R. L. Bucs, L. G. Murillo, E. Korotcenko, G. Dugge, R. Leupers, G. Ascheid, A. Ropers, M. Wedler, and A. Hoffmann. “Virtual hardware- in-the-loop co-simulation for multi-domain automotive systems via the functional mock-up interface,” in Specification and Design Languages (FDL),p.1-8(2015).
 R. Leupers, F. Schirrmeister, G. Martin, T. Kogel, R. Plyaskin, A. Herkersdorf, and M. Vaupel. “Virtual Platforms: Breaking New Grounds,” in Design, Automation & Test in Europe Conference & Exhibition (DATE), Germany, p. 685-690(March 2012).
 M. Shedeed, G. Bahig, M. W. Elkharashi, and M. Chen, “Functional Design and Verification of Automotive Embedded Software: An Integrated System Verification Flow,” In The Proceedings of The IEEE Saudi International Electronics, Communications and Photonics Conference, pp. 1-5, July 2013.
 R. Saleh, S. Wilton, S. Mirabbasi, A. Hu, M. Greenstreet, G. Lemieux, P. Pande, C. Grecu, and A. Ivanov, “System-on-Chip: Reuse and Integrate,” In The Proceedings of The IEEE, Vol. 94, No. 6, pp. 1050-1069, June 2006.
 R. Leupers, F. Schirrmeister, G. Martin, T. Kogel, R. Plyaskin, A. Herkersdorf, and M. Vaupel, “Virtual Platforms: Breaking New Grounds,” In The Proceedings of The IEEE Design Automation and Test in Europe Conference and Exhibition, pp. 685-690, March 2012.
 C-S. Peng, Li-C. Chang, C-H. Kuo, and B-D. Liu, “Dual-Core Virtual Platform with QEMU and SystemC,” In The Proceedings of The IEEE International Symposium on Next-Generation Electronics, pp. 69-70, November 2010.
 L. B. and S. Sujatha, “Creating Virtual Platform for Cloud Computing,” In The Proceedings of The IEEE International Conference on Computational Intelligence and Computing Research, pp. 1-4, December 2010.
 M. A. El-Moursy, A. Sheirah, M. Safar, and A. Salem, “Efficient Embedded SoC Hardware/Software Codesign using Virtual Platform,” In The Proceedings of The International Design & Test Symposium, December 2014.
 M. Safar, A. Bakr, M. A. El-Moursy, and A. Salem, ”AUTOSAR Software Debug and Analysis using Virtual Platforms," In The Proceedings of The IEEE International Workshop on Automotive Reliability & Test, December 2016.
 C.-C. Wang, R.-P. Wong, J.-W. Lin, C.-H. Chen, System-level development and verification framework for high-performance system accelerator,” In The Proceedings of The International Symposium on VLSI Design, Automation and Test, pp. 359–36, April 2009.
 F. Mendoza, C. Kollner, J. Becker, and K. Muller-Glaser, “An Automated Approach to SystemC/Simulink Co-Simulation,” In The Proceedings of The IEEE International Symposium on Rapid System Prototyping, pp. 135–141, May 2011.
 F. Wawrzik, W. Chipman, J. Molina, and C. Grimm, “Modeling and Simulation of Cyber-Physical Systems with SICYPHOS,” In The Proceedings of The International Conference on Design and Technology of Integrated Systems in Nanoscale Era, pp. 1–6, April 2015.
 AUTOSAR (AUTomotive Open System ARchitecture). Available at: AUTOSAR.org
 Functional Mock-up Interface (FMI). Available at: fMI-Standard.org
 Mentor, A Siemens Business, Vista Architect®.
 MathWorks®, MATLAB/Simulink. Available at: Mathworks.com.
 TASS A Siemens Business, PreScan. Available at: Siemens.com.
 Vector CANoe, Vector.com
 Siemens PLM Software, Simcenter Amesim. Available at: PLM.Automation.Siemens.com.
This article was previously presented as a paper at DVCon US 2019.
Back to Top