| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → EDA Simulator Link |
| Contents | Index |
| Learn more about EDA Link Simulator |
| On this page… |
|---|
Coding a MATLAB M-function that is to visualize an HDL module or component requires that you follow specific coding conventions. You must also understand the data type conversions that occur, and program data type conversions for operating on data and returning data to the HDL simulator.
To code a MATLAB function that is to verify an HDL module or component, perform the following steps:
Learn the syntax for a MATLAB EDA Simulator Link component function (see Syntax of a Component Function.).
Understand how EDA Simulator Link software converts data from the HDL simulator for use in the MATLAB environment (see Performing Data Type Conversionsin Advanced Operational Topics).
Choose a name for the MATLAB component function (see Invoke matlabcp to Bind MATLAB Component Function Calls).
Define expected parameters in the component function definition line (see Defining EDA Simulator Link M-Functions and Function Parameters).
Determine the types of port data being passed into the function (see Defining EDA Simulator Link M-Functions and Function Parameters).
Extract and, if appropriate for the simulation, apply information received in the portinfo structure (see Gaining Access to and Applying Port Information in the Defining EDA Simulator Link M-Functions and Function Parameters).
Convert data for manipulation in the MATLAB environment, as necessary (see Converting HDL Data to Send to MATLAB in Advanced Operational Topics).
Convert data that needs to be returned to the HDL simulator (see Converting Data for Return to the HDL Simulator in Advanced Operational Topics).
The syntax of a MATLAB component function is
function [iport, tnext] = MyFunctionName(oport, tnow, portinfo)
The input/output arguments (iport and oport) for a MATLAB component function are the reverse of the port arguments for a MATLAB test bench function. That is, the MATLAB component function returns signal data to the outputs and receives data from the inputs of the associated HDL module.
Initialize the function outputs to empty values at the beginning of the function as in the following example:
tnext = []; oport = struct();
See the Defining EDA Simulator Link M-Functions and Function Parameters for an explanation of each of the function arguments. For more information on using tnext and tnow for simulation scheduling with matlabtb (it is the same for matlabcp), see Scheduling Test Bench M-Functions Using the tnext Parameter.
![]() | Code HDL Modules for Visualization Using MATLAB | Place Component Function on MATLAB Search Path | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |