© 2003 The MathWorks, Inc. 1 Importing C code into Simulink for Signal Processing Applications © 2003 The MathWorks, Inc. Colin Warwick

Slides:



Advertisements
Similar presentations
Basic S-Functions and TLC Coding
Advertisements

© 2003 Xilinx, Inc. All Rights Reserved Course Wrap Up DSP Design Flow.
Visual Scripting of XML
SIMULINK EXAMPLE transmitter Receiver Channel
MATLAB and SimulinkLecture 71 To days Outline  Callbacks  MATLAB And Simulink  S-functions  Project suggestions.
F. Nagi Dep. Of Mech Eng. Universiti Tenaga Nasional
1 Mind Visual Diff An architecture comparison tool December 16 th, 2014 – v0.2.2 Seyvoz Stephane Assystem.
Developing Video Applications on Xilinx FPGAs
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Senior Capstone Project Integration of Matlab Tools for DSP Code Generation ECE Department March 2nd, 2006 Team Members: Kwadwo Boateng and Charles Badu.
Using an FPGA to Control the Protection of National Security and Sailor Lives at Sea Brenda G. Martinez, Undergraduate Student K.L. Butler-Purry, Ph.D.,
MotoHawk Training Model-Based Design of Embedded Systems.
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
1 Steps for Production Code Generation Wind Turbine Pitch Controller 1. Generate test data and extract controller 2. Discretize Change integrator blocks.
SSP Re-hosting System Development: CLBM Overview and Module Recognition SSP Team Department of ECE Stevens Institute of Technology Presented by Hongbing.
Tejas Bhatt and Dennis McCain Hardware Prototype Group, NRC/Dallas Matlab as a Development Environment for FPGA Design Tejas Bhatt June 16, 2005.
Matlab as a Design Environment for Wireless ASIC Design June 16, 2005 Erik Lindskog Beceem Communications, Inc.
Copyright © 2012 BEST Robotics, Inc. All rights reserved. 1 BEST Software Options Greg Young William Polanco Saturday Apr 27, 2013.
Anne Mascarin DSP Marketing The MathWorks
GallagherP188/MAPLD20041 Accelerating DSP Algorithms Using FPGAs Sean Gallagher DSP Specialist Xilinx Inc.
© 2011 Xilinx, Inc. All Rights Reserved Intro to System Generator This material exempt per Department of Commerce license exception TSU.
64-QAM Communications System Design and Characterization Project #1 EE283
© 2005 The MathWorks, Inc. Advanced Technologies to Accelerate Mixed Signal Simulation Pieter J. Mosterman Senior Research Scientist The MathWorks, Inc.
Introduction 01_intro.ppt
MapleSim and the Advantages of Physical Modeling
© 2004 The MathWorks, Inc. 1 MATLAB for C/C++ Programmers Support your C/C++ development using MATLAB’s prebuilt graphics functions and trusted numerics.
W.Skulski Phobos Workshop April /2003 Firmware & software development Digital Pulse Processor DDC-8 (Universal Trigger Module) Wojtek Skulski University.
© 2002 The MathWorks, Inc. September 2002 Advanced Embedded Tool capabilities for Texas Instruments DSPs © 2002 The MathWorks, Inc. David Hilf Third Party.
Model-Based Design and SDR Fabio Ancona Sundance Italia SRL CEO – Sales Director.
Obsydian OLE Automation Ranjit Sahota Chief Architect Obsydian Development Ranjit Sahota Chief Architect Obsydian Development.
Gedae, Inc. Implementing Modal Software in Data Flow for Heterogeneous Architectures James Steed, Kerry Barnes, William Lundgren Gedae, Inc.
Digital Radio Receiver Amit Mane System Engineer.
DIFFERENCE BETWEEN ORCAD AND LABVIEW
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Software Defined Radio
Upgrade to Real Time Linux Target: A MATLAB-Based Graphical Control Environment Thesis Defense by Hai Xu CLEMSON U N I V E R S I T Y Department of Electrical.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
1 LabVIEW DSP Test Integration Toolkit. 2 Agenda LabVIEW Fundamentals Integrating LabVIEW and Code Composer Studio TM (CCS) Example Use Case Additional.
C-MEX S-Function MATLAB SIMULINK SI Lab Presentation Presented by: Ashkan Jalili 2007/12/08.
Simulink ® Interface Course 13 Active-HDL Interfaces.
MATLAB
Developing a SDR Testbed Alex Dolan Mohammad Khan Ahmet Unsal Project Advisor Dr. Aditya Ramamoorthy.
SW and HW platforms for development of SDR systems SW: Model-Based Design and SDR HW: Concept of Modular Design and Solutions Fabio Ancona Sundance Italia.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
MotoHawk™ Components Scalable, Secure, Model-Based Design of Embedded Systems.
© 2010 Altera Corporation—Public Modeling and Simulating Wireless Systems Using MATLAB ® and Simulink ® 2010 Technology Roadshow.
Sub-Nyquist Sampling Algorithm Implementation on Flex Rio
LIST OF EXPERIMENTS USING TMS320C5X Study of various addressing modes of DSP using simple programming examples Sampling of input signal and display Implementation.
Final Presentation Implementation of DSP Algorithm on SoC Student : Einat Tevel Supervisor : Isaschar Walter Accompanying engineer : Emilia Burlak The.
Separating the Interface from the Engine: Creating Custom Add-in Tasks for SAS Enterprise Guide ® Peter Eberhardt Fernwood Consulting Group Inc.
1 MotoHawk Components Scalable, Secure, Model-Based Design of Embedded Systems MotoHawk Training.
Computer Science Faculty School of Software Engineering C INTERPRETER AND DEBUGGER (ISO/IEC 9899:2011) Developer: student of 203SE group: Lukyanov Dmitry.
© 2003 Xilinx, Inc. All Rights Reserved Course Wrap Up DSP Design Flow.
Structured Component Composition Frameworks for Embedded System Design Sandeep Shukla, Virginia Tech. Frederic Doucet, Rajesh Gupta University of California,
1 ® ® Agenda 8:30 a.m.Introduction to The MathWorks, Xilinx, and Avnet 9:00 a.m.Video System Design with Simulink 9:45 a.m.Break 10:00 a.m.FPGA Implementation.
M ATLAB – What Is It ? Name is from matrix laboratory Powerful tool for – Computation and visualization of engineering and science mathematics – Communication.
Introduction to Simulink Matlab based Both Continuous Time and Discrete Time Simulation Based on Blocksets Model Based Design: a software model of the.
Simulink by Dr. Amin Danial Asham. References  MATLAB Help  Telemark University College - Department of Electrical Engineering, Information Technology.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
Ganga/Dirac Data Management meeting October 2003 Gennady Kuznetsov Production Manager Tools and Ganga (New Architecture)
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Fermilab Scientific Computing Division Fermi National Accelerator Laboratory, Batavia, Illinois, USA. Off-the-Shelf Hardware and Software DAQ Performance.
M ATLAB – What Is It ? Name is from matrix laboratory Powerful tool for – Computation and visualization of engineering and science mathematics – Communication.
MATLAB Distributed, and Other Toolboxes
SOFTWARE DESIGN AND ARCHITECTURE
64-QAM Communications System Design and Characterization
Embedded Systems Design
Matlab as a Development Environment for FPGA Design
Matlab as a Design Environment for Wireless ASIC Design
MATLAB/SIMULINK Professor Walter W. Olson
Presentation transcript:

