Model-Based Design Using Model Composer (UG1259)

2y ago
89 Views
10 Downloads
2.52 MB
49 Pages
Last View : 19d ago
Last Download : 3m ago
Upload by : Harley Spears
Transcription

Tutorial:Model-Based Design Using ModelComposerUG1259 (v2018.3) December 5, 2018See all versions of this document

Revision HistoryThe following table shows the revision history for this document.SectionRevision Summary12/05/2018 Version 2018.3Design filesUpdates to design files.Lab 3: Automatic Code GenerationRevisions to Lab 306/06/2018 Version 2018.2General updatesEditorial updates and corrections.Changed all instances of xmcCreateLibrarycommand to xmcImportFunction command.Command has been renamed to better indicate itsfunction.Added a Step 2 to Lab 2 to create a custom block usingStep 2: Custom Blocks with Function Templates (Labfunction templates.2)04/04/2018 Version 2018.1General updatesEditorial updates and corrections.Updated dialog box displays throughout manual toreflect appearance in 2018.1 release.Step 1: Set up the Import Function Example (Lab 2)Added this Note:IMPORTANT: You can use the const qualifier in thefunction signature to identify the inputs to the block oruse the pragma INPORT.Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback2

Table of ContentsRevision History .2Model Composer Lab Overview.4Introduction .4Software Requirements .5Launching Model Composer .5Locating and Preparing the Tutorial Files .6Lab 1: Introduction to Model Composer .7Introduction .7Step 1: Review the Model Composer Library .8Step 2: Build Designs with Model Composer Blocks .9Step 3: Work with Data Types . 11Conclusion . 19Lab 2: Importing Code into Model Composer . 20Introduction . 20Step 1: Set up the Import Function Example . 20Step 2: Custom Blocks with Function Templates . 23Conclusion . 29Lab 3: Automatic Code Generation . 30Introduction . 30Step 1: Review Requirements for Generating Code . 30Step 2: Mapping Interfaces . 32Step 3: Generate IP from Model Composer Design . 35Step 4: Generate HLS Synthesizable Code . 39Step 5: Port a Model Composer Design to System Generator . 42Conclusion . 48Legal Notices . 49Please Read: Important Legal Notices . 49Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback3

Model Composer Lab OverviewIntroductionXilinx Model Composer is a model-based design tool that enables rapid design exploration within theSimulink environment and accelerates the path to production on Xilinx programmable devicesthrough automatic code generation.Model Composer is designed as an add-on to Simulink and provides a library of performanceoptimized blocks for design and implementation of algorithms on Xilinx FPGAs. The Model Composerlibrary offers over 80 predefined blocks, including application-specific blocks for Computer Vision andImage Processing and functional blocks for Math, Linear Algebra, Logic, and Bit-wise operations, amongothers.You can focus on expressing algorithms using blocks from the Xilinx Model Composer library as well ascustom user-imported blocks, without worrying about implementation specifics, and leverage all thecapabilities of Simulink’s graphical environment for algorithm design, simulation, and functionalverification. Model Composer then transforms your algorithmic specifications to production-qualityimplementation using automatic optimizations that extend the Xilinx High Level Synthesis technology.This tutorial introduces the end-to-end workflow for using Model Composer.The included labs are as follows: Lab 1: Introduction to Model ComposeroIntroduction to Model Composer Library Blocks for designoIntegration with native Simulink and Support for vectors and matricesoWorking with data typesLab 2: Create Custom Blocks in Model Composer Using the xmcImportFunction command to specify functions defined in source andheader files to import into Model Composer and create Model Composer blocks or a blocklibrary. Creating custom blocks with Function templatesLab 3: Automatic Code GenerationoRequirements for Code GenerationModel-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback4

