Development of Elementary Mathematics Functions in an Avionics Context
Total Page:16
File Type:pdf, Size:1020Kb
Fakultät für Maschinenwesen Lehrstuhl für Flugsystemdynamik Development of Elementary Mathematics Functions in an Avionics Context Dipl.-Ing. Kajetan Nürnberger Vollständiger Abdruck der von der Fakultät für Maschinenwesen der Technischen Universität München zur Erlangung des akademischen Grades eines Doktor-Ingenieurs (Dr.-Ing.) genehmigten Dissertation. Vorsitzender: Prof. Dr.-Ing. Manfred Hajek Prüfer der Dissertation: 1. Prof. Dr.-Ing. Florian Holzapfel 2. Prof. Dr. Marco Caccamo Die Dissertation wurde am 12.04.2019 bei der Technischen Universität München eingereicht und durch die Fakultät für Maschinenwesen am 29.09.2019 angenommen. Acknowledgement This thesis is the final output after working for five years at the Institute of Flight System Dynamics at TU Munich plus some long evenings after leaving the university. The time at the institute was one of the most inspiring times of my life. I did not only gain many new insights in the area of my research, but also in many related fields as handling of projects or communicating in complex organizations. Although working at the institute was a really interesting and often quite funny time, there were also parts that were challenging. Without the support of various people, writing this thesis would not have been possible. Therefore, I would like to express my gratitude to all of these here. First of all, I would like to thank Professor Florian Holzapfel. He gave me the chance to work at the institute on really interesting technology. During the time at the institute, I had the chance to gain insights into different research fields. I appreciate a lot that Florian gave me the possibility to freely decide on the research area this thesis is dealing with. A big thank you to all my colleagues at the institute who contributed to the flight control model which served as a real-world example for the research work presented in this thesis. Special thanks to our coffee group at various locations. During the coffee breaks, several interesting discussions took place. In case I was suck at a problem, this brake gave the necessary distraction. Really important for me is that during the time at the institute, I met a lot of new colleagues who became good friends in the meantime. I would like to express my gratitude to Professor Marco Caccamo for taking the task of the second examiner shortly after he joined TU Munich. Thanks also to Professor Manfred Hajek who acted as the chairman of the committee after the original chairman has left the TU Munich. Thanks to everyone who gave comments on the work which showed me the right spots where further improvement was necessary. Finally, I want to thank my family who always supported me during the time the thesis was constructed. Without their support, it would not have been possible to finalize the thesis. Page iii Abstract Model based development approaches enable an early test of the developed algorithm in a simulation environment. To get the system to the actual target platform, auto code generation can be used. As the auto generated code relies on external components, the target behavior can deviate from the behavior in the simulation, although the automatically generated code does not contain any error. This problem is addressed in this thesis for a flight control system where the external components are elementary math functions. The main challenges addressed during the development of the math functions are an efficient execution and a formal verification of the algorithms. The efficient implementation can reduce the overall latency of the control loop and, therefore, lead to a better overall performance. The formal verification mainly addresses the precision of the implementation. Many available library implementations lack of such a precision proof. In case it is available the goal is to show the accuracy up to the last bit, which is not desired for an embedded system. To reach the goal of an efficient formally verified implementation, the input ranges of the elementary math functions are adapted. This is motivated based on functional considerations and verified by a runtime error analysis of the integrated software. In order to successfully execute this analysis with no false alarms, the elementary math functions are replaced by specific stubs in the analysis. These stubs abstract the behavior of the original function in a way that sound result with a low number of false alarms is achieved in the runtime error analysis. The validity of all properties of the stubs are shown via formal proofs along with the verification of the reached precision. In order to reach a high precision in an efficient manner advanced polynomial approximations are used and executed using double precision floating-point arithmetic. To ensure the portability between the target and the development host architecture, hardware specific functions are omitted. In case it is not possible to omit functions custom to the hardware, these are captured in a separate abstraction layer to ensure an easy portability. Approximations are given for the trigonometric functions, the square root and the power function with integer exponents. The proposed algorithms can completely be implemented on any processor supporting double precision floating-point arithmetic, as they do not rely on special hardware features. Different approximation methods are evaluated and the actually selected implementation is based on the worst case execution time. To determine the worst case timing a static analysis method is used. As the analysis during the early development phase is limited to a small function of the overall software, it is assumed that the function is available in the cache memory for the analysis. The validity of this assumption is later shown in an execution time analysis of the complete software. Here it is shown that locking the elementary math functions to the cache statically brings a benefit of the analyzed worst case time and the measured maximum and average execution time. With the use of the WCET analysis results further parts of the software can be identified as candidates for a cache locking. By statically locking these parts, the WCET, the measured maximum and average execution time can be further reduced. Page v Contents and Lists Table of Contents List of Figures ........................................................................................................................ xi List of Tables ....................................................................................................................... xiii List of Acronyms ................................................................................................................... xv List of Symbols ................................................................................................................... xvii 1 Introduction .................................................................................................................... 1 1.1 Motivation and Background ..................................................................................... 1 1.2 State of the Art ........................................................................................................ 5 1.3 Objectives ............................................................................................................... 9 1.4 Contributions ..........................................................................................................10 1.5 Outline ....................................................................................................................11 2 Fundamentals ...............................................................................................................13 2.1 Nomenclature .........................................................................................................13 2.2 Floating-Point Arithmetic ........................................................................................14 2.3 Worst Case Execution Time ...................................................................................17 3 Demonstration Environment Description .......................................................................21 3.1 Flight Control Computer Hardware Overview .........................................................21 3.2 Application Software Overview ...............................................................................22 3.3 Model-Based Development Approach ....................................................................23 3.4 Base Software ........................................................................................................25 3.5 Software Statistics ..................................................................................................26 4 Library Development Process........................................................................................29 4.1 Workflow ................................................................................................................29 4.2 Architecture and Implementation Considerations ...................................................35 4.3 Relation to Certification Aspects .............................................................................38 5 Trigonometric Functions ................................................................................................41 5.1 Sine and Cosine .....................................................................................................41 5.1.1 Input Restrictions ............................................................................................41