© 2003 The MathWorks, Inc. 1 Importing C code into Simulink for Signal Processing Applications © 2003 The MathWorks, Inc. Colin Warwick #2 in the webinar series “Today’s Simulink for Wireless Design” MATLAB and Simulink are registered trademarks of The MathWorks, Inc.

© 2003 The MathWorks, Inc. 2 Agenda What's available? Interoperability between MATLAB, Simulink, and C Why call C from Simulink? The MathWorks’ System-Level Design Flow How? S-function Builder block – new in R13 (August 2002) C-code S-function – full API  Same “full strength” API as we use to build our blocks Webex live Q&A

© 2003 The MathWorks, Inc. 3 Flexible usage model: Six permutations C SimulinkMATLAB From Simulink, call C

© 2003 The MathWorks, Inc. 4 Flexible usage model: Six permutations S-function Builder C-code S-function CSimulink M-code S-function Caution: interpreted, not compiled MATLABSimulink >> sim(‘mymodel’) SimulinkMATLAB MEX ActiveX/COM & DDE CMATLAB Engine or COM [x,y,t] = sim(‘mymodel’,u0) SimulinkC MATLAB Engine ActiveX/COM & DDE MATLAB Compiler & runtime MATLABC How?Call…From…

© 2003 The MathWorks, Inc. 5 M ATLAB S imulink Why use Simulink as a framework for your C-code? Capture and validate an executable specification before component-level implementation Use our blocks as a first cut and as a test harness Capture your IP in C using Simulink as a framework Validated Executable Specification DSP/MCU Software Tools EDA Tools Analog & Digital Hardware DSP & MCU Software IMPLEMENTATION TOOLS C

© 2003 The MathWorks, Inc. 6 Why use Simulink as a framework for your C-code? Jump start your project Prebuilt Blocksets and application examples  MathWorks, 3 rd parties Test bench surrounding your product Stimulus generation  From a simple sin wave to a complete transmitter & channel model Response instrumentation, visualization  Time (eye), I-Q (constellation), frequency (spectra) M-file scripting (test executive), BER versus E b /N o plot Block diagram paradigm Intuitive capture of concurrent simulation time Divide and conquer Self-documenting  Algorithm visualization  Library of reusable blocks