Model Composer Lab OverviewoMapping InterfacesoGenerate an IP for use in the Vivado IP IntegratoroGenerate Vivado HLS Synthesizable CodeoPort a Model Composer Synthesized Design into System Generator for DSPSoftware RequirementsThe lab exercises in this tutorial require that you have installed the following software: MATLAB : The MATLAB releases and simulation tools supported in this release of ModelComposer are described in the Compatible Third-Party Tools section of the Vivado Design SuiteUser Guide: Release Notes, Installation, and Licensing (UG973). Vivado Design Suite release: 2018.2 (Includes Vivado HLS) Model Composer: 2018.2See the Vivado Design Suite User Guide: Release Notes, Installation, and Licensing (UG973) for acomplete list and description of the system and software requirementsLaunching Model ComposerTo launch Model Composer: On Windows systems:oSelect Start All Programs Xilinx Design Tools Model Composer 2018.x ModelComposer 2018.x.ORo Double-click the Model Composer icon which was placed on your desktop after installation.On Linux systems:You launch Model Composer under Linux using a shell script called model composer locatedin the Model composer install dir /2018.x/bin directory. Before launching thisscript, you must make sure the MATLAB executable can be found in your Linux system’s PATHenvironment variable for your Linux system. When you execute the model composer script, itwill launch the first MATLAB executable found in PATH and attach Model Composer to thatsession of MATLAB. Also, the model composer shell script supports all the options thatModel-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback5

Model Composer Lab OverviewMATLAB supports and all options can be passed as command line arguments to themodel composer script.When Model Composer opens, you can confirm the version of MATLAB to which Model Composer isattached by entering the version command in the MATLAB Command Window. versionans '9.2.0.538062 (R2017a)'Locating and Preparing the Tutorial FilesThere are separate project files and sources for each of the labs in this tutorial. You can find the designfiles for this tutorial on the www.xilinx.com website.1. Download the Reference Design Files from the Xilinx website.2. Extract the zip file contents into any write-accessible location on your hard drive or networklocation.RECOMMENDED: You will modify the tutorial design data while working through this tutorial.You should use a new copy of the ModelComposer Tutorial directory extracted fromug1259-model-composer-tutorial.zip each time you start this tutorial.TIP: This document assumes the tutorial files are stored at C:\ModelComposer Tutorial. Allpathnames and figures in this document refer to this pathname. If you choose to store the tutorialin another location, adjust the pathnames accordingly.TIP: Make sure to save the tutorial files in a folder structure with no spaces in them. There is aknown limitation that does not support spaces in the directory structure for code generation.Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback6

Lab 1: Introduction to Model ComposerIntroductionThis tutorial shows how you can use Model Composer for rapid algorithm design and simulation in theSimulink environment.ProcedureThis lab has the following steps: In Step 1, you examine the Model Composer Simulink library. In Step 2, you build a simple design using Model Composer blocks to see how Model Composerblocks integrate with native Simulink blocks and supported Signal Dimensions. In Step 3, you look at data types supported by Model Composer and the conversion betweendata types.Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback7

Lab 1: Introduction to Model ComposerStep 1: Review the Model Composer LibraryIn this step you see how Model Composer fits into the Simulink environment, and then review thecategories of blocks available in the Model Composer library.Access Model Composer LibraryModel Composer provides 80 blocks for use within the Simulink environment that you can accessthem from within the Simulink Library Browser:1. Use any of these techniques to open the Simulink Library Browser:a. On the Home tab, click Simulink, and choose a model template. In the new model, click theLibrary Browser button.b. At the command prompt, type:slLibraryBrowser2. In the browser, navigate to the Xilinx Model Composer library.Figure 1: Xilinx Model Composer LibraryModel-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback8

