Addressing Fixed Point Design Challenges Manohar Reddy M Application Engineer MathWorks India Manohar.Reddy@mathworks.in 2015 The MathWorks, Inc. 1
Fixed Point Design Challenges Consideration Floating Point Fixed Point Fixed Point with MathWorks Tools RAM Consumption Execution Speed Hardware Power Consumption Embedded Hardware Cost Development Time Implementation Complexity Error Prone 2
Fixed-Point Concepts What is Fixed-Point? Fixed-Point Arithmetic Fixed-Point Targets Introducing Fixed-Point Designer Fixed-Point Designer Tools Floating-Point to Fixed-Point Conversion Workflows Using the Fixed-Point Tool in Simulink Using the Fixed-Point Converter App in MATLAB Code Generation from Fixed-Point Design C/HDL 3
Fixed-Point Concepts What is Fixed-Point? Fixed-Point Arithmetic Fixed-Point Targets Introducing Fixed-Point Designer Fixed-Point Designer Tools Floating-Point to Fixed-Point Conversion Workflows Using the Fixed-Point Tool in Simulink Using the Fixed-Point Converter App in MATLAB Code Generation from Fixed-Point Design C/HDL 4
What is Fixed Point? Floating-point: Sign bit Exponent Width Range Mantissa / Fraction bits Precision Floating Radix / Decimal Point Same word size, we can increase both precision and range IEEE 754 single-precision binary floating-point format: binary32* Fixed-point: Sign bit Whole Number Part Range Fractional Part Precision Fixed Radix / Decimal Point Fixed size, Trade-off between Precision and Range *Picture from http://en.wikipedia.org/wiki/single_precision_floating-point_format 5
Fixed Point Arithmetic 6 6.8 x 10 = 68 9 + + + 3 3.4 x 10 = 34 102 10 = 10.2 6
Example: Fixed-Point C hand implementation void differentialeq( void ) { /* Implements a fixed point first order difference equation */ int Prod; long Accum; static short lastval=0; short a=0x7eb8; // 0.99 in s16,15 short oneminusa=0x0148; //.01 in s16,15 short temp; Convert variables to integer types Need lots of comments to understand code Prod = galg_in1 * galg_in1; temp = Prod >> 15; Accum = a*lastval + oneminusa*temp; Keep track of binary point location } galg_out1 = (short)(accum >> 15); lastval = galg_out1; 7
Weinmann Develops Life-Saving Transport Ventilator Using Model-Based Design Challenge Develop embedded software for an advanced emergency and hospital transport ventilator Solution Use MATLAB and Simulink for Model-Based Design to model and simulate the controller, generate production code, and streamline compliance certification Results Code development and reviews accelerated by 50% Dozens of design alternatives explored 60% of core design reused Link to user story Modeling, simulating, and implementing the ventilator s embedded software with Simulink greatly simplified compliance certification. The model helped ensure a structured development process and provided thorough documentation and a visual representation of the system for the certification review. The MEDUMAT Transport ventilator Image Weinmann Medical Technology Dr. Florian Dietz Weinmann 8
Fixed-Point Concepts What is Fixed-Point? Fixed-Point Arithmetic Fixed-Point Targets Introducing Fixed-Point Designer Fixed-Point Designer Tools Floating-Point to Fixed-Point Conversion Workflows Using the Fixed-Point Tool in Simulink Using the Fixed-Point Converter App in MATLAB Code Generation from Fixed-Point Design C/HDL 9
Fixed Point ECU Development Process with Model-Based Design System Requirements Simulation System Design Rapid Prototyping Hardware-in-the-Loop Testing Processor-in-the-Loop Testing Vehicle Integration & Calibration Hardware/Software Integration Software Design Software Integration On-Target Rapid Prototyping Software-in-the-Loop Testing Coding Production Code Generation Requirements Traceability Configuration Management Documentation 10
Fixed Point ECU Development Using MathWorks Tools MATLAB / SIMULINK Algorithm Design FIXED-POINT DESIGNER Fixed-Point Conversion MATLAB CODER SIMULINK CODER EMBEDDED CODER HDL CODER Gen Gen C/C++ VHDL/Verilog FPGA MCU ASIC DSP FPGA ASIC 11
Tools for Converting a Design to Fixed Point Fixed-Point Tool for Simulink Requires: Works on: Fixed-Point Designer Simulink Simulink Blocks Stateflow Charts Fixed-Point Converter App for MATLAB Requires: Works on: Fixed-Point Designer MATLAB MATLAB Code 12
Fixed-Point Concepts What is Fixed-Point? Fixed-Point Arithmetic Fixed-Point Targets Introducing Fixed-Point Designer Fixed-Point Designer Tools Floating-Point to Fixed-Point Conversion Workflows Using the Fixed-Point Tool in Simulink Using the Fixed-Point Converter App in MATLAB Code Generation from Fixed-Point Design C/HDL 13
Workflow using Fixed-Point Tool in Simulink: Prepare for Fixed-Point Conversion Collect Range Information Propose Data types Apply Data types Compare Results Generate Code 14
Workflow using Fixed-Point Converter App in MATLAB: Prepare for Fixed-Point Conversion Collect Range Information Propose Data types Generate Fixed-Point MATLAB Code Test Numerics Generate Code 15
Fixed-Point Concepts What is Fixed-Point? Fixed-Point Arithmetic Fixed-Point Targets Introducing Fixed-Point Designer Fixed-Point Designer Tools Floating-Point to Fixed-Point Conversion Workflows Using the Fixed-Point Tool in Simulink Using the Fixed-Point Converter App in MATLAB Code Generation from Fixed-Point Design C/HDL 16
Code Generation Automatically generate readable C/HDL code Automatically generate C/HDL code from MATLAB/Simulink/Stateflow 17
Summary Fixed-Point Designer Conversion Workflow MATLAB Simulink Code Generation C/HDL Gen MATLAB / SIMULINK Algorithm Design FIXED-POINT DESIGNER Fixed-Point Conversion SIMULINK CODER EMBEDDED CODER MATLAB CODER Gen HDL CODER Gen Gen C/C++ VHDL/Verilog FPGA MCU ASIC DSP FPGA ASIC 18
Key Takeaway Consideration Floating Point Fixed Point Fixed Point with MathWorks Tools RAM Consumption Execution Speed Hardware Power Consumption Embedded Hardware Cost Development Time Implementation Complexity Error Prone 19
Training Services Exploit the full potential of MathWorks products Flexible delivery options: Public training available in several cities Onsite training with standard or customized courses Web-based training with live, interactive instructor-led courses More than 30 course offerings: Introductory and intermediate training on MATLAB, Simulink, Stateflow, code generation, and Polyspace products Specialized courses in control design, signal processing, parallel computing, code generation, communications, financial analysis and other areas. www.mathworks.in/training 20
Public Trainings in the next Few Months Guaranteed to run Course Dates Location MATLAB Fundamentals 8 th 10 th June Chennai Simulink for System and Algorithm Modeling 11 th 12th June Chennai Signal Processing with MATLAB 16 th 17 th June Bangalore Image Processing with MATLAB 18 th 19 th June Bangalore MATLAB Fundamentals Simulink for System and Algorithm Modeling 29 th Jun 01st July 31 st Aug 2 nd Sep 2 nd 3 rd July 3 rd Sep 4 th Sep Bangalore Pune Bangalore Pune Statistical Methods in MATLAB 20 th 21 st July Bangalore MATLAB based Optimization Techniques 22 nd Jul Bangalore Building Interactive Applications with MATLAB 23 rd July Bangalore MATLAB to C with MATLAB Coder 3 rd 4 th Aug Bangalore Embedded Coder for Production Code Generation 5 th 7 th Aug Bangalore Generating HDL Code from Simulink 7 th 8 th Sep Bangalore Programming Xilinx Zynq SoCs with MATLAB and Simulink 10 th 11 th Sep Bangalore Email: training@mathworks.in URL: http://www.mathworks.in/services/training Phone: 080-6632-6000 21
Training Certification Accelerate professional growth Validate proficiency with MATLAB Increase productivity and project success MathWorks Certified MATLAB Associate Examination Bangalore Pune 29 th July & 25 th Nov 3 rd June Recommended Courses MATLAB Fundamentals (MLBE) Email: training@mathworks.in URL: http://in.mathworks.com/#training Phone: 080-6632-6000 22