141
EDA Simulator Link™ 3 Reference

EDA Simulator Link Block and Function Reference

Embed Size (px)

Citation preview

Page 1: EDA Simulator Link Block and Function Reference

EDA Simulator Link™ 3Reference

Page 2: EDA Simulator Link Block and Function Reference

How to Contact The MathWorks

www.mathworks.com Webcomp.soft-sys.matlab Newsgroupwww.mathworks.com/contact_TS.html Technical Support

[email protected] Product enhancement [email protected] Bug [email protected] Documentation error [email protected] Order status, license renewals, [email protected] Sales, pricing, and general information

508-647-7000 (Phone)

508-647-7001 (Fax)

The MathWorks, Inc.3 Apple Hill DriveNatick, MA 01760-2098For contact information about worldwide offices, see the MathWorks Web site.

EDA Simulator Link™ Reference© COPYRIGHT 2003–2010 by The MathWorks, Inc.The software described in this document is furnished under a license agreement. The software may be usedor copied only under the terms of the license agreement. No part of this manual may be photocopied orreproduced in any form without prior written consent from The MathWorks, Inc.

FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentationby, for, or through the federal government of the United States. By accepting delivery of the Programor Documentation, the government hereby agrees that this software or documentation qualifies ascommercial computer software or commercial computer software documentation as such terms are usedor defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms andconditions of this Agreement and only those rights specified in this Agreement, shall pertain to and governthe use, modification, reproduction, release, performance, display, and disclosure of the Program andDocumentation by the federal government (or other entity acquiring for or through the federal government)and shall supersede any conflicting contractual terms or conditions. If this License fails to meet thegovernment’s needs or is inconsistent in any respect with federal procurement law, the government agreesto return the Program and Documentation, unused, to The MathWorks, Inc.

Trademarks

MATLAB and Simulink are registered trademarks of The MathWorks, Inc. Seewww.mathworks.com/trademarks for a list of additional trademarks. Other product or brandnames may be trademarks or registered trademarks of their respective holders.

Patents

The MathWorks products are protected by one or more U.S. patents. Please seewww.mathworks.com/patents for more information.

Page 3: EDA Simulator Link Block and Function Reference

Revision HistoryAugust 2003 Online only New for Version 1 (Release 13SP1)February 2004 Online only Updated for Version 1.1 (Release 13SP1)June 2004 Online only Updated for Version 1.1.1 (Release 14)October 2004 Online only Updated for Version 1.2 (Release 14SP1)December 2004 Online only Updated for Version 1.3 (Release 14SP1+)March 2005 Online only Updated for Version 1.3.1 (Release 14SP2)September 2005 Online only Updated for Version 1.4 (Release 14SP3)March 2006 Online only Updated for Version 2.0 (Release 2006a)September 2006 Online only Updated for Version 2.1 (Release 2006b)March 2007 Online only Updated for Version 2.2 (Release 2007a)September 2007 Online only Updated for Version 2.3 (Release 2007b)March 2008 Online only Updated for Version 2.4 (Release 2008a)October 2008 Online only Updated for Version 2.5 (Release 2008b)March 2009 Online only Updated for Version 2.6 (Release 2009a)September 2009 Online only Updated for Version 3.0 (Release 2009b)March 2010 Online only Updated for Version 3.1 (Release 2010a)

Page 4: EDA Simulator Link Block and Function Reference
Page 5: EDA Simulator Link Block and Function Reference

Contents

Block Reference

1HDL Cosimulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

FPGA Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

Virtual Platform Simulation . . . . . . . . . . . . . . . . . . . . . . . . 1-4

Blocks — Alphabetical List

2

Function Reference

3HDL Cosimulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

FPGA Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4

Virtual Platform Simulation . . . . . . . . . . . . . . . . . . . . . . . . 3-5

v

Page 6: EDA Simulator Link Block and Function Reference

Functions — Alphabetical List

4

Index

vi Contents

Page 7: EDA Simulator Link Block and Function Reference

1

Block Reference

HDL Cosimulation (p. 1-2) Describes the EDA Simulator Link™Simulink blocks available for usewith HDL cosimulation

FPGA Implementations (p. 1-3) Describes the EDA SimulatorLink Simulink blocks availablefor use with generating FPGAimplementations

Virtual Platform Simulation (p. 1-4) Describes the EDA Simulator LinkSimulink blocks available for usewith generating Virtual Platformsimulations

Page 8: EDA Simulator Link Block and Function Reference

1 Block Reference

HDL Cosimulation

HDL Cosimulation Cosimulate hardware component bycommunicating with HDL moduleinstance executing in HDL simulator

To VCD File Generate value change dump (VCD)file

1-2

Page 9: EDA Simulator Link Block and Function Reference

FPGA Implementations

FPGA ImplementationsCurrently, there are no EDA Simulator Link Simulink blocks available foruse with generating FPGA implementations.

1-3

Page 10: EDA Simulator Link Block and Function Reference

1 Block Reference

Virtual Platform SimulationCurrently, there are no EDA Simulator Link Simulink blocks available foruse with generating Virtual Platform simulations.

1-4

Page 11: EDA Simulator Link Block and Function Reference

2

Blocks — Alphabetical List

Page 12: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Purpose Cosimulate hardware component by communicating with HDL moduleinstance executing in HDL simulator

Library EDA Simulator Link

Description The HDL Cosimulation block cosimulates a hardware component byapplying input signals to and reading output signals from an HDLmodel under simulation in the HDL simulator. You can use this blockto model a source or sink device by configuring the block with inputor output ports only.

The tabbed panes on the block’s dialog box let you configure:

• Block input and output ports that correspond to signals (includinginternal signals) of an HDL module. You must specify a sampletime for each output port; you can also specify a data type for eachoutput port.

• Type of communication and communication settings used to exchangedata between simulators.

• The timing relationship between units of simulation time in Simulinkand the HDL simulator.

• Rising-edge or falling-edge clocks to apply to your model (Incisive andModelSim users only; Discovery users see launchDiscovery). Youcan specify the period for each clock signal.

• Tcl commands to run before and after the simulation (Incisive andModelSim users only; Discovery users see launchDiscovery).

The HDL Cosimulation Block Panes

The Ports pane provides fields for mapping signals of your HDL designto input and output ports in your block. The signals can be at any levelof the HDL design hierarchy.

The Timescales pane lets you choose an optimal timing relationshipbetween Simulink and the HDL simulator. You can configure either ofthe following timing relationships:

2-2

Page 13: EDA Simulator Link Block and Function Reference

HDL Cosimulation

• Relative timing relationship (Simulink seconds correspond to an HDLsimulator-defined tick interval)

• Absolute timing relationship (Simulink seconds correspond to anabsolute unit of HDL simulator time)

The Connection pane specifies the communications mode usedbetween Simulink and the HDL simulator. If you use TCP socketcommunication, this pane provides fields for specifying a socketport and for the host name of a remote computer running the HDLsimulator. The Connection pane also provides the option for bypassingthe cosimulation block during Simulink simulation.

The Clocks pane lets you create optional rising-edge and falling-edgeclocks that apply stimuli to your cosimulation model.

The Tcl pane provides a way of specifying tools command language(Tcl) commands to be executed before and after the HDL simulatorsimulates the HDL component of your Simulink model. You can usethe Pre-simulation commands field on this pane for simulationinitialization and startup operations, but you cannot use it to changesimulation state.

Note You must make sure that signals being used in cosimulationhave read/write access. This rule applies to all signals on the Ports,Clocks, and Tcl panes.

Incisive and ModelSim users: Verify such access through the HDLsimulator—see product documentation for details.

Discovery users: A tab file is included in the simulation via therequired launchDiscovery property "AccFile".

2-3

Page 14: EDA Simulator Link Block and Function Reference

HDL Cosimulation

DialogBox

The Block Parameters dialog box consists of the following tabbed panesof configuration options:

• “Ports Pane” on page 2-4

• “Connection Pane” on page 2-11

• “Timescales Pane” on page 2-15

• “Clocks Pane” on page 2-19 (Incisive and ModelSim users only)

• “Tcl Pane” on page 2-22 (Incisive and ModelSim users only)

Ports Pane

Specify fields for mapping signals of your HDL design to input andoutput ports in your block. Simulink deposits an input port signal on anHDL simulator signal at the signal’s sample rate. Conversely, Simulinkreads an output port signal from a specified HDL simulator signal atthe specified sample rate.

In general, Simulink handles port sample periods as follows:

• If you connect an input port to a signal that has an explicit sampleperiod, based on forward propagation, Simulink applies that rateto the port.

• If you connect an input port to a signal that does not have an explicitsample period, Simulink assigns a sample period that is equal tothe least common multiple (LCM) of all identified input port sampleperiods for the model.

• After Simulink sets the input port sample periods, it appliesuser-specified output sample times to all output ports. You mustspecify an explicit sample time for each output port.

In addition to specifying output port sample times, you can forcethe fixed-point data types on output ports. For example, setting theData Type property of an 8-bit output port to Signed and setting itsFraction Length property to 5 would force the data type to sfix8_En5.

2-4

Page 15: EDA Simulator Link Block and Function Reference

HDL Cosimulation

You can not force width; the width is always inherited from the HDLsimulator.

Note The Data Type and Fraction Length properties apply only tothe following signals:

• VHDL signals of any logic type, such asSTD_LOGIC orSTD_LOGIC_VECTOR

• Verilog signals of wire or reg type

You can set input/output ports in the Ports pane also. To do so, specifyport as both input and output (example shown for use with ModelSim).

2-5

Page 16: EDA Simulator Link Block and Function Reference

HDL Cosimulation

If your model contains purely combinational paths, you canselect Enable direct feedthrough for HDL design with purecombinational datapath to eliminate the one output-sample delaythat occurs with using EDA Simulator Link blocks and Simulink. Formore information on block simulation latency and using the directfeedthrough feature to eliminate it, see “Eliminating Block SimulationLatency”.

2-6

Page 17: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Discovery Users You may not enable direct feedthrough if your designcontains mixed HDL (VHDL and Verilog). If you do, EDA SimulatorLink will display an error in the HDL simulator.

The list at the center of the pane displays HDL signals correspondingto ports on the HDL Cosimulation block. Maintain this list with thebuttons on the left of the pane:

• Auto Fill — Transmit a port information request to the HDLsimulator. The port information request returns port names andinformation from an HDL model (or module) under simulation in theHDL simulator and automatically enters this information into theports list. See “Obtaining Signal Information Automatically from theHDL Simulator” for a detailed description of this feature.

• New— Add a new signal to the list and select it for editing.

• Delete — Remove a signal from the list.

• Up — Move the selected signal up one position in the list.

• Down—Move the selected signal down one position in the list.

To commit edits to the Simulink model, you must also click Apply afterselecting parameter values.

Note When you import VHDL signals from the HDL simulator , EDASimulator Link returns the signal names in all capitals.

To edit a signal name, double-click on the name. Set the signalproperties on the same line and in the appropriate columns. Theproperties of a signal are as follows.

2-7

Page 18: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Full HDL NameSpecifies the signal path name, using the HDL simulator pathname syntax. For example (for use with Incisive), a path name foran input port might be manchester.samp. The signal can be atany level of the HDL design hierarchy. The HDL Cosimulationblock port corresponding to the signal is labeled with the FullHDL Name.

For rules on specifying signal/port and module path specificationsin Simulink, see “Specifying HDL Signal/Port and Module Pathsfor Cosimulation”.

Copying Signal Path Names (For Incisive and ModelSimUsers) You can copy signal path names directly from the HDLsimulator wave window and paste them into the Full HDLName field, using the standard copy and paste commands in theHDL simulator and Simulink. You must use the Path.Name viewand not Db::Path.Name view. After pasting a signal path nameinto the Full HDL Name field, you must click the Apply buttonto complete the paste operation and update the signal list.

I/O ModeSelect either Input, Output, or both ("both" applies to Incisiveand ModelSim users only).

Input designates signals of your HDL module that Simulinkwill drive. Simulink deposits values on the specified the HDLsimulator signal at the signal’s sample rate.

2-8

Page 19: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Note When you define a block input port, make sure that onlyone source is set up to drive input to that signal. For example, youshould avoid defining an input port that has multiple instances.If multiple sources drive input to a single signal, your simulationmodel may produce unexpected results.

Output designates signals of your HDL module that Simulinkwill read. For output signals, you must specify an explicit sampletime. You can also specify any data type (except width). Fordetails on specifying a data type, see Date Type and FractionLength in a following section.

Because Simulink signals do not have the semantic of tri-states(there is no ’Z’ value), you will gain no benefit by connecting to abidirectional HDL signal directly. To interface with bidirectionalsignals, you can first interface to the input of the output driver,then the enable of the output driver and the output of the inputdriver. This approach leaves the actual tri-state buffer in HDLwhere resolution functions can handle interfacing with othertri-state buffers.

Sample TimeThis property becomes available only when you specify an outputsignal. You must specify an explicit sample time.

Sample Time represents the time interval between consecutivesamples applied to the output port. The default sample time is 1.The exact interpretation of the output port sample time dependson the settings of the Timescales pane of the HDL Cosimulationblock. See also “Understanding the Representation of SimulationTime”.

Data TypeFraction Length

These two related parameters apply only to output signals.

2-9

Page 20: EDA Simulator Link Block and Function Reference

HDL Cosimulation

The Data Type property is enabled only for output signals. Youcan direct Simulink to determine the data type, or you can assignan explicit data type (with option fraction length). By explicitlyassigning a data type, you can force fixed-point data types onoutput ports of an HDL Cosimulation block.

The Fraction Length property specifies the size, in bits, ofthe fractional part of the signal in fixed-point representation.Fraction Length becomes available if you do not set the DataType property to Inherit.

The data type specification for an output port depends on thesignal width and by the Data Type and Fraction Lengthproperties of the signal.

Note The Data Type and Fraction Length properties applyonly to the following signals:

• VHDL signals of any logic type, such as STD_LOGIC orSTD_LOGIC_VECTOR

• Verilog signals of wire or reg type

To assign a port data type, set the Data Type and FractionLength properties as follows:

• Select Inherit from the Data Type list if you want Simulinkto determine the data type.

This property defaults toInherit. When you select Inherit,the Fraction Length edit field becomes unavailable.

Simulink always double checks that the word-length backpropagated by Simulink matches the word length queried fromthe HDL simulator. If they do not match, Simulink generatesan error message. For example, if you connect a Signal

2-10

Page 21: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Specification block to an output, Simulink will force the datatype specified by Signal Specification block on the output port.

If Simulink cannot determine the data type of the signalconnected to the output port, it will query the HDL simulatorfor the data type of the port. As an example, if the HDLsimulator returns the VHDL data type STD_LOGIC_VECTOR for asignal of size N bits, the data type ufixN is forced on the outputport. (The implicit fraction length is 0.)

• Select Signed from the Data Type list if you want to explicitlyassign a signed fixed point data type. When you selectSigned,the Fraction Length edit field becomes available. EDASimulator Link assigns the port a fixed-point type sfixN_EnF,where N is the signal width and F is the Fraction Length.

For example, if you specify Data Type as Signed and aFraction Length of 5 for a 16-bit signal, Simulink forces thedata type to sfix16_En5. For the same signal with a DataType set to Signed and Fraction Length of -5, Simulinkforces the data type to sfix16_E5.

• Select Unsigned from the Data Type list if you want toexplicitly assign an unsigned fixed point data type When youselectUnsigned, the Fraction Length edit field becomesavailable. EDA Simulator Link assigns the port a fixed-pointtype ufixN_EnF, where N is the signal width and F is theFraction Length.

For example, if you specify Data Type as Unsigned and aFraction Length of 5 for a 16-bit signal, Simulink forces thedata type to ufix16_En5. For the same signal with a DataType set to Unsigned and Fraction Length of -5 , Simulinkforces the data type to ufix16_E5.

Connection Pane

This figure shows the default configuration of the Connection pane(example shown is for use with Discovery). The block defaults to a

2-11

Page 22: EDA Simulator Link Block and Function Reference

HDL Cosimulation

shared memory configuration for communication between Simulink andthe HDL simulator, when they run on a single computer.

If you select TCP/IP socket mode communication, the pane displaysadditional properties, as shown in the following figure.

2-12

Page 23: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Connection ModeIf you want to bypass the HDL simulator when you run a Simulinksimulation, use these options to specify what type of simulationconnection you want. Select one of the following options:

• Full Simulation: Confirm interface and run HDL simulation(default).

• Confirm Interface Only: Connect to the HDL simulator andcheck for proper signal names, dimensions, and data types, butdo not run HDL simulation.

• No Connection: Do not communicate with the HDL simulator.The HDL simulator does not need to be started.

With the second and third options, the EDA Simulator Linkcosimulation interface does not communicate with the HDLsimulator during Simulink simulation.

2-13

Page 24: EDA Simulator Link Block and Function Reference

HDL Cosimulation

The HDL Simulator is running on this computerSelect this option if you want to run Simulink and the HDLsimulator on the same computer. When both applications run onthe same computer, you have the choice of using shared memoryor TCP sockets for the communication channel between the twoapplications. If you do not select this option, only TCP/IP socketmode is available, and the Connection method list becomesunavailable.

Connection methodThis list becomes available when you selectThe HDL Simulatoris running on this computer. Select Socket if you wantSimulink and the HDL simulator to communicate via a designatedTCP/IP socket. Select Shared memory if you want Simulink andthe HDL simulator to communicate via shared memory. For moreinformation on these connection methods, see “Communicationsfor HDL Cosimulation”.