Lab 1: Introduction to Model ComposerThe Model Composer blocks are organized into subcategories based on functionality. Spend a fewminutes navigating through the sub-libraries and familiarizing yourself with the available blocks.Step 2: Build Designs with Model Composer BlocksIn this step, you build a simple design using the existing Model Composer blocks.Sobel Edge Detection: Algorithm OverviewSobel edge detection is a classical algorithm in the field of image and video processing for theextraction of object edges. Edge detection using Sobel operators works on the premise of computingan estimate of the first derivative of an image to extract edge information.Figure 2: Sobel Edge DetectionImplementing Algorithm in Model Composer1. In the MATLAB Current Folder, navigate to ModelComposer Tutorial\Lab1\Section1.2. Double-click the Sobel EdgeDetection start.slx model.This model already contains source and sink blocks (from Simulink’s Computer Vision SystemToolbox), to stream video files as input directly into your algorithm and view the results. The modelalso contains some of the needed Model Composer blocks required for this section. Note thedifference in appearance for the Model Composer blocks in the design versus the Simulink blocks.3. From the Library Browser, select the Sobel Filter block from the Computer Vision sub-library of theXilinx Model Composer library. Drag the block into the area labeled Convolve Image Frame withSobel Kernel and Compute Gradient as shown in Figure 4 and connect the input of this block tothe output of the From Multimedia File block.Note: You can also add Model Composer blocks directly into your model by typing the block nameonto the canvas (same as Simulink blocks).Figure 3: Searching for Sobel Filter BlockModel-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback9

Lab 1: Introduction to Model Composer4. From the Library Browser, select the Gradient Magnitude block from the Xilinx Model Composerlibrary (also found in the Computer Vision sub-library), drag it into the model, and connect the Xand Y outputs of the Sobel Filter block to the input of this block.5. Connect the rest of the blocks to complete the algorithm as shown in the following figure:Figure 4: Algorithm with Sobel Filter and Gradient Magnitude6. Select the Simulation Run command or click theresults of the Sobel Edge Detection algorithm.button to simulate the model and view theNote: The Model Composer blocks can operate on matrices (image frames in the following figure).Figure 5: Input and Output VideosOne way to assess the simulation performance of the algorithm is to check the video frame rate of thesimulation. To do this:7. Add the Frame Rate Display block from the Simulink Computer Vision System Toolbox (underthe Sinks category) and connect it to the output of the algorithm as shown in Figure 6.8. Simulate the model again to see the number of video frames processed per second.Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback10

Lab 1: Introduction to Model ComposerFigure 6: Frames Processed Per Second9. Try these things: Change the input video through the From Multimedia File block by double-clicking the blockand changing the File Name field to select a different video. Notice that changing the videoresolution in the Source block does not require any structural modifications to the algorithm itself.Note: You must stop simulation before you can change the input file. Also, the .mp4 files in theMATLAB vision data tool box directory are not supported. Build any variations using other available blocks in the Computer Vision sub-library in ModelComposer.Note: You can find other smaller examples for reference in the folderModelComposer Tutorial\Lab1\Section1\ExamplesStep 3: Work with Data TypesIn this step, you become familiar with the supported Data Types for Model Composer and conversionfrom floating to fixed-point types.This exercise has two primary parts, and one optional part: Review a simple floating-point algorithm using Model Composer. Look at Data Type Conversions in Model Composer designs.Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback11

Lab 1: Introduction to Model ComposerWork with Native Simulink Data Types1. In the MATLAB Current Folder, navigate to the ModelComposer Tutorial\Lab1\Section2folder.2. Double-click ColorSpace Conversion.slx to open the design.This is a Color Space conversion design, built with basic Model Composer blocks, that performs a RGBto YCbCr conversion.3. Update the model (Ctrl D) and observe that the Data Types, Signal Dimensions and Sample Timesfrom the Source blocks in Simulink all propagate through the Model Composer blocks. Note that thedesign uses single precision floating point data types.4. Simulate the model and observe the results from simulation.Convert Data TypesTo convert the previous design to use Xilinx Fixed Point types:Note: Fixed point representation helps to achieve optimal resource usage and performance for ausually acceptable trade-off in precision, depending on the dataset/algorithm.1. Double-click ColorSpace Conversion fixed start.slx in the Current Folder to open thedesign.2. Open the Xilinx Model Composer library in the Simulink Library Browser.3. Navigate to the Signal Attributes sub-library, select the Data Type Conversion block, and drag itinto the empty slots in the designs, before and after the RGB to YCbCr subsystem.Figure 7: Model Composer Data Type Conversion BlockModel-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback12

