MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by Edward on 19 Oct 2011

http://www.mathworks.com/help/releases/R2010a/toolbox/edalink/ug/bsctzv_-63.html#bsctzv_-66

When I get to the part of tutorial, "Loading Instances of the VHDL Entity for Cosimulation with Simulink" BUT the command

"vsimulink work.inverter" does not work. Modelsim says 'vsimulink' is an invalid command.

I can't really get passed that and its very frustrating.

Answer by Kaustubha Govind on 20 Oct 2011

I think the issue may be that Modelsim is not on the system path, and MATLAB can't find it. For example, try the following from MATLAB:

>> !vsim -version

If this doesn't work, make sure that vsim.exe on the system path and restart MATLAB.

Edward on 21 Oct 2011

That does work...Matlab does seem to find the version.

But I noticed the "!" in front....should I use that whenever I am executing "vsim"?

Edward on 7 Nov 2011

What is the distinction between typing "vsim" in MATLAB vs. typing "!vsim" ?

What does the ! do? From my messages, it looks like it is working with ! but not without....why would that be?

Here is the two responses I get from MATLAB:

>> !vsim -version

Model Technology ModelSim PE vsim 10.0 Simulator 2010.12 Dec 4 2010

>> vsim

??? SWITCH expression must be a scalar or string constant.

Error in ==> hdlsim>l_GetModelSimLibInfo at 549

switch (lfmVer)

Error in ==> hdlsim at 113

case 'ModelSim', libInfo = l_GetModelSimLibInfo;

Error in ==> vsim at 101

hdlsim(pvpairs{:});

Kaustubha Govind on 8 Nov 2011

"vsim" executes the vsim.m file that is part of the EDA Simulator Link product (type "which vsim" to see the full path to the file), whereas "!vsim" redirects the command to the system shell. So it is equivalent to opening a system command window and running "vsim".

It looks like vsim.exe is on your system path, but MATLAB has trouble parsing the command. It could be that ModelSim 10.0 is not supported with the version of MATLAB you have installed. Open your help window (type "doc") and navigate to EDA Simulator Link->Getting Started->Product Requirements->Supported EDA Tools to see the list of supported tools for your version.

Also, please consider contacting Tech Support if this doesn't help.

Answer by Walter Roberson on 7 Nov 2011

Put a breakpoint in at hdlsim>l_GetModelSimLibInfo at 549 and examine lfmVer and see whether it is indeed a scalar or a string constant. If we knew the value that lfmVer had at that point, we might be able to get further.

Also, please look at the lines immediately after that and tell us what data type the switch() code is expecting to receive.

Edward on 8 Nov 2011

Wow... This helped me a great deal. When I trace the generation of this message I find the following code:

switch (lfmVer)

% when using the tmwgcc libs, we do NOT want to let MTI prepend to

% LD_LIBRARY_PATH.

case {'6.3', '6.4', '6.5'}

libInfo.letMtiPrependLdPath = false;

This seems to be telling me that MATLAB is expecting a version of Modelsim of 6.3, 6.4, or 6.5. But for whatever reason, Modelsim jumped up to 10.0 in its later releases and that is what I'm using.

I will try using an older version of Modelsim and see what happens.

Thanks.

## 4 Comments

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/18763#comment_41349

This was my first attempt to try and use EDA Link to have a simultaneous Simulink and Modelsim session----is their some sort of setup step that I am missing and is not included in the tutorial?

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/18763#comment_41350

Looking closely at the screen captures in the tutorial i can see that 'simulink' is supposed to get interpreted as:

vsim -foreign {simlinkserver {C:/Program Files/MATLAB/R2010a/toolbox/edalink/extensions/modelsim/windows32/liblfmhdls_tmwvs.dll} } work.inverter

This actually almost seems to work....but my simulink still doesn't seem to find the Modelsim when I run the Simulink simulation.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/18763#comment_41351

Is there a more basic simulation I should start with?

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/18763#comment_41681

Whenever I try typing the vsim commands in the MATLAB windows per the tutorial's directions I also get errors:

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

??? SWITCH expression must be a scalar or string constant.

Error in ==> hdlsim>l_GetModelSimLibInfo at 549

switch (lfmVer)

Error in ==> hdlsim at 113

case 'ModelSim', libInfo = l_GetModelSimLibInfo;

Error in ==> vsim at 101

hdlsim(pvpairs{:});

>> vsim('tclstart', 'vsimulink work.parse')

??? SWITCH expression must be a scalar or string constant.

Error in ==> hdlsim>l_GetModelSimLibInfo at 549

switch (lfmVer)

Error in ==> hdlsim at 113

case 'ModelSim', libInfo = l_GetModelSimLibInfo;

Error in ==> vsim at 101

hdlsim(pvpairs{:});