Host nameIf you run Simulink and the HDL simulator on differentcomputers, this text field becomes available. The field specifiesthe host name of the computer that is running your HDLsimulation in the HDL simulator.

Port number or serviceIndicate a valid TCP socket port number or service for yourcomputer system (if not using shared memory). For informationon choosing TCP socket ports, see “Choosing TCP/IP Socket Ports”.

Show connection info on iconWhen you select this option, Simulink indicates informationabout the selected communication method and (if applicable)communication options information on the HDL Cosimulationblock icon. If you select shared memory, the icon displays thestring SharedMem. If you select TCP socket communication, theicon displays the string Socket and displays the host name andport number in the format hostname:port.

2-14

Page 25: EDA Simulator Link Block and Function Reference

HDL Cosimulation

In a model that has multiple HDL Cosimulation blocks, with eachcommunicating to different instances of the HDL simulator indifferent modes, this information helps to distinguish betweendifferent cosimulation sessions.

Timescales Pane

The Timescales pane of the HDL Cosimulation block parametersdialog box lets you choose a timing relationship between Simulink andthe HDL simulator, either manually or automatically. The followingfigure shows the default settings of the Timescales pane (exampleshown for use with Incisive).

The Timescales pane specifies a correspondence between one second ofSimulink time and some quantity of HDL simulator time. This quantityof HDL simulator time can be expressed in one of the following ways:

2-15

Page 26: EDA Simulator Link Block and Function Reference

HDL Cosimulation

• Using relative timing mode. EDA Simulator Link defaults to relativetiming mode.

• Using absolute timing mode

For more information on calculating relative and absolute timing modes,see “Defining the Simulink and HDL Simulator Timing Relationship”.

For detailed information on the relationship between Simulink and theHDL simulator during cosimulation, and on the operation of relativeand absolute timing modes, see “Understanding the Representationof Simulation Time”.

The following sections describe how to specify the timing relationship,either automatically or manually.

Automatically Specifying the Timing RelationshipYou can have the EDA Simulator Link software calculate the timingrelationship for you by performing the following steps:

1 Verify that the HDL simulator is running. EDA Simulator Linksoftware can get the resolution limit of the HDL simulator only whenthat simulator is running.

2 Click on Auto Timescale.

The following graphic shows the result of clicking Auto Timescalein the Timescales pane of the HDL Cosimulation block in theManchester Receiver demo (example shown for use with ModelSim).

EDA Simulator Link software analyzes all the clock and port signalrates from the HDL Cosimulation block when it calculates the scalefactor.

2-16

Page 27: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Note EDA Simulator Link cannot automatically calculate a sampletimescale based on any signals driven via Tcl commands or in theHDL simulator. The link software cannot perform such calculationsbecause it cannot know the rates of these signals.

The link software returns the sample rate in either seconds orticks. If the results are in seconds, then the link software was ableto resolve the timing differences in favor of fidelity (absolute time).If the results are in ticks, then the link software was best able toresolve the timing differences in favor of efficiency (relative time).

Each time you press Auto Timescale, the EDA Simulator Linksoftware opens an informational GUI display that explains theresults of Auto Timescale. If the link software cannot calculate atimescale for the given sample times, use the information in thisdialog box to adjust your sample times.

Click Show Details... for information specific to your model’ssignals. Click OK to exit the informational dialog box.

3 Click Apply to commit your changes.

2-17

Page 28: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Note EDA Simulator Link does not support Auto Timescale calculatedfrom frame-based signals.

For more on the timing relationship between the HDL simulator andSimulink, see “Understanding the Representation of Simulation Time”.

Manually Specifying a Relative Timing RelationshipTo manually configure relative timing mode for a cosimulation, performthe following steps:

1 Select the Timescales tab of the HDL Cosimulation blockparameters dialog box.

2 Verify that Tick, the default setting, is selected. If it is not, thenselect it from the list on the right.

3 Enter a scale factor in the text box on the left. The default scalefactor is 1. For example, the next figure, shows the Timescales paneconfigured for a relative timing correspondence of 10 HDL simulatorticks to 1 Simulink second.

4 Click Apply to commit your changes.

Manually Specifying an Absolute Timing RelationshipTo manually configure absolute timing mode for a cosimulation, performthe following steps:

1 Select the Timescales tab of the HDL Cosimulation blockparameters dialog box.

2 Select a unit of absolute time from the list on the right. Theunits available include fs (femtoseconds), ps (picoseconds), ns(nanoseconds), us (microseconds), ms (milliseconds), and s (seconds).

2-18

Page 29: EDA Simulator Link Block and Function Reference

HDL Cosimulation

3 Enter a scale factor in the text box on the left. The default scalefactor is 1. For example, in the next figure, the Timescales pane isconfigured for an absolute timing correspondence of 1 HDL simulatorsecond to 1 Simulink second.

4 Click Apply to commit your changes.

Clocks Pane

Discovery Users The Clocks pane is not available on theHDL Cosimulation block for use with Synopsys Discovery. SeelaunchDiscovery for instructions on adding clocks to your cosimulationmodel.

You can create optional rising-edge and falling-edge clocks that applystimuli to your cosimulation model. To do so, use the Clocks pane of theHDL Cosimulation block (example shown for use with Incisive).

2-19

Page 30: EDA Simulator Link Block and Function Reference

HDL Cosimulation

The scrolling list at the center of the pane displays HDL clocks thatdrive values to the HDL signals that you are modeling, using thedeposit method.

Maintain the list of clock signals with the buttons on the left of the pane:

• New— Add a new clock signal to the list and select it for editing.

• Delete — Remove a clock signal from the list.

• Up— Move the selected clock signal up one position in the list.

• Down—Move the selected clock signal down one position in the list.

To commit edits to the Simulink model, you must also click Apply.

A clock signal has the following properties.

2-20

Page 31: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Full HDL NameSpecify each clock as a signal path name, using the HDLsimulator path name syntax. For example: /manchester/clk ormanchester.clk.

For information about and requirements for path specificationsin Simulink, see “Specifying HDL Signal/Port and Module Pathsfor Cosimulation”.

Note You can copy signal path names directly from the HDLsimulator wave window and paste them into the Full HDLName field, using the standard copy and paste commands in theHDL simulator and Simulink. You must use the Path.Name viewand not Db::Path.Name view. After pasting a signal path nameinto the Full HDL Name field, you must click the Apply buttonto complete the paste operation and update the signal list.

EdgeSelect Rising or Falling to specify either a rising-edge clock or afalling-edge clock.

PeriodYou must either specify the clock period explicitly or accept thedefault period of 2.

If you specify an explicit clock period, you must enter a sampletime equal to or greater than 2 resolution units (ticks).

If the clock period (whether explicitly specified or defaulted) is notan even integer, Simulink cannot create a 50% duty cycle. Instead,the EDA Simulator Link software creates the falling edge at

clockperiod / 2

(rounded down to the nearest integer).

2-21

Page 32: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Note The Clocks pane does not support vectored signals. Signalsmust be logic types with 1 and 0 values.

For instructions on adding and editing clock signals, see “CreatingOptional Clocks with the Clocks Pane of the HDL Cosimulation Block”.

Tcl Pane

Discovery Users The Tcl pane is not available on the HDLCosimulation block for use with Synopsys Discovery. SeelaunchDiscovery for instructions on issuing Tcl commands during acosimulation session.

Specify tools command language (Tcl) commands to be executed beforeand after the HDL simulator simulates the HDL component of yourSimulink model (example shown for use with ModelSim).

2-22

Page 33: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Pre-simulation commandsContains Tcl commands to be executed before the HDL simulatorsimulates the HDL component of your Simulink model. You canspecify one Tcl command per line in the text box or enter multiplecommands per line by appending each command with a semicolon(;), the standard Tcl concatenation operator.

Use of this field can range from something as simple as aone-line echo command to confirm that a simulation is runningto a complex script that performs an extensive simulationinitialization and startup sequence.

Post-simulation commandsContains Tcl commands to be executed after the HDL simulatorsimulates the HDL component of your Simulink model. You canspecify one Tcl command per line in the text box or enter multiplecommands per line by appending each command with a semicolon(;), the standard Tcl concatenation operator.

2-23

Page 34: EDA Simulator Link Block and Function Reference

HDL Cosimulation

Creating a Tcl Script as an Alternative to Using the Tcl PaneYou can create a Tcl script that lists the Tcl commands you want toexecute on the HDL simulator, either pre- or post-simulation.

Tcl Scripts for ModelSim Users

You can create a ModelSim DO file that lists Tcl commands and thenspecify that file with the ModelSim do command as follows:

do mycosimstartup.do

Or

do mycosimcleanup.do

You can include the quit -f command in an after-simulation Tclcommand string or DO file to force ModelSim to shut down at the endof a cosimulation session. To ensure that all other after-simulationTcl commands specified for the model will execute, specify all aftersimulation Tcl commands in a single cosimulation block and place quitat the end of the command string or DO file.

With the exception of quit, the command string or DO file that youspecify cannot include commands that load a ModelSim project ormodify simulator state. For example, they cannot include commandssuch as start, stop, or restart.

Tcl Scripts for Incisive Users

You can create an HDL simulator Tcl script that lists Tcl commandsand then specify that file with the HDL simulator source commandas follows:

source mycosimstartup.script_extension

Or

source mycosimcleanup.script_extension

2-24

Page 35: EDA Simulator Link Block and Function Reference

HDL Cosimulation

You can include the exit command in an after-simulation Tcl scriptto force the HDL simulator to shut down at the end of a cosimulationsession. To ensure that all other after-simulation Tcl commandsspecified for the model will execute, specify all after simulation Tclcommands in a single cosimulation block and place exit at the end ofthe command string or Tcl script.

With the exception of the exit command, the command string or Tclscript that you specify cannot include commands that load an HDLsimulator project or modify simulator state. For example, neither caninclude commands such as run, stop, or reset.

The following example shows a Tcl script when the -gui argument wasused with hdlsimmatlab or hdlsimulink:

after 1000 {ncsim -submit exit}

This next example is of a Tcl exit script to use when the -tcl argumentwas used with hdlsimmatlab or hdlsimulink:

after 1000 {exit}

2-25

Page 36: EDA Simulator Link Block and Function Reference

To VCD File

Purpose Generate value change dump (VCD) file

Library EDA Simulator Link

DescriptionThe To VCD File block generates a VCD file that contains informationabout changes to signals connected to the block’s input ports and namesthe file with the specified file name. You can use VCD files duringdesign verification in the following ways:

• For comparing results of multiple simulation runs, using the same ordifferent simulator environments

• As input to post-simulation analysis tools

• For porting areas of an existing design to a new design

Using the Block Parameters dialog box, you can specify the followingparameters:

• The file name to be used for the generated file

• The number of block input ports that are to receive signal data

• The timescale to relate Simulink sample times with HDL simulatorticks

VCD files can grow very large for larger designs or smaller designs withlonger simulation runs. However, the only limitation on the size of aVCD file generated by the To VCD File block is the maximum numberof signals (and symbols) supported, which is 943 (830,584).

For a description of the VCD file format, see “VCD File Format” onpage 2-29.

2-26

Page 37: EDA Simulator Link Block and Function Reference

To VCD File

Note The To VCD File block is integrated into the Simulink Signal &Scope Manager. See the Simulink User’s Guide for more information onusing the Signal & Scope Manager.

Graphically Displaying VCD File Data

You can graphically display VCD file data or analyze the data withpostprocessing tools. For example, the ModelSim vcd2wlf tool convertsa VCD file to a WLF file that you can view in a ModelSim wavewindow. Other examples of postprocessing include the extraction ofdata pertaining to a particular section of a design hierarchy or datagenerated during a specific time interval.

DialogBox

2-27

Page 38: EDA Simulator Link Block and Function Reference

To VCD File

VCD file nameThe file name to be used for the generated VCD file. If you specifya file name only, Simulink places the file in your current MATLABfolder. Specify a complete path name to place the generated file ina different location. If you specify the same name for multiple ToVCD File blocks, Simulink automatically adds a numeric postfixto identify each instance uniquely.

Note If you want the generated file to have a .vcd file typeextension, you must specify it explicitly.

Do not give the same file name to different VCD blocks. Doingso results in invalid VCD files.

Number of input portsThe number of block input ports on which signal data is to becollected. The block can handle up to 943 (830,584) signals, eachof which maps to a unique symbol in the VCD file.

In some cases, a single input port maps to multiple signals (andsymbols). This multiple mapping occurs when the input portreceives a multidimensional signal.

Because the VCD specification does not include multidimensionalsignals, Simulink flattens them to a 1D vector in the file.

TimescaleChoose an optimal timing relationship between Simulink andthe HDL simulator.

The timescale options specify a correspondence between onesecond of Simulink time and some quantity of HDL simulatortime. You can express this quantity of HDL simulator time inone of the following ways:

2-28

Page 39: EDA Simulator Link Block and Function Reference

To VCD File

• In relative terms (i.e., as some number of HDL simulator ticks).In this case, the cosimulation operates in relative timing mode,which is the timing mode default.

To use relative mode, select Tick from the pop-up list at thelabel in the HDL simulator, and enter the desired number ofticks in the edit box at 1 second in Simulink correspondsto. The default value is 1 Tick.

• In absolute units (such as milliseconds or nanoseconds). In thiscase, the cosimulation operates in absolute timing mode.

To use absolute mode, select the desired resolution unit fromthe pop-up list at the label in the HDL simulator (availableunits are fs, ps, ns, us, ms, s ), and enter the desired numberof resolution units in the edit box at 1 second in Simulinkcorresponds to. Then, set the value of the HDL simulatortick by selecting 1, 10, or 100 from the pop-up list at 1 HDLTick is defined as and the resolution unit from the pop-uplist at defined as.

VCD FileFormat

The format of generated VCD files adheres to IEEE Std 1364-2001. Thefollowing table describes the format.

Generated VCD File Format

File Content Description

$date23-Sep-2003 14:38:11$end

Data and time the filewas generated.

$version EDA SimulatorLink version 1.0 $ end

Version of the VCDblock that generatedthe file.

2-29

Page 40: EDA Simulator Link Block and Function Reference

To VCD File

Generated VCD File Format (Continued)

File Content Description

$timescale 1 ns $ endThe time scale thatwas used during thesimulation.

$scope module manchestermodel $endThe scope of the modulebeing dumped.

$var wire 1 ! Original Data [0] $end

$var wire 1 " Recovered Clock [0] $end

$var wire 1 # Recovered Data [0] $end

$var wire 1 $ Data Validity [0] $end

Variable definitions.Each definitionassociates a signal withcharacter identificationcode (symbol).

The symbols arederived from printablecharacters in the ASCIIcharacter set from ! to~.

Variable definitionsalso include thevariable type (wire)and size in bits.

$upscope $endMarks a change to thenext higher level in theHDL design hierarchy.

$enddefinitions $endMarks the end of theheader and definitionssection.

#0Simulation start time.

2-30

Page 41: EDA Simulator Link Block and Function Reference

To VCD File

Generated VCD File Format (Continued)

File Content Description

$dumpvars0!0"0#0$

$end

Lists the values of alldefined variables attime equals 0.

#6301!

The starting point oflogged value changesfrom checks of variablevalues made at eachsimulation timeincrement.

This entry indicatesthat at 63 nanoseconds,the value of signalOriginal Datachanged from 0 to1.

.

.

.#11601#1$

At 116 nanosecondsthe values of signalsRecovered Dataand Data Validitychanged from 0 to 1.

$dumpoffx!x"x#x$

Marks the end of thefile by dumping thevalues of all variablesas the value x.

2-31

Page 42: EDA Simulator Link Block and Function Reference

To VCD File

Generated VCD File Format (Continued)

File Content Description

$end

2-32

Page 43: EDA Simulator Link Block and Function Reference

3

Function Reference

HDL Cosimulation (p. 3-2) Describes the EDA Simulator LinkMATLAB functions available for usewith HDL cosimulation

FPGA Implementations (p. 3-4) Describes the EDA SimulatorLink MATLAB functions availablefor use with generating FPGAimplementations

Virtual Platform Simulation (p. 3-5) Describes the EDA Simulator LinkMATLAB functions available for usewith generating Virtual Platformsimulations

Page 44: EDA Simulator Link Block and Function Reference

3 Function Reference

HDL CosimulationbreakHdlSim Execute stop command in HDL

simulator from MATLAB

configuremodelsim Configure ModelSim for use withEDA Simulator Link

dec2mvl Convert decimal integer to binarystring

hdldaemon Control MATLAB server thatsupports interactions with HDLsimulator

hdlsimmatlab Load instantiated HDL design forverification with Cadence Incisiveand MATLAB

hdlsimulink Load instantiated HDL design forcosimulation with Cadence Incisiveand Simulink

launchDiscovery Launch Synopsys Discovery tools foruse with Simulink and MATLABusing EDA Simulator Link software

matlabcp Associate MATLAB componentfunction with instantiated HDLdesign

matlabtb Schedule MATLAB test benchsession for instantiated HDL module

matlabtbeval Call specified MATLAB functiononce and immediately on behalf ofinstantiated HDL module

mvl2dec Convert multivalued logic to decimal

nclaunch Start and configure Cadence Incisivesimulators for use with EDASimulator Link software

nomatlabtb End active MATLAB test bench andMATLAB component sessions

3-2

Page 45: EDA Simulator Link Block and Function Reference

