Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Trying simple tutorial for EDA Link between Simulink and Modelsim for MATLAB R2010a

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.

4 Comments

Edward on 19 Oct 2011

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.

Edward on 19 Oct 2011

Is there a more basic simulation I should start with?

Edward on 20 Oct 2011

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{:});

Edward

Products

2 Answers

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.

3 Comments

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.

Kaustubha Govind
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.

1 Comment

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.

Walter Roberson

Contact us