| Contents | Index |
| On this page… |
|---|
Coding a MATLAB 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 HDL Verifier component function (see Syntax of a Component Function.).
Understand how HDL Verifier software converts data from the HDL simulator for use in the MATLAB environment (see Data Type Conversions).
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 MATLAB Function Syntax and Function Argument Definitions).
Determine the types of port data being passed into the function (see MATLAB Function Syntax and Function Argument Definitions).
Extract and, if applicable to the simulation, apply information received in the portinfo structure (see Gaining Access to and Applying Port Information).
Convert data for manipulation in the MATLAB environment, as applicable (see Converting HDL Data to Send to MATLAB).
Convert data that needs to be returned to the HDL simulator (see Converting Data for Return to the HDL Simulator).
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 MATLAB Function Syntax and Function Argument Definitions for an explanation of each of the function arguments. For more information on using tnext and tnow for simulation scheduling with matlabcp, see Scheduling Component 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-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |