Fix Float Art
Fix Float Art
1Introduction
Embedded System Lab Embedded System Lab
Design and Imp. of Algorithms
for Fixed-Point and Floating-Point Arith.
Embedded System
- 2 -
1Introduction
Embedded System Lab Embedded System Lab
Outline
Design of algorithms in fixed-point and floating-point
arithmetic
In the microcontroller onboard the ECU
Related to several basic issues that occur in the context of
design and implementation of machine-based arithmetic
- 3 -
1Introduction
Embedded System Lab Embedded System Lab
Binary number system
In all processors
In order to represent a number x, the coefficients a
i
of the
binary decomposition are used
Example: Binary notation of the number x = 9
After decomposition, the number x = 9
has the binary notation 1001.
Representation of Numbers in Processors
- 4 -
1Introduction
Embedded System Lab Embedded System Lab
Processors provide only a fixed finite number n of
binary positions.
Word length
It is determined by processor construction and can be
expanded to full multiples (e.g., 2n, 3n) of n.
Microprocessors with a word length of 8 positions
8-bit microprocessors
Those with a word length of 16 bits
16-bit microprocessors
Representation of Numbers in Digital Processors
- 5 -
1Introduction
Embedded System Lab Embedded System Lab
Two ways to use the word length of n positions to
represent a number.
In fixed-point representation
In floating-pint representation
Representation of Numbers in Digital Processors
- 6 -
1Introduction
Embedded System Lab Embedded System Lab
Fixed-Point Representation
Not only the number n, but also the numbers n
1
and n
2
of the positions before and after the decimal
point are fixed,
where n = n
1
+ n
2
In most cases, n
1
= n, or n
1
= 0.
To this day, the functions of many processors
deployed in ECUs are limited to the fixed-point
representation and processing of numbers.
- 7 -
1Introduction
Embedded System Lab Embedded System Lab
Fixed-Point Representation
We may assume n1 = n for fixed-point notation.
Then the number n determines the set of numbers
represented.
For example, for n = 8,
Numbers 0 through 255 can be represented
By 0000 0000 through 1111 1111.
8-bit unsigned integer notation, or uint8
Numbers 128 through +127 can be represented
By 1000 0000 through 0111 1111.
8-bit signed integer notation, or sint8
- 8 -
1Introduction
Embedded System Lab Embedded System Lab
Fixed-Point Representation
We may assume n1 = n for fixed-point notation.
Then the number n determines the set of numbers
represented.
Range of numbers for n = 16 and 32
uint16 ?
sint16 ?
unit32 ?
sint32 ?
- 9 -
1Introduction
Embedded System Lab Embedded System Lab
Fixed-Point Representation
Number of Binary Position Abbreviation Range
8-bit unsigned integer uint8 0 ~ 255
8-bit signed integer sint8 -128 ~ 127
16-bit unsigned integer uint16
16-bit signed integer sint16
32-bit unsigned integer uint32
32-bit signed integer sint32
- 10 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
The decimal point floats in accordance with the value
that a given number assumes.
A real number x can be expressed as the product of
with |a| < 1 and b as an integer.
The exponent b indicates the position of the
decimal point in the mantissa a.
- 11 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
The decimal point floats in accordance with the value
that a given number assumes.
Example: Binary representation of the number x = 9.5
produces binary notation 1001.1 or 0.10011 * 2
100
.
- 12 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
For the representation of mantissa a and exponent
b,
processors provide only a fixed finite number m and e of
binary positions, where n = m + e.
- 13 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
Depending on the requirements of the respective
application,
ECUs are equipped with microprocessors capable of
supporting floating-point operations.
But there is ALWAYS limitation in floating-point
representation.
- 14 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
Floating-point representations of a given number
are not necessarily unique.
9.5 = 0.010011 * 2
101
= 0.10011 * 2
100
For this reason, the floating-point notation of any
number for which the first digit of mantissa a is
unlike 0 (nonzero) is termed normalized.
In the binary system, |a| 2
1
applies.
Thus, all numbers of mantissa a, excluding the leading
zeros, are termed significant digits.
- 15 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
The numbers m and e, together with base B = 2 of
the notation, determine the set A of numbers that
can be accurately represented in the machine.
This set A comprises a subset of the real numbers R(A
R) .
The elements of which set A is composed are termed
machine numbers.
- 16 -
1Introduction
Embedded System Lab Embedded System Lab
Floating-Point Representation
For n = 32 and n = 64,
floating-point representations are defined in the
IEEE standard.
In a manner similar to fixed-point numbers, 32-bit and 64-
bit floating-point numbers are termed real32 and real64,
respectively.
- 17 -
1Introduction
Embedded System Lab Embedded System Lab
Representation of Numbers in Processors
The set A of the numbers available
for the rep. of fixed-point and floating point numbers
Finite set
Design and implementation of the behavior of a software
component
presents the immediate issue of how to approximate a given
number ( ) with a machine number.
This issue manifests itself
not only at the time of data entry in the computer,
but also during internal data handling in the processor.
- 18 -
1Introduction
Embedded System Lab Embedded System Lab
Representation of Numbers in Processors
Although ,
it may be possible that
- 19 -
1Introduction
Embedded System Lab Embedded System Lab
Representation of Numbers in Processors
App. for a number x ( ) by a machine number rd(x)
x is not a machine number
rd(x), gk: machine numbers (rd(x) gk)
rd(x): rounding of x
Schauffele
- 20 -
1Introduction
Embedded System Lab Embedded System Lab
Rounding Errors in Integer Division
Division for a, b, and c in uint8 notation
- 21 -
1Introduction
Embedded System Lab Embedded System Lab
is not an integer
Rounding is required
Representation of c = 9.5 in normal binary representation
Rounding Errors in Integer Division
- 22 -
1Introduction
Embedded System Lab Embedded System Lab
is not an integer
rd(9.5) = 10
1010B
Rounding
- 23 -
1Introduction
Embedded System Lab Embedded System Lab
Integer division in many processors produces a
simple truncation (i.e. round-off)
Gives rd(c) = 9, or 1001B for c = 9.5
Truncation
- 24 -
1Introduction
Embedded System Lab Embedded System Lab
rd(240/161) = rd(1.49 ) = 1
for both rounding and truncation of the decimal places
In this case, the relative rounding error
fairly large
It determines the accuracy of the result
Rounding Errors in Integer Division
- 25 -
1Introduction
Embedded System Lab Embedded System Lab
rd(100/201) = rd(0.49 ) = 0
for both rounding and truncation of the decimal places
Relative rounding error
Particular large
This case is especially critical for error propagation
e.g. when further processing the intermediate result in a
multiplication
Rounding Errors in Integer Division
- 26 -
1Introduction
Embedded System Lab Embedded System Lab
rd(100/1) = rd(100) = 100
rd(100/0)
Not defined
Exception handling
Rounding Errors in Integer Division
- 27 -
1Introduction
Embedded System Lab Embedded System Lab
For c > 1,
the relative rounding error
i.e. rd(c) can be rep. as
The relative error becomes smaller as the result increases.
Relative Rounding Errors
- 28 -
1Introduction
Embedded System Lab Embedded System Lab
For c > 1,
the relative truncation error
i.e. rd(c) can be rep. as
The relative error becomes smaller as the result increases.
Relative Truncation Errors
- 29 -
1Introduction
Embedded System Lab Embedded System Lab
(Fixed-point integer rep) Machine number operands
Results of a + b, a b, and a * b
integer values
A rounding error does not occur.
Because of the finite number n of binary positions,
there are always numbers that are not machine
numbers.
Overflow and Underflow in Add, Sub, and Mul
- 30 -
1Introduction
Embedded System Lab Embedded System Lab
Addition Example:
Variables a, b, and c of uint8 notation
Addition with
Test case 2 gives us overflow example.
How a microprocessor does detect this?
Overflow and Underflow in Add, Sub, and Mul
- 31 -
1Introduction
Embedded System Lab Embedded System Lab
Addition Example:
Variables a, b, and c of sint8 notation
Addition with
Overflow example?
How detect?
Overflow and Underflow in Add, Sub, and Mul
- 32 -
1Introduction
Embedded System Lab Embedded System Lab
Subtraction Example:
Variables a, b, and c of uint8 notation
Addition with
Test case 4 gives us underflow (overflow) example.
How a microprocessor does detect this?
Overflow and Underflow in Add, Sub, and Mul
- 33 -
1Introduction
Embedded System Lab Embedded System Lab
Subtraction Example:
Variables a, b, and c of sint8 notation
Addition with
Overflow example?
How detect?
Overflow and Underflow in Add, Sub, and Mul
- 34 -
1Introduction
Embedded System Lab Embedded System Lab
Similar situations may occur in conjunction with
multiplications.
Overflow and Underflow in Add, Sub, and Mul
- 35 -
1Introduction
Embedded System Lab Embedded System Lab
The implementation in floating-point arithmetic is
another area in which errors in the input data as well as
approximation errors have such an effect on the
selected calculation modes.
However, when compared with fixed-point arithmetic,
the rounding errors occurring in floating-point integers
and floating-point arithmetic are smaller by several
orders of magnitude.
Overflow and Underflow in Add, Sub, and Mul
- 36 -
1Introduction
Embedded System Lab Embedded System Lab
Binary representation in the processor
If the operand b is in the set ,
a*b and a/b may be handled quite efficiently by means of shift
operations .
Shift Operations
- 37 -
1Introduction
Embedded System Lab Embedded System Lab
Example:
Decimal number x = 9
binary notation 01001
Shift Operations
- 38 -
1Introduction
Embedded System Lab Embedded System Lab
Example:
Decimal number x = 9
binary notation 01001
Product of 9 * 2
a left-shift operation 010011 10010 (decimal 18)
Shift Operations
- 39 -
1Introduction
Embedded System Lab Embedded System Lab
Example:
Decimal number x = 9
binary notation 01001
Division 9/2
a right-shift operation 010011 00100 (decimal 4)
may cause the decimal positions to be truncated.
Shift Operations
- 40 -
1Introduction
Embedded System Lab Embedded System Lab
Shift in signed integers ?
Logical Shift & Arithmetic Shift
Overflow check
Shift Operations
- 41 -
1Introduction
Embedded System Lab Embedded System Lab
The actions taken in the event of a value range
violation due to overflow or underflow depend on the
processor.
Each algorithm may provide different responses.
Handling Overflows and Underflows
- 42 -
1Introduction
Embedded System Lab Embedded System Lab
Some options for overflow handling
Overflow with or without overflow detection
Limiting the result
Extending the value range of the result
Rescaling the result
Example: Overflow handling
Variables a, b, and c in uint8 notation.
Addition with
Handling Overflows and Underflows
- 43 -
1Introduction
Embedded System Lab Embedded System Lab
Overflow is permitted.
Most microprocessors output
A compare operation can be
used to detect and handle an overflow of unsigned
integers in the algorithm.
Carry in unit and Overflow in sint?
Overflow with or without Overflow Detection
- 44 -
1Introduction
Embedded System Lab Embedded System Lab
The overflow is recognized in the algorithm
The result c is limited to the max representable value c
= 255.
Limiting The Result
- 45 -
1Introduction
Embedded System Lab Embedded System Lab
The result c is represented in a variable with extended
value range (e.g., in a uint16 or sint16 variable).
Thus,
and
or
An overflow can no longer occur.
In the event that c is represented as a variable of the
sint16 type, an underflow can no longer occur in a
subtraction also.
Extending The Value Range of The Result
- 46 -
1Introduction
Embedded System Lab Embedded System Lab
The overflow is recognized, and the result c is rescaled
to rd(c) .
To do this, a quantification or resolution q for c at |q| > 1
is introduced.
By rescaling the result c to the equation c = q * rd(c) ,
the value range of c can be extended, and overflow no
longer occurs.
Rescaling The Result
- 47 -
1Introduction
Embedded System Lab Embedded System Lab
Rescaling The Result
Rescaling with factors q
from the set
can be realized by means of shift operations.
Thus,
where
- 48 -
1Introduction
Embedded System Lab Embedded System Lab
An overflow can no longer occur.
On the downside, the accuracy of the result rd(c) = 256 is
reduced.
The relative error is as follows:
As in a previous example, the relative error decreases as
the size of the result increases.
Rescaling The Result
- 49 -
1Introduction
Embedded System Lab Embedded System Lab
Errors propagate within a given algorithm.
Algorithm
clearly defined sequence of a finite number of simple
operations
which can be used to produce the solution to a problem through
the calculation of specific input data.
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 50 -
1Introduction
Embedded System Lab Embedded System Lab
Example: d = a + b + c
d = (a + b) + c and d = a + (b + c)
mathematically equivalent
may produce divergent results due to numerical reasons in fixed-
point calculation.
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 51 -
1Introduction
Embedded System Lab Embedded System Lab
a, b, c, d in sint8
Algorithm 1:
Algorithm 2:
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 52 -
1Introduction
Embedded System Lab Embedded System Lab
For a = 101, b = 51, and c = 100,
The propagation of rounding and limitation errors
is an essential factor.
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 53 -
1Introduction
Embedded System Lab Embedded System Lab
In fixed-point calculation,
an approx. value rd(d) is obtained instead of d.
For Algorithm 1,
rd
1
(d) can be determined:
The relative error
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 54 -
1Introduction
Embedded System Lab Embedded System Lab
As the first approx., when disregarding higher order
terms such as
In Algorithm 1
In Algorithm 2
The rounding errors of the intermediate results
affect the relative error
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 55 -
1Introduction
Embedded System Lab Embedded System Lab
Critical factor
and
Depending on whether (a+b) or (b+c) is smaller,
numerically more stable to calculate the sum a+b+c
(a+b)+c or
a + (b+c)
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 56 -
1Introduction
Embedded System Lab Embedded System Lab
For a = 101, b = 51, and c = 100,
a + b = 50 and b + c = 151
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 57 -
1Introduction
Embedded System Lab Embedded System Lab
Algo 1 and 2 for a = 101, b = 51, and c = 100
Algo 2
The relative error of Step 1 enters the result with an
amplification factor of 3
Step 2 is executed without a relative error.
This explains why Algo1, considering the input values of this
test case, is more beneficial in numerical terms.
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 58 -
1Introduction
Embedded System Lab Embedded System Lab
Algo 3
Rescaling and not limiting the intermediate result in Algo
2 of the preceding example by a factor of 2
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 59 -
1Introduction
Embedded System Lab Embedded System Lab
Algo 3
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 60 -
1Introduction
Embedded System Lab Embedded System Lab
Algo 3
With these input values, the selected rescaling produces a
much more accurate result than Algorithm 2 with a limitation of
the intermediate result.
Limitations of this type must be watched closely because they
may implicitly occur in algorithms (e.g., through the transfer of
arguments in conjunction with subprogram calls).
Error Propagation
with Algorithms in Fixed-Point Arithmetic
- 61 -
1Introduction
Embedded System Lab Embedded System Lab
Two physical signals in the microprocessor with
different scaling must be handled in an arithmetical
operation.
Example: Addition of two signals of different scaling
Addition of the two signals a and b
Implementation of the physical relation c
phys
= a
phys
+ b
phys
.
In the microprocessor, the signals a, b, and c are available in
the form of fixed-point variables a
imp1
, b
imp1
, and c
imp1
in uint8
representation.
Physical Interrelation and Fixed-Point Arithmetic
- 62 -
1Introduction
Embedded System Lab Embedded System Lab
Interrelation btw A Physical Variable and Imp
<Schauffele>
- 63 -
1Introduction
Embedded System Lab Embedded System Lab
The interrelation btw the physical continuous variables
and the imp variables in discrete fixed-point notation
is specified by a linear formula and by the lower and
upper limits.
The value range of a
imp1
in uint8: {0, 1, 2,
, 255}
Or the general value range {a
imp1 MIN
, , a
imp1 MAX
}.
Physical Interrelation and Fixed-Point Arithmetic
- 64 -
1Introduction
Embedded System Lab Embedded System Lab
Accordingly, this example yields the upper and lower
limits for the physically representable value range:
The range of physically occurring values
{a
physmin
a
physmax
}
Different from { a
physMIN
a
physMAX
}
Physical Interrelation and Fixed-Point Arithmetic
- 65 -
1Introduction
Embedded System Lab Embedded System Lab
Similar interrelations apply to the variables b and c.
For the linear range, the following applies:
Because of only fixed-point values at the imp level,
each case requires a rounding
1/K
1i
is also termed a quantization or resolution
K
0i
is known as offset.
Physical Interrelation and Fixed-Point Arithmetic
- 66 -
1Introduction
Embedded System Lab Embedded System Lab
The addition of the physical variables at the imp level
can be accomplished with the following algorithm:
Step 1: Removing offset from a
imp1
and b
imp1
Step 2: Approx. quantization of a
imp1_1
and b
imp1_1
Physical Interrelation and Fixed-Point Arithmetic
- 67 -
1Introduction
Embedded System Lab Embedded System Lab
Step 3: Addition
Step 4: Approx. quantization of c
imp1
Step 5: Allowing for offset of c
imp1
Physical Interrelation and Fixed-Point Arithmetic
c
_
= a
_
+b
_
c
_
= c
_
- 68 -
1Introduction
Embedded System Lab Embedded System Lab
At the physical level of a model, a differentiation may
be made between continuous-value, discrete-value,
and Boolean variables:
Continuous-value variables
physical signals of continuous value
temperatures, revolutions per minute, or pressures
Value-discrete variables
natural variables
the number of cylinders in an engine
the number of stages (shift levels) in a transmission
Boolean variables describe state pairs
a switch position
On/Off, High/Low, TRUE/FALSE
Physical Model Level and Imp Level
- 69 -
1Introduction
Embedded System Lab Embedded System Lab
If a continuous-value variable is to be implemented in
fixed-point representation, it first must be discretized.
For this reason, this aspect of value discretization often gains
central significance in data modeling.
Each physical value X
phys
must be assigned exactly one
discrete implementation value that is unique and
unambiguous.
Physical Model Level and Imp Level
- 70 -
1Introduction
Embedded System Lab Embedded System Lab
The relative error is the determining quality factor for
the result produced by an algorithm.
Integer divisions, as well as overflow and underflow
handling, limit the numerical accuracy.
Notes on Imp in Fixed-Point Arithmetic
- 71 -
1Introduction
Embedded System Lab Embedded System Lab
Because the relative error in integer divisions is large,
every effort should be made to avoid their utilization.
Divisions by 0 (zero) are not defined and therefore
must be handled as an exception.
Divisions by {2
1
, 2
2
, , 2
n
}
by using shift operations.
Useful Pointers on Integer Divisions
- 72 -
1Introduction
Embedded System Lab Embedded System Lab
For necessary divisions,
the division operations should occur as late in the
algorithm as possible.
In this way, the relative error enters the result only at a very late
stage.
Useful Pointers on Integer Divisions
- 73 -
1Introduction
Embedded System Lab Embedded System Lab
The larger the result of the integer division, the
smaller the relative error.
If possible, the value of the numerator should be
considerably larger than that of the denominator.
This may be accomplished by defining an offset or through a
requantization by means of a shift operation prior to the actual
division.
Useful Pointers on Integer Divisions
- 74 -
1Introduction
Embedded System Lab Embedded System Lab
a
imp1
, temp in uint16, b
imp1
, c
imp1
in uint8
Physical values a
phys
= 79, b
phys
= 5
The exact value of c
phys
would be
Calculation of Division c = a/b
- 75 -
1Introduction
Embedded System Lab Embedded System Lab
The conversion formulas
Value range
Calculation of Division c = a/b
- 76 -
1Introduction
Embedded System Lab Embedded System Lab
Step 1
Shift operation by 8 places for a
imp1
to take advantage of
the full 16-bit value range
Algo. for Calculation of Division c = a/b
- 77 -
1Introduction
Embedded System Lab Embedded System Lab
Step 2
Executing the actual integer division
For ,
The equivalent of 15.7968
* 2
8
.
Compared with the integer division ,
rescaling the variable temp aids in obtaining significantly higher
accuracy.
Algo. for Calculation of Division c = a/b
- 78 -
1Introduction
Embedded System Lab Embedded System Lab
Step 3:
Rescaling the result by 8 decimal places
The variable temp must be rescaled to the scale of c
imp1
:
This causes a relative error and loss of accuracy.
Therefore, this step should be inserted in the algorithm at the
latest possible time.
From this point onward, any calculating steps should use the
more accurate intermediate temp variable.
Algo. for Calculation of Division c = a/b
- 79 -
1Introduction
Embedded System Lab Embedded System Lab
Overflow and underflow handling limit the
accuracy of additions, subtractions, and
multiplications.
Several strategies for overflow and underflow
handling are available.
Rescaling
Limitation
Extension of the value range by means of type
conversion
Permitting overflow or underflow with or without
detection and response in the algorithm
Useful Pointers on Add, Sub, and Mult
- 80 -
1Introduction
Embedded System Lab Embedded System Lab
Rescaling the value range reduces the relative
accuracy across the entire value range, even if
overflow or underflow does not occur.
Limiting the value range causes a drop in relative
accuracy only if an overflow or underflow occurs.
Useful Pointers on Add, Sub, and Mult
- 81 -
1Introduction
Embedded System Lab Embedded System Lab
Converting physical signal to imp variables
the offset can be set in such a way that the calculations
at the implementation level occur in the middle of the
chosen value range.
This also aids the in-processor representation using a shorter
word length.
However, offsets may cause additional conversion operations
when linking different signals.
Useful Pointers on Add, Sub, and Mult
- 82 -
1Introduction
Embedded System Lab Embedded System Lab
Multiplications and divisions using values from the
set {2
1
, 2
2
, , 2
n
}
By shift operations
Logical shift and Arithmetic shift
Unsigned and Signed numbers
Useful Pointers on Add, Sub, and Mult
- 83 -
1Introduction
Embedded System Lab Embedded System Lab
Even with accurately executed operations such as
additions, subtractions, and multiplications,
a relative error in the input variables may quickly become
amplified.
Useful Pointers on error Propagation
- 84 -
1Introduction
Embedded System Lab Embedded System Lab
The machine number set A is finite for floating-point
numbers.
Rounding errors in the arithmetical operations
Associative and distributive laws do not apply here
because the exact arithmetical operations are approximated by
floating-point operations
Notes on Imp in Floating-Point Arith
- 85 -
1Introduction
Embedded System Lab Embedded System Lab
Not all numerical problems are solved by means of
floating-point arithmetic.
The adv of larger numerical value range
Reduction of the influence of numerical rounding errors as well
as overflows and underflows
Scaling of physical variablesa frequent source of error in the
implementation in integer arithmeticis not required.
Notes on Imp in Floating-Point Arith
- 86 -
1Introduction
Embedded System Lab Embedded System Lab
Disadv of higher numerical accuracy
greater word length Increased memory and runtime
In a preemptive arbitration strategy,
backing up and restoring floating-point data may have a
significant influence on runtime in real-time systems.
Notes on Imp in Floating-Point Arith
- 87 -
1Introduction
Embedded System Lab Embedded System Lab
Thus, a solution of combining fixed-point and floating-
point arith is used for many applications.
An awareness and understanding of general numerical
methods is essential in solving problems:
Conversion of fixed-point numbers to floating-point
numbers, and vice versa
Handling division by zero conditions
Propagation of approximation errors that may be
generated by filter and integration algorithms
Propagation of rounding errors
Notes on Imp in Floating-Point Arith
- 88 -
1Introduction
Embedded System Lab Embedded System Lab
Compare operations of two floating-point numbers
a and b should be avoided in many cases.
Instead, compare the diff =|a b| vis--vis a
barrier ,
which also requires consideration of the relative
accuracy (e.g., in the form of = |a * | or = |b * | ).
Divisions by 0 (zero) must be excluded by means
of conditions and queries.
Useful Pointers on Compare and Div Operations
- 89 -
1Introduction
Embedded System Lab Embedded System Lab
The optimizations for production ECUs depend on
the application
the hardware platform
Thus, close cooperation is necessary btw
fct developer responsible for the model-based physical
specification
SW engineer in charge of the design and implementation
Modeling and Imp Guidelines
- 90 -
1Introduction
Embedded System Lab Embedded System Lab
Modeling and imp guidelines are vital prerequisites for
dedicated optimization measures.
The function model must facilitate the explicit
specification of all software relevant information
without unnecessarily impeding physical
understanding.
Example of modeling guidelines
MSR(Manufacturer Supplier Relationship) standards
Example of imp guidelines
MISRA(Motor Industry SW Reliability Association) Guidelines
Modeling and Imp Guidelines
- 91 -
1Introduction
Embedded System Lab Embedded System Lab
MISRA(Motor Industry Sw Reliability Asso.)
MISRA
An organization that produces guidelines for the SW
developed for electronic components used in Automotive
Industry.
It is a collaboration between vehicle manufacturers,
component suppliers, and engineering consultancies.
Aim
To provide important advice to the automotive industry for the
creation and application of safe, reliable SW within vehicles.
The safety requirements of the SW used in Automobiles is
different from that of other areas.
Reliability and cost
- 92 -
1Introduction
Embedded System Lab Embedded System Lab
MISRA(Motor Industry Sw Reliability Asso.)
Formation
MISRA was formed by a consortium of organizations formed in
response to the UK Safety Critical Systems REsearch
Programme.
This programme was supported by the Department of Trade and
Industry and the Engineering and Physical Sciences Research
Council.
MISRA steering committee
AB Automotive Electronics Ltd, Ford Motor Company Ltd
Jaguar Cars Ltd, Lotus Engineering
MIRA Ltd, Ricardo UK Ltd
TRW Automotive Electronics, The University of Leeds
Visteon
- 93 -
1Introduction
Embedded System Lab Embedded System Lab
MISRA(Motor Industry Sw Reliability Asso.)
The Guidelines
MISRA guidelines are the development guidelines for vehicle
based SW.
The guidelines are intended to achieve the following.
Ensure Safety
Bring in robustness, reliability to the SW.
Human safety must take precedence when in conflict with
security of property.
Consider both random and systematic faults in system design.
Demonstrate robustness, not just rely on the absence of
failures.
Application of safety considerations across the design,
manufacture, operation, servicing and disposal of products.
- 94 -
1Introduction
Embedded System Lab Embedded System Lab
MISRA C
First published in 1998
To provide a "restricted subset of a standardized
structured language" as required in the 1994 MISRA
Guidelines for automotive systems being developed to
meet the requirements of Safety Integrity Level (SIL) 2
and above.
Since its launch in 1998, the uptake and usage of
MISRA C has far exceeded the authors' original
expectations.
- 95 -
1Introduction
Embedded System Lab Embedded System Lab
MISRA C
MISRA C was originally developed to support the
language requirements of the 1994 MISRA Guidelines.
Since that time, however, MISRA C has been adopted
and used across a wide variety of industries and
applications including the rail, aerospace, military and
medical sectors.
Furthermore, a significant number of tools are
available that support enforcing the MISRA C rules.
In Japan, a Japanese translation of MISRA C has been
published by JSAE, and the MISRA C Study Group have
produced a book (in Japanese) giving detailed explanations of
the rules and additional code examples.
- 96 -
1Introduction
Embedded System Lab Embedded System Lab
MISRA C
Updated in 2004
Rules (required) & advisories covering 21 areas:
Areas addressed include: language extensions, pointer type
conversions, control flow, and standard libraries
Total of 122 rules + 20 advisories
Example rule: (6.2) Signed and unsigned char shall only be
used for the storage and use of numeric values.
Some compliance checks can be automated
TIs TMS470/TMS570 C/C++ compiler will check 70% of the
rules
Remaining rules require manual checks
- 97 -
1Introduction
Embedded System Lab Embedded System Lab
The separation btw specification and design facilitates
the porting to new hardware platforms.
In a best-case scenario, only the adaptation of the hardware-
specific design decisions will be required to accomplish this.
Modeling and Imp Guidelines
- 98 -
1Introduction
Embedded System Lab Embedded System Lab
The consistency of specification and design represents
a basic problem in function development.
A variety of data and behavioral modeling tools support these
design steps.
Tools also facilitate the definition of guidelines in the
form of libraries of graphical modeling blocks, scaling
recommendations, and naming conventions for
variables, as well as formula libraries, data structures,
and interpolation routines for characteristic curves and
maps, memory segmentation, and so forth.
Modeling and Imp Guidelines
- 99 -
1Introduction
Embedded System Lab Embedded System Lab
References
J. Schauffele and T. Zurawka, Automotive Software Engineering: Principles, Processes,
Methods, and Tools, 2003.