14
votes

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?

8

8 Answers

6
votes

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

6
votes

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.

3
votes

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.

3
votes

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.

3
votes

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

2
votes

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
votes

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.
1
votes

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.