image thumbnail

Simulink block set for Gtkwave : An alternative of simulink scope.

by

 

04 Jun 2012 (Updated )

Simulink blockset to display the simulation data from simulink on GTKWave

GTKWaveRunVCD(VcdFile)
%%
%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%
%   File Name       : GTKWaveBlockSet:GTKWaveRunVCD.m
%   Version         : v1.2
%   Created By      : Tabrez Alam (TAB)
%   Last updated on : 11 June,2012
%   -----------------------------
%       Change Log
%   -----------------------------
%   Initial
%   v1.1 -  Version updated due to change in library model.   
%   v1.2 -  Version updated due to change in file GTKWaveCreateVCD.m
%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%

%%
function GTKWaveRunVCD(VcdFile)

    
    %----------------------------------------------------------------------
    % Directory of GTKWave tool
    %----------------------------------------------------------------------
    GTKWavePath = fileparts(fileparts(mfilename('fullpath')));
    
    %----------------------------------------------------------------------
    % Check whether GTKWave is installed or not
    %----------------------------------------------------------------------
    if exist(GTKWavePath,'dir')~=7 || ...
       exist([GTKWavePath '\bin\gtkwave.exe'],'file')~=2
       msgbox(sprintf('GTKWave is not installed.\nPlease install it on "c:\GTKWave" path.'),'GTKWave Error','error','modal');
       return;
    end
    if exist([GTKWavePath '\AutoSigAddn.tcl'],'file')~=2
       msgbox(sprinf('Supporting tcl file not exist.\nPlease install GTKWave properly'),'GTKWave Error','error','modal');
       return;
    end
    if exist([GTKWavePath '\MenuConfg.gtkwaverc'],'file')~=2
       msgbox(sprinf('Supporting rc file not exist.\nPlease install GTKWave properly'),'GTKWave Error','error','modal');
       return;
    end
    
    
    Wbh = waitbar(0.5,'Collecting the simulation data','WindowStyle','modal');
   
    %----------------------------------------------------------------------
    % Set the name of VCD file with full path
    %----------------------------------------------------------------------
    VCDFileName = [VcdFile '.vcd'];
    
    if exist(VCDFileName,'file')~=2 
        error('[GTKWave] VCD file not created.');
    end
    
    %----------------------------------------------------------------------
    % Assemble the command to call GTKWave
    %----------------------------------------------------------------------
    waitbar(1,Wbh,'Generaring runnables');
     
    GTKWaveCmd = ['"' GTKWavePath '\bin\gtkwave.exe' '"'];
    TCLFile    = ['"' GTKWavePath '\AutoSigAddn.tcl' '"'];
    MenuFile   = ['"' GTKWavePath '\MenuConfg.gtkwaverc' '"'];
    VCDFile    = ['"' VCDFileName '"'];
    Cmd = [GTKWaveCmd ' -o ' ' -S ' TCLFile ' -r ' MenuFile ' ' VCDFile];
    
    %----------------------------------------------------------------------
    % Create batch file & run the GTKWave through batch file 
    % ADVANTAGE - GTKWave closes command window after exiting.
    %----------------------------------------------------------------------
    BatFileName = [fileparts(VCDFileName) '\' 'RunGTKWave.bat'];
    BatFileh = fopen(BatFileName,'w');
    
    if(BatFileh == -1)
        msgbox('Unable to create runnable batch file.','GTKWave Error','error','modal');
        close(Wbh);
        return;
    end

    fprintf(BatFileh,'%s',Cmd);
    fclose(BatFileh);
    
    winopen(BatFileName);
    
    close(Wbh);
      
end

Contact us