UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
8,243 Views
Registered: ‎02-04-2008

Matlab/Simulink - ISim (ModelSim) co-simulation - how ?

Hi all,

 

I am wondering is there any way to do hdl co-simulation with Simulink + ISim?

I know about the SystemGenerator, but I don't want to use it (commercial, too big/complex, eval. version is not an option for me, etc.).

I need to perform some 'simple' co-simulation where my mathematical model is built in Simulink and some portion of the algorithm is built in Verilog HDL. Now I want to test this hdl module within Simulink.

I've only heard there was some possibility to do this with ModelSim XE, but newer versions of the ISE do not support it.

So my question is: is there a way to co-simulate with Simulink + ISim? If not, can it be done with Simulink + ModelSim PE Student Version? Can you offer any clues for this with some very simple example?

 

Thanks

0 Kudos
5 Replies
Teacher eilert
Teacher
8,232 Views
Registered: ‎08-14-2007

Re: Matlab/Simulink - ISim (ModelSim) co-simulation - how ?

Hi,

in any way you need some software to enable Simulink to controll and synchronize to some HDL simulator.

If this is not System Generator then you will have to use some other Matlab/Simulink Product like HDL-Coder etc.

But for these tools you will also have to pay.

 

Or you have to reinvent the wheel, which will cost you a lot of time.

Modelsim will probably better suited, if you are not going to use sysgen, since it can be put to run under full script controll.

 

 

Have a nice simulation

  Eilert

0 Kudos
Contributor
Contributor
8,228 Views
Registered: ‎02-04-2008

Re: Matlab/Simulink - ISim (ModelSim) co-simulation - how ?

Hi,

 

Thank you for your feedback.

Actually I don't want to synthesize the HDL from Matlab. My goal is to do just co-simulation. I mean I have some Simulink model that would act as a testbench for the HDL code that have been already written and compiled in ModelSim. Thus it would be possible just to test/verify my HDL (in my case Verilog) - all input vectors are given from Simulink as well as all the visualization.

What I've learned, there is "Link for ModelSim" in some former Matlab versions, and now "EDA Simulator Link MQ". The problem is that I have access to Matlab/Simulink but I can afford only the "ModelSim PE Student Edition". (Xilinx and Mentor does not support the free XE version anymore). Well, I have tried with this product. The 'vsim' command at the Matlab prompt invokes the ModelSim and from there I was able to write, compile and simulate a library. But there are some other things that prevent me to use that HDL code from whithin Simulink. I use the "Link for ModelSim".

I found this thread co-simulation in matlab, so obviously my goal is feasible.

 

However, when I try to simulate I get some errors:

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

 Ok, then I found this thread: Matlab Newsgroup ModelSim with the similar problem, but it did not helped me.

 

Now, I am almost sure things can be done and I am seeking for some help to get this running using the ModelSim PE Student Edition.

 

Thanks for any help.

Regards,

    Yassen

0 Kudos
Teacher eilert
Teacher
8,226 Views
Registered: ‎08-14-2007

Re: Matlab/Simulink - ISim (ModelSim) co-simulation - how ?

Hi,

this seems like something that similarly happens with using Questa with ISE.

Some programmers thing its of ultimate importance to exactly check version names of other companies tools and libraries, even if there's no technological demand for it, since it is absolutely sure that these strings will change over time.

Probably Modelsim PE returns some other string, than what the programmer has expected and so this useless error pops up.

If you are lucky, you might get into that script, find the lines that identify the modelsim version string and just add the return value of Modelsim PE to the script.

A nasty patch, but something similar must be done for the Questa-ISE problem too.

So, maybe you are lucky and able to make that change for your tool configuration too.

 

Have a nice simulation

  Eilert

0 Kudos
Adventurer
Adventurer
8,047 Views
Registered: ‎02-09-2012

Re: Matlab/Simulink - ISim (ModelSim) co-simulation - how ?

>  synthesize the HDL from Matlab

 

It is not necessary to setup the toolchain like this, you just have to make the sysGen synthesize HDL for the simulation process. You do not even have to make strong usage of the Xilinx toolbox in Simulink.

 

You just drop in the whole code and use it as a symbol to place it into the Simulink design.

 

The only thing you should have a look at, is to clearly distinguish between logical design (HDL, functions) and physical (IO, DDR, SERDES).

0 Kudos
Newbie ermanuret
Newbie
7,916 Views
Registered: ‎02-09-2008

Re: Matlab/Simulink - ISim (ModelSim) co-simulation - how ?

You can do this with using HDL-Verifier product from mathworks. With this product you can produce Modelsim block with using hand written or automatic generated hdl code. 

 

It initiate modelsim and wait for simulation. When you start simulation inputs from simulink send to modelsim and result send back to simulink.

 

Also you can do FPGA in the loop simulation with HDL-coder product with supported board.

0 Kudos