views:

981

answers:

6

We're using Matlab Simulink for model development (and Real-Time Workshop autocoding) within a team of several developers.

We currently use Visual Source Safe (yes, I know its terrible) for version control, using locks to prevent conflicting changes.

We'd like to migrate our programme to a different version control system (svn, hg or git), but we're concerned about performing merges and diffs on Simulink .mdl files.

Does anybody have useful experience in performing merges on Simulink files?

+1  A: 

Hi Jon,

Text merging of Simulink model files will be difficult. Here's an article which gives some information on configuration management when using Simulink.

As for diffs, there is a differencing tool in the Simulink Report Generator starting I believe in R2008b+. Here's a link to the doc for that feature.

Mike

MikeT
Thanks Mike, I hadn't found that article that you referenced, which is a very good discussion of some of the issues involved.It seems like the only realistic option ATM is to use locks, or at least enforce manual merges.
Jon Mills
Actually, there are tools such as SimDiff and SimMerge which can directly diff and merge your models, without having to convert them to another format. SimDiff has been available since 2005. The paper referenced is a bit dated; here are two newer papers: http://www.xilinx.com/support/documentation/application_notes/xapp498.pdf and http://www.sae.org/technical/papers/2010-01-0940 The Xilinx paper explains how to use SimDiff and SimMerge with SVN. See my answer for more details: http://stackoverflow.com/questions/1788646/matlab-simulink-version-control-with-multiple-developers/2436711#2436711
rob
+1  A: 

Though I don't have a specific experience, svn handles non-text files well. You have two options:

  1. If mdl files aren't binary already (it's been way too many years since I've used Simulink) set the file svn:mime-type property for mdl files to "application/octet-stream" using the auto-props feature or by setting the property manually with svn propset. It won't attempt to merge, and on a conflicting checkin will require operator action to resolve the differences.
  2. Set up your repository to be a locking one, like VSS (no flames please). Here is a nice step-by-step guide.
Marc
Marc, Simulink .mdl files are text-based, but there are elements within them that increase the probability of an automated merge breaking the file (for example, AFAIK, the lines between blocks are defined by their x-y co-ordinates, so if a block is moved on the screen an automatic merge could do damage).Thanks for the tips on SVN setup. It sounds like locking or manual merges are the only solutions at present.
Jon Mills
+2  A: 

Hi,

As mentioned Mathworks are working on differencing tools for Simulink, basically exporting them to XML files and then comparing them. Although I don't believe that will help in merging the files anymore than any existing version control system can.

I've started using Mercurial for our MATLAB code and Simulink models. It works well and quick on some fairly large simulink models but as a single developer I haven't had to deal with any complicated merges yet. A simple diff and merge usually throws up several conflicts which are nothing more than syntax changes, usually date stamps and version numbers.

My suggestion would be, if possible, to use model references. I have a large model which basically links half a dozen sub models using model referencing. Each sub model is under version control and only one developer is responsible for a sub model then it side steps a lot of the problems in merging different simulink models.

Adrian
Thanks Adrian. The model referencing strategy you mentioned is similar to the one in the article referenced by Mike.I'd definitely like to see Mathworks come up with more merge-friendly file format for models, so the XML route might be a solution.
Jon Mills
A: 

Hi Jon,

Please take a look at http://www.ikv.de/mediniunite/ Maybe that helps to solve your problems. With medini unite we are providing a usefull Diff/Merge-tool for Matlab/Simulink/Stateflow which is very easy to use and of course to integrate within different version control systems.

Olaf Irmscher
Olaf,That looks like an excellent solution - although I suspect its pretty expensive. I'm not very keen on products with websites that make you fill in all your details just to get a quotation, rather than just telling you how much they cost on the website.
Jon Mills
Jon, I understand what you mean. But on the other hand it's very difficult to develop a tool like medini unite without any user feedback. Unfortunately that's our experience when our tool was available without registration. Send me your questions to [email protected], I'll quickly reply.
Olaf Irmscher
+2  A: 

SimDiff and SimMerge are the industry-standard tools to do exactly what you need. You can pair them with any software configuration management/version control system that you like. SimDiff and SimMerge are used by virtually every major automotive and aerospace company in the world, including Toyota, Honda, Mazda, Mitsubishi, Chrysler, Ford, Daimler, Peugeot, Renault, Volkswagen, Boeing, EADS, BAE Systems, Lockheed Martin, etc.

You can view a flash demo of SimMerge here: http://www.ensoftcorp.com/SimMerge/Demo.htm

The 2007 SAE paper referenced by Mike was written before SimMerge was available. Now you can use a modern software configuration management system like AccuRev or IBM Unified Change Management for your Simulink projects.

There are at least two newer papers which supersede the 2007 paper. The one from Xilinx shows exactly how to integrate SimDiff and SimMerge with SVN/Subversion.

rob
+2  A: 

Xilinx has recently published an app note detailing how to configure Subversion with SimDiff and SimMerge for team-based development of Simulink models.

From the app note:

"This application note provides an overview on how to perform source version control and team-based design using the System Generator tool. These tasks can be accomplished using the version control features native to the MATLAB®Simulink® software environment, or with an external source control system. While this application note focuses on Subversion, a well-known, free, open-source control system, other version control software such as CVS, MS Source Safe, and Clear Case can also be used—depending on the design environment. This application note also demonstrates how to graphically compare and merge model-based designs using the SimDiff and SimMerge external software packages from Ensoft."

Jeremias Sauceda