© 2003 The MathWorks, Inc. 7 Structure of code to be imported: `core and leaves´ test_slicer.exe //test_slicer.c main() { for(){ slicer(); } //slicer.c slicer() { return; } t

© 2003 The MathWorks, Inc. 8 Try it! Quick demo. Today’s demos use… Simulink (simulink.dll & matlab.exe) Optional: Symbolic Debugger See Tech Note 1601 for a list User-defined Blocks (“S-function.dll ”) in a block diagram (“Model”.mdl ) MATLAB Central.c.h Compiler: see Tech Note 1601 for a list

© 2003 The MathWorks, Inc. 9 Structure of code after import: `wrapped leaves´ Call your `leaf´ code from a wrapper to interface with Simulink Compile both and link .dll Simulink calls the DLL using several functions (“methods”) wrap_slicer.dll Simulink //wrap_slicer.c mdlOutputs(S) { slicer(); } //slicer.c //definition // of //slicer() UNIX is a registered trademark of The Open Group t

© 2003 The MathWorks, Inc. 10 The “S-function” DLL contains several methods mdlInitializeSizes() mdlInitializeSampleTimes() mdlOutputs() mdlTerminate() y t = f(t, u t ) y = outputs, t = time u = inputs Done? n y

© 2003 The MathWorks, Inc. 11 What about leaf functions with states? States preserved across time steps Independent set of states per instance FIR, IIR, coders, decoders Also known as... Computer science: “Re-entrant persistent storage” Object-oriented: “property” C++: “member variable” Different from… static variables in C are persistent but shared, not re-entrant If a leaf contains static data it can only be instantiated once int always_one(void) { int y = 0; y = y + 1; return y; } int up(void) { static int y = 0; y = y + 1; return y; } int counter(int *z) { *z = *z + 1; return *z; }

© 2003 The MathWorks, Inc. 12 Two main types of state available in Simulink Discrete states, x d  Read-only ( const ) in the mdlOutput() method  Available in S-Function Builder block and full S-function Work vectors, w  Read-write in mdlOutput()  Presently only accessible from full S-function API states x d, w input u output y=f(t,x d,w,u)

© 2003 The MathWorks, Inc. 13 Approach depends on code structure 1) “Output-update” structure – use S-function Builder block Leaf with separate output and update functions  Use “discrete states”, update them in mdlUpdate() 2) General structure or advanced needs – use full S-function Leaf with output and update functions intermixed  Use “work vectors”, update them in mdlOutputs() y t = f(t, x t, u t ), x t+  t = g(t, x t, u t ) y = outputs, t = time, x = states, u = inputs [x t+  t, y t ]= f(t, x t, u t )

© 2003 The MathWorks, Inc. 14 1) “Output-update” leaf structure mdlInitializeSizes() mdlInitializeSampleTimes() mdlOutputs() mdlTerminate() x t+  t = g(t, x t, u t ) Done? n y mdlUpdate() y t = f(t, x t, u t ) y = outputs, t = time x = states, u = inputs “Division of labor is preferred”

© 2003 The MathWorks, Inc. 15 2) General leaf structure mdlInitializeSizes() mdlInitializeSampleTimes() mdlOutputs() mdlTerminate() y t = f(t, w t, u t ) w t+  t = g(t, w t, u t ) y = outputs t = time w = work vec u = inputs Done? n y

© 2003 The MathWorks, Inc. 16 Demonstrations S-function Builder block features Slicer: a memoryless block IIR Filter: a block with memory Output-update structure  S-function Builder  A Discrete state  Output in mdlOutputs() and update in mdlUpdate() General structure  Full S-function  1-element Work vector  Output and update in mdlOutputs() Using the sample code as a resource Tour of the S-function reference material

© 2002 The MathWorks, Inc. 17 Summary

© 2003 The MathWorks, Inc. 18 M ATLAB S imulink Why use Simulink as a framework for your C-code? Capture and validate an executable specification before component-level implementation Use our blocks as a first cut and as a test harness Capture your IP in C using Simulink as a framework Validated Executable Specification DSP/MCU Software Tools EDA Tools Analog & Digital Hardware DSP & MCU Software IMPLEMENTATION TOOLS C

© 2003 The MathWorks, Inc. 19 Further Information on Products and Services Twelve compilers across nine platforms - Tech Note 1601 mathworks.com/support/tech-notes/v5/1600/1601.shtml Documentation, including templates and sample code Writing S-functions File Download for this webinar matlabcentral.com Consulting – Jump Start mathworks.com/consulting Thank you!

© 2002 The MathWorks, Inc. 20 Webex Q&A session

© 2002 The MathWorks, Inc. 21 Webinar End Thank You