CES Public Seminar China Sept 2008

download CES Public Seminar China Sept 2008

of 59

Transcript of CES Public Seminar China Sept 2008

  • 8/13/2019 CES Public Seminar China Sept 2008

    1/59

    Model-Based Design ofEmbedded Signal Processing Systems

    with Simulink

    2008TheMathWorks,

    Inc.

    September, 2008

    Neil Ding,Zhenggao Xu

    Zhiqiang Wang

    Stella Sun

    The MathWorks, Inc.

  • 8/13/2019 CES Public Seminar China Sept 2008

    2/59

    2

    Agenda Introduction to Model Based Design

    A WiMAX Communications System Design Example

    Embedded MATLAB Extend the flexibility and the text programming capability of

    MATLAB into Simulink

    Build System Models Using Simulink Build an OFDM System a Step by Step Illustration Using Embedded MATLAB Blocks in Simulink Using Existing C Codes in Simulink

    Implementation & Verification Fixed Point Design in Simulink C Code Generation and Hardware-in-the-Loop Testing HDL Code Generation and Co-Simulation with ModelSim

    Summary

  • 8/13/2019 CES Public Seminar China Sept 2008

    3/59

    3

    System Design Challenges

    Analyze data, explore ideas, develop algorithms Manage timing and concurrency issues

    Understand the system-wide context

    Incorporate hardware constraints Test and verify design without final hardware

    Iterate back to modify algorithm

  • 8/13/2019 CES Public Seminar China Sept 2008

    4/59

    4

    System design requires integration of multipledisciplines, languages, and modeling approaches

    Block Diagrams

    MATLAB Code

    State Machines

    C/C++ Code

    Modeling Interactions

    System Level Effects

    Architecture Exploration

    System Design

    Model BasedDesign Using

    MATLAB

    &

    Simulink

  • 8/13/2019 CES Public Seminar China Sept 2008

    5/59

    5

    Requirements and

    Specifications

    Implementation

    Test andVerification

    Traditional Development Process

    Design

  • 8/13/2019 CES Public Seminar China Sept 2008

    6/59

    6

    SpecDesign

    ImplementTest

    Introduced

    Detected

    8%

    15%

    22%

    55%

    60%

    21%

    12%

    7%0%

    10%

    20%

    30%

    40%

    50%

    60%

    70%

    Where Errors Are Introduced... and Detected

    Source: Migration from Simulation to Verification withModelSim by Paul Yanik. EDA Tech Forum, 2004 Mar 11,Newton MA

    Challenge: How to catch errors early?

    each delay in thedetection and

    correction of a

    design error makesit an order ofmagnitude more

    expensive to fixClive Maxfield and Kuhoo Goyal

    EDA: Where Electronics BeginsTechBites Interactive, October 1, 2001

    ISBN: 0971406308

  • 8/13/2019 CES Public Seminar China Sept 2008

    7/59

    7

    Requirements and

    Specifications Design

    Implementation

    Test andVerification

    Adopting Model-Based Design

    AlgorithmsAlgorithms

    C, C++C, C++

    MCUMCU DSPDSP FPGAFPGA ASICASIC

    VHDL, VerilogVHDL, Verilog

    Automatic codegeneration- Reduces time, effort

    - Enables code reuse- Minimizes coding errors

    Generate

    Generate Ge

    nerate

    Generate

    System Behavior modelsSystem Behavior models

    Environment modelsEnvironment models

    Executable models- Unambiguous,

    one truth- Links to textual

    requirements

    Physical

    Components models

    Physical

    Components models

    Environment modelsEnvironment models

    AlgorithmsAlgorithms

    Simulation- Reduces need for

    physical prototypes- Enables systematic

    what-if analysis

  • 8/13/2019 CES Public Seminar China Sept 2008

    8/59

  • 8/13/2019 CES Public Seminar China Sept 2008

    9/59

    9

    TestEnvironments

    ContinuousT&V

    Requirements

    Model Based Design Workflow

    MCU DSP FPGA ASIC

    Embedded

    Software

    Digital

    ElectronicsC, C++ VHDL, Verilog

    Implement

    Integration

    Design

    Physical Components

    Environment

    Algorithms

    Generate

    Generate

  • 8/13/2019 CES Public Seminar China Sept 2008

    10/59

    10

    TestEnvironments

    ContinuousT&V

    Requirements

    MCU DSP FPGA ASIC

    EmbeddedSoftware

    DigitalElectronics

    C, C++ VHDL, Verilog

    Implement

    Integration

    Design

    Physical Components

    Environment

    Algorithms

    Generate

    Generate

    Model Based Design Workflow

    Implementation

    with AutomaticCode Generation

    Design withSimulation

    Executable

    Specificationsfrom Models

    ContinuousTest and

    Verification

  • 8/13/2019 CES Public Seminar China Sept 2008

    11/59

    11

    AlgorithmsAlgorithms

    C, C++C, C++

    MCUMCU DSPDSP FPGAFPGA ASICASIC

    VHDL, VerilogVHDL, Verilog

    Automatic codegeneration- Reduces time, effort- Enables code reuse- Minimizes coding errors

    Generate

    Generate Ge

    nerate

    Generate

    Requirements and

    Specifications Design

    Implementation

    Model Based Design Workflow

    Physical

    Components models

    Physical

    Components models

    Environment modelsEnvironment models

    AlgorithmsAlgorithms

    Simulation- Reduces need for

    physical prototypes- Enables systematic

    what-if analysis

    System Behavior modelsSystem Behavior models

    Environment modelsEnvironment models

    Executable models- Unambiguous,

    one truth- Links to textual

    requirementsTest andVerification

  • 8/13/2019 CES Public Seminar China Sept 2008

    12/59

    12

    A WiMAX Communications System

  • 8/13/2019 CES Public Seminar China Sept 2008

    13/59

    13

    Agenda Introduction to Model Based Design

    A WiMAX Communications System Design Example

    Embedded MATLAB Extend the flexibility and the text programming capability of

    MATLAB into Simulink

    Build System Models Using Simulink Build an OFDM System a Step by Step Illustration Using Embedded MATLAB Blocks in Simulink Using Existing C Codes in Simulink

    Implementation & Verification Fixed Point Design in Simulink C Code Generation and Hardware-in-the-Loop Testing HDL Code Generation and Co-Simulation with ModelSim

    Summary

  • 8/13/2019 CES Public Seminar China Sept 2008

    14/59

    14

    Embedded MATLAB is the subset of MATLAB language

    MATLABEmbedded

    cellarrays

    dynamically-sized arrays

    objects

    java

    visualization

    analysis

    arrays

    struct

    numericfixed-point

    dynamic data types

    functions

    nested functionscomplex

    sparse

    What is Embedded MATLAB?

    Two main purposes

    Efficient codegeneration fordeployment in

    embedded systems

    Acceleration of fixed-point algorithms

    Two associatedMATLAB commands:

    emlc

    emlmex

  • 8/13/2019 CES Public Seminar China Sept 2008

    15/59

    15

    Supported MATLAB Features N-dimensional arrays Matrix operations

    Subscripting Complex numbers Numeric classes Double-precision, single-precision, and integer math Fixed-point arithmetic If, switch, while, and for statements Sub-functions Persistent variables Structures

    Characters Function handles Frames Variable length input and output argument lists

    Subset of MATLAB functions Ability to call MATLAB functions

  • 8/13/2019 CES Public Seminar China Sept 2008

    16/59

    16

    Unsupported MATLAB Features

    Cell arrays

    Command/function duality Dynamic variables/Dynamic memory allocations Global variables Java Matrix deletion

    Nested functions Objects Sparse matrices Try/catch statements

    Other restrictions- For fixed point arithmetic, the word length is limited to32 bits in current release

  • 8/13/2019 CES Public Seminar China Sept 2008

    17/59

    17

    Two Main Commands

    EMLC

    Check for embedded MATLAB compliance Generate C code

    Compile to MEX file

    Compile to external library

    EMLMEX

    Check for embedded MATLAB compliance Generate C executable

    Compile to MEX file

  • 8/13/2019 CES Public Seminar China Sept 2008

    18/59

    18

    EMLC: Generating C-Code from M-Files

    1. Examine the original M-code and understand the algorithm

    2. Modify the M-code so that it complies with EmbeddedMATLAB

    3. Generate C-code using the emlccommand

    4. Evaluate the C-code for memory and speed

    5. Optimize the compliant M-code as required6. Generate optimized C-code

    OriginalM-Code

    CompliantM-Code

    GenerateC-Code

    C-Code

    Optimize the M-Code

  • 8/13/2019 CES Public Seminar China Sept 2008

    19/59

    19

    EMLMEX: Generating C-MEX Filesfrom M-Files

    1. Examine the original M-code and understand the algorithm

    2. Modify the M-code so that it complies with Embedded

    MATLAB3. Generate C-MEX file using the emlmexcommand

    Original

    M-Code

    Compliant

    M-Code

    Generate

    C-MEX File

    Faster

    M-Code

  • 8/13/2019 CES Public Seminar China Sept 2008

    20/59

    20

    EMLMEX: Two Intended Usages

    1. Accelerate fixed-point calculation in MATLAB

    Original

    M-Code

    Compliant

    Fixed-Point

    M-Code

    Generate

    C-MEX File

    100-1000s

    Times

    Faster

    M-Code

    2. Run m-code in Simulink (generate embedded MATLAB block)

    - Extend MATLAB functions into Simulink

  • 8/13/2019 CES Public Seminar China Sept 2008

    21/59

    21

    MEX vs. EMLMEX

    Faster M-codeand

    Block in Simulink

    Faster M-codePurpose

    MATLAB callable

    functions

    MATLAB callable

    functionsResult in

    M-filesC filesOperate on

    emlmexmexCommand

  • 8/13/2019 CES Public Seminar China Sept 2008

    22/59

    22

    Where does Embedded MATLAB fitin MathWorks flow?

  • 8/13/2019 CES Public Seminar China Sept 2008

    23/59

    23

    Agenda Introduction to Model Based Design

    A WiMAX Communications System Design Example

    Embedded MATLAB Extend the flexibility and the text programming capability of

    MATLAB into Simulink

    Build System Models Using Simulink Build an OFDM System a Step by Step Illustration Using Embedded MATLAB Blocks in Simulink Using Existing C Codes in Simulink

    Implementation & Verification Fixed Point Design in Simulink C Code Generation and Hardware-in-the-Loop Testing HDL Code Generation and Co-Simulation with ModelSim

    Summary

  • 8/13/2019 CES Public Seminar China Sept 2008

    24/59

    24

    Introduction to Simulink

    Block-diagram environment Accurately design, implement,

    and test:

    Control systems

    Signal processing systems

    Communications systems

    Other dynamic systems

    Platform for Model-BasedDesign

  • 8/13/2019 CES Public Seminar China Sept 2008

    25/59

    25

    Simulink Product KeyFeatures

    Extensive and expandablelibraries of predefinedblocks

    Hierarchical, component-

    based modeling Model/simulate systems Linear & Nonlinear

    Hybrid (mixed-signal)/Multi-domain

    Multi-rate Multi-tasking

    Full MATLAB integration

  • 8/13/2019 CES Public Seminar China Sept 2008

    26/59

    26

    Simulink Blocksets

    Simulink

    Sources Sinks

    Continuous

    Discrete

    Math

    Other

    Signal Processing

    Communications Video and Image Processing

    RF

  • 8/13/2019 CES Public Seminar China Sept 2008

    27/59

    27

    Signal Processing Blockset Statistics

    Multi-rate systems Transforms

    Filtering

    Estimation

  • 8/13/2019 CES Public Seminar China Sept 2008

    28/59

    28

    Communications Blockset

    http://www.mathworks.com/products/commblockset/

    Comm sources

    Comm sinks Source coding

    Channel coding

    Modulations RF impairments

    Comm filters

    Equalizers

  • 8/13/2019 CES Public Seminar China Sept 2008

    29/59

    29

    Video and Image Processing Blockset

    http://www.mathworks.com/products/viprocessing/

    Video/image sources

    Video/Image sinks 2-D filters

    2-D conversions

    Geometric transforms 2-D transforms

    Motion estimation

    I/O techniques

  • 8/13/2019 CES Public Seminar China Sept 2008

    30/59

    30

    Other Behavioral Level ModelingPerformance ofcommunications systems are

    also significantly impacted byother factors:

    RF Effects

    State Control

  • 8/13/2019 CES Public Seminar China Sept 2008

    31/59

    31

    RF Blockset

    Access networks

    parameter files of RFcomponents

    Intra-cascade

    reflections are modeled Frequency response Noise Phase noise

    Non-linearity

    http://www.mathworks.com/products/rfblockset/

  • 8/13/2019 CES Public Seminar China Sept 2008

    32/59

    32

    Stateflow Overview Extend Simulink with a design environment for

    developing state machines and flow charts

    Design systems containing control, supervisory, andmode logic

    Describe logic in a natural and understandable form

    with deterministic execution semantic

  • 8/13/2019 CES Public Seminar China Sept 2008

    33/59

    33

    Build an OFDM System Model

    Understand Simulink blocks

    Learning by examples

    Art vs. technique

    Use Embedded MATLAB blocks

    Use existing models, codes and programs

    Simulink models

    M-code

    C-code

    Build your own libraries

  • 8/13/2019 CES Public Seminar China Sept 2008

    34/59

    34

    Demos: Use Embedded MATLAB Blocksin Simulink

    Space-time encoding and decoding in WiMAXcommunication system

    Integration of digital pre-distortion into wirelesscommunications systems

    From MATLAB to Simulink

  • 8/13/2019 CES Public Seminar China Sept 2008

    35/59

    35

    Legacy Code Tool Build SimulinkBlocks Using Existing C Codes

    Two Examples A First Order IIR Filter

    FFT

  • 8/13/2019 CES Public Seminar China Sept 2008

    36/59

    36

    Break (15 minutes)

  • 8/13/2019 CES Public Seminar China Sept 2008

    37/59

    37

    Agenda Introduction to Model Based Design

    A WiMAX Communications System Design Example

    Embedded MATLAB Extend the flexibility and the text programming capability of

    MATLAB into Simulink

    Build System Models Using Simulink

    Build an OFDM System a Step by Step Illustration

    Using Embedded MATLAB Blocks in Simulink

    Using Existing C Codes in Simulink

    Implementation & Verification

    Fixed Point Design in Simulink

    C Code Generation and Hardware-in-the-Loop Testing

    HDL Code Generation and Co-Simulation with ModelSim

    Summary

  • 8/13/2019 CES Public Seminar China Sept 2008

    38/59

    38

    Fixed Point Design

    Architecture considerations

    Implementability

    Complexity

    Power consumption

    Cost Determination of word lengths

    Precision

    Dynamic range

    Resources

    Design optimization

    Meet requirements at minimum cost

  • 8/13/2019 CES Public Seminar China Sept 2008

    39/59

    39

    Fixed Point Design Work Flow

    Build Golden Reference

    Floating point implementation

    Test platform

    Perform Fixed Point Design

    Architecture

    Word lengths

    Optimization

    Verify the Design Hardware-in-the-loop testing

  • 8/13/2019 CES Public Seminar China Sept 2008

    40/59

    40

    Design Example: 16-QAM Transmitter

  • 8/13/2019 CES Public Seminar China Sept 2008

    41/59

    41

    Architecture Consideration

  • 8/13/2019 CES Public Seminar China Sept 2008

    42/59

    42

    Word Length Determination

    Compare BER vs. Eb/No for different word lengths

    Log internal min/max signal

    values to determine

    binary point location

  • 8/13/2019 CES Public Seminar China Sept 2008

    43/59

    43

    C Code GenerationImplementation and Verification on General Processors and DSPs

    Compile& Link

    C/ASM

    Code3rd Party

    IntegratedDevelopment

    Environment

    Download

    Debug

    DSP

    MathWorks

    Modeling Environment

    MATLAB Simulink Comms/VIP

    ImplementVerify

    Implement and Verify

    Embedded IDE Link

    Real Time WorkshopEmbedded Coder

    Target Support

    Package

  • 8/13/2019 CES Public Seminar China Sept 2008

    44/59

    44

    16QAM Transmitter:

    Behavioral floating-point model Fixed-point model using LUT

    Generate C code with

    Real-Time WorkshopEmbedded Coder

    Verify using Processor-In-Loopsimulation with Embedded IDELink CCfor Code ComposerStudio

    Demo - 16QAM Transmitter

  • 8/13/2019 CES Public Seminar China Sept 2008

    45/59

    45

    Code Generation: Generated CCS Project

    Source Files

    Generated Code SuccessfullyBuilt within CCS

    Processor Specific Interrupt

    Handler and Timer Code

  • 8/13/2019 CES Public Seminar China Sept 2008

    46/59

    46

    Processor-In-Loop (PIL) Simulation:TI C6416 DSP

  • 8/13/2019 CES Public Seminar China Sept 2008

    47/59

    47

    Simulink HDL Coder Product Features

    Generates synthesizable VHDL or Verilog from

    subsets of

    Simulink models

    Simulink Embedded MATLAB blocks

    Stateflow

    Automatic Test-bench generation

  • 8/13/2019 CES Public Seminar China Sept 2008

    48/59

    48

    What Blocks are Supported? Most supported

    blocks are low-

    level blockstoday

    Support forhigher-levelblocks will comein future releases

    Use hdllib tobuild a librarywith supported

    blocks

  • 8/13/2019 CES Public Seminar China Sept 2008

    49/59

    49

    EDA Simulator LinksLink for ModelSim

    Link for Cadence Incisive

    EDA Simulator Linkis a fast, bidirectional co-

    simulation interface

    System-level functional verification

    Reuse system model as test environment

    Modeling

    and Simulation

    Modeling

    and SimulationCosimulation and

    Verification

    Cosimulation and

    Verification HDL SimulationHDL Simulation

    MATLABor

    Simulink

    MATLABor

    SimulinkEDA Simulation Link

    EDA Simulation LinkEDA SimulatorEDA Simulator

  • 8/13/2019 CES Public Seminar China Sept 2008

    50/59

    50

    EDA Simulator LinkBrings Together Leading Tools ForModeling and HDL Simulation

    SynthesisSynthesis

    Digital

    Simulator

    Digital

    Simulator

    HDL Code

    Modeling

    and Simulation

    Modeling

    and SimulationCosimulation and

    Verification

    Cosimulation and

    Verification HDL SimulationHDL Simulation

    MATLABor

    Simulink

    MATLABor

    Simulink

    EDA Simulator LinkEDA Simulator Link

    HDL Creation:

    IP

    Hand-coded

    Auto-generated

    HDL Creation:

    IP

    Hand-coded

    Auto-generated

    Stimulus

    TestBench

    Response

  • 8/13/2019 CES Public Seminar China Sept 2008

    51/59

    51

    Three Viterbi Decoder implementations:

    Behavioral floating point model Elaborated fixed point design

    HDL implementation code

    Verify system BER metricsare being met

    Generate HDL code

    with Simulink HDL Coder

    Co-simulate HDL code with

    Link for ModelSimfor ModelSim

    Viterbi Decoder Demonstration

  • 8/13/2019 CES Public Seminar China Sept 2008

    52/59

    52

    Agenda Introduction to Model Based Design

    A WiMAX Communications System Design Example

    Embedded MATLAB Extend the flexibility and the text programming capability of

    MATLAB into Simulink

    Build System Models Using Simulink

    Build an OFDM System a Step by Step Illustration Using Embedded MATLAB Blocks in Simulink

    Using Existing C Codes in Simulink

    Implementation & Verification

    Fixed Point Design in Simulink C Code Generation and Hardware-in-the-Loop Testing

    HDL Code Generation and Co-Simulation with ModelSim

    Summary

  • 8/13/2019 CES Public Seminar China Sept 2008

    53/59

    53

    Summary

    Model based design (MBD) is a new concept or approachfor system modeling, design, implementation, test andverification

    Simulink is the platform for MBD

    Key features of the Simulink are

    Hierarchical, component-based modeling Multi-domain, multi-rate

    Non-linear and linear

    Full MATLAB integration

    C and HDL codes can be automatically generated fromSimulink models

    Continuous verification can be achieved via processor-in-the-loop, hardware-in-the-loop or co-simulation

  • 8/13/2019 CES Public Seminar China Sept 2008

    54/59

    54

    Advantages of Simulink andModel-Based Design

    Model elaboration:fixed-point andRF/analog effects

    System-levelverification by

    reuse of themodels testenvironment

    Hierarchical blockdiagrams clearly

    convey: Architecture

    Interfaces

    Concurrency Multirate

    Fasterimplementationand fewer codingerrors

  • 8/13/2019 CES Public Seminar China Sept 2008

    55/59

    55

    Support and Community

  • 8/13/2019 CES Public Seminar China Sept 2008

    56/59

    56

    Consulting from The MathWorks

    Engineering expertise and deep product knowledge,

    specializing in: Application development using MATLAB technical computing

    software

    Model-Based Design using Simulink and Stateflowsoftware

    Embedded-system development Enterprise-wide integration of MathWorks products into

    engineering process and systems

    Jumpstart services

    Project-based services for a growing number ofindustries, including aerospace and defense, automotive,communications, power and marine, and financial

    serviceswww.mathworks.com/consulting

  • 8/13/2019 CES Public Seminar China Sept 2008

    57/59

    57

    Training from The MathWorks

    Three ways to get training

    Public training Offered throughout the world

    Schedule and course information at www.mathworks.com/training

    Onsite training

    Bring training to your site, with course customization available Web-based training

    Instructor-led e-learning

    Train at work or at home, with flexible dates and times

    Example course topics Introductory and intermediate training on MATLAB, Simulink,

    and Stateflow

    Specialized courses in control design, signal processing, test andmeasurement, communications, financial analysis, and other areas

    www.mathworks.com/training

  • 8/13/2019 CES Public Seminar China Sept 2008

    58/59

    58

    1. Capture challenges

    2. Identify business case*

    3. Schedule resources

    4. Execute evaluation plan

    5. Post-evaluation review

    Best Practice: Five-Step Evaluation ofModel-Based Design The MathWorks China

    2 C 3

    301 : 100190

    Tel: +86-10-5982-7000

    www.mathworks.cn [email protected]

    * See ROI spreadsheet: http://www.edac.org/resources_add_roi.jsp

    Seminarend!

    Thank you!

  • 8/13/2019 CES Public Seminar China Sept 2008

    59/59

    Thank You for Attending!