Floating-point numbers represent values using sign, exponent, and mantissa. This allows a wide dynamic range and high precision.
Fixed-point numbers represent values using a fixed number of bits with an implied scaling factor.
| Fixed-Point | Floating-Point |
|---|---|
| Faster execution | Higher precision |
| Lower memory usage | Higher computational cost |
| Suitable for embedded systems | Suitable for complex calculations |
Automotive Example:
Motor current control implemented using fixed-point arithmetic in an ECU.
Fixed-point arithmetic is preferred because:
- ECUs have limited computational resources
- Many microcontrollers lack hardware floating-point units
- Fixed-point operations execute faster
Automotive Example:
Engine control algorithms running on low-cost microcontrollers.
Scaling defines how integer values represent fractional numbers.
Formula:
Value = Integer × ScaleFactor
Automotive Example:
Representing motor current with fixed-point values.
Quantization error occurs when continuous values are approximated by discrete fixed-point values.
Automotive Example:
Quantization error in sensor signal processing.
Overflow occurs when a calculated value exceeds the representable range.
Automotive Example:
Motor torque calculation exceeding data type limits.
Underflow occurs when values are too small to be represented accurately.
Automotive Example:
Very small sensor values lost during scaling.
Word length is the number of bits used to represent the number.
| Common Word Lengths |
|---|
| 8-bit |
| 16-bit |
| 32-bit |
Automotive Example:
16-bit signals in motor control algorithms.
Fraction length determines how many bits represent fractional values.
Automotive Example:
High-resolution torque calculation.
Dynamic range defines the range between smallest and largest representable numbers.
Automotive Example:
Sensor signals with wide dynamic range.
Precision defines how accurately numbers can be represented.
Automotive Example:
Precise vehicle dynamics calculations.
Fixed-point conversion converts floating-point models into fixed-point representations for embedded implementation.
Automotive Example:
Converting motor control algorithm to fixed-point.
Autoscaling automatically determines optimal scaling factors based on simulation data.
Automotive Example:
Autoscaling engine torque calculation signals.
Fixed-Point Advisor helps:
- Convert floating-point models
- Analyze numerical behavior
- Optimize scaling
Automotive Example:
Preparing model for ECU deployment.
An FPU is a processor component designed to execute floating-point operations efficiently.
Automotive Example:
High-performance ADAS processors.
Floating-point should be used when:
- High precision required
- Dynamic range is large
- Processor supports FPU
Automotive Example:
ADAS perception algorithms.
Saturation limits values within maximum and minimum representable range.
Automotive Example:
Throttle command limiting.
Wrap-around overflow occurs when exceeding limits causes the value to wrap around.
Automotive Example:
Negative torque value due to overflow.
Resolution is the smallest representable change in value.
Automotive Example:
High-precision sensor readings.
Numeric stability ensures calculations remain accurate despite rounding errors.
Automotive Example:
PID controller implementation.
Bit growth occurs when arithmetic operations require additional bits to represent the result.
Automotive Example:
Multiplication of fixed-point numbers.
Multiplication requires adjusting scaling to maintain the correct numeric value.
Automotive Example:
Torque computation from current and flux.
Rounding modes include:
- Round to nearest
- Floor
- Ceiling
- Truncation
Automotive Example:
Sensor data processing.
Mismatch occurs when floating-point simulation differs from fixed-point code behavior.
Automotive Example:
Different torque values in simulation vs ECU.
Fixed-point simulation replicates embedded behavior during model simulation.
Automotive Example:
Testing motor control algorithm.
Range analysis determines the minimum and maximum values signals can take.
Automotive Example:
Determining signal ranges in engine control.
Floating-point numbers cannot represent some decimal values exactly, leading to small precision errors.
Automotive Example:
Accumulated errors in integration calculations.
Mixed precision uses both fixed-point and floating-point operations within a system.
Automotive Example:
Sensor fusion algorithms.
Floating-point operations require more processing cycles than fixed-point operations on processors without FPUs.
Automotive Example:
High-frequency control loops.
Validation ensures that the fixed-point implementation behaves similarly to the original floating-point model.
Automotive Example:
SIL testing after fixed-point conversion.
Best practices include:
- Analyze dynamic range
- Consider processor capability
- Evaluate computational cost
- Validate numerical accuracy
Automotive Example:
Floating-point used in ADAS perception ECUs.