HDL Cosimulation

notifyMatlabServer Send HDL simulator event andprocess IDs to MATLAB server

pingHdlSim Block cosimulation until HDLsimulator is ready for simulation

tclHdlSim Execute Tcl command in Incisive orModelSim simulator

vsim Start and configure ModelSim foruse with EDA Simulator Link

vsimmatlab Load instantiated HDL module forverification with ModelSim andMATLAB

vsimulink Load instantiated HDL module forcosimulation with ModelSim andSimulink

waitForHdlClient Wait until specified event ID isobtained or time-out occurs

3-3

Page 46: EDA Simulator Link Block and Function Reference

3 Function Reference

FPGA Implementationsfpgamodelsetup Set Simulink model parameters for

FPGA workflow

makefpgaproject Generate Xilinx® ISE project andFPGA hardware-in-the-loop

setupxilinxtools Configure MATLAB environment foruse with Xilinx FPGA workflow

3-4

Page 47: EDA Simulator Link Block and Function Reference

Virtual Platform Simulation

Virtual Platform SimulationCurrently, there are no EDA Simulator Link MATLAB functions available foruse with generating Virtual Platform simulations.

3-5

Page 48: EDA Simulator Link Block and Function Reference

3 Function Reference

3-6

Page 49: EDA Simulator Link Block and Function Reference

4

Functions — AlphabeticalList

Page 50: EDA Simulator Link Block and Function Reference

breakHdlSim

Purpose Execute stop command in HDL simulator from MATLAB

Syntax breakHdlSim()breakHdlSim('portNumber')breakHdlSim('portNumber','hostName')

Description breakHdlSim() executes a stop command on the HDL simulator on thelocal host. Use this function to unblock the HDL simulator after theHDL simulator has loaded the simulation but before Simulink startsthe simulation. If, after starting the simulation, you decide to add moresignals to the waveform window, use this function to unblock the HDLsimulator first. When you usebreakHdlSim, make sure that you specifythe proper connection information to the HDL simulator.

breakHdlSim('portNumber') executes a stop command on the HDLsimulator on port portNumber.

breakHdlSim('portNumber','hostName') executes a stop commandon the HDL simulator on host hostName.

Examples Stop the HDL simulator that is currently running on the local host.

>> breakHdlSim()

Stop the HDL simulator that is currently running on port 1234.

>> breakHdlSim('1234')

Stop the HDL simulator that is currently running on port 1234 andhost "mylinux".

>> breakHdlSim('1234', 'mylinux')

See Also pingHdlSim

4-2

Page 51: EDA Simulator Link Block and Function Reference

configuremodelsim

Purpose Configure ModelSim for use with EDA Simulator Link

Syntax configuremodelsimconfiguremodelsim('PropertyName', 'PropertyValue'...)

DescriptionNote configuremodelsim has been replaced by the guided setupscript (syscheckmq) for configuring your simulator setup. Althoughconfiguremodelsim is supported for backward compatibility, youshould consider using the setup script instead. See “Diagnosing andCustomizing Your Setup for Use with the HDL Simulator and EDASimulator Link Software”.

configuremodelsim configures ModelSim for use with the MATLABand Simulink features of EDA Simulator Link. There are two usesfor this function:

• To configure ModelSim so that it may access EDA Simulator Linkwhen invoked from outside of MATLAB

• To add Tcl commands to the Tcl startup script that runs every timeyou invoke ModelSim

When you use configuremodelsim without any arguments,the function prompts you to either allow it to find the installedModelSim executable or have you provide the path to the ModelSiminstallation you want to use. If you had not configured the softwarepreviously (no Tcl DO file exists), configuremodelsim creates anew ModelSimTclFunctionsForMATLAB.tcl script in the tcl folderunder the ModelSim installation. If a previous configuration exists,configuremodelsim prompts you to decide if you want to replace theexisting configuration.

configuremodelsim('PropertyName', 'PropertyValue'...) startsan interactive or programmatic script (depending on which propertyname/value pairs you select) that allows you to customize the ModelSim

4-3

Page 52: EDA Simulator Link Block and Function Reference

configuremodelsim

configuration. See configuremodelsim Property Name/Property Valuepairs.

After you call this function, ModelSim is ready to use EDA SimulatorLink when you invoke ModelSim from outside of MATLAB. You canuse the EDA Simulator Link functions for use in the HDL simulatorto perform the following actions:

• Load instances of VHDL entities or Verilog modules for simulationsthat use MATLAB or Simulink for verification or cosimulation

• Begin MATLAB test bench or component sessions for loadedinstances

• End MATLAB test bench or component sessions

If you have specified Tcl commands to add to the Tclstartup DO file, those commands are now added to theModelSimTclFunctionsForMATLAB.tcl script.

Note that configuremodelsim can only configure one platform. Theprocess hard-codes the path to the HDL server/client libraries, whichare specific to the OS (and GCC).

Usage Considerations

• configuremodelsim is intended to be used for setting up ModelSimand MATLAB when you plan to start ModelSim from outside ofMATLAB.

If you intend to invoke vsim from the MATLAB prompt, then you donot need to use configuremodelsim. (MATLAB will find vsim ifit already appears in the system path, and, if it does not, you canset the vsimdir property value of vsim in MATLAB to provide thepath information.)

In addition, if you are starting ModelSim from outside of MATLAB,you should define your environment with the path to the ModelSimexecutable before running configuremodelsim.

4-4

Page 53: EDA Simulator Link Block and Function Reference

configuremodelsim

Note The property name/property value options for vsim may havebeen set previously with a call to configuremodelsim. To check oncurrent settings, search for and browse through the contents of thefile \tcl\ModelSimTclFunctionsForMATLAB.tcl in your ModelSiminstallation path. The vsim function overrides any options previouslydefined by the configuremodelsim function.

To start ModelSim from MATLAB with a default configurationpreviously defined by configuremodelsim, issue the command !vsimat the MATLAB command prompt.

• The vsimdir property value of configuremodelsim only instructsconfiguremodelsim where to put the Tcl DO file. It does not set upMATLAB workspace for MATLAB invocation of ModelSim (instead,you can perform this setup with the vsimdir property value of vsim).

• If you are using configuremodelsim to add Tcl commands to the Tclstartup DO file, to change the location of the Tcl startup DO file, or toremove the Tcl startup DO file, you can run configuremodelsim asmany times as you wish. You need to run configuremodelsim onlyonce to set the location of the Tcl DO file.

PropertyName/PropertyValuePairs

'action', 'install'Instructs configuremodelsim to create a newModelSimTclFunctionsForMATLAB.tcl script.

This script is programmatic if you use 'vsimdir' to specifythe ModelSim installation you want to use; otherwise,configuremodelsim prompts you for the desired folder.

If a previous configuration exists, configuremodelsim promptsyou to decide if you want to replace the existing configuration. Ifyou respond yes, the old Tcl DO file is overwritten with a new one.

4-5

Page 54: EDA Simulator Link Block and Function Reference

configuremodelsim

'action', 'uninstall'Removes the EDA Simulator Link configuration from theModelSim startup DO file. The property replaces the contents ofModelSimTclFunctionsForMATLAB.tcl with this single line oftext: “# MATLAB and Simulink option was deconfigured.”

This script is programmatic if you use 'vsimdir' to specifythe ModelSim installation you want to use; otherwise,configuremodelsim prompts you for the desired folder.

'tclstart', 'tcl_commands'Adds one or more Tcl commands to the Tcl DO file that executesduring ModelSim startup. Specify a command string or a cellarray of command strings that configuremodelsim will appendto ModelSimTclFunctionsForMATLAB.tcl.

This script is programmatic only; if you do not also use 'vsimdir'with this property, configuremodelsim uses the first vsim itencounters on the system path and modifies the Tcl DO file(ModelSimTclFunctionsForMATLAB.tcl) in the \tcl folder underthis ModelSim installation.

'vsimdir', 'pathname'Specifies where to put the Tcl script containing EDA SimulatorLink Tcl commands. This script is programmatic only; if you donot specify a folder with this property, configuremodelsim usesthe first vsim it encounters on the system path and installs theTcl DO file (ModelSimTclFunctionsForMATLAB.tcl) in the \tclfolder under this ModelSim installation.

Examples The following function call starts the interactive installation script thatinstalls EDA Simulator Link commands for use with ModelSim:

configuremodelsim

Because the property name vsimdir was not supplied,configuremodelsim prompts you for the folder:

4-6

Page 55: EDA Simulator Link Block and Function Reference

configuremodelsim

Identify the ModelSim installation to be configured for MATLAB and Simulink

Do you want configuremodelsim to locate installed ModelSim executables [y]/n? n

Please enter the path to your ModelSim executable file (modelsim.exe or vsim.exe):

D:\Applications\Modeltech_6.0e\win32

Modelsim successfully configured to be used with MATLAB and Simulink

When configuremodelsim is run on an existing configuration, thedialog looks similar to the following sample:

Identify the ModelSim installation to be configured for MATLAB and Simulink

Do you want configuremodelsim to locate installed ModelSim executables [y]/n? n

Please enter the path to your ModelSim executable file (modelsim.exe or vsim.exe):

D:\Applications\Modeltech_6.0e\win32

Previous MATLAB startup file found in this installation of ModelSim:

D:\Applications\Modeltech_6.0e\win32\..\tcl\ModelSimTclFunctionsForMATLAB.tcl

Do you want to replace this file [y]/n? y

Modelsim successfully configured to be used with MATLAB and Simulink

If you answer no to the prompt for replacing the file, you receive thismessage instead:

Modelsim configuration not updated for MATLAB and Simulink

This next example shows adding a Tcl command to the ModelSimconfiguration, for a customized Tcl DO file:

configuremodelsim('tclstart','echo Starting ModelSim and EDA Simulator Link')

vsimoptions =

echo Starting ModelSim and EDA Simulator Link

4-7

Page 56: EDA Simulator Link Block and Function Reference

configuremodelsim

Modelsim successfully configured to be used with MATLAB and Simulink

If you now inspect ModelSimTclFunctionsForMATLAB.tcl you will findthis last Tcl command appended to the file.

The following example shows removing the EDA Simulator Linkconfiguration from ModelSim:

configuremodelsim ('action', 'uninstall')

Identify the Modelsim installtion to be deconfigured for MATLAB and Simulink

Do you want configuremodelsim to locate installed Modelsim executables [y]/n? n

Please enter the path to your Modelsim executable file (modelsim.exe or vsim.exe):

D:\Applications\Modeltech_6.0e\win32

Previous MATLAB startup file found in this installation of Modelsim:

D:\Applications\Modeltech_6.0e\win32...\tcl\ModelsimTclFunctionsForMATLAB.tcl

Do you want to replace this file (required for deconfiguration) [y]/n? y

Modelsim successfully deconfigured

If you now inspect ModelSimTclFunctionsForMATLAB.tcl you will findthat the contents of the file have been removed.

4-8

Page 57: EDA Simulator Link Block and Function Reference

dec2mvl

Purpose Convert decimal integer to binary string

Syntax dec2mvl(d)dec2mvl(d,n)

Description dec2mvl(d) returns the binary representation of d as a multivaluedlogic string. d must be an integer smaller than 2^52.

dec2mvl(d,n) produces a binary representation with at least n bits.

Examples The following function call returns the string ’10111’:

dec2mvl(23)

The following function call returns the string ’01001’:

dec2mvl(-23)

The following function call returns the string ’11101001’:

dec2mvl(-23,8)

See Also mvl2dec

4-9

Page 58: EDA Simulator Link Block and Function Reference

fpgamodelsetup

Purpose Set Simulink model parameters for FPGA workflow

Syntax fpgamodelsetup (Model)

Description fpgamodelsetup (Model) changes the parameters of the Simulinkmodel specified by the model argument to values that are commonlyused for HDL code generation and the Xilinx FPGA workflow. It alsocauses the Simulink® HDL Coder™ pane and the EDA Simulator Linkpane to be visible in the Configuration Parameters dialog box.

The fpgamodelsetup command uses the Simulink set_param functionto set up models for HDL code generation and FPGA workflowquickly and consistently. The model parameters settings provided byfpgamodelsetup are intended as useful defaults, but they may not beappropriate for all your applications.

Issue this function after you open or create a model but before you wantto generate the FPGA project. You must set the GUI up first with thiscommand or the EDA Link configuration panel will not be availableto you.

Inputs Model

Name of the model whose generated code is to be used in creatingthe FPGA project, FPGA HIL, or in generating Tcl script

Examples >>model = 'sfir_fixed';>>open_system(model);>>fpgamodelsetup(model);

See Also makefpgaproject

4-10

Page 59: EDA Simulator Link Block and Function Reference

hdldaemon

Purpose Control MATLAB server that supports interactions with HDL simulator

Syntax hdldaemons=hdldaemonhdldaemon(’ParameterName’,ParameterValue)s=hdldaemon(’ParameterName’,ParameterValue)hdldaemon(’Option’)

Description hdldaemon starts the HDL Link MATLAB server using shared memoryinterprocess communication. Only one hdldaemon per MATLAB sessioncan be running at any given time.

s=hdldaemon starts the MATLAB server using shared memory andreturns the server status connection in structure s.

hdldaemon(’ParameterName’,ParameterValue) starts the MATLABserver using shared memory and accepts optional inputs as one or morecomma-separated parameter-value pairs. ParameterName is the nameof the parameter inside single quotes. ParameterValue is the valuecorresponding to ParameterName. To start the server in socket mode,use the 'socket' parameter.

Note If server is already running, issuing hdldaemon with thesearguments will shut down the current server and start the server upagain using shared memory (unless socket is specified). The exceptionis issuing hdldaemon

s=hdldaemon(’ParameterName’,ParameterValue) works the sameas hdldaemon(’ParameterName’,ParameterValue) and returns theserver status connection in structure s.

hdldaemon(’Option’) accepts a single optional input. Only oneoption may be specified in a single call. You must establish the serverconnection before calling hdldaemon with one of these options.

4-11

Page 60: EDA Simulator Link Block and Function Reference

hdldaemon

Inputs Option

Select one of the following options:

• 'kill'

Shuts down the MATLAB server without shutting downMATLAB.

• 'stop'

Shuts down the MATLAB server without shutting downMATLAB. There is no difference between using 'kill' and'stop'.

• 'status'

Displays status of the MATLAB server. You can also uses=hdldaemon('status'), which displays MATLAB serverstatus and returns status in structure s.

Parameter/Value Pairs

'time'

Specifies how the MATLAB server sends and returns time values.

• 'int64'

Specifies that the MATLAB server send and return timevalues in the MATLAB function callbacks as 64-bit integersrepresenting the number of simulation steps.See the matlabcp/matlabtb tnow parameter reference(“Defining EDA Simulator Link MATLAB Functions andFunction Parameters”).

• 'sec'

Specifies that the MATLAB server sends and returns timevalues in the MATLAB function callbacks as double valuesthat EDA Simulator Link scales to seconds based on thecurrent HDL simulation resolution.

4-12

Page 61: EDA Simulator Link Block and Function Reference

hdldaemon

If server is already running, issuing hdldaemon with the timeparameter alone will shut down the current server and start theserver up again using shared memory.

Default: 'sec'

'quiet'

Suppresses printing diagnostic messages. Errors still appear. Usethis option to suppress the MATLAB server shutdown messagewhen using hdldaemon to get an unused socket number.

• 'true'

Suppress printing diagnostic messages.

• 'false'

Do not suppress printing diagnostic messages.

If server is already running, issuing hdldaemon with the quietparameter alone will shut down the current server and start theserver up again using shared memory.

Default: 'false'

'socket'

Defines the TCP/IP port used for communication. The socketvalue can be:

• 0, indicating the host automatically chooses a valid TCP/IP port

• An explicit port number (1024 < port < 49151)

• A service name (that is, alias) from /etc/services file

If you specify the operating system option (0), usehdldaemon('status') to acquire the assigned socket portnumber.

4-13

Page 62: EDA Simulator Link Block and Function Reference

hdldaemon

See “Specifying TCP/IP Values” for more information aboutTCP/IP ports.

'tclcmd'

Transmits a Tcl command to all connected clients (ModelSim andIncisive users only).

You may specify any valid Tcl command string. The Tcl commandstring you specify cannot include commands that load an HDLsimulator project or modify simulator state. For example, thestring cannot include commands such as start, stop, or restart(for ModelSim) or run, stop, or reset (for Incisive).

Note You can issue this command only after the softwareestablishes a server connection.

Caution

Do not call hdldaemon(tclcmd, 'tclcmd') from inside amatlabtb or matlabcp function. Doing so results in a racecondition, and the simulator hangs.

Outputs s

s is a structure with these fields:

• comm

Shared memory or sockets

• connections

Number of open connections

• ipc_id

4-14

Page 63: EDA Simulator Link Block and Function Reference

hdldaemon

File system name (for shared memory communication channel)or TCP/IP port number (for socket)

Examples Start the MATLAB server using shared memory communication anduse an integer representation of time:

hdldaemon('time', 'int64')

Start MATLAB server and specify socket communication on port 4449:

hdldaemon('socket', 4449)

Start MATLAB server with socket communication and use a 64-bitrepresentation of time:

hdldaemon('socket', 4449, 'time', 'int64')

Check hdldaemon server status:

hdldaemon('status')

Returns, for example,

HDLDaemon socket server is running on port 4449 with 1 connections

Or

HDLDaemon shared memory server is running with 0 connections

Or

