function tclcmd = multimanchestercmds(varargin)
% MULTIMANCHESTERCMDS - Creates Tcl commands for Multi Manchester Model
%   The returned cell array can be passed as parameters ('cmd') to
%   VSIMULINK.  This will launch ModelSim, build the VHDL design and 
%   also has the commands for cosimulation with MULTIMANCHESTER.MDL.
%
%   MULTIMANCHESTERCMDS(Property,Value)
%   
%   Property :
%
%   'ProjDir'- Specify where to run the HDL simulator.  If unspecified, the
%        'TEMPDIR', a temporary directory will be created in which the HDL
%        simulator will run. 
%
%   Examples:
%   1. After opening multimanchester.mdl in Shared mode type the following
%   command in the MATLAB command window.
%   >> vsim('tclstart',multimanchestercmds)    "or"
%   >> vsim('tclstart',multimanchestercmds('ProjDir','C:\tmp\'))
%
%   See also VSIM

%   Copyright 2003-2009 The MathWorks, Inc.
%   $Revision $ 
%
p = inputParser;              % Creating an instance of inputParser class.
p.addOptional('ProjDir','');  % This creates an optional parameter-value pair.
p.parse(varargin{:});         % Calling the parse method of the object to read and validate each argument.
projdir = p.Results.ProjDir;  % Saving ProjDir parameter value to projdir.

srcfile1 = fullfile(matlabroot,'toolbox','edalink','extensions','modelsim','modelsimdemos','vhdl','manchester','statecnt.vhd');
srcfile2 = fullfile(matlabroot,'toolbox','edalink','extensions','modelsim','modelsimdemos','vhdl','manchester','iqconv.vhd');
srcfile3 = fullfile(matlabroot,'toolbox','edalink','extensions','modelsim','modelsimdemos','vhdl','manchester','decoder.vhd');
srcfile4 = fullfile(matlabroot,'toolbox','edalink','extensions','modelsim','modelsimdemos','vhdl','manchester','multimanchester.vhd');

unixsrcfile1 = ['"' strrep(srcfile1,'\','/') '"']; 
unixsrcfile2 = ['"' strrep(srcfile2,'\','/') '"']; 
unixsrcfile3 = ['"' strrep(srcfile3,'\','/') '"']; 
unixsrcfile4 = ['"' strrep(srcfile4,'\','/') '"']; 

if isempty(projdir)
    if strcmp(computer,'PCWIN'),
        projdir = tempdir;
    else
        projdir = tempname;
        mkdir(tempdir,strrep(projdir,tempdir,''));
    end
end
unixprojdir = strrep(projdir,'\','/'); 

tclcmd = { 
           ['cd ',unixprojdir],...            
            'vlib work',... %create library (if necessary)
           ['vcom -performdefaultbinding ' unixsrcfile1],...
           ['vcom -performdefaultbinding ' unixsrcfile2],...
           ['vcom -performdefaultbinding ' unixsrcfile3],...
           ['vcom -performdefaultbinding ' unixsrcfile4],...           
            'vsimulink -voptargs=+acc work.multimanchester',...
         };
