Documentation

hdldaemon

Control MATLAB server that supports interactions with HDL simulator

Syntax

Description

hdldaemon starts the HDL Link MATLAB® server using shared memory inter-process communication. Only one hdldaemon per MATLAB session can be running at any given time.

example

hdldaemon(Name, Value) uses additional options specified by one or more Name, Value pair arguments.

  • If you do not specify memory type, the server starts using shared memory.

  • If you specify the socket Name, Value argument, the server starts using socket memory.

    Note:   If server is already running, issuing hdldaemon with these arguments shuts down the current server and then starts a new server session using shared memory (unless socket is specified).

example

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

example

s=hdldaemon(___) returns the server status connection in structure s, using any of the input arguments in the previous syntaxes.

Examples

collapse all

Start the MATLAB server using shared memory communication and use an integer representation of time.

hdldaemon('time','int64')
HDLDaemon shared memory server is running with 0 connections

Start MATLAB server and specify socket communication on port 4449.

hdldaemon('socket','4449')
HDLDaemon socket server is running on port 4449 with 0 connections

With one or more connections:

hdldaemon('status')
HDLDaemon socket server is running on port 4449 with 1 connections

With no connections:

hdldaemon('status')
HDLDaemon shared memory server is running with 0 connections

Server has not been started:

hdldaemon('status')
HDLDaemon is NOT running

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

Returned message for a socket connection:

x=hdldaemon('status')
x = 
           comm: 'sockets'
    connections: 0
         ipc_id: '4449'

Returned message for a shared memory connection:

x=hdldaemon('status')
x = 
           comm: 'shared memory'
    connections: 0
         ipc_id:  '\\.\pipe\E505F434-F023-42a6-B06D-DEFD08434C67'

You can examine ipc_id by entering it at the MATLAB command prompt:

x.ipc_id
 '\\.\pipe\E505F434-F023-42a6-B06D-DEFD08434C67'

Shut down server without shutting down MATLAB.

hdldaemon('kill')
HDLDaemon server was shutdown

Issue simple or complex Tcl commands.

Simple example:

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

Complex example:

tclcmd = {['cd ',unixprojdir],...
           'vlib work',... % create library (if applicable)
          ['vcom -performdefaultbinding ' unixsrcfile1],...
          ['vcom -performdefaultbinding ' unixsrcfile2],...
          ['vcom -performdefaultbinding ' unixsrcfile3],...
           'vsimmatlab work.osc_top ',...
           'matlabcp u_osc_filter -mfunc oscfilter',...
           'add wave sim:/osc_top/clk',...
           'add wave sim:/osc_top/clk_enable',...
           'add wave sim:/osc_top/reset',...
          ['add wave -height 100 -radix decimal -format analog-step -scale 0.001 -offset 50000 ',...
           'sim:/osc_top/osc_out'],...
          ['add wave -height 100 -radix decimal -format analog-step -scale 0.00003125 -offset 50000 ',...
           'sim:/osc_top/filter1x_out'],...
          ['add wave -height 100 -radix decimal -format analog-step -scale 0.00003125 -offset 50000 ',...
           'sim:/osc_top/filter4x_out'],...
          ['add wave -height 100 -radix decimal -format analog-step -scale 0.00003125 -offset 50000 ',...
           'sim:/osc_top/filter8x_out'],...
           'force sim:/osc_top/clk_enable 1 0',...
           'force sim:/osc_top/reset 1 0, 0 120 ns',...
           'force sim:/osc_top/clk 1 0 ns, 0 40 ns -r 80ns',...
          };

This example is taken from "Implementing the Filter Component of an Oscillator in MATLAB". See the full example for use of this complex Tcl command in context.

Related Examples

Input Arguments

collapse all

Server option to shut down MATLAB server or display server status, specified as one of these character vectors:

'kill'Shuts down the MATLAB server without shutting down MATLAB.
'stop'Shuts down the MATLAB server without shutting down MATLAB. There is no difference between using 'kill' and 'stop'.
'status'Displays status of the MATLAB server. You can also use s=hdldaemon('status'), which displays MATLAB server status and returns status in structure s.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'time','int64','quiet','true' specifies time values are returned as 64-bit integers and output messages are suppressed.

collapse all

Instruction to MATLAB server on how it should send and return time values, specified as the comma-separated pair consisting of 'time' and one of these values:

'int64'

Specifies that the MATLAB server send and return time values in the MATLAB function callbacks as 64-bit integers representing the number of simulation steps.
See the matlabcp/matlabtb tnow parameter reference (MATLAB Function Syntax and Function Argument Definitions).

'sec'

Specifies that the MATLAB server sends and returns time values in the MATLAB function callbacks as double values that HDL Verifier™ scales to seconds based on the current HDL simulation resolution.

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

Example: 'time','int64'

Indicator to suppress printing diagnostic messages, specified as the comma-separated pair consisting of 'quiet' and one of the following values:

'true'

Suppress printing diagnostic messages.

'false'

Do not suppress printing diagnostic messages.

Errors still appear. Use this option to suppress the MATLAB server shutdown message when using hdldaemon to get an unused socket number. If server is already running, issuing hdldaemon with the quiet parameter alone will shut down the current server and start the server up again using shared memory.

Example: 'quiet', 'true'

TCP/IP port used for communication, specified as the comma-separated pair consisting of 'socket' and a character vector. The character vector can be either '0', indicating that the host automatically chooses a valid TCP/IP port, or an explicit port number (1024 < port < 49151) or a service (alias) name from /etc/services file.

If you specify the operating system option (0), use hdldaemon('status') to acquire the assigned socket port number.

Example: 'socket','4449'

Tcl command transmitted to all connected clients, specified as any valid Tcl command character vector.

The Tcl command character vector you specify cannot include commands that load an HDL simulator project or modify simulator state. For example, the character vector 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 software establishes a server connection.

    Caution   Do not call hdldaemon('tclcmd', 'Tcl command') from inside a matlabtb or matlabcp function. Doing so results in a race condition, and the simulator hangs.

Example: 'tclcmd','puts' '"done"'

Output Arguments

collapse all

Structure containing information about the connection. The structure contains the following variables:

'comm'Either 'shared memory' or 'sockets'
'connections'Number of open connections
'ipc_id'If shared memory, file system name for the shared memory communication channel. If socket, the TCP/IP port number.

See Also

|

Introduced in R2012a

Was this topic helpful?