HDLDaemon is NOT running

4-15

Page 64: EDA Simulator Link Block and Function Reference

hdldaemon

Check connection information for communication mode, number ofexisting connections, and the interprocess communication identifier(ipc_id) the MATLAB server is using for a link:

x=hdldaemon('status')

For a socket connection, returns:

x =comm: 'sockets'

connections: 0ipc_id: '4449'

For shared memory, returns:

x =

comm: 'shared memory'

connections: 0

ipc_id: [1x45 char]

You can examine ipc_id by entering it at the MATLAB commandprompt:

>>x.ipc_id

Shut down server without shutting down MATLAB:

hdldaemon('kill')

Issue simple Tcl commands:

hdldaemon('tclcmd','puts "This is a test"')

Issue complex Tcl commands:

4-16

Page 65: EDA Simulator Link Block and Function Reference

hdldaemon

See the demo for Implementing the Filter Component of an Oscillator inMATLAB for an extensive example of a compound Tcl command.

See Also launchDiscovery | nclaunch | vsim

How To • “Starting the HDL Simulator from MATLAB”

• “Run MATLAB Test Bench Simulation”

• “Stop Test Bench Simulation”

• “Run MATLAB Component Function Simulation”

4-17

Page 66: EDA Simulator Link Block and Function Reference

hdlsimmatlab

Purpose Load instantiated HDL design for verification with Cadence Incisiveand MATLAB

Syntax hdlsimmatlab <instance> [<ncsim_args>]

Description The hdlsimmatlab command loads the specified instance of an HDLdesign for verification and sets up the Cadence Incisive simulator soit can establish a communication link with MATLAB. The CadenceIncisive simulator opens a simulation workspace as it loads the HDLdesign.

This command may be run from the HDL simulator prompt or froma Tcl script shell (tclsh).

This command is issued in the HDL simulator.

Arguments <instance>Specifies the instance of an HDL design to load for verification.

<ncsim_args>Specifies one or more ncsim command arguments. For details,see the description of ncsim in the Cadence Incisive simulatordocumentation.

Examples The following command loads the module instance parse from librarywork for verification and sets up the Cadence Incisive simulator so itcan establish a communication link with MATLAB:

tclshell> hdlsimmatlab work.parse

4-18

Page 67: EDA Simulator Link Block and Function Reference

hdlsimulink

Purpose Load instantiated HDL design for cosimulation with Cadence Incisiveand Simulink

Syntax hdlsimulink [<ncsim_args>] <instance>[-socket <tcp_spec>]

Description The hdlsimulink command loads the specified instance of an HDLdesign for cosimulation and sets up the Cadence Incisive simulator soit can establish a communication link with Simulink. The CadenceIncisive simulator opens a simulation workspace into which it loadsthe HDL design.

This command is issued in the HDL simulator.

Argument <ncsim_args>Specifies one or more ncsim command arguments. At a minimum,either -gui or -tcl is required. If you specify -gui, the SimulinkGUI launches when the HDL design is loaded. If you specify-tcl, a Tcl script shell launches instead. If you do not specifyeither of these arguments, the HDL simulator runs the simulationwithout Simulink. Other valid ncsim arguments may be specifiedin addition to -gui or -tcl. For more information on -gui, -tcl,or other ncsim arguments, see the description of ncsim in theCadence Incisive simulator documentation.

<instance>Specifies the instance of an HDL design to load for cosimulation.

-socket <tcp_spec>Specifies TCP/IP socket communication for the link between theCadence Incisive simulator and MATLAB. This setting overridesthe setting specified with the MATLAB nclaunch function. The<tcp_spec> can consist of a TCP/IP socket port number or servicename (alias). For example, you might specify port number 4449 orthe service name matlabservice.

For more information on choosing TCP/IP socket ports, see“Choosing TCP/IP Socket Ports”.

4-19

Page 68: EDA Simulator Link Block and Function Reference

hdlsimulink

If you run the HDL simulator and MATLAB on the samecomputer, you have the option of using shared memoryfor communication. Shared memory is the default mode ofcommunication and takes effect if you do not specify -socket<tcp-spec> on the command line.

Note The communication mode that you specify with thehdlsimulink command must match what you specify for thecommunication mode when you configure EDA Simulator Linkblocks in your Simulink model. For more information on modesof communication, see “Communications for HDL Cosimulation”.For more information on establishing the Simulink end of thecommunication link, see “Configuring the Communication Link inthe HDL Cosimulation Block”.

Examples The following command loads the module instance parse from librarywork for cosimulation, sets up the Cadence Incisive simulator so it canestablish a communication link with Simulink, and opens a Tcl scriptshell:

tclshell> hdlsimulink -gui work.parse

4-20

Page 69: EDA Simulator Link Block and Function Reference

launchDiscovery

Purpose Launch Synopsys Discovery tools for use with Simulink and MATLABusing EDA Simulator Link software

Syntax pv = launchDiscovery('PropertyName', 'PropertyValue'...)pv = launchDiscovery(PropertyValueStruct)

Description pv = launchDiscovery('PropertyName', 'PropertyValue'...)generates HDL compile scripts and HDL simulator launch scripts andexecutes them. These scripts set up an appropriate GCC environmentand load the correct EDA Simulator Link library into the ModelSim®

simulator. The function returns a structure of properties and theirvalues.

For custom scripting requirements, you can use launchDiscovery togenerate template "sh" scripts that you can modify and invoke fromMATLAB using a "system" command.

You must use a property name/property value pair withlaunchDiscovery('PropertyName', 'PropertyValue'...).

pv = launchDiscovery(PropertyValueStruct) both passes andreturns a structure of properties and their values.

In batch run modes, the function returns only after the HDL simulatorstarts and the HDL simulation begins. In interactive run modes,the function returns without waiting for the user to start the HDLsimulation.

PropertyName/PropertyValuePairs

Required Properties

'LinkType' , 'appname'Specifies either Simulink or MATLAB. A Simulink link sessionincludes using the HDL Cosimulation block in a Simulink modelfor cosimulation with the HDL simulator. A MATLAB link sessionincludes using matlabtb, matlabcp, and matlabtbeval to employMATLAB functions as callbacks for HDL simulator events.

4-21

Page 70: EDA Simulator Link Block and Function Reference

launchDiscovery

'VerilogFiles', 'pathname'Specifies the full or relative (to "RunDir") path to Verilog files.Specify as single string in double quotes or as cell array offilenames.

Only one of "VerilogFiles" and "VhdlFiles" is required; specifyboth for mixed language designs.

'VhdlFiles', 'pathname'Specifies the full or relative (to "RunDir") path to VHDL files.Specify as single string in double quotes or as cell array offilenames.

Only one of "VerilogFiles" and "VhdlFiles" is required; specifyboth for mixed language designs.

'TopLevel', 'modulename'Specifies the name of the top-level HDL module.

'AccFile', 'filename'Specifies the name of the signal access file that gives cosimulatedsignals read/write/force access to the EDA Simulator Linkapplication. See the Synopsys Discovery documentation (searchfor "PLI table") on how to create this file.

Common Optional Properties

'PreSimTcl', 'command'Specifies Tcl commands to execute before starting the HDLsimulation. Use this property for simple waveform generationstatements for signals such as clocks, resets, and enables.

'PingTimeout', 'seconds'For Simulink link sessions only. Specifies the number of secondsto wait for the HDL simulator to launch before reporting back anerror. To avoid waiting for the simulator to start, use the value of’0’. This property defaults to ’60’ for 'Batch' and 'Batch withXterm' run modes, and ’0’ for 'CLI' and 'GUI' run modes.

4-22

Page 71: EDA Simulator Link Block and Function Reference

launchDiscovery

'RunDir', 'dirname'Specifies the folder from which to execute the compilation andlaunch scripts. This property defaults to an automatically createdtemporary folder.

'RunMode', 'modetype'Specifies how to start the HDL simulator. This property acceptsthe following valid values:

• 'Batch': Start the HDL simulator in the background with nowindow.

• 'Batch with Xterm': Start the HDL simulator in thebackground but show session in an Xterm.

• 'CLI': Start the HDL simulator in an interactive shell.

• 'GUI': Start the HDL simulator in the Synopsys DVE GUI.

This value defaults to 'GUI'.

'RunTime', 'runtime'Amount of time to run the simulation for when running in ’Batch’or ’Batch with Xterm’ run modes. You can specify a raw number(which uses the time resolution unit value) or a number with atime unit (one of {’s’,’ms’,’us’,’ns’,’ps’,’fs’}). The default amount ofrun time is: ’’

For MATLAB link sessions only.

'VlogAnFlags', 'flagnames'Specifies 'vlogan' flags.

'VhdlAnFlags', 'flagnames'Specifies 'vhdlan' flags.

'UumCompFlags', 'flagnames'Sets UUM-compatible compilation flags to 'vcs' .

'UumRunFlags', 'flagnames'Sets UUM-compatible runtime flags to 'simv' .

4-23

Page 72: EDA Simulator Link Block and Function Reference

launchDiscovery

Advanced Optional Properties

'CosimBlockList', 'blocklist'For Simulink links only. Specifies a cell array of HDLCosimulation block instances that are bound to the HDLsimulator about to be built and launched. This value defaults toall cosimulation blocks in the current model. Correct syntax is:

'CosimBlockList', { 'block1', block2', ... }

'HostComm','commtype'For Simulink link sessions only. Specifies the communicationsmechanism between Simulink and a local HDL simulator. Thisproperty accepts the following valid values:

• 'AutoGenSocketPort': Find an available TCP port on thecurrent host and program the CosimBlockList with that port.This is the default value for HostComm.

• 'SharedPipe': Program the CosimBlockList to use a sharedpipe connection.

• 'GetFromCosimBlock': Use whichever communicationparameters appear in any existing cosimulation block masks.

• '<portnumber>': Program the CosimBlockList with a numericsocket port value, '<portnumber>', specified as a string.

• '<servicename>': Program the CosimBlockList with an OSTCP/IP service name, '<servicename>', specified as a string.

Note launchDiscovery currently does not directly supportremote host execution; see “Examples” on page 4-26 section forhelp in setting up remote connections.

'HostName', 'name'Specifies a remote host name for cross-machine co-simulationswith Simulink.

4-24

Page 73: EDA Simulator Link Block and Function Reference

launchDiscovery

'SkipCompilation', true|falseWhen true, instructs the HDL simulator not to execute thecompilation script. This value defaults to false.

'SkipLaunch', true|falseWhen true, instructs the HDL simulator not to execute the launchscript. This value defaults to false.

'SkipScriptGeneration', true|falseWhen true, instructs HDL simulator not to write the compilationand launch scripts. This value defaults to false.

'UserEnv,' 'arrayname'Specifies a cell array of VAR=value environment variables for useby the compilation and launch scripts. Correct syntax is:

'UserEnv', { 'VAR1=val1', 'VAR2=val2', ... }

VG_GNU_PACKAGE Properties

The default GCC compiler used is the default VG_GNU_PACKAGEfrom a standard installation in the VCS tree. If you want tocompile using a different version of GCC, you must specify thefollowing properties.

'UseDefaultVgGnuPackage', true|falseSpecifies using the default VG_GNU_PACKAGE in the VCSinstallation tree. See Synopsys documentation for the installationinstructions. When you set the UseDefaultVgGnuPackageproperty to True, the function ignoresVgGnuPackage andVgGnuGccVersion. To guarantee inter-operability of the linkapplication with the ModelSim software, keep this property set toTrue. This value defaults to True.

'VgGnuPackage', 'dirpath'Specifies the full directory path to a nondefault installation (aninstallation outside of the VCS tree) of VG_GNU_PACKAGE. Thisvalue defaults to 'none'.

4-25

Page 74: EDA Simulator Link Block and Function Reference

launchDiscovery

'VgGnuGccVersion', 'version'Specifies the version of GCC to use. Currently, only gcc-4.2.2 issupported.

The default value is ’gcc-4.2.2’.

Typical use cases for these properties include:

• Use default GCC version in the default VG_GNU_PACKAGEinstallation location. You specify nothing. Synopsys and theVG_GNU_PACKAGE distribution determine these defaults.

• Use default GCC version in a nondefault VG_GNU_PACKAGEinstallation location. For this property, you must specify:

- 'UseDefaultVgGnuPackage', false

- 'VgGnuPackage', '/path/to/vg/gnu/installation'

• Use nondefault GCC version in the default VG_GNU_PACKAGEinstallation location. For this property, you must specify:

- 'UseDefaultVgGnuPackage', false

- 'VgGnuGccVersion', 'gcc-4.4.2' (for example)

• Use nondefault GCC version in a nondefault VG_GNU_PACKAGEinstallation location. For this property, you must specify:

- 'UseDefaultVgGnuPackage', false

- 'VgGnuPackage', '/path/to/vg/gnu/installation'

- 'VgGnuGccVersion', 'gcc-4.4.2' (for example)

Examples This example compiles and launches a single-file HDL design forcosimulation with Simulink. The code allows the use of Verilog-2000syntax in the HDL source. This code launches the Synopsys DVEsoftware.

>> launchDiscovery( ...'LinkType', 'Simulink', ...

4-26

Page 75: EDA Simulator Link Block and Function Reference

launchDiscovery

'VerilogFiles', 'myinverter.v', ...'VlogAnFlags', '+v2k', ...'TopLevel', 'myinverter', ...'AccFile', 'myinverter.acc' ...

);

This next example compiles and launches an HDL design in batchmode. In batch mode, the HDL simulator exits after the simulationcompletes, thus the example relaunches the simulation by callinglaunchDiscovery again with the previously returned property/valuestructure.

To run cosimulation after HDL simulator has exited:

>> pv = launchDiscovery( ...

'LinkType', 'Simulink', ...

'VhdlFiles', '"mymultiplier.vhd mymultiplier_tb.vhd"', ...

'TopLevel', 'mymultiplier_tb', ...

'AccFile', 'mymultiplier.acc', ...

'RunMode', 'Batch', ...

);

To rerun cosimulation:

>> pv.SkipScriptGeneration = true;

>> pv.SkipCompilation = true;

>> pv = launchDiscovery(pv); % relaunch the simulator

This next example generates scripts for customizing the environmentof a specific project (USER_ENV includes some custom environment).Some common reasons to customize the resultant script include:

• You want to run the scripts on a different platform.

• You want to run the scripts on the same platform but on a remotemachine.

• The build and run for the HDL simulator is part of a largerenvironment involving Perl scripts, makefiles, or LSF.

4-27

Page 76: EDA Simulator Link Block and Function Reference

launchDiscovery

• You want to run in 32-bit mode on a 64-bit machine

>> srcDir = '/path/to/src';

>> launchDiscovery( ...

'LinkType', 'MATLAB', ...

'VhdlFiles', {[srcDir '/top.vhd'], [srcDir '/dut.vhd']}, ...

'TopLevel', 'top', ...

'AccFile', 'top.acc', ...

'RunDir', '/testruns/myrun', ...

'UserEnv', {'LM_LICENSE_FILE=/path/to/license.dat'}, ...

'SkipCompilation', true, ...

'SkipLaunch', true ...

);

On remote machine, for example, you might use:

sh> cd /testruns/myrunsh> (edit scripts as needed)sh> . tmwESLDS.compile.shsh> . tmwESLDS.launch.sh

After you finalize the scripts, you can execute them from MATLAB:

>> system('rsh linux100 cd /testruns/myrun ; sh tmwESLDS.compile.sh ;

sh tmwESLDS.launch.sh');

This example shows the generated compilation script:

4-28

Page 77: EDA Simulator Link Block and Function Reference

launchDiscovery

# AUTO-GENERATED SH SCRIPT FOR Simulink COSIMULATION

#--- EDA Link Environment ---

LAUNCHER_NAME=tmwESLDS

NUM_BITS=64

LINK_LIB_DIR=/matlab/toolbox/edalink/extensions/discovery/linux64

LINK_SL_FILE=liblfdhdls_vlog_gcc336.so

LINK_ML_FILE=liblfdhdlc_vlog_gcc336.so

BITS_FLAG=-full64

export VG_GNU_PACKAGE=${VCS_HOME}/gnu/linux

COMPILE_SETUP_CMDS=". ${VG_GNU_PACKAGE}/source_me_${NUM_BITS}.sh"

export LD_LIBRARY_PATH=${VG_GNU_PACKAGE}/gcc-${NUM_BITS}/slib64:${LINK_LIB_DIR}:${LD_LIBRARY_PATH}

LOAD_SL_LIB="-load ${LINK_SL_FILE}:simlinkserver"

LOAD_ML_LIB="-load ${LINK_ML_FILE}:matlabclient"

VHPI_SL_LIB="-vhpi ${LINK_SL_FILE}:simlinkserver"

VHPI_ML_LIB="-vhpi ${LINK_ML_FILE}:matlabclient"

export SL_LIB_SOCKET=37592

VLOG_FILES=/matlab/toolbox/edalink/extensions/discovery/discoverydemos/Filter/lowpass_filter.v

VHDL_FILES=

TOP_LEVEL=lowpass_filter

ACC_FILE=/matlab/toolbox/edalink/extensions/discovery/discoverydemos/Filter/lowpass_filter.pli_acc.tab

VHDLAN_FLAGS=

VLOGAN_FLAGS="+v2k"

UUMCOMP_FLAGS=

UUMRUN_FLAGS=

COMP_DEBUG_FLAGS=-debug_all

LAUNCH_DEBUG_FLAGS="-gui -i tmwESLDS.presim.tcl"

#--- User Environment ---

eval ${COMPILE_SETUP_CMDS}

vlogan ${BITS_FLAG} ${VLOGAN_FLAGS} ${VLOG_FILES}

vcs ${COMP_DEBUG_FLAGS} ${UUMCOMP_FLAGS} +vpi +applylearn+${ACC_FILE} ${BITS_FLAG} ${TOP_LEVEL} ${LOAD_ML_LIB}

4-29

Page 78: EDA Simulator Link Block and Function Reference

launchDiscovery

This example shows the generated launch script:

# AUTO-GENERATED SH SCRIPT FOR Simulink COSIMULATION

#--- EDA Link Environment ---

LAUNCHER_NAME=tmwESLDS

NUM_BITS=64

LINK_LIB_DIR=/matlab/toolbox/edalink/extensions/discovery/linux64

LINK_SL_FILE=liblfdhdls_vlog_gcc336.so

LINK_ML_FILE=liblfdhdlc_vlog_gcc336.so

BITS_FLAG=-full64

export VG_GNU_PACKAGE=${VCS_HOME}/gnu/linux

COMPILE_SETUP_CMDS=". ${VG_GNU_PACKAGE}/source_me_${NUM_BITS}.sh"

LAUNCH_SETUP_CMDS=". ${VG_GNU_PACKAGE}/source_me_${NUM_BITS}.sh"

export LD_LIBRARY_PATH=${VG_GNU_PACKAGE}/gcc-${NUM_BITS}/slib64:${LINK_LIB_DIR}:${LD_LIBRARY_PATH}

LOAD_SL_LIB="-load ${LINK_SL_FILE}:simlinkserver"

LOAD_ML_LIB="-load ${LINK_ML_FILE}:matlabclient"

VHPI_SL_LIB="-vhpi ${LINK_SL_FILE}:simlinkserver"

VHPI_ML_LIB="-vhpi ${LINK_ML_FILE}:matlabclient"

export SL_LIB_SOCKET=37592

VLOG_FILES=/matlab/toolbox/edalink/extensions/discovery/discoverydemos/Filter/lowpass_filter.v

VHDL_FILES=

TOP_LEVEL=lowpass_filter

ACC_FILE=/matlab/toolbox/edalink/extensions/discovery/discoverydemos/Filter/lowpass_filter.pli_acc.tab

VHDLAN_FLAGS=

VLOGAN_FLAGS="+v2k"

UUMCOMP_FLAGS=

UUMRUN_FLAGS=

COMP_DEBUG_FLAGS=-debug_all

LAUNCH_DEBUG_FLAGS="-gui -i tmwESLDS.presim.tcl"

#--- User Environment ---

eval ${LAUNCH_SETUP_CMDS}

simv ${LAUNCH_DEBUG_FLAGS} ${UUMRUN_FLAGS}

4-30

Page 79: EDA Simulator Link Block and Function Reference

launchDiscovery

4-31

Page 80: EDA Simulator Link Block and Function Reference

makefpgaproject

Purpose Generate Xilinx ISE project and FPGA hardware-in-the-loop

Syntax makefpgaproject(model/subsystem)makefpgaproject(model/subsystem,'ParameterName',

ParameterValue)

Description makefpgaproject(model/subsystem) generates a Xilinx ISE projectworkflow according to Simulink model parameter settings. modelspecifies the name of the Simulink model, and subsystem specifies thename of a subsystem at the top level of the Simulink model.

makefpgaproject(model/subsystem,'ParameterName',ParameterValue)accepts one or more comma-separated parameter name/value pairs sothat you may specify optional build settings such as whether or not tocontinue build on warnings and HDL Coder parameters. SpecifyParameterName inside single quotes.

Inputs model/subsystem

Name and path of the top-level subsystem whose generated codeis to be used in creating and updating the FPGA project, FPGAHIL, and in generating Tcl script

Parameter Name/Value Pairs

ContinueOnWarning

When ContinueOnWarning is set to ’on’, makefpgaprojectcontinues to run when a warning is encountered, without pausingfor user action. For example, instead of asking if you want tooverwrite an existing ISE project, makefpgaproject overwritesthe project without asking and displays a warning message.

• 'on'

Continue build when it encounters a warning withoutprompting user.

• 'off'

4-32

Page 81: EDA Simulator Link Block and Function Reference

makefpgaproject

Prompt input from user when build encounters a warning.

Default: 'off'

HDLCoderParam

Specify HDL code generation options in a cell array ofproperty-value pairs.

• (HDLCoderParam, {HDLCParamName1, HDLCParamValue1,HDLCParamName2, HDLCParamValue2, …} )

See Simulink HDL Coder documentation for a list of validparameters and values for the makehdl command; you can usethose same property-value pairs with makefpgaproject.

For example:

{'TargetLanguage', 'VHDL', ...'TargetDirectory', 'myhdlsrc'}

You may have to turn on the option "Always generate HDL" inthe EDA Link configuration parameters pane for the HDL codegeneration options to take effect.

Examples Create FPGA project workflow with all defaults from the specified toplevel subsystem.

> makefpgaproject('model/subsystem')

Create FPGA project workflow from specified top level subsystem anddo not prompt for action when warnings are encountered.

>makefpgaproject('model/subsystem', 'ContinueOnWarning', 'on')

4-33

Page 82: EDA Simulator Link Block and Function Reference

makefpgaproject

Create FPGA project workflow from specified top level subsystem anduse the specified HDL Coder property value pairs when generatingHDL code.

>makefpgaproject('model/subsystem', 'HDLCoderParam', ...

{'TargetLanguage', 'VHDL', 'TargetDirectory', 'myhdlsrc'})

See Also fpgamodelsetup

4-34

Page 83: EDA Simulator Link Block and Function Reference

matlabcp

Purpose Associate MATLAB component function with instantiated HDL design

Syntax matlabcp <instance>[<time-specs>][-socket <tcp-spec>][-rising <port>[,<port>...]][-falling <port> [,<port>,...]][-sensitivity <port>[,<port>,...]][-mfunc <name>][-use_instance_obj][-argument]

Description The matlabcp command has the following characteristics:

• Starts the HDL simulator client component of the EDA SimulatorLink software.

• Associates a specified instance of an HDL design created in the HDLsimulator with a MATLAB function.

• Creates a process that schedules invocations of the specifiedMATLAB function.

• Cancels any pending events scheduled by a previous matlabcpcommand that specified the same instance. For example, if you issuethe command matlabcp for instance foo, all previously scheduledevents initiated by matlabcp on foo are canceled.

This command is issued in the HDL simulator.

MATLAB component functions simulate the behavior of modules in theHDL model. A stub module (providing port definitions only) in the HDLmodel passes its input signals to the MATLAB component function. TheMATLAB component processes this data and returns the results to theoutputs of the stub module. A MATLAB component typically providessome functionality (such as a filter) that is not yet implemented inthe HDL code. See “Replacing an HDL Component with a MATLAB®

Component Function”.

4-35

Page 84: EDA Simulator Link Block and Function Reference

matlabcp

Notes The communication mode that you specify for matlabcp mustmatch the communication mode you specified for hdldaemon when youestablished the server connection.

For socket communications, specify the port number you selected forhdldaemon when you issue a link request with the matlabcp commandin the HDL simulator.

Arguments <instance>Specifies an instance of an HDL design that is associated with aMATLAB function. By default, matlabcp associates the instanceto a MATLAB function that has the same name as the instance.For example, if the instance is myfirfilter, matlabcp associatesthe instance with the MATLAB function myfirfilter (note thathierarchy names are ignored; for example, if your instance nameis top.myfirfilter, matlabcp would associate only myfirfilterwith the MATLAB function). Alternatively, you can specify adifferent MATLAB function with -mfunc.

Note Do not specify an instance of an HDL module that hasalready been associated with a MATLAB function (via matlabcpor matlabtb). If you do, the new association overwrites theexisting one.

<time-specs>Specifies a combination of time specifications consisting of any orall of the following:

4-36

Page 85: EDA Simulator Link Block and Function Reference

matlabcp

<timen>,... Specifies one or more discrete time values at which theHDL simulator calls the specified MATLAB function. Eachtime value is relative to the current simulation time. Evenif you do not specify a time, the HDL simulator calls theMATLAB function once at the start of the simulation.Separate multiple time values by a space.For example:

matlabtb vlogtestbench_top 10 ns, 10 ms, 10 sec

The MATLAB function executes when time equals 0 andthen 10 nanoseconds, 10 milliseconds, and 10 seconds fromtime zero.

Note For time-based parameters, you can specify anystandard time units (ns, us, and so on). If you do not specifyunits, the command treats the time value as a value ofHDL simulation ticks.

-repeat <time> Specifies that the HDL simulator calls the MATLABfunction repeatedly based on the specified <timen>,...pattern. The time values are relative to the value of tnowat the time the HDL simulator first calls the MATLABfunction.

-cancel <time> Specifies a time at which the specified MATLAB functionstops executing. The time value is relative to the value oftnow at the time the HDL simulator first calls the MATLABfunction. If you do not specify a cancel time, the applicationcalls the MATLAB function until you finish the simulation,quit the session, or issue a nomatlabtb call.

Note The -cancel option works only with the <time-specs>arguments. It does not affect any of the other schedulingarguments for matlabcp.

4-37

Page 86: EDA Simulator Link Block and Function Reference

matlabcp

Note Place time specifications after the matlabcp instance andbefore any additional command arguments; otherwise the timespecifications are ignored.

All time specifications for the matlabcp functions appear as anumber and, optionally, a time unit:

• fs (femtoseconds)

• ps (picoseconds)

• ns (nanoseconds)

• us (microseconds)

• ms (milliseconds)

• sec (seconds)

• no units (tick)

-socket <tcp_spec>Specifies TCP/IP socket communication for the link betweenthe HDL simulator and MATLAB. When you provide TCP/IPinformation for matlabcp, you can choose a TCP/IP port number orTCP/IP port alias or service name for the <tcp_spec> parameter.If you are setting up communication between computers, youmust also specify the name or Internet address of the remote hostthat is running the MATLAB server (hdldaemon). See “SpecifyingTCP/IP Values” for some valid tcp_spec examples.

For more information on choosing TCP/IP socket ports, see“Choosing TCP/IP Socket Ports”.

If you run the HDL simulator and MATLAB on the samecomputer, you have the option of using shared memoryfor communication. Shared memory is the default mode ofcommunication and takes effect if you do not specify -socket<tcp_spec> on the command line.

4-38

Page 87: EDA Simulator Link Block and Function Reference

matlabcp

Note The communication mode that you specify with thematlabcp command must match what you specify for thecommunication mode when you issue the hdldaemon command inMATLAB.

For more information on modes of communication, see“Communications for HDL Cosimulation”. For more informationon establishing the MATLAB end of the communication link, see“Starting the HDL Simulator from MATLAB”.

-rising <signal>[, <signal>...]Indicates that the application calls the specified MATLABfunction on the rising edge (transition from '0' to '1') of any ofthe specified signals. Specify -rising with the path names ofone or more signals defined as a logic type (STD_LOGIC, BIT, X01,and so on).

For determining signal transition in:

• VHDL: Rising edge is {0 or L} to {1 or H}.

• Verilog: Rising edge is the transition from 0 to x, z, or 1, andfrom x or z to 1.

Note When specifying signals with the -rising, -falling, and-sensitivity options, specify them in full path name format. Ifyou do not specify a full path name, the command applies theHDL simulator rules to resolve signal specifications.

-falling <signal>[, <signal>...]Indicates that the application calls the specified MATLABfunction whenever any of the specified signals experiences afalling edge—changes from '1' to '0'. Specify -falling with

4-39

Page 88: EDA Simulator Link Block and Function Reference

matlabcp

the path names of one or more signals defined as a logic type(STD_LOGIC, BIT, X01, and so on).

For determining signal transition in:

• VHDL: Falling edge is {1 or H} to {0 or L}.

• Verilog: Falling edge is the transition from 1 to x, z, or 0, andfrom x or z to 0.

Note When specifying signals with the -rising, -falling, and-sensitivity options, specify them in full path name format. Ifyou do not specify a full path name, the command applies theHDL simulator rules to resolve signal specifications.

-sensitivity <signal>[, <signal>...]Indicates that the application calls the specified MATLABfunction whenever any of the specified signals changes state.Specify -sensitivity with the path names of one or more signals.Signals of any type can appear in the sensitivity list and can bepositioned at any level in the HDL model hierarchy.

Note When specifying signals with the -rising, -falling, and-sensitivity options, specify them in full path name format. Ifyou do not specify a full path name, the command applies theHDL simulator rules to resolve signal specifications.

-mfunc <name>The name of the MATLAB function that is associated with theHDL module instance you specify for instance. By default, theEDA Simulator Link software invokes a MATLAB function thathas the same name as the specified HDL instance. Thus, if thenames are the same, you can omit the -mfunc option. If the namesare not the same, use this argument when you call matlabcp. If

4-40

Page 89: EDA Simulator Link Block and Function Reference

matlabcp

you omit this argument and matlabcp does not find a MATLABfunction with the same name, the command generates an errormessage.

-use_instance_objInstructs the function specified with the argument -mfunc touse an HDL instance object passed by EDA Simulator Link tothe function. You include the -use_instance_obj argument withmatlabcp in the following format:

matlabcp modelname -mfunc funcname -use_instance_obj

When you call matlabcp with the use_instance_obj argument, thefunction has the following signature:

function MyFunctionName(hdl_instance_obj)

The HDL instance object (hdl_instance_obj) has the fields shownin the following table.

Field Read/WriteAccess

Description

tnext Write only Used to schedule a callback during the set time value.This field is equivalent to old tnext. For example:

hdl_instance_obj.tnext = hdl_instance_obj.tnow + 5e-9

will schedule a callback at time equals 5 nanoseconds fromtnow.

userdata Read/Write Stores state variables of the current matlabcp instance.You can retrieve the variables the next time the callbackof this instance is scheduled.

4-41

Page 90: EDA Simulator Link Block and Function Reference

matlabcp

Field Read/WriteAccess

Description

simstatus Read only Stores the status of the HDL simulator. The EDASimulator Link software sets this field to ’Init’ during thefirst callback for this particular instance and to ’Running’thereafter. simstatus is a read-only property.

>> hdl_instance_obj.simstatus

ans=Init

instance Read only Stores the full path of the Verilog/VHDL instanceassociated with the callback. instance is a read-onlyproperty. The value of this field equals that of the moduleinstance specified with the function call. For example:

In the HDL simulator:

hdlsim> matlabcp osc_top -mfunc oscfilter use_instance_obj

In MATLAB:

>> hdl_instance_obj.instance

ans=osc_top

4-42

Page 91: EDA Simulator Link Block and Function Reference

matlabcp

Field Read/WriteAccess

Description

argument Read only Stores the argument set by the -argument option ofmatlabcp. For example:

matlabtb osc_top -mfunc oscfilter -use_instance_obj -argument foo

The link software supports the -argument option onlywhen it is used with -use_instance_obj, otherwise theargument is ignored. argument is a read-only property.

>> hdl_instance_obj.argument

ans=foo

portinfo Read only Stores information about the VHDL and Verilog portsassociated with this instance. portinfo is a read-onlyproperty, which has a field structure that describes theports defined for the associated HDL module. For eachport, the portinfo structure passes information such asthe port’s type, direction, and size. For more informationon port data, see “Gaining Access to and Applying PortInformation”.

hdl_instance_obj.portinfo.field1.field2.field3

Note When you use use_instance_obj, you access tscalethrough the HDL instance object. If you do not useuse_instance_obj, you can still access tscale throughportinfo.

4-43

Page 92: EDA Simulator Link Block and Function Reference

matlabcp

Field Read/WriteAccess

Description

tscale Read only Stores the resolution limit (tick) in seconds of the HDLsimulator. tscale is a read-only property.

>> hdl_instance_obj.tscale

ans=1.0000e-009

Note When you use use_instance_obj, you access tscalethrough the HDL instance object. If you do not useuse_instance_obj, you can still access tscale throughportinfo.

tnow Read only Stores the current time. tnow is a read-only property.

hdl_instance_obj.tnext = hld_instance_obj.tnow + fastestrate;

portvalues Read/Write Stores the current values of and sets new values for theoutput and input ports for a matlabcp instance. Forexample:

>> hdl_instance_obj.portvalues

ans =Read Only Input ports:clk_enable: []clk: []reset: []

Read/Write Output ports:sine_out: [22x1 char]

4-44

Page 93: EDA Simulator Link Block and Function Reference

matlabcp

Field Read/WriteAccess

Description

linkmode Read only Stores the status of the callback. The EDA Simulator Linksoftware sets this field to ’testbench’ if the callback isassociated with matlabtb and ’component’ if the callbackis associated with matlabcp. linkmode is a read-onlyproperty.

>> hdl_instance_obj.linkmode

ans=component

-argumentUsed to pass user-defined arguments from the matlabcpinvocation on the HDL side to the MATLAB function callbacks.Supported with -use_instance_obj only. See the field listingunder the -use_instance_obj property.

Examples The following examples demonstrate some ways you might use thematlabcp function.

Using matlabcp with the -mfunc option to Associate an HDLComponent with a MATLAB Function of a Different Name

This example explicitly associates the Verilog modulevlogtestbench_top.u_matlab_component with the MATLAB functionvlogmatlabc using the -mfunc option. The '-socket' option specifiesusing socket communication on port 4449.

matlabcp vlogtestbench_top.u_matlab_component -mfunc vlogmatlabc -socket 4449

Using matlabcp with Explicit Times and the -cancel Option

This example implicitly associates the Verilog module, vtestbench_top,with the MATLAB function vlogtestbench_top, and includes explicittimes with the -cancel option.

matlabcp vlogtestbench_top 1e6 fs 3 2e3 ps -repeat 3 ns -cancel 7ns

4-45

Page 94: EDA Simulator Link Block and Function Reference

matlabcp

Using matlabcp with Rising and Falling Edges

This example implicitly associates the Verilog module,vlogtestbench_top, with the MATLAB function vlogtestbench_top, andalso uses rising and falling edges.

hldsim> matlabcp vlogtestbench_top 1 2 3 4 5 6 7 -rising outclk3

-falling u_matlab_component/inoutclk

Using matlabcp and the HDL Instance Object

In this example, the HDL simulator makes repeated calls to matlabcpto bind multiple HDL instances to the same MATLAB function. Eachcall contains -argument as a constructor parameter to differentiatebehavior.

> matlabcp u1_filter1x -mfunc osc_filter -use_instance_obj -argument oversample=1

> matlabcp u1_filter8x -mfunc osc_filter -use_instance_obj -argument oversample=8

> matlabcp u2_filter8x -mfunc osc_filter -use_instance_obj -argument oversample=8

The MATLAB function callback, osc_filter.m, sets up userinstance-based state using obj.userdata, queries port and simulationcontext using other obj fields, and uses the passed in obj.argument todifferentiate behavior.

function osc_filter(obj)

if (strcmp(obj.simstatus,'Init'))

ud = struct('Nbits', 22, 'Norder', 31, 'clockperiod', 80e-9, 'phase', 1));

eval(obj.argument);

if (~exist('oversample','var'))

error('HdlLinkDemo:UseInstanceObj:BadCtorArg', ...

'Bad constructor arg to osc_filter callback. Expecting

''oversample=value''.');

end

ud.oversample = oversample;

ud.oversampleperiod = ud.clockperiod/ud.oversample;

ud.InDelayLine = zeros(1,ud.Norder+1);

4-46

Page 95: EDA Simulator Link Block and Function Reference

matlabcp

centerfreq = 70/256;

passband = [centerfreq-0.01, centerfreq+0.01];

b = fir1((ud.Norder+1)*ud.oversample-1, passband./ud.oversample);

ud.Hresp = ud.oversample .* b;

obj.userdata = ud;

end

...

4-47

Page 96: EDA Simulator Link Block and Function Reference

matlabtb

Purpose Schedule MATLAB test bench session for instantiated HDL module

Syntax matlabtb <instance>[<time-specs>][-socket <tcp-spec>][-rising <port>[,<port>...]][-falling <port> [,<port>,...]][-sensitivity <port>[,<port>,...]][-mfunc <name>][-use_instance_obj][-argument]

Description The matlabtb command has the following characteristics:

• Starts the HDL simulator client component of the EDA SimulatorLink software.

• Associates a specified instance of an HDL design created in the HDLsimulator with a MATLAB function.

• Creates a process that schedules invocations of the specifiedMATLAB function.

• Cancels any pending events scheduled by a previous matlabtbcommand that specified the same instance. For example, if you issuethe command matlabtb for instance foo, all previously scheduledevents initiated by matlabtb on foo are canceled.

This command is issued in the HDL simulator.

MATLAB test bench functions mimic stimuli passed to entities in theHDL model. You force stimulus from MATLAB or HDL scheduledwith matlabtb.

4-48

Page 97: EDA Simulator Link Block and Function Reference

matlabtb

Notes The communication mode that you specify for matlabtb mustmatch the communication mode you specified for hdldaemon when youestablished the server connection.

For socket communications, specify the port number you selected forhdldaemon when you issue a link request with the matlabtb commandin the HDL simulator.

Arguments <instance>Specifies the instance of an HDL module that the EDA SimulatorLink software associates with a MATLAB test bench function.By default, matlabtb associates the instance with a MATLABfunction that has the same name as the instance. For example,if the instance is myfirfilter, matlabtb associates the instancewith the MATLAB function myfirfilter (note that hierarchynames are ignored; for example, if your instance name istop.myfirfilter, matlabtb would associate only myfirfilterwith the MATLAB function). Alternatively, you can specify adifferent MATLAB function with -mfunc.

Note Do not specify an instance of an HDL module that hasalready been associated with a MATLAB function (via matlabcpor matlabtb). If you do, the new association overwrites theexisting one.

<time-specs>Specifies a combination of time specifications consisting of any orall of the following:

4-49

Page 98: EDA Simulator Link Block and Function Reference

matlabtb

<timen>,... Specifies one or more discrete time values at which theHDL simulator calls the specified MATLAB function. Eachtime value is relative to the current simulation time. Evenif you do not specify a time, the HDL simulator calls theMATLAB function once at the start of the simulation.Separate multiple time values by a space.For example:

matlabtb vlogtestbench_top 10 ns, 10 ms, 10 sec

The MATLAB function executes when time equals 0 andthen 10 nanoseconds, 10 milliseconds, and 10 seconds fromtime zero.

Note For time-based parameters, you can specify anystandard time units (ns, us, and so on). If you do not specifyunits, the command treats the time value as a value ofHDL simulation ticks.

-repeat <time> Specifies that the HDL simulator calls the MATLABfunction repeatedly based on the specified <timen>,...pattern. The time values are relative to the value of tnowat the time the HDL simulator first calls the MATLABfunction.For example:

matlabtb vlogtestbench_top 5 ns -repeat 10 ns

The MATLAB function executes at time equals 0 ns, 5 ns,15 ns, 25 ns, and so on.

-cancel <time> Specifies a time at which the specified MATLAB functionstops executing. The time value is relative to the value oftnow at the time the HDL simulator first calls the MATLABfunction. If you do not specify a cancel time, the applicationcalls the MATLAB function until you finish the simulation,quit the session, or issue a nomatlabtb call.

4-50

Page 99: EDA Simulator Link Block and Function Reference

matlabtb

Note The -cancel option works only with the <time-specs>arguments. It does not affect any of the other schedulingarguments for matlabtb.

Note Place time specifications after the matlabtb instance andbefore any additional command arguments; otherwise the timespecifications are ignored.

All time specifications for the matlabtb functions appear as anumber and, optionally, a time unit:

• fs (femtoseconds)

• ps (picoseconds)

• ns (nanoseconds)

• us (microseconds)

• ms (milliseconds)

• sec (seconds)

• no units (tick)

-socket <tcp_spec>Specifies TCP/IP socket communication for the link betweenthe HDL simulator and MATLAB. When you provide TCP/IPinformation for matlabtb, you can choose a TCP/IP port number orTCP/IP port alias or service name for the <tcp_spec> parameter.If you are setting up communication between computers, youmust also specify the name or Internet address of the remote hostthat is running the MATLAB server (hdldaemon). See “SpecifyingTCP/IP Values” for some valid tcp_spec examples.

4-51

Page 100: EDA Simulator Link Block and Function Reference

matlabtb

For more information on choosing TCP/IP socket ports, see“Choosing TCP/IP Socket Ports”.

If you run the HDL simulator and MATLAB on the samecomputer, you have the option of using shared memoryfor communication. Shared memory is the default mode ofcommunication and takes effect if you do not specify-socket<tcp_spec> on the command line.

Note The communication mode that you specify with thematlabtb command must match what you specify for thecommunication mode when you issue the hdldaemon command inMATLAB. For more information on modes of communication, see“Communications for HDL Cosimulation”. For more informationon establishing the MATLAB end of the communication link, see“Starting the HDL Simulator from MATLAB”.

-rising <signal>[, <signal>...]Indicates that the application calls the specified MATLABfunction on the rising edge (transition from '0' to '1') of any ofthe specified signals. Specify -rising with the path names ofone or more signals defined as a logic type (STD_LOGIC, BIT, X01,and so on).

For determining signal transition in:

• VHDL: Rising edge is {0 or L} to {1 or H}.

• Verilog: Rising edge is the transition from 0 to x, z, or 1, andfrom x or z to 1.

4-52

Page 101: EDA Simulator Link Block and Function Reference

matlabtb

Note When specifying signals with the -rising, -falling, and-sensitivity options, specify them in full path name format. Ifyou do not specify a full path name, the command applies theHDL simulator rules to resolve signal specifications.

-falling <signal>[, <signal>...]Indicates that the application calls the specified MATLABfunction whenever any of the specified signals experiences afalling edge—changes from '1' to '0'. Specify -falling withthe path names of one or more signals defined as a logic type(STD_LOGIC, BIT, X01, and so on).

For determining signal transition in:

• VHDL: Falling edge is {1 or H} to {0 or L}.

• Verilog: Falling edge is the transition from 1 to x, z, or 0, andfrom x or z to 0.

Note When specifying signals with the -rising, -falling, and-sensitivity options, specify them in full path name format. Ifyou do not specify a full path name, the command applies theHDL simulator rules to resolve signal specifications.

-sensitivity <signal>[, <signal>...]Indicates that the application calls the specified MATLABfunction whenever any of the specified signals changes state.Specify -sensitivity with the path names of one or more signals.Signals of any type can appear in the sensitivity list and can bepositioned at any level of the HDL design.

If you specify the option with no signals, the interface is sensitiveto value changes for all signals.

4-53

Page 102: EDA Simulator Link Block and Function Reference

matlabtb

Note Use of this option for INOUT ports can result in double calls.

For example:

-sensitivity /randnumgen/dout

The MATLAB function executes if the value of dout changes.

Note When specifying signals with the -rising, -falling, and-sensitivity options, specify them in full path name format. Ifyou do not specify a full path name, the command applies theHDL simulator rules to resolve signal specifications.

-mfunc <name>The name of the associated MATLAB function. If you omit thisargument, matlabtb associates the HDL module instance to aMATLAB function that has the same name as the HDL instance.If you omit this argument and matlabtb does not find a MATLABfunction with the same name, the command generates an errormessage.

-use_instance_objInstructs the function specified with the argument -mfunc to usean HDL instance object passed by EDA Simulator Link to thefunction. The -use_instance_obj argument is called with matlabtbin the following format:

matlabtb modelname -mfunc funcname -use_instance_obj

When you call matlabcp with the use_instance_obj argument, thefunction has the following signature:

function MyFunctionName(hdl_instance_obj)

4-54

Page 103: EDA Simulator Link Block and Function Reference

matlabtb

The HDL instance object (hdl_instance_obj) has the fields shownin the following table.

Field Read/WriteAccess

Description

tnext Write only Used to schedule a callback during the set time value.This field is equivalent to old tnext. For example:

hdl_instance_obj.tnext = hdl_instance_obj.tnow + 5e-9

will schedule a callback at time equals 5 nanosecondsfrom tnow.

userdata Read/Write Stores state variables of the current matlabtbinstance. You can retrieve the variables the next timethe callback of this instance is scheduled.

simstatus Read only Stores the status of the HDL simulator. The EDASimulator Link software sets this parameter to ’Init’during the first callback for this particular instanceand to ’Running’ thereafter. simstatus is a read-onlyproperty.

>> hdl_instance_obj.simstatus

ans=Init

4-55

Page 104: EDA Simulator Link Block and Function Reference

matlabtb

Field Read/WriteAccess

Description

instance Read only Stores the full path of the Verilog/VHDL instanceassociated with the callback. instance is a read-onlyproperty. The value of this field equals that of themodule instance specified with the function call. Forexample:

In the HDL simulator:

hdlsim> matlabtb osc_top -mfunc oscfilter use_instance_obj

In MATLAB:

>> hdl_instance_obj.instance

ans=osc_top

argument Read only Stores the argument set by the -argument option ofmatlabtb. For example:

matlabtb osc_top -mfunc oscfilter -use_instance_obj -argument foo

The link software supports the -argument option onlywhen it is used with -use_instance_obj, otherwisethe argument is ignored. argument is a read-onlyproperty.

>> hdl_instance_obj.argument

ans=foo

4-56

Page 105: EDA Simulator Link Block and Function Reference

matlabtb

Field Read/WriteAccess

Description

portinfo Read only Stores information about the VHDL and Verilog portsassociated with this instance. portinfo is a read-onlyproperty, which has a field structure that describesthe ports defined for the associated HDL module. Foreach port, the portinfo structure passes informationsuch as the port’s type, direction, and size. For moreinformation on port data, see “Gaining Access to andApplying Port Information”.

hdl_instance_obj.portinfo.field1.field2.field3

Note When you use use_instance_obj, you accesstscale through the HDL instance object. If you donot use use_instance_obj, you can still access tscalethrough portinfo.

tscale Read only Stores the resolution limit (tick) in seconds of theHDL simulator. tscale is a read-only property.

>> hdl_instance_obj.tscale

ans=1.0000e-009

4-57

Page 106: EDA Simulator Link Block and Function Reference

matlabtb

Field Read/WriteAccess

Description

Note When you use use_instance_obj, you accesstscale through the HDL instance object. If you donot use use_instance_obj, you can still access tscalethrough portinfo.

tnow Read only Stores the current time. tnow is a read-only property.

hdl_instance_obj.tnext = hld_instance_obj.tnow + fastestrate;

portvalues Read/Write Stores the current values of and sets new values forthe output and input ports for a matlabtb instance.For example:

>> hdl_instance_obj.portvalues

ans =Read/Write Input ports:clk_enable: []clk: []reset: []

Read Only Output ports:sine_out: [22x1 char]

4-58

Page 107: EDA Simulator Link Block and Function Reference

matlabtb

Field Read/WriteAccess

Description

For example, you can set the reset port to 1 by callinghdl_instance_obj.portvalues.reset = '1'.

linkmode Read only Stores the status of the callback. The EDA SimulatorLink software sets this parameter to ’testbench’ if thecallback is associated with matlabtb and ’component’if the callback is associated with matlabcp. linkmodeis a read-only property.

>> hdl_instance_obj.linkmode

ans=testbench

-argumentUsed to pass user-defined arguments from the matlabtbinstantiation on the HDL side to the MATLAB function callbacks.Supported with -use_instance_obj only. See the field listing forargument under the -use_instance_obj property.

Examples The following examples demonstrate some ways you might use thematlabtb function.

4-59

Page 108: EDA Simulator Link Block and Function Reference

matlabtb

Using matlabtb with the -socket Argument and TimeParameters

The following command starts the HDL simulator client component ofEDA Simulator Link, associates an instance of the entity, myfirfilter,with the MATLAB function myfirfilter, and begins a local TCP/IPsocket-based test bench session using TCP/IP port 4449. Based on thespecified test bench stimuli, myfirfilter.m executes 5 nanosecondsfrom the current time, and then repeatedly every 10 nanoseconds:

hdlsim> matlabtb myfirfilter 5 ns -repeat 10 ns -socket 4449

Applying Rising Edge Clocks and State Changes withmatlabtb

The following command starts the HDL simulator client component ofEDA Simulator Link, and begins a remote TCP/IP socket-based sessionusing remote MATLAB host compb and TCP/IP port 4449. Based on thespecified test bench stimuli, myfirfilter.m executes 10 nanosecondsfrom the current time, each time the signal /top/fclk experiences arising edge, and each time the signal /top/din changes state.

hdlsim> matlabtb /top/myfirfilter 10 ns -rising /top/fclk -sensitivity /top/din

-socket 4449@computer123

Specifying a MATLAB Function Name and Sensitizing Signalswith matlabtb

The following command starts the HDL simulator client component ofthe EDA Simulator Link software. The '-mfunc' option specifies theMATLAB function to connect to and the '-socket' option specifies theport number for socket connection mode. '-sensitivity' indicatesthat the test bench session is sensitized to the signal sine_out.

hdlsim> matlabtb osc_top -sensitivity /osc_top/sine_out-socket 4448 -mfunc hosctb

4-60

Page 109: EDA Simulator Link Block and Function Reference

matlabtbeval

Purpose Call specified MATLAB function once and immediately on behalf ofinstantiated HDL module

Syntax matlabtbeval <instance> [-socket <tcp_spec>][-mfunc <name>]

Description The matlabtbeval command has the following characteristics:

• Starts the HDL simulator client component of the EDA SimulatorLink software.

• Associates a specified instance of an HDL design created in the HDLsimulator with a MATLAB function.

• Executes the specified MATLAB function once and immediately onbehalf of the specified module instance.

This command is issued in the HDL simulator.

Note The matlabtbeval command executes the MATLAB functionimmediately, while matlabtb provides several options for schedulingMATLAB function execution.

Notes The communication mode that you specify for matlabtbevalmust match the communication mode you specified for hdldaemon whenyou established the server connection.

For socket communications, specify the port number you selected forhdldaemon when you issue a link request with the matlabtbevalcommand in the HDL simulator.

Arguments <instance>Specifies the instance of an HDL module that is associated witha MATLAB function. By default, matlabtbeval associates the

4-61

Page 110: EDA Simulator Link Block and Function Reference

matlabtbeval

HDL module instance with a MATLAB function that has thesame name as the HDL module instance. For example, if the HDLmodule instance is myfirfilter, matlabtbeval associates theHDL module instance with the MATLAB function myfirfilter.Alternatively, you can specify a different MATLAB function withthe -mfunc property.

-socket <tcp_spec>Specifies TCP/IP socket communication for the link between theHDL simulator and MATLAB. For TCP/IP socket communicationon a single computer, the <tcp_spec> can consist of just aTCP/IP port number or service name (alias). If you are setting upcommunication between computers, you must also specify thename or Internet address of the remote host. See “SpecifyingTCP/IP Values” for some valid tcp_spec examples.

For more information on choosing TCP/IP socket ports, see“Choosing TCP/IP Socket Ports”.

If you run the HDL simulator and MATLAB on the samecomputer, you have the option of using shared memoryfor communication. Shared memory is the default mode ofcommunication and takes effect if you do not specify -socket<tcp-spec> on the command line.

Note The communication mode that you specify with thematlabtbeval command must match what you specify forthe communication mode when you call the hdldaemoncommand to start the MATLAB server. For more informationon communication modes, see “Communications for HDLCosimulation”. For more information on establishing theMATLAB end of the communication link, see “Starting the HDLSimulator from MATLAB”.

4-62

Page 111: EDA Simulator Link Block and Function Reference

matlabtbeval

-mfunc <name>The name of the associated MATLAB function. If you omit thisargument, matlabtbeval associates the HDL module instancewith a MATLAB function that has the same name as the HDLmodule instance.. If you omit this argument and matlabtbevaldoes not find a MATLAB function with the same name, thecommand displays an error message.

Examples This example starts the HDL simulator client component of thelink software, associates an instance of the module myfirfilter withthe function myfirfilter.m, and uses a local TCP/IP socket-basedcommunication link to TCP/IP port 4449 to execute the functionmyfirfilter.m:

> matlabtbeval myfirfilter -socket 4449:

4-63

Page 112: EDA Simulator Link Block and Function Reference

mvl2dec

Purpose Convert multivalued logic to decimal

Syntax mvl2dec('mv_logic_string')mvl2dec('mv_logic_string', signed)

Description mvl2dec('mv_logic_string') converts a multivalued logic string to apositive decimal. If mv_logic_string contains any character other than'0' or '1', NaN is returned. mv_logic_string must be a vector.

mvl2dec('mv_logic_string', signed) converts a multivalued logicstring to a positive or a negative decimal. If signed is true, this functionassumes the first character mv_logic_string(1) to be a signed bit of a 2scomplement number. If signed is missing or false, the multivalued logicstring becomes a positive decimal.

Examples The following function call returns the decimal value 23:

mvl2dec('010111')

The following function call returns NaN:

mvl2dec('xxxxxx')

The following function call returns the decimal value -9:

mvl2dec('10111',true)

See Also dec2mvl

4-64

Page 113: EDA Simulator Link Block and Function Reference

nclaunch

Purpose Start and configure Cadence Incisive simulators for use with EDASimulator Link software

Syntax nclaunch('PropertyName', 'PropertyValue'...)

Description nclaunch('PropertyName', 'PropertyValue'...) starts theCadence Incisive simulator for use with the MATLAB and Simulinkfeatures of the EDA Simulator Link software. The first folder in theCadence Incisive simulator matches your MATLAB current folder if youdo not specify an explicit rundir parameter.

After you call this function, you can use EDA Simulator Link functionsfor the HDL simulator (for example, hdlsimmatlab, hdlsimulink) todo interactive debug setup.

The property name/property value pair settings allow you to customizethe Tcl commands used to start the Cadence Incisive simulator, thencsim executable to be used, the path and name of the Tcl script thatstores the start commands, and for Simulink applications, details aboutthe mode of communication to be used by the applications. You mustuse a property name/property value pair with nclaunch.

PropertyName/PropertyValuePairs

'hdlsimdir', 'pathname'Specifies the path name to the Cadence Incisive simulatorexecutable to be started. By default, the function uses the firstversion of the simulator that it finds on the system path (definedby the path variable) . Use this option to start different versionsof the Cadence Incisive simulator or if the version of the simulatoryou want to run does not reside on the system path.

'hdlsimexe', 'simexename'Specifies the name of a Cadence Incisive simulator executable.By default, this function uses 'ncsim'. You can specify acustom-built simulator executable with 'simexename.'

'libdir', 'folder'Specifies the folder containing MATLAB shared libraries. Thisproperty creates an entry in the startup Tcl file that points to the

4-65

Page 114: EDA Simulator Link Block and Function Reference

nclaunch

folder with the shared libraries needed for the Cadence Incisivesimulator to communicate with MATLAB when the CadenceIncisive simulator runs on a machine that does not have MATLAB.

'libfile', 'library_file_name'Specifies a particular library file. This value defaults to theversion of the library file that was built using the same compilerthat MATLAB itself uses. If the HDL simulator links otherlibraries, including SystemC libraries, that were built using acompiler supplied with the HDL simulator, you can specify analternate library file with this property. See “Using the EDASimulator Link Libraries for HDL Cosimulation” for versions ofthe library built using other compilers.

'rundir', 'dirname'Specifies where to run the HDL simulator. By default, thefunction uses the current working folder.

The following conditions apply to this name/value pair:

• If the value of dirname is “TEMPDIR”, the function creates atemporary folder in which it runs the HDL simulator.

• If you specifydirnameand the folder does not exist, you willget an error.

'runmode', 'mode'Specifies how to start the HDL simulator. This property acceptsthe following valid values:

• 'Batch': Start the HDL simulator in the background with nowindow.

• 'Batch with Xterm': Run HDL simulator in annon-interactive Xterm window.

• 'CLI': Start the HDL simulator in an interactive terminalwindow.

• 'GUI': Start the HDL simulator with the SimVision graphicaluser interface.

4-66

Page 115: EDA Simulator Link Block and Function Reference

nclaunch

This value defaults to 'GUI'.

'socketsimulink', 'tcp_spec'Specifies TCP/IP socket communication for links between theCadence Incisive simulator and Simulink. See “Specifying TCP/IPValues” for valid TCP/IP examples. For more information onchoosing TCP/IP socket ports, see “Choosing TCP/IP Socket Ports”.

If the Cadence Incisive simulator and Simulink run on the samecomputing system, you have the option of using shared memoryfor communication. Shared memory is the default mode ofcommunication and takes effect if you do not specify -socket<tcp-spec> on the command line.

'starthdlsim', ['yes' | 'no']Determines whether the Cadence Incisive simulator is launched.This parameter defaults to yes, which launches the CadenceIncisive simulator and creates a startup Tcl file. If yousetstarthdlsim to no, the function does not launch the CadenceIncisive simulator , but it still creates a startup Tcl file.

This startup Tcl file contains pointers to MATLAB and Simulinkshared libraries. To run the Cadence Incisive simulator manually,see “Starting the HDL Simulator from MATLAB”.

'startupfile', 'pathname'Each invocation of nclaunch creates a Tcl script that, whenexecuted, compiles and launches the HDL simulator. By default,this function generates a filename of compile_and_launch.tclin the folder specified by rundir. With this property, you canspecify the name and location of the generated Tcl script. If thefile name already exists, that file’s contents are overwritten. Youcan edit and use the generated file in a regular shell outside ofMATLAB. For example:

sh> tclsh compile_and_launch.tcl

4-67

Page 116: EDA Simulator Link Block and Function Reference

nclaunch

'tclstart', 'tcl_commands'Specifies one or more Tcl commands to execute before the CadenceIncisive simulator launches. Specify a command string or acell array of command strings. You must specify at least onecommand; otherwise, no action occurs.

Note You must type exec in front of non-Tcl system shellcommands. For example:

exec -ncverilog -c +access+rw +linedebug top.vhdlsimulink -gui work.top

Examples The following function call sequence compiles the design and startsSimulink with a GUI from the "proj" folder with the model loaded.Simulink is instructed to communicate with the EDA Simulator Linkinterface on socket port 4449. All of these commands are specified in asingle string as the property value to tclstart.

nclaunch(...'tclstart',...{'exec ncverilog -c +access+rw +linedebug top.v',...'hdlsimulink -gui work.top'},...'socketsimulink','4449',...'rundir', '/proj');

In this next example, tclcmd is used to build the sequence of Tclcommands that are executed in a Tcl shell after calling nclaunch fromMATLAB, as follows:

• tclcmd{1} compiles vlogtestbench_top.

• tclcmd{2} elaborates the model.

• tclcmd{3} calls hdlsimmatlab in gui mode and loads the elaboratedvlogtestbench_top in the simulator.

4-68

Page 117: EDA Simulator Link Block and Function Reference

nclaunch

The function executes the arguments being passed with -input(matlabtb and run) in the ncsim Tcl shell. In this example,matlabcp associates the function vlogmatlabc to the module instanceu_matlab_component. It assumes that the hdldaemon in MATLAB islistening on port 32864. The run function will run 50 resolution units(ticks).

tclcmd{1} = 'exec ncvlog vlogtestbench_top.v'

tclcmd{2} = 'exec ncelab -access +wc vlogtestbench_top'

tclcmd{3} = ['hdlsimmatlab -gui vlogtestbench_top ' ...

'-input "{@matlabcp vlogtestbench_top.u_matlab_component...

-mfunc vlogmatlabc -socket 32864}" '...

'-input "{@run 50}"']

nclaunch('hdlsimdir', 'local.IUS.glnx.tools.bin', 'tclstart',tclcmd);

The following example shows using the property startupfile todesignate a Tcl script that the function then uses to start the HDLsimulator from the Tcl shell.

In MATLAB:

nclaunch (`tclstart', `xxx', `startupfile', `mytclscript',...

`starthdlsim', `no')

In Tcl shell:

shell> tclsh mytclscript

4-69

Page 118: EDA Simulator Link Block and Function Reference

nomatlabtb

Purpose End active MATLAB test bench and MATLAB component sessions

Syntax nomatlabtb

Description The nomatlabtb command ends all active MATLAB test bench andMATLAB component sessions that were previously initiated bymatlabtb or matlabcp commands.

This command is issued in the HDL simulator.

Note This command should be called before shutting down hdldaemonor hdldaemon will block shutdown until the call occurs.

Examples The following command ends all MATLAB test bench and MATLABcomponent sessions:

> nomatlabtb

See Also matlabtb,matlabcp

4-70

Page 119: EDA Simulator Link Block and Function Reference

notifyMatlabServer

Purpose Send HDL simulator event and process IDs to MATLAB server

Syntax notifyMatlabServer EventID -socket tcp-spec

Description notifyMatlabServer EventID -socket tcp-spec sends the HDLsimulator event ID and process identification (PID) to the MATLABserver (hdldaemon) using the specified connection methods (socket orshared memory). For MATLAB to receive this message, hdldaemonmust be running with the same communication mode as specified withthe notifyMatlabServer command. The event ID and the PID queuein hdldaemon. notifyMatlabServer is often used in conjunction withwaitForHdlClient to make sure the HDL simulator is ready to begin orcontinue processing.

This command issues in the HDL simulator.

Inputs EventID

Specifies the event ID to be sent to hdldaemon. The ID requiresa positive number less than the maximum value of 32-bit signedinteger. This parameter contains the event ID expected by thecommand waitForHdlClient in MATLAB.

Default: 1

socket tcp_spec

Specifies that TCP/IP socket communication be used for thelink between the HDL simulator and MATLAB. For TCP/IPsocket communication on a single computer, tcp_spec requireseither a TCP/IP port number or service name (alias). To set upcommunication between computers, you must also specify thename or Internet address of the remote host that is running theMATLAB server (hdldaemon).

When you omit the socket option, MATLAB and the HDLsimulator use shared memory communication.

4-71

Page 120: EDA Simulator Link Block and Function Reference

notifyMatlabServer

Examples In MATLAB, use the function waitForHdlClient to verify whether theHDL simulator event ID has been received. In the following example,the function returns the HDL Simulator PID if EventID = 5 is receivedwithin 100 seconds. If a time-out occurs, the function returns –1.

>> hdldaemon('socket',5002);...>> hdlpid = waitForHdlClient(100,5);

In the HDL simulator, issue the notifyMatlabServer command tosend event ID 5 to hdldaemon running on the same machine usingTCP/IP socket port 5002.

>> notifyMatlabServer 5 -socket 5002

See Also waitForHdlClient

4-72

Page 121: EDA Simulator Link Block and Function Reference

pingHdlSim

Purpose Block cosimulation until HDL simulator is ready for simulation

Syntax pingHdlSim(timeout)pingHdlSim(timeout, 'portnumber')pingHdlSim(timeout, 'portnumber', 'hostname')

Description pingHdlSim(timeout) blocks cosimulation by not returning until theHDL server loads or until the specified time-out occurs. pingHdlSimreturns the process ID of the HDL simulator or -1 if a time-out occurs.You must enter a time-out value. You may find this function useful ifyou are trying to automate a cosimulation and need to know that theHDL server has loaded before your script continues the simulation.

pingHdlSim(timeout, 'portnumber') tries to connect to the local hoston port portnumber and times out after timeout seconds you specify.

pingHdlSim(timeout, 'portnumber', 'hostname') tries to connectto the host hostname on port portname. It times out after timeoutseconds you specify.

Examples The following function call blocks further cosimulation until the HDLserver loads or until 30 seconds have passed:

pingHdlSim(30)

If the server loads within 30 seconds, pingHdlSim returns the processID. If it does not, pingHdlSim returns -1.

The following function call blocks further cosimulation on port 5678until the HDL server loads or until 20 seconds have passed:

pingHdlSim(20, '5678')

The following function call blocks further cosimulation on port 5678 onhost name msuser until the HDL server loads or until 20 seconds pass:

pingHdlSim(20, '5678', 'msuser')

4-73

Page 122: EDA Simulator Link Block and Function Reference

setupxilinxtools

Purpose Configure MATLAB environment for use with Xilinx FPGA workflow

Syntax setupxilinxtools

Description setupxilinxtools performs the following tasks to ensure yourenvironment is set up correctly to use the Xilinx FPGA workflow:

• Checks that the XILINX system environment variable is defined andpoints to a valid Xilinx ISE installation.

• Checks if your platform and Xilinx ISE version is supported for theFPGA workflow.

• Adds any paths to your MATLAB search path necessary for usingthe Xilinx FPGA workflow.

Examples Enter the following command at the MATLAB command prompt:

>setupxilinxtools

See Also fpgamodelsetup | makefpgaproject

4-74

Page 123: EDA Simulator Link Block and Function Reference

tclHdlSim

Purpose Execute Tcl command in Incisive or ModelSim simulator

Syntax tclHdlSim(tclCmd)tclHdlSim(tclCmd,'portNumber')tclHdlSim(tclCmd, 'portnumber', 'hostname')

Description tclHdlSim(tclCmd) executes a Tcl command on the Incisive orModelSim simulator using a shared connection during a Simulinkcosimulation session.

tclHdlSim(tclCmd,'portNumber') executes a Tcl command on theIncisive or ModelSim simulator by connecting to the local host on portportNumber.

tclHdlSim(tclCmd, 'portnumber', 'hostname') executes a Tclcommand on the Incisive or ModelSim simulator by connecting to thehost hostname on port portname.

The Incisive or ModelSim simulator must be connected to MATLAB andSimulink using the EDA Simulator Link software for this function towork (see either vsimulink or hdlsimulink).

To execute a Tcl command on the Incisive or ModelSimsimulator during a MATLAB cosimulation session, usehdldaemon('tclcmd','command').

Examples The following function call displays a message in the HDL simulatorcommand window using port 5678 on host name msuser:

tclHdlSim('puts "Done"', '5678', 'msuser')

See Also hdldaemon, launchDiscovery, nclaunch, vsim

4-75

Page 124: EDA Simulator Link Block and Function Reference

vsim

Purpose Start and configure ModelSim for use with EDA Simulator Link

Syntax vsim('PropertyName', 'PropertyValue'...)

Description vsim('PropertyName', 'PropertyValue'...) starts and configuresthe ModelSim simulator (vsim) for use with the MATLAB and Simulinkfeatures of EDA Simulator Link. The first folder in ModelSim matchesyour MATLAB current folder.

After you call this function, you can use EDA Simulator Link functionsfor the HDL simulator (for example, vsimmatlab, vsimulink) to performthe following actions:

• Load instances of VHDL entities or Verilog modules for simulationsthat use MATLAB for verification

• Load instances of VHDL entities or Verilog modules for simulationsthat use Simulink for cosimulation

The property name/property value pair settings allow you to customizethe Tcl commands used to start ModelSim, the vsim executable to beused, the path and name of the DO file that stores the start commands,and for Simulink applications, details about the mode of communicationto be used by the applications.

Tip Use pingHdlSim to add a pause between the call to vsim andthe call to actually run the simulation when you are attempting toautomate the cosimulation.

PropertyName/PropertyValuePairs

'libdir', 'folder'Specifies the folder containing MATLAB library files. Thisproperty creates an entry in the startup Tcl file that points to thefolder with the libraries needed for ModelSim to communicatewith MATLAB when ModelSim runs on a machine that does nothave MATLAB.

4-76

Page 125: EDA Simulator Link Block and Function Reference

vsim

'libfile', 'library_file_name'Specifies a particular library file. This value defaults to theversion of the library file that was built using the same compilerthat MATLAB itself uses. If the HDL simulator links otherlibraries, including SystemC libraries, that were built using acompiler supplied with the HDL simulator, you can specify analternate library file with this property. See “Using the EDASimulator Link Libraries for HDL Cosimulation” for versions ofthe library built using other compilers.

'pingTimeout', 'seconds'Time to wait, in seconds, for the HDL simulator to start. Specify 0(the default) to immediately return without waiting.

'rundir', 'dirname'Specifies where to run ModelSim. By default, the function usesthe current working folder.

The following conditions apply to this name/value pair:

• If the value of dirname is “TEMPDIR”, the function creates atemporary folder in which it runs ModelSim.

• If you specify dirname and the folder does not exist, you willget an error.

'runmode', 'mode'Specifies how to start the HDL simulator. This property acceptsthe following valid values:

• 'Batch': Start the HDL simulator in the background withno window (Linux) or in a non-interactive command window(Windows).

• 'CLI': Start the HDL simulator in an interactive terminalwindow.

• 'GUI': Start the HDL simulator with the ModelSim graphicaluser interface.

This value defaults to 'GUI'.

4-77

Page 126: EDA Simulator Link Block and Function Reference

vsim

'socketsimulink', 'tcp_spec'Specifies TCP/IP socket communication for links betweenModelSim and Simulink. For TCP/IP socket communicationon a single computing system, the tcp_spec can consist of justa TCP/IP port number or service name. If you are setting upcommunication between computing systems, you must also specifythe name or Internet address of the remote host. See “SpecifyingTCP/IP Values” for some valid tcp_spec examples.

For more information on choosing TCP/IP socket ports, see“Choosing TCP/IP Socket Ports”

If ModelSim and Simulink run on the same computing system,you have the option of using shared memory for communication.Shared memory is the default mode of communication and takeseffect if you do not specify -socket <tcp-spec> on the commandline.

Note The function applies the communication mode specified bythis property to all invocations of Simulink from ModelSim.

'startms', ['yes' | 'no']Determines whether ModelSim will launch from vsim. Thisproperty defaults to yes, which launches ModelSim and creates astartup Tcl file. If startms is set to no, ModelSim does not launch,but the HDL simulator still creates a startup Tcl file.

This startup Tcl file contains pointers to MATLAB libraries. Torun ModelSim on a machine without MATLAB, copy the startupTcl file and MATLAB library files to the remote machine andstart ModelSim manually. See “Using the EDA Simulator LinkLibraries for HDL Cosimulation”.

4-78

Page 127: EDA Simulator Link Block and Function Reference

vsim

'startupfile', 'pathname'Each invocation of vsim creates a Tcl script that, when executed,compiles and launches the HDL simulator. By default, thisfunction generates the filename of compile_and_launch.tclin the folder specified by rundir.. With this property, you canspecify the name and location of the generated Tcl script. If thefile name already exists, that file’s contents are overwritten. Youcan edit and use the generated file in a regular shell outside ofMATLAB. For example:

sh> vsim -gui -do compile_and_launch.tcl

'tclstart', 'tcl_commands'Specifies one or more Tcl commands to execute after ModelSimlaunches. Specify a command string or a cell array of commandstrings.

'vsimdir', 'pathname'Specifies the path name to the ModelSim simulator executable(vsim.exe) to be started. By default, the function uses the firstversion of vsim.exe that it finds on the system path (defined bythe path variable) . Use this option to start different versions ofthe ModelSim simulator or if the version of the simulator youwant to run does not reside on the system path.

Examples The following function call sequence changes the folder location toVHDLproj and then calls the function vsim. Because the call to vsimomits the 'vsimdir' and 'startupfile' properties, vsim uses thedefault vsim executable and creates a temporary DO file in a temporaryfolder. The 'tclstart' property specifies a Tcl command that loads aninstance of a VHDL entity for MATLAB verification:

• The vsimmatlab command loads an instance of the VHDL entityparse in the library work for MATLAB verification.

• The matlabtb command begins the test bench session for an instanceof entity parse, using TCP/IP socket communication on port 4449and a test bench timing value of 10 ns.

4-79

Page 128: EDA Simulator Link Block and Function Reference

vsim

cd VHDLproj % Change folder to ModelSim project folder

vsim('tclstart','vsimmatlab work.parse; matlabtb parse 10 ns -socket 4449')

The following function call sequence changes the folder location toVHDLproj and then calls the function vsim.

• Because the call to vsim omits the 'vsimdir' and 'startupfile'properties, vsim uses the default vsim executable and creates a DOfile in a temporary folder.

• The 'tclstart' property specifies a Tcl command that loads theVHDL entity parse in the library work for cosimulation betweenvsim and Simulink.

• The 'socketsimulink' property specifies that TCP/IP socketcommunication on the same computer is to be used for links betweenSimulink and ModelSim, using socket port 4449.

cd VHDLproj % Change folder to ModelSim project folder

vsim('tclstart','vsimulink work.parse','socketsimulink','4449')

4-80

Page 129: EDA Simulator Link Block and Function Reference

vsimmatlab

Purpose Load instantiated HDL module for verification with ModelSim andMATLAB

Syntax vsimmatlab <instance> [<vsim_args>]

Description The vsimmatlab command loads the specified instance of an HDLmodule for verification and sets up ModelSim so it can establish acommunication link with MATLAB. ModelSim opens a simulationworkspace and displays a series of messages in the command window asit loads the HDL module’s packages and architectures.

This command is generally issued in the HDL simulator. It also may berun from the HDL simulator prompt or from a Tcl script shell (tclsh).

Arguments <instance>Specifies the instance of an HDL module to load for verification.

<vsim_args>Specifies one or more ModelSim vsim command arguments.For details, see the description of vsim in the ModelSimdocumentation.

Examples The following command loads the HDL module instance parse fromlibrary work for verification and sets up ModelSim so it can establish acommunication link with MATLAB:

ModelSim> vsimmatlab work.parse

4-81

Page 130: EDA Simulator Link Block and Function Reference

vsimulink

Purpose Load instantiated HDL module for cosimulation with ModelSim andSimulink

Syntax vsimulink <instance>[-socket <tcp_spec>] [<vsim_args>]

Description The vsimulink command loads the specified instance of an HDLmodule for cosimulation and sets up ModelSim so it can establish acommunication link with Simulink. ModelSim opens a simulationworkspace and displays a series of messages in the command window asit loads the HDL module’s packages and architectures.

This command is issued in the HDL simulator.

Argument <instance>Specifies the instance of an HDL module to load for cosimulation.

-socket <tcp_spec>Specifies TCP/IP socket communication for the link betweenModelSim and MATLAB. This setting overrides the settingspecified with the MATLAB vsim function. The <tcp_spec> canconsist of a TCP/IP socket port number or service name (alias).For example, you might specify port number 4449 or the servicename matlabservice.

For more information on choosing TCP/IP socket ports, see“Specifying TCP/IP Values”.

If you run the HDL simulator and MATLAB on the samecomputer, you have the option of using shared memoryfor communication. Shared memory is the default mode ofcommunication and takes effect if you do not specify -socket<tcp-spec> on the command line.

4-82

Page 131: EDA Simulator Link Block and Function Reference

vsimulink

Note The communication mode that you specify with thevsimulink command must match what you specify for thecommunication mode when you configure EDA Simulator Linkblocks in your Simulink model. For more information on modesof communication, see “Communications for HDL Cosimulation”.For more information on establishing the Simulink end of thecommunication link, see “Configuring the Communication Link inthe HDL Cosimulation Block”

<vsim_args>Specifies one or more ModelSim vsim command arguments.For details, see the description of vsim in the ModelSimdocumentation.

Examples The following command loads the HDL module instance parse fromlibrary work for cosimulation and sets up ModelSim so it can establish acommunication link with Simulink:

ModelSim> vsimulink work.parse

4-83

Page 132: EDA Simulator Link Block and Function Reference

waitForHdlClient

Purpose Wait until specified event ID is obtained or time-out occurs

Syntax waitForHdlClient(TimeOut,EventID)waitForHdlClient(TimeOut)waitForHdlClientoutput = waitForHdlClient(TimeOut,EventID)

Description waitForHdlClient(TimeOut,EventID) waits for the expected HDLsimulator event ID to arrive at the MATLAB server (hdldaemon)before processing continues. If the expected event ID arrives beforethe number of seconds specified by the TimeOut parameter, thevalue returned by the HDL simulator is the HDL simulator processidentification (PID). Otherwise, the returned value is –1.

waitForHdlClient(TimeOut) waits for EventID = 1 for TimeOutseconds.

waitForHdlClient waits for EventID = 1 for 60 seconds.

output = waitForHdlClient(TimeOut,EventID) returns the processidentification (PID) in output. Although you are not required to providean output variable, MATLAB returns an error if a time-out occurs andthe output argument is not specified.

Inputs TimeOut

Number of seconds to wait for a response from the HDL simulator

EventID

The HDL simulator event ID. EventID must be a positive numberless than the maximum value of a 32-bit signed integer. Thevalue should match the event ID sent by the notifyMatlabServercommand in the HDL simulator.

EventID can be either a scalar or vector value. If EventID is avector, the function return a value only if all elements of thevector have been collected or if a time-out occurs. The returnedoutput value is the same size as the event ID, and each element of

4-84

Page 133: EDA Simulator Link Block and Function Reference

waitForHdlClient

the output variable is the detected PID of the HDL simulator thatsends the corresponding event ID element.

Outputs output

Output variable for holding returned value from call towaitForHdlClient. Contains either the HDL simulator processidentification (PID) or –1 if an error occurs.

Examples Wait for event ID 2 for 120 seconds.

>> hdlpid = waitForHdlClient(120, 2);

See Also notifyMatlabServer

4-85

Page 134: EDA Simulator Link Block and Function Reference

wrapverilog

Purpose Apply VHDL wrapper to Verilog module

Syntax wrapverilog [-nocompile] <verilog_module>

DescriptionNote wrapverilog will be removed in a future version. EDA SimulatorLink now supports Verilog models directly, without requiring a VHDLwrapper.

The wrapverilog command applies a VHDL wrapper to the specifiedVerilog module and then automatically compiles the resulting VHDLfile. You can then use your wrapped Verilog module with EDASimulator Link.

This command is issued in the HDL simulator.

Before executing the wrapverilog command on a Verilog file, you mustcompile and load the Verilog module in ModelSim, as in the followingexample.

vlib workvmap work workvlog myverilogmod.vvsim myverilogmodwrapverilog [-nocompile] myverilogmod

Arguments <verilog_module>Specifies the Verilog module to which a VHDL wrapper is to beapplied. The module you specify must be in a valid ModelSimdesign library when you issue the command.

-nocompileSuppresses automatic compilation of the resulting VHDL file,verilog_module_wrap.vhd.

4-86

Page 135: EDA Simulator Link Block and Function Reference

wrapverilog

Examples The following command applies a VHDL wrapper to Verilog modulemyverilogmod.v and writes the output to myverilogmod_wrap.vhd.The -nocompile option suppresses automatic compilation.

ModelSim> wrapverilog -nocompile myverilogmod

4-87

Page 136: EDA Simulator Link Block and Function Reference

wrapverilog

4-88

Page 137: EDA Simulator Link Block and Function Reference

Index

IndexAaction property

description of 4-3arguments

for hdlsimmatlab command 4-18for hdlsimulink command 4-19for matlabcp command 4-35for matlabtb command 4-48for matlabtbeval command 4-61for pingHdlSim function 4-73for tclHdlSim function 4-75for vsimmatlab command 4-81for vsimulink command 4-82

Auto fillin Ports pane of HDL Cosimulation block 2-2

Bblock input ports parameter

description of 2-2block output ports parameter

description of 2-2blocks

HDL Cosimulationdescription of 2-2

To VCD Filedescription of 2-26

C-cancel option 4-48Clocks pane

description of 2-2configuremodelsim function

description of 4-3Connection pane

description of 2-2Cosimulation timing

absolute mode 2-2relative mode 2-2

Ddec2mvl function

description of 4-9dialogs

for HDL Cosimulation block 2-2for To VCD File block 2-26

direct feedthrough optionfor eliminating block latency 2-2

Eexamples

configuremodelsim function 4-3dec2mvl function 4-9hdlsimmatlab command 4-18hdlsimulink command 4-19launchDiscovery function 4-21matlabcp command 4-35matlabtb command 4-48matlabtbeval command 4-61mvl2dec function 4-64nclaunch function 4-65nomatlabtb command 4-70pingHdlSim function 4-73tclHdlSim function 4-75vsim function 4-76vsimmatlab command 4-81vsimulink command 4-82

F-falling option 4-48falling-edge clocks

description of 2-2files

VCD 2-29FPGA implementation functions

reference for 3-4functions 4-1

hdlsimmatlab

Index-1

Page 138: EDA Simulator Link Block and Function Reference

Index

description of 4-18hdlsimulink

description of 4-19makefpgaproject 4-32matlabcp

description of 4-35matlabtb

description of 4-48matlabtbeval

description of 4-61nomatlabtb 4-70notifyMatlabServer 4-71setupxilinxtools 4-74tdkfpgasetup 4-10waitForHdlClient 4-84See also MATLAB functions

functions for generating FPGA projectsmakefpgaproject 4-32setupxilinxtools 4-74tdkfpgasetup 4-10

Ggenerating FPGA projects

from command line 4-32

HHDL Cosimulation block

description of 2-2HDL cosimulation functions

reference for 3-2HDL cosimulation library

reference for 1-2HDL simulator running on this computer

parameterdescription of 2-2

hdlsimdir propertywith launchDiscovery function 4-21with nclaunch function 4-65

hdlsimmatlab commanddescription of 4-18

hdlsimulink commanddescription of 4-19

Host name parameterdescription of 2-2

IIncisive simulator commands

hdlsimmatlabdescription of 4-18

INOUT portsspecifying 2-2

LlaunchDiscovery function

description of 4-21

MMATLAB functions 4-1

configuremodelsimdescription of 4-3

dec2mvldescription of 4-9

launchDiscoverydescription of 4-21

mvl2decdescription of 4-64

nclaunchdescription of 4-65

pingHdlSimdescription of 4-73

tclHdlSimdescription of 4-75

vsimdescription of 4-76

matlabcp commanddescription of 4-35

Index-2

Page 139: EDA Simulator Link Block and Function Reference

Index

matlabtb commanddescription of 4-48

matlabtbeval commanddescription of 4-61

-mfunc optionwith matlabcp command 4-35with matlabtb command 4-48with matlabtbeval command 4-61

ModelSim commandsvsimmatlab

description of 4-81vsimulink

description of 4-82mvl2dec function

description of 4-64

Nnclaunch function

description of 4-65nomatlabtb command 4-70Number of input ports parameter 2-26Number of output ports parameter

description of 2-26

Ooptions

for hdlsimulink command 4-19for matlabcp command 4-35for matlabtb command 4-48for matlabtbeval command 4-61for vsimulink command 4-82property

with configuremodelsim function 4-3with launchDiscovery function 4-21with nclaunch function 4-65with vsim function 4-76

Output sample time parameterdescription of 2-2

Pparameters

for HDL Cosimulation block 2-2for To VCD File block 2-26

path specificationfor ports/signals and modules in Simulink

with HDL Cosimulation block 2-2pingHdlSim function

description of 4-73port names

specifying paths in Simulinkwith HDL Cosimulation block 2-2

Port number or service parameterdescription of 2-2

Ports paneAuto fill option 2-2description of 2-2Enable direct feedthrough option 2-2

Post-simulation command parameterdescription of 2-2

propertiesaction 4-3for configuremodelsim function 4-3for launchDiscovery function 4-21for nclaunch function 4-65for vsim function 4-76nclaunchdir

with nclaunch function 4-65socketsimulink 4-21 4-65 4-76startupfile 4-21 4-65 4-76tclstart

with configuremodelsim function 4-3with launchDiscovery function 4-21with nclaunch function 4-65with vsim function 4-76

vsimdirwith configuremodelsim function 4-3with vsim function 4-76

property optionfor configuremodelsim function 4-3

Index-3

Page 140: EDA Simulator Link Block and Function Reference

Index

for launchDiscovery function 4-21for nclaunch function 4-65for vsim function 4-76

Prsimulation command parameterdescription of 2-2

R-repeat option 4-35-rising option 4-35rising-edge clocks

description of 2-2

Ssending messages to MATLAB

notifyMatlabServer function 4-71-sensitivity option 4-35setupxilinxtools

function for generating FPGA projects 4-74Shared memory parameter

description of 2-2signal names

specifying paths in Simulinkwith HDL Cosimulation block 2-2

signalsread/write access required 2-2

-socket optionwith hdlsimulink command 4-19with matlabcp command 4-35with matlabtb command 4-48with matlabtbeval command 4-61with vsimulink command 4-82

socketsimulink propertydescription of 4-21 4-65 4-76

startupfile propertydescription of 4-21 4-65 4-76

TTcl commands

added to startup script vialaunchDiscovery 4-21

added to startup script via nclaunch 4-65hdlsimmatlab 4-18hdlsimulink 4-19specified in Tcl pane of HDL Cosimulation

block 2-2Tcl pane

description of 2-2tclHdlSim function

description of 4-75tclstart property

with configuremodelsim function 4-3with launchDiscovery function 4-21with nclaunch function 4-65with vsim function 4-76

time scale, VCD file 2-29Timescales pane

description of 2-2To VCD File block

description of 2-26

VVCD file name parameter

description of 2-26VCD files

format of 2-29Virtual Platform simulation functions

reference for 3-5vsim function

description of 4-76vsimdir property

with configuremodelsim function 4-3with vsim function 4-76

vsimmatlab commanddescription of 4-81

vsimulink commanddescription of 4-82

Index-4

Page 141: EDA Simulator Link Block and Function Reference

Index

Wwaiting for the HDL simulator

waitForHdlClient function 4-84

Index-5