14

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?

Jon Mills
  • 1,625
  • 3
  • 15
  • 27

8 Answers8

6

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
  • 1,624
  • 8
  • 11
  • 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 Nov 25 '09 at 12:33
  • 3
    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 Mar 17 '10 at 00:08
  • 1
    The link to the article is broken – Joakim Mar 17 '15 at 16:38
6

SimDiff will do what you need. You can pair it with any software configuration management/version control system that you like.

The 2007 SAE paper referenced by Mike was written before SimMerge (later rebranded to SimDiff 4) 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 with SVN/Subversion.

Disclosure: I was involved in the development of SimDiff from 2005-2015.

rob
  • 5,947
  • 1
  • 35
  • 54
3

DiffPlug can diff Simulink files graphically, and it integrates into SVN and Git. It has a command line interface, so you could probably integrate it with SourceSafe too...

http://www.diffplug.com/products/dp.simulink.differ

Ned Twigg
  • 2,009
  • 2
  • 19
  • 37
3

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
  • 3,166
  • 16
  • 22
  • 1
    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 Nov 25 '09 at 12:42
3

The Mathworks recommend using Simulink Projects, which is new in R2011b. See the Seth on Simulink blog for details.

Simulink Projects will integrate the MATLAB/Simulink with your version control system, as well as providing additional features.

As far as merging Simulink goes, I believe that current best practice is to avoid it as much as possible. This can be done using model references and library links, where appropriate, to ensure that each configuration item is small enough.

Nzbuu
  • 5,076
  • 27
  • 48
2

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."

1

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
  • 3,016
  • 2
  • 24
  • 36
  • 1
    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 Nov 25 '09 at 12:31
1

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.

  • 1
    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 Jan 25 '10 at 18:06
  • 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 information@ikv.de, I'll quickly reply. – Olaf Irmscher Jan 27 '10 at 11:14