Lab 1: Introduction to Model ComposerFigure 8: RGB to YCbCr Subsystem with DTC Blocks Connected4. Open the Data Type Conversion blocks at the inputs of the RGB to YCbCr Subsystem, and do thefollowing:oChange the Output data type parameter to fixed.oSet the Signedness to Unsigned.oSet the Word length to 8.oSet Fractional length to 7.oClick Apply, and close the dialog box.Model-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback13

Lab 1: Introduction to Model ComposerFigure 9: Data Type Conversion Block Parameters5. Add the Data Type Conversion blocks at the output of the RGB to YCbCr Subsystem and set theOutput data type parameter to single. This will enable connecting the output signals to the VideoViewer blocks for visualization.Figure 10: Setting Output Data TypeModel-Based Design Using Model ComposerUG1259 (v2018.3) December 5, 2018www.xilinx.comSend Feedback14

Lab 1: Introduction to Model Composer6. Double-click the RGB to YCbCr subsystem to descend the hierarchy and open the model. Withinthe RGB to YCbCr subsystem, there are subsystems to calculate Y, Cb, and Cr components usingGain and Constant blocks.You can control the fixed point types for the gain parameter in the Gain blocks and the value in theConstant blocks. You can do this by opening up the Calculate Y, Calculate Cb, and Calculate Crblocks and setting the data types as follows.For Gain blocks, set the Gain data type to fixed and the following options appear:oSignedness to SignedoGain data type to fixedoWord length to 8oFractional length to 7For Constant blocks, on the Data Types tab set the Output data type to fixed and the followingoptions appear:oSignedness to SignedoOutput data type to fixedoWord Length to 8oFractional Length to 7TIP: You can use the View Property Inspector command to open the PropertyInspector window. When you s

In Step 1, you examine the Model Composer Simulink library. In Step 2, you build a simple design using Model Composer blocks to see how Model Composer blocks integrate with native Simulink blocks and supported Signal Dimensions. In Step 3, you look at data types supported

Related Documents:

Model based design . Control design and closed-loop simulation Code generation and transfer to target Model based design (MBD) Main steps of model based (controller) design . Pendulum friction is set to zero (d 2 0) The 4th line of the linearized model is used for identification

Use Model-Based Design to model the system design and software design, and to generate flight code Results Software testing time cut by two-thirds Requirements stabilized earlier Certified flight software automatically generated Eurocopter Accelerates Development of DO-178B Certified Software with Model-Based Design "We use our system design

2 Landscape design based on research: a guide 12 2.1 The relationship between research and design in landscape architecture 12 2.1.1 Research into design 13 2.1.2 Research through design 13 2.1.3 Research for design 15 2.2 Research-based knowledge and landscape design 17 2.2.1 Evidence-based landscape architecture and design 17

1 EXTERNAL USE Agenda Overview: Introduction and Objectives Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader Hands-On Demo: Motor Kit (Describe Freescale 3-Phase Motor Kit) Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER Model-Based Design: Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262

Design of D.C. Machine By Using Matlab 6 3. Design of 3-φ Transformer By Using Matlab 8 4. Design of 1-φ Induction Motor By Using Matlab 10 5. Design of Synchronous Machine By Using Matlab 12 6. Design of Circuit Breaker Operation By using Matlab 15 7. Testing of Different Types of Relays By Using Matlab 17 8.

Design Traditional Development Workflow SPECIFICATIONS DESIGN AND IMPLEMENTATION RESEARCH REQUIREMENTS Embedded Software C/C INTEGRATION AND TEST Electrical Components EDA Mechanical . Model-Based Design: Test and Verification. 13 Building a Wave Farm with Model-Based Design. 14

16 Design Verification for Model-Based Design Requirements based test cases Automated testing using SystemTest/Simulink V&V Traceability using Requirements Management Interface Capability to inject faults for FMEA Robustness testing and analysis Built in Simulink run-time diagnostics Formal proofs using Simulink Design Verifier Coverage Analysis

Legal Design Service offerings Legal Design - confidential 2 Contract design Litigation design Information design Strategy design Boardroom design Mastering the art of the visual Dashboard design Data visualization Legal Design What is especially interesting in the use of visual design in a p