1,32d0
< %
< %   cppsimview: a waveform viewer written in MATLAB code
< %   by Michael Perrott for viewing CppSim/Cppsim output
< %   Distribution:  http://www.cppsim.com
< %
< %   To use this code in Matlab, simply run Matlab (version 7
< %   or greater) and then type:
< %   cd location_of_this_directory
< %   mex loadsig_cppsim.c
< %   mex min_max_decimate.c
< %   addpath('location_of_this_program')
< %   cppsimview
< %
< %   For those that use this code - please
< %   keep my name attached to it (as currently done).  
< %
< % This program is free software; you can redistribute it and/or modify
< % it under the terms of the GNU General Public License as published by
< % the free Software Foundation; either version 2 of the License, or
< % (at your option) any later version.
< %
< % This program is distributed in the hope that it will be useful,
< % but WITHOUT ANY WARRANTY; without even the implied warranty of
< % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
< % GNU General Public License for more details.
< %
< % You should have received a copy of the GNU Library General Public
< % License along with this library; if not, write to the MxFree
< % Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
< %
< 
< 
43c11
< %      varargin to CppsimView_OpeningFcn.  This calling syntax produces a
---
> %      varargin to CppSimView_OpeningFcn.  This calling syntax produces a
55c23
< % Edit the above text to modify the response to help CppsimView
---
> % Edit the above text to modify the response to help CppSimView
57c25
< % Last Modified by GUIDE v2.5 28-Jul-2005 17:31:24
---
> % Last Modified by GUIDE v2.5 23-Jul-2009 12:16:11
63,64c31,32
<                    'gui_OpeningFcn', @CppsimView_OpeningFcn, ...
<                    'gui_OutputFcn',  @CppsimView_OutputFcn, ...
---
>                    'gui_OpeningFcn', @CppSimView_OpeningFcn, ...
>                    'gui_OutputFcn',  @CppSimView_OutputFcn, ...
79,80c47,48
< % --- Executes just before CppsimView is made visible.
< function CppsimView_OpeningFcn(hObject, eventdata, handles, varargin)
---
> % --- Executes just before CppSimView is made visible.
> function CppSimView_OpeningFcn(hObject, eventdata, handles, varargin)
88c56
< % Choose default command line output for CppsimView
---
> % Choose default command line output for CppSimView
90c58
< rehash toolboxcache;
---
> % rehash toolboxcache;
94c62
<         set(fig,'Name','CppsimView');
---
>         set(fig,'Name','CppSimView');
100,101c68,69
<     mssg = sprintf('Error:  UNIX environment variable CPPSIMHOME is undefined!\n  -> you must fix this before CppsimView will run\n');
<     uiwait(msgbox(mssg,'Error trying to locate Cppsim home directory','modal'));
---
>     mssg = sprintf('Error:  UNIX environment variable CPPSIMHOME is undefined!\n  -> you must fix this before CppSimView will run\n');
>     uiwait(msgbox(mssg,'Error trying to locate CppSim home directory','modal'));
103a72,74
> cppsim_home_var = strrep(cppsim_home_var,'\','/'); 
> cppsim_home_var = strrep(cppsim_home_var,'C:','c:'); 
> cppsim_home_var = strrep(cppsim_home_var,' ',''); 
106,107c77,78
<     mssg = sprintf('Error:  UNIX environment variable CPPSIMHOME points to an invalid directory %s\n  -> you must fix this before CppsimView will run',cppsim_home_dir);
<     uiwait(msgbox(mssg,'Error trying to locate Cppsim home directory','modal'));
---
>     mssg = sprintf('Error:  UNIX environment variable CPPSIMHOME points to an invalid directory %s\n  -> you must fix this before CppSimView will run',cppsim_home_var);
>     uiwait(msgbox(mssg,'Error trying to locate CppSim home directory','modal'));
111a83,87
> current_home_string = sprintf('--- CppSimHome: %s ---',handles.home);
> set(handles.change_cppsim_home,'Label',current_home_string);
> 
> netlist = sprintf('%s/Netlist/netlist.cppsim',handles.home);
> 
116,117c92,93
<     mssg = sprintf('Error:  UNIX environment variable CPPSIMSHAREDHOME is undefined!\n  -> you must fix this before CppsimView will run\n');
<     uiwait(msgbox(mssg,'Error trying to locate CppsimShared home directory','modal'));
---
>     mssg = sprintf('Error:  UNIX environment variable CPPSIMSHAREDHOME is undefined!\n  -> you must fix this before CppSimView will run\n');
>     uiwait(msgbox(mssg,'Error trying to locate CppSimShared home directory','modal'));
119a96,98
> cppsimshared_home_var = strrep(cppsimshared_home_var,'\','/'); 
> cppsimshared_home_var = strrep(cppsimshared_home_var,'C:','c:'); 
> cppsimshared_home_var = strrep(cppsimshared_home_var,' ',''); 
122,123c101,102
<     mssg = sprintf('Error:  UNIX environment variable CPPSIMSHAREDHOME points to an invalid directory %s\n  -> you must fix this before CppsimView will run',cppsim_home_dir);
<     uiwait(msgbox(mssg,'Error trying to locate CppsimShared home directory','modal'));
---
>     mssg = sprintf('Error:  UNIX environment variable CPPSIMSHAREDHOME points to an invalid directory %s\n  -> you must fix this before CppSimView will run',cppsimshared_home_var);
>     uiwait(msgbox(mssg,'Error trying to locate CppSimShared home directory','modal'));
127c106,107
< handles.root_dir = cppsimshared_home_var;
---
> %disp(cppsimshared_home_var)
> %pause(3)
128a109
> handles.root_dir=cppsimshared_home_var;   
130,131c111,116
< %netlist = sprintf('%s/Netlist/netlist.cppsim',handles.home);
< 
---
> os_var = getenv('OS');
> if length(os_var) == 0
>    handles.operating_system = 'Linux';
> else
>    handles.operating_system = 'Windows';
> end
139c124,131
<         plot_fig_filename = sprintf('%s/MatlabGui/CppsimView/cppsimview_plot.fig',handles.root_dir);
---
>         plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %%     set(handles.listbox_shared,'String',plot_fig_filename);
> %%     set(handles.listbox_shared,'Value',1);
> %%     set(handles.edit_plot_entry,'Enable','off'); 
> %%     pause(5);
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
148c140
<         set(fHandle,'Name','Plot for CppsimView');
---
>         set(fHandle,'Name','Plot for CppSimView');
186,187d177
< set(handles.pushbutton_edit_test_par,'String','Edit Sim File');
< 
192,194d181
< handles.copy_sim_file_name = [];
< handles.paste_sim_file_name = [];
< handles.copy_sim_file_name_candidate = [];
241a229,230
> handles.plot_functions = strvcat(handles.plot_functions,'plot_psd(x,''nodes'',''logxy'')');
> handles.plot_functions = strvcat(handles.plot_functions,'plot_psd_db(x,''nodes'',''logx'')');
255c244
<     plotsig_vpp(x,'nodes');
---
>     plotsig(x,'nodes');
265,266c254,255
<     eyesig_vpp(x,1,0,'nodes');
<     eyesig_vpp_gmsk(x,1,0,'nodes');
---
>     eyesig(x,1,0,'nodes');
>     eyesig_gmsk(x,1,0,'nodes');
268a258,259
>     plot_psd(x,'nodes','logxy');
>     plot_psd_db(x,'nodes','logx');
272a264,265
>     x = loadsig('file');
>     x = loadsig_modified('file');
286c279
< % UIWAIT makes CppsimView wait for user response (see UIRESUME)
---
> % UIWAIT makes CppSimView wait for user response (see UIRESUME)
291c284
< function varargout = CppsimView_OutputFcn(hObject, eventdata, handles)
---
> function varargout = CppSimView_OutputFcn(hObject, eventdata, handles)
326a320,323
> global min_x_global max_x_global
> 
> prev_min_x = min_x_global;
> prev_max_x = max_x_global;
351,380c348
<   if strcmp(name,'New Sim File') == 1
<          set(handles.radio_test,'ForegroundColor','red');
<          set(handles.pushbutton_edit_test_par,'String','Create Sim File');  
<          set(handles.edit_plot_entry,'Enable','on'); 
<          set(handles.edit_plot_entry,'BackgroundColor',[1.0,1.0,1.0]);
< 
<          i = 1;
<          while 1
<             if i == 1
<                new_sim_file_name = sprintf('test.par');
<             else
<                new_sim_file_name = sprintf('test%d.par',i);
<             end
<             i = i + 1;
<             flag = 0;
<             for j = 1:length(name_cell)
<                if strcmp(name_cell{j},new_sim_file_name) == 1
<                   flag = 1;
<                   break;
<                end
<             end
<             if flag == 1
<                continue;
<             else
<                set(handles.edit_plot_entry,'String',new_sim_file_name);
<                handles.new_sim_file_name = new_sim_file_name;
<                break;
<             end
<      end
<   else
---
> 
382d349
<       set(handles.pushbutton_edit_test_par,'String','Edit Sim File');
386,387d352
<       handles.copy_sim_file_name_candidate = sprintf('%s/%s',handles.cur_dir,name);
<   end
389,394c354
<   guidata(hObject, handles);
<   if strcmp(get(handles.figure1,'SelectionType'),'open')
<      if strcmp(name,'New Sim File') == 0
<         pushbutton_edit_test_par_Callback(hObject, eventdata, handles);
<      end
<   end
---
>     guidata(hObject, handles);
444,445c404,409
<        cur_node = node_cell_list{index_selected};
< 
---
>        if (strcmp(node_cell_list{1},'FREQUENCY') == 1)
>            cur_node = sprintf('abs(%s)',node_cell_list{index_selected});
>        else
>            cur_node = node_cell_list{index_selected};
>        end
>    
446a411
> 
448a414
> 
455a422,426
>            if (strncmp(prev_plot_string,'plot_psd',8) == 1 || ...
>                strncmp(prev_plot_string,'plotsig',7) == 1)
>                j = j(1:2);
>            end
> 
476a448
> 
479a452
> 
484a458,462
>              if (strncmp(prev_plot_string,'plot_psd',8) == 1 || ...
>                  strncmp(prev_plot_string,'plotsig',7) == 1)
>                   i = i(1:2);
>              end
> 
485a464
> 
494a474
> 
499a480,483
>              if (strncmp(prev_plot_string,'plot_psd',8) == 1 || ...
>                  strncmp(prev_plot_string,'plotsig',7) == 1)
>                   i = i(1:2);
>              end
501a486
> 
506a492
> 
532a519
> 
545c532
<               plot_fig_filename = sprintf('%s/MatlabGui/CppsimView/cppsimview_plot.fig',handles.root_dir);
---
>               plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
554c541
<               set(fHandle,'Name','Plot for CppsimView');
---
>               set(fHandle,'Name','Plot for CppSimView');
574a562,563
>           global error_box_flag
>           error_box_flag = 0;
582a572,576
>           elseif error_box_flag == 0
>              command_string = get(handles.pushbutton_plot,'String');
>              if strcmp(command_string,'Reset Node List') == 1
>                 deci_plot(prev_min_x,prev_max_x,4);
>              end
663,665d656
< elseif handles.shared_listbox_flag == 5 %% hierarchy functions
< 
<     set(handles.edit_plot_entry,'String',name);
687,688c678
< filename = sprintf('%s/CppsimView_history.mat',handles.cur_dir);
< save(filename,'history');
---
> save CppSimView_history.mat history;
691c681
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
698c688
< %#function plotsig_vpp, plot_xy, plot_fft, plot_fft_mag,plot_fft_db, plot_fft_db_mag, plot_fft_logx, plot_fft_logx_mag, plot_fft_db_logx, plot_fft_db_logx_mag, eyesig_vpp, eyesig_vpp_gmsk, scatter_eye_gmsk, plot_pll_phasenoise, plot_pll_mod_spectrum, plot_pll_jitter, plot_pll_jitter_vs_time, loadsig_cppsim, mult, div, xzoom, close_req_function
---
> %#function plotsig, plot_xy, plot_fft, plot_fft_mag,plot_fft_db, plot_fft_db_mag, plot_fft_logx, plot_fft_logx_mag, plot_fft_db_logx, plot_fft_db_logx_mag, eyesig, eyesig_gmsk, scatter_eye_gmsk, plot_pll_phasenoise, plot_psd, plot_psd_db, plot_pll_mod_spectrum, plot_pll_jitter, plot_pll_jitter_vs_time, loadsig_cppsim, loadsig, loadsig_modified, mult, div, xzoom, close_req_function
786a777,813
>    if (strcmp(func,'plotsig') == 1)
>        if (i == 3)
>           if (strcmp(char(arg(3)),'logx') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'logy') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'logxy') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'loglog') == 1)
>              continue;
>           end
>        end
>    elseif (strcmp(func,'plot_psd') == 1)
>        if (i == 3)
>           if (strcmp(char(arg(3)),'logx') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'logy') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'logxy') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'loglog') == 1)
>              continue;
>           end
>        end
>    elseif (strcmp(func,'plot_psd_db') == 1)
>        if (i == 3)
>           if (strcmp(char(arg(3)),'logx') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'logy') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'logxy') == 1)
>              continue;
>           elseif (strcmp(char(arg(3)),'loglog') == 1)
>              continue;
>           end
>        end
>    end
797,798c824
< func=regexprep(func,'plotsig','plotsig_vpp');
< func=regexprep(func,'eyesig','eyesig_vpp');
---
> 
817,818c843
< 
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
820a846,847
> global plot_string_global
> 
851a879
> plot_string_global = new_plot_string;
853c881
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
871c899
<         plot_fig_filename = sprintf('%s/MatlabGui/CppsimView/cppsimview_plot.fig',handles.root_dir);
---
>         plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
880c908
<         set(fHandle,'Name','Plot for CppsimView');
---
>         set(fHandle,'Name','Plot for CppSimView');
908,913c936,982
< % zip
< temp_text = sprintf('%s/Netlist/netlist.cppsim',handles.home);
< [cell,library] = get_current_cell_name(temp_text);
< library_cellname = strcat(library,'/',cell);
< if length(library) == 0
<     disp('--> error:  cannot determine current cellview ...');
---
> 
> temp_text = sprintf('%s/Sue2/current_cell.cppsimview',handles.home);
> if exist(temp_text) ~= 0
>    file_info = dir(temp_text);
>    sue2_date = datenum(file_info.date);
> else
>    sue2_date = -1;
> end
> 
> netlist_text = sprintf('%s/Netlist/netlist.cppsim',handles.home);
> if exist(netlist_text) ~= 0
>    file_info = dir(netlist_text);
>    netlist_date = datenum(file_info.date);
> else
>    netlist_text = sprintf('%s/Netlist/netlist.vppsim',handles.home);
>    if exist(netlist_text) ~= 0
>       file_info = dir(netlist_text);
>       netlist_date = datenum(file_info.date);
>    else
>       netlist_date = -1;
>    end
> end
> 
> if (sue2_date > netlist_date)
>    temp_text = sprintf('%s/Sue2/current_cell.cppsimview',handles.home);
>    library_cellname = get_output_message(temp_text);
>    if length(library_cellname) == 0
>       disp('error:  no current_cell.cppsimview file from Sue2 - use Plan B ...');
>       library_cellname = most_recent_saved_sue_file(handles.home);
>    else
>       i = strfind(library_cellname,'SueLib');
>       if i < 1
>         disp('error:  current_cell.cppsimview file from Sue2 is corrupted - use Plan B ...');
>         library_cellname = most_recent_saved_sue_file(handles.home);
>       else
>         library_cellname = library_cellname(i+7:length(library_cellname));
>       end
>    end
> else
>    % zip
> %   temp_text = sprintf('%s/Netlist/netlist.cppsim',handles.home);
>    temp_text = netlist_text;
>    [cell,library] = get_current_cell_name(temp_text);
>    library_cellname = strcat(library,'/',cell);
>    if length(library) == 0
>        disp('--> error:  cannot determine current cellview ...');
>    end
928,930c997,1005
< %     cd(base_dir);
<      run_program = sprintf('mkdir %s/%s',base_dir,library_name);
<      [status] = unix(run_program);
---
>      cd(base_dir);
>      if strcmp(handles.operating_system,'Linux') == 1
>         run_program = sprintf('mkdir %s',library_name);
>         [status] = unix(run_program);
>      else
>         run_program = sprintf('%s/Msys/bin/mkdir %s',handles.root_dir,library_name);
>         [status] = dos(run_program);
>      end
> 
933,935c1008,1016
< %     cd(library_dir);
<      run_program = sprintf('mkdir %s/%s/%s',base_dir,library_name,cell_name);
<      [status] = unix(run_program);
---
>      cd(library_dir);
>      if strcmp(handles.operating_system,'Linux') == 1
>         run_program = sprintf('mkdir %s',cell_name);
>         [status] = unix(run_program);
>      else
>         run_program = sprintf('%s/Msys/bin/mkdir %s',handles.root_dir,cell_name);
>         [status] = dos(run_program);
>      end
> 
939c1020
< %   cd(cur_dir);
---
>    cd(cur_dir);
945,946d1025
<    set(handles.pushbutton_edit_test_par,'String','Edit Sim File');
< 
951,953d1029
< %   handles.copy_sim_file_name = [];
<    handles.paste_sim_file_name = [];
<    handles.copy_sim_file_name_candidate = [];
972,973c1048,1049
<    filename = sprintf('%s/CppsimView_history.mat',handles.cur_dir);
<    fid = fopen(filename,'r');
---
> 
>    fid = fopen('CppSimView_history.mat','r');
978c1054
<           history_root = load(filename);
---
>           history_root = load('CppSimView_history.mat');
1039a1116,1117
>       handles.plot_functions = strvcat(handles.plot_functions,'plot_psd(x,''nodes'',''logxy'')');
>       handles.plot_functions = strvcat(handles.plot_functions,'plot_psd_db(x,''nodes'',''logx'')');
1053c1131
< new_name = sprintf('Plot for CppsimView --- Library: %s, Cell: %s', library_name,cell_name);
---
> new_name = sprintf('Plot for CppSimView --- Library: %s, Cell: %s', library_name,cell_name);
1057c1135
< new_name = sprintf('CppsimView --- Library: %s, Cell: %s', library_name,cell_name);
---
> new_name = sprintf('CppSimView --- Library: %s, Cell: %s', library_name,cell_name);
1068,1071c1146,1150
< %%%%% this is now used for 'Reload'
< % --- Executes on button press in pushbutton_run_cppsim.
< function pushbutton_run_cppsim_Callback(hObject, eventdata, handles)
< % hObject    handle to pushbutton_run_cppsim (see GCBO)
---
> 
> 
> % --- Executes on button press in pushbutton_load_signals.
> function pushbutton_load_signals_Callback(hObject, eventdata, handles)
> % hObject    handle to pushbutton_load_signals (see GCBO)
1083a1163,1167
> 
> command_string = get(handles.pushbutton_plot,'String');
> if strcmp(command_string,'Reset Node List') == 1
>    set(handles.pushbutton_plot,'String','Plot');
> end
1088a1173
> 
1116,1118c1201,1203
< % --- Executes on button press in pushbutton_edit_modules.
< function pushbutton_edit_modules_Callback(hObject, eventdata, handles)
< % hObject    handle to pushbutton_edit_modules (see GCBO)
---
> % --- Executes on button press in create_matlab_code
> function pushbutton_create_matlab_code_Callback(hObject, eventdata, handles)
> % hObject    handle to create_matlab_code (see GCBO)
1120a1206
>  error_box('Auto-creation of Matlab code will be supported in an upcoming release.','Warning:  Currently Unsupported Feature');
1122,1128d1207
< %% zip
< if get(handles.radio_hierarchy,'Value') ~= 1
<        error_box('You must first select hierarchy edit radio button and choose a module.','Error:  Need to select hierarchy radio button');
< else
<    index_selected = get(handles.listbox_shared,'Value');
<    name_list = get(handles.listbox_shared,'String');
<    name_cell = cellstr(name_list);
1130d1208
<    cur_module_entry = name_cell{index_selected};
1132,1142d1209
<    [t,r] = strtok(cur_module_entry);
<    if (strcmp(t,':') == 1)
<        error_box('You need to select a module line that does not begin with :.','Error:  Need to select module');
<    else
<        [module_name,r] = strtok(r);
<        [lib_name,r] = strtok(r);
<        if lib_name(1) == '-'
<           lib_name = strtok(lib_name,'-');
<        else
<           lib_name = '';
<        end
1143a1211,1215
> % --- Executes on button press in pushbutton_load_and_replot.
> function pushbutton_load_and_replot_Callback(hObject, eventdata, handles)
> % hObject    handle to pushbutton_load_and_replot (see GCBO)
> % eventdata  reserved - to be defined in a future version of MATLAB
> % handles    structure with handles and user data (see GUIDATA)
1145,1151d1216
<        netlist_filename = sprintf('%s/Netlist/netlist.cppsim',handles.home);
<        filename = get_current_module_filename(netlist_filename,module_name,lib_name);
<        if t(1) == 'v'
<           filename = strcat(filename,'/verilog/',module_name,'.v');
<        else
<           filename = strcat(filename,'/cppsim/','text.txt');
<        end
1153,1156c1218,1222
<        editor = getenv('EDITOR');
<        if (length(editor) == 0)
<           editor = 'emacs';
<        end
---
> global background_color;
> global message_lock_flag plot_linewidth;
> global x_sig
> global min_x_global max_x_global number_of_samples_global
> global plot_axes_handle cur_marker_saved cur_marker
1158,1162c1224,1226
<        temp_text = sprintf('%s %s &',editor,filename);
< %       temp_text = sprintf('c:/cppsim/cppsimshared/matlabgui/emacs-21.3/bin/%s %s &',editor,char(filename));
<        [status] = unix(temp_text);
<    end
< end
---
> prev_min_x = min_x_global;
> prev_max_x = max_x_global;
> prev_number_of_samples = number_of_samples_global;
1163a1228,1230
>   if message_lock_flag ~= 0
>      return
>   end
1165a1233
>   handles.reload_nodes_flag = 1;
1167,1171c1235,1239
< % --- Executes on button press in pushbutton_edit_test_par.
< function pushbutton_edit_test_par_Callback(hObject, eventdata, handles)
< % hObject    handle to pushbutton_edit_test_par (see GCBO)
< % eventdata  reserved - to be defined in a future version of MATLAB
< % handles    structure with handles and user data (see GUIDATA)
---
>   command_string = get(handles.pushbutton_plot,'String');
>   if strcmp(command_string,'Plot') == 1
>      set(handles.pushbutton_plot,'String','Reset Node List');
>   end
>   guidata(hObject, handles);
1173c1241
< new_sim_file_name = [];
---
>   radio_nodes_Callback(hObject, eventdata, handles);
1175,1181c1243,1248
< emacs_flag = 1;
< if strcmp(get(handles.radio_test,'String'),'New Sim File') == 1
<     if length(handles.new_sim_file_name) == 0
<        new_sim_file_name = get(handles.edit_plot_entry,'String');
<     else
<        new_sim_file_name = handles.new_sim_file_name;
<     end
---
>   if message_lock_flag == 1
>      return
>   end
>   if get(handles.radio_nodes,'Value') ~= 1
>      return
>   end
1183,1191c1250,1256
<     i = strfind(new_sim_file_name,'.par');
<     flag = 0;
<     if i > 0
<        if i+3 ~= length(new_sim_file_name)
<           flag = 1;
<        end
<     else
<        flag = 1;
<     end
---
>    if strcmp(background_color,'yellow') == 1
>       set(handles.listbox_shared,'BackgroundColor','cyan');
>    else
>       set(handles.listbox_shared,'BackgroundColor','yellow');
>    end
>    set(handles.edit_plot_entry,'Enable','off'); 
>    pause(0.1);
1193,1203c1258,1264
<     if flag == 1
<         radio_messages_Callback(hObject, eventdata, handles);
<         result_string = sprintf('Error:  Sim File must end in .par');
<         set(handles.listbox_shared,'String',result_string);
<         set(handles.listbox_shared,'Value',length(cellstr(result_string)));
<         handles.cur_message = result_string;
<         guidata(hObject, handles);
<         return;
<     else
<         handles.new_sim_file_name = [];
<     end
---
>    all_figures = get(0,'Children');
>    if length(all_figures) == 1
>         plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
>         handles.fighandle = openfig(plot_fig_filename,'new');
>         plot_fig_handles = guihandles(handles.fighandle);
>         fHandle = plot_fig_handles.figure1;
>         aHandle = plot_fig_handles.axes1;
1205,1209c1266,1273
<     full_filename = sprintf('%s/%s',handles.cur_dir,new_sim_file_name);
<     fid = fopen(full_filename,'w');
<     if fid == -1
<        return;
<     end
---
>         set(fHandle,'Visible','on');
>         set(fHandle,'HandleVisibility','on');
>         set(fHandle,'IntegerHandle','off');
>         set(fHandle,'Name','Plot for CppSimView');
>         set(fHandle,'NumberTitle','off');
>         plot_axes_handle = aHandle;        
>         handles.plot_handle = fHandle;        
>    end
1211,1252c1275,1280
<     home = char(handles.home);
<     cur_dir = char(handles.cur_dir);
<     temp_index = strfind(cur_dir,'SimRuns');
<     base_names = cur_dir(temp_index+8:length(cur_dir));
<     [library_name,r] = strtok(base_names,'/');
<     cell_name = r(2:length(r));
< 
<     fprintf(fid,'/////////////////////////////////////////////////////////////\n');
<     fprintf(fid,'// Cppsim Sim File: %s\n',new_sim_file_name);
<     fprintf(fid,'// Cell: %s\n',cell_name);
<     fprintf(fid,'// Library: %s\n',library_name);
<     fprintf(fid,'/////////////////////////////////////////////////////////////\n\n');
<     fprintf(fid,'// Simulator options:  cppsim, ncverilog, verilog\n');
<     fprintf(fid,'simulator: cppsim\n\n');
<     fprintf(fid,'// VCD file is optional and only generated for verilog\n');
<     fprintf(fid,'vcd: out.vcd\n\n');
<     fprintf(fid,'// Number of simulation time steps\n');
<     fprintf(fid,'// Example: num_sim_steps: 10e3\n');
<     fprintf(fid,'num_sim_steps: \n\n');
<     fprintf(fid,'// Time step of simulator (in seconds)\n');
<     fprintf(fid,'// Example: Ts: 1/10e9\n');
<     fprintf(fid,'Ts: \n\n');
<     [name_base,r] = strtok(new_sim_file_name,'.');
<     fprintf(fid,'// Output File name\n');
<     fprintf(fid,'// Example:  name below produces %s.tr0, %s.tr1, ...\n',name_base,name_base);
<     fprintf(fid,'// Note: you can decimate, start saving at a given time offset, etc.\n');
<     fprintf(fid,'//    -> See pages 34-35 of CppSim manual (i.e., output: section)\n');
<     fprintf(fid,'output: %s\n\n',name_base);
<     fprintf(fid,'// Nodes to be included in Output File\n');
<     fprintf(fid,'// Example: probe: n0 n1 xi12.n3 xi14.xi12.n0\n');
<     fprintf(fid,'probe: \n\n');
<     fprintf(fid,'/////////////////////////////////////////////////////////////\n');
<     fprintf(fid,'// Note:  Items below can be kept blank if desired\n');
<     fprintf(fid,'/////////////////////////////////////////////////////////////\n\n');
<     fprintf(fid,'// Values for global parameters used in schematic\n');
<     fprintf(fid,'// Example: global_param: in_gl=92.1 delta_gl=0.0 step_time_gl=100e3*Ts\n');
<     fprintf(fid,'global_param: \n\n');
< 
<     fprintf(fid,'// Rerun simulation with different global parameter values\n');
<     fprintf(fid,'// Example: alter: in_gl = 90:2:98\n');
<     fprintf(fid,'// See pages 37-38 of CppSim manual (i.e., alter: section)\n');
<     fprintf(fid,'alter: \n');
---
>    %%%%%%%%%%%%% plot setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>    set(handles.fighandle,'Color',[0.0 0.0 0.0]);
>    fig_handles = guihandles(handles.fighandle);
>    color_order = [1 1 0; 1 0 1; 0 1 1; 1 0 0; 0 1 0; 0 0 1; .75 .75 .75];
>    set(fig_handles.figure1,'DefaultAxesColorOrder',color_order);
>    guidata(handles.fighandle,fig_handles);
1254,1257c1282,1287
<     fclose(fid);
< else
<    new_sim_file_name = get(handles.radio_test,'String');
< end
---
>    set(plot_axes_handle,'Color',[0.0 0.0 0.0]);
>    set(plot_axes_handle,'XColor',[1.0 1.0 1.0]);
>    set(plot_axes_handle,'YColor',[1.0 1.0 1.0]);
>    set(plot_axes_handle,'LineWidth',1.5);
>    axes(plot_axes_handle);
>    guidata(hObject,handles);
1259,1264c1289
< if strcmp(get(handles.radio_test,'String'),'No Sim File') ~= 1
<    if emacs_flag == 1
<        editor = getenv('EDITOR');
<        if (length(editor) == 0)
<           editor = 'emacs';
<        end
---
>    plot_string = char(get(handles.edit_plot_entry,'String'));
1266,1269c1291,1295
<        temp_text = sprintf('%s %s/%s &',editor,handles.cur_dir,new_sim_file_name);
< %       temp_text = sprintf('c:/cppsim/cppsimshared/matlabgui/emacs-21.3/bin/%s %s/%s &',editor,handles.cur_dir,new_sim_file_name);
<        [status] = unix(temp_text);
<    end
---
>    if length(x_sig) > 0 & length(plot_string) > 0 
>       plot_string = clean_up_plot_string(plot_string);
>       global error_box_flag
>       error_box_flag = 0;
>       out = eval_plot_string(plot_string);
1271c1297,1309
<    radio_test_Callback(hObject, eventdata, handles);
---
>       if out == -1
>           radio_messages_Callback(hObject, eventdata, handles);
>           result_string = sprintf('Error:  %s',lasterr);
>           set(handles.listbox_shared,'String',result_string);
>           set(handles.listbox_shared,'Value',length(cellstr(result_string)));
>           handles.cur_message = result_string;
>       elseif error_box_flag == 0
>           if prev_number_of_samples == number_of_samples_global
>              deci_plot(prev_min_x,prev_max_x,4);
>              plot_axes_handle = gca;
>           end
>       end
>       flag_update = 1;
1273,1284c1311,1313
<    name_list = get(handles.listbox_shared,'String');
<    name_cell = cellstr(name_list);
<    for i = 1:length(name_cell)
<       if strcmp(name_cell{i},new_sim_file_name) == 1
<           set(handles.listbox_shared,'Value',i);
<           handles.listbox_test_index = i;
<           handles.old_num_test_files = length(name_cell);
<           set(handles.radio_test,'String',new_sim_file_name);
<           set(handles.edit_plot_entry,'Enable','off'); 
<           set(handles.edit_plot_entry,'BackgroundColor',[0.831,0.816,0.784]);
<           set(handles.edit_plot_entry,'String','');
<           break;
---
>       global xzoom_flag
>       if xzoom_flag == 1
>          out = eval('xzoom','-1');
1286d1314
<    end
1288c1316,1320
<    % Update handles structure
---
>    end
>    figure(handles.fighandle);
>    plot_axes_handle = gca;
>    set(handles.listbox_shared,'BackgroundColor',background_color);
>    set(handles.edit_plot_entry,'Enable','on'); 
1291c1323,1344
< end
---
>    cur_marker = cur_marker_saved;
>     ax_list = get(gcf,'Children');
>     for i = 1:length(ax_list)
>         if strcmp(get(ax_list(i),'Type'),'axes') == 1
>            if strcmp(get(ax_list(i),'YAxisLocation'),'left') == 1 & ...
>               strcmp(get(ax_list(i),'Tag'),'legend') == 0
>               hli=get(ax_list(i),'Children'); % get the handle of lines in axis
>             
>                for i=1:length(hli)
>                   if strcmp(cur_marker,'o') == 1
>                       set(hli(i),'Marker','o');
>                   else
>                       set(hli(i),'Marker','none');
>                   end
>               end
>            end
>         end
>     end
> 
> 
> % zippy
> 
1334c1387
<         plot_fig_filename = sprintf('%s/MatlabGui/CppsimView/cppsimview_plot.fig',handles.root_dir);
---
>         plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
1343c1396
<         set(fHandle,'Name','Plot for CppsimView');
---
>         set(fHandle,'Name','Plot for CppSimView');
1366a1420
> 
1369c1423
<       if out == -1
---
>       if out == -1 
1387c1441,1443
<    set(handles.edit_plot_entry,'Enable','on'); 
---
>    set(handles.edit_plot_entry,'Enable','on');
> 
>    set(handles.pushbutton_plot,'String','Reset Node List');
1461,1462c1517
<    filename = sprintf('%s/CppsimView_history.mat',handles.cur_dir);
<    save(filename,'history');
---
>    save CppSimView_history.mat history;
1468c1523
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1548c1603
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1628c1683
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1649c1704
<   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_nodes,handles.radio_messages,handles.radio_hierarchy];
---
>   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_nodes,handles.radio_messages];
1699c1754
<   off = [handles.radio_test_tr0,handles.radio_nodes,handles.radio_plot_function,handles.radio_messages,handles.radio_hierarchy];
---
>   off = [handles.radio_test_tr0,handles.radio_nodes,handles.radio_plot_function,handles.radio_messages];
1726,1742c1781,1786
<   if strcmp(name,'New Sim File') == 1
<       set(handles.radio_test,'ForegroundColor','red');
<       set(handles.pushbutton_edit_test_par,'String','Create Sim File');  
<       set(handles.edit_plot_entry,'Enable','on'); 
<       set(handles.edit_plot_entry,'BackgroundColor',[1.0,1.0,1.0]);
<       if length(handles.new_sim_file_name) == 0
<          set(handles.edit_plot_entry,'String','test.par');
<       else
<          set(handles.edit_plot_entry,'String',handles.new_sim_file_name);
<       end
<   else
<       set(handles.radio_test,'ForegroundColor','black');
<       set(handles.pushbutton_edit_test_par,'String','Edit Sim File');
<       set(handles.edit_plot_entry,'Enable','off'); 
<       set(handles.edit_plot_entry,'BackgroundColor',[0.831,0.816,0.784]);
<       set(handles.edit_plot_entry,'String','');
<   end
---
> 
>   set(handles.radio_test,'ForegroundColor','black');
>   set(handles.edit_plot_entry,'Enable','off'); 
>   set(handles.edit_plot_entry,'BackgroundColor',[0.831,0.816,0.784]);
>   set(handles.edit_plot_entry,'String','');
> 
1753c1797
<    dir_list = dir(handles.cur_dir);
---
>    dir_list = dir;
1763a1808,1814
>       k = strfind(dir_list(i).name,'.hspc');
>       if k >= 1
>          if length(dir_list(i).name) > k+4
>             continue;
>          end
>          file_list = strvcat(dir_list(i).name,file_list);
>       end
1767,1768d1817
<    file_list = strvcat(file_list,'New Sim File');
< 
1773c1822
<    dir_list = dir(handles.cur_dir);
---
>    dir_list = dir;
1776,1779d1824
<    if strcmp(get(handles.radio_test,'String'),'New Sim File') == 1
<        error_box('You must select (or create and then select) a simulation file before you can choose an associated output file.','Error:  No Simulation File');
<        return;
<    end
1781c1826,1827
<    test_tr0_list_name = sprintf('%s/%s.outfile_list',handles.cur_dir,test_par_name);
---
>    if strcmp(r,'.par') == 1
>       test_tr0_list_name = sprintf('%s.outfile_list',test_par_name);
1783,1795c1829,1853
<    fid = fopen(test_tr0_list_name);
<    if fid == -1
<        error_box('You must run CppSim on the simulation file before you can choose an associated output file.','Error:  Simulation File Needs to be Run');
<        return;      
<    end
<    while 1
<        test_tr0_name = fgetl(fid);
<        if ~ischar(test_tr0_name)
<           break
<        end
<        test_tr0_name = sprintf('%s.tr',test_tr0_name);
<        for i = 1:num_files
<           if strfind(dir_list(i).name,test_tr0_name) >= 1
---
>       fid = fopen(test_tr0_list_name);
>       if fid == -1
>          error_box('You must run CppSim on the simulation file before you can choose an associated output file.','Error:  Simulation File Needs to be Run');
>          return;      
>       end
>       while 1
>          test_tr0_name = fgetl(fid);
>          if ~ischar(test_tr0_name)
>             break
>          end
>          test_tr0_name = sprintf('%s.tr',test_tr0_name);
>          for i = 1:num_files
>             if strfind(dir_list(i).name,test_tr0_name) >= 1
>                file_list = strvcat(dir_list(i).name,file_list);
>             end
>          end
>       end
>       fclose(fid);
>    else
>       for i = 1:num_files
>           k = strfind(dir_list(i).name,'.raw');
>           if k >= 1
>              if length(dir_list(i).name) > k+3
>                  continue;
>              end
1798c1856
<        end
---
>       end
1800,1801d1857
<    fclose(fid);
< 
1820c1876
<   off = [handles.radio_test,handles.radio_nodes,handles.radio_plot_function,handles.radio_messages,handles.radio_hierarchy];
---
>   off = [handles.radio_test,handles.radio_nodes,handles.radio_plot_function,handles.radio_messages];
1887c1943
<       status = check_run_file(handles.home,handles.cur_dir,sim_file);
---
>       status = check_run_file(handles.cur_dir,sim_file,handles);
1918c1974
<   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_plot_function,handles.radio_messages,handles.radio_hierarchy];
---
>   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_plot_function,handles.radio_messages];
1930,1932c1986,2009
<      full_filename = sprintf('%s/%s',handles.cur_dir,test_tr0_filename);
<      dir_struct = dir(full_filename);
<      temp = sprintf('... Loading Nodes:  ---  x = loadsig_cppsim(''%s'');  ---  ... (File Size:  %5.2f MegaBytes)',test_tr0_filename,dir_struct.bytes/1e6);
---
>      dir_struct = dir(test_tr0_filename);
>      
>      global test_tr_file
>      test_tr_file = get(handles.radio_test_tr0,'String');
>      clear x_sig;
>      global x_sig;
>      global switch_to_loadsig_flag;
>      
>      switch_to_loadsig_flag = 0;
>      fid_check = fopen(test_tr_file);
>      if (fid_check ~= -1)
>          line_check = char(fread(fid_check,8));
>          if (strncmp(line_check,'Title: ',7) == 1)
>              switch_to_loadsig_flag = 1;
>          end
>          fclose(fid_check);
>      end
>      
>      if (switch_to_loadsig_flag == 0)
>          temp = sprintf('... Loading Nodes:  ---  x = loadsig_cppsim(''%s'');  ---  ... (File Size:  %5.2f MegaBytes)',test_tr0_filename,dir_struct.bytes/1e6);
>      else
>          temp = sprintf('... Loading Nodes:  ---  x = loadsig(''%s'');  ---  ... (File Size:  %5.2f MegaBytes)',test_tr0_filename,dir_struct.bytes/1e6);     
>      end
>      
1937,1941c2014
< 
<      test_tr_file = get(handles.radio_test_tr0,'String');
<      full_filename = sprintf('%s/%s',handles.cur_dir,test_tr_file);
<      clear x_sig;
<      global x_sig;
---
>      
1943c2016,2020
<           x_sig = loadsig_cppsim(full_filename);
---
>         if (switch_to_loadsig_flag == 0)
>             x_sig = loadsig_cppsim(test_tr_file);
>         else
>             x_sig = loadsig_modified(test_tr_file);
>         end
1945c2022
<           x_sig = -1;
---
>            x_sig = -1;
1947c2024
< 
---
>    
1951c2028,2032
<           result_string = sprintf('Error:  loadsig_cppsim could not open file ''%s''',test_tr_file);
---
>           if (switch_to_loadsig_flag == 0)
>               result_string = sprintf('Error:  loadsig_cppsim could not open file ''%s''',test_tr_file);
>           else
>               result_string = sprintf('Error:  loadsig could not open file ''%s''',test_tr_file);
>           end
2038c2119
< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
---
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2071c2152
<       status = check_run_file(handles.home,handles.cur_dir,sim_file);
---
>       status = check_run_file(handles.cur_dir,sim_file,handles);
2084c2165
<   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_plot_function,handles.radio_messages,handles.radio_nodes,handles.radio_hierarchy];
---
>   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_plot_function,handles.radio_messages,handles.radio_nodes];
2097,2176d2177
< % --- Executes on button press in radio_nodes.
< function radio_hierarchy_Callback(hObject, eventdata, handles)
< % hObject    handle to radio_messages (see GCBO)
< % eventdata  reserved - to be defined in a future version of MATLAB
< % handles    structure with handles and user data (see GUIDATA)
< 
< % Hint: get(hObject,'Value') returns toggle state of radio_nodes
< 
<   global background_color;
<   global message_lock_flag;
<   global prev_message;
< 
<   handles.shared_listbox_flag = 5; 
<   if message_lock_flag == 1
<       set(handles.radio_hierarchy,'Value',1);
<       guidata(hObject, handles);
<       return
<   elseif message_lock_flag == 2
<       handles.reload_nodes_flag = 1;
<       sim_file = get(handles.radio_test,'String');
<       status = check_run_file(handles.home,handles.cur_dir,sim_file);
<       if status == 0
<          message_lock_flag = 0;
<          message_filename = sprintf('%s_message.out',strtok(sim_file,'.'));
<          result = get_output_message(message_filename);
<          handles.cur_message = strvcat(prev_message,result);
<          set(handles.listbox_shared,'BackgroundColor','white');
<          background_color = 'white';
<          guidata(hObject, handles);
<          pause(0.1);
<       end
<   end
< 
<   off = [handles.radio_test,handles.radio_test_tr0,handles.radio_plot_function,handles.radio_messages,handles.radio_nodes,handles.radio_hierarchy];
<   mutual_exclusive(off);
<   set(handles.radio_hierarchy,'Value',1);
< 
<   set(handles.edit_plot_entry,'Enable','off'); 
<   set(handles.edit_plot_entry,'BackgroundColor',[0.831,0.816,0.784]);
<   set(handles.edit_plot_entry,'String','');
< 
<   guidata(hObject, handles);
< 
< home = char(handles.home);
< cur_dir = char(handles.cur_dir);
< parfile = char(get(handles.radio_test,'String'));
< 
< message_filename = sprintf('%s_message.out',strtok(parfile,'.'));
< 
< %run_program = sprintf('%s/bin/net2code -hier_v %s/%s >! %s/%s', handles.root_dir,handles.cur_dir, strtok(parfile,'.'), handles.cur_dir, message_filename);
< run_program = sprintf('%s/bin/net2code -hier_v %s/%s',handles.root_dir,handles.cur_dir, strtok(parfile,'.'));
< [status] = unix(run_program);
< result = get_output_message(message_filename);
< handles.cur_message = result; 
< 
< % radio_messages_Callback(hObject, eventdata, handles);
< 
< message_filename = sprintf('%s/%s.hier_v',handles.cur_dir,strtok(parfile,'.'));
< result = get_output_message(message_filename);
< result_string = result;
< 
< set(handles.listbox_shared,'String',result_string);
< % set(handles.listbox_shared,'Value',length(cellstr(result_string)));
< set(handles.listbox_shared,'Value',1);
< guidata(hObject, handles);
< % zip
< 
< index_selected = get(handles.listbox_shared,'Value');
< name_list = get(handles.listbox_shared,'String');
< name_cell = cellstr(name_list);
< if (index_selected <= length(name_cell))
<    cur_hier_line = name_cell{index_selected};
< else
<    cur_hier_line = 'Error:  click on messages radio button to view';
< end
< set(handles.edit_plot_entry,'Enable','on'); 
< set(handles.edit_plot_entry,'BackgroundColor',[1.0,1.0,1.0]);
< set(handles.edit_plot_entry,'String',cur_hier_line);
< 
< guidata(hObject, handles);
2187c2188
< global x_sig;
---
> global x_sig min_x_global max_x_global;
2189,2197c2190,2193
< if get(handles.radio_test,'Value') == 1
<    if strcmp(get(handles.radio_test,'String'),'New Sim File') == 1
<       handles.new_sim_file_name = char(get(handles.edit_plot_entry,'String'));
<       handles.copy_sim_file_name = [];
<       handles.paste_sim_file_name = [];
<    end
<    guidata(hObject, handles);
< %%   pushbutton_edit_test_par_Callback(hObject, eventdata, handles);
< elseif get(handles.radio_plot_function,'Value') == 1
---
> prev_min_x = min_x_global;
> prev_max_x = max_x_global;
> 
> if get(handles.radio_plot_function,'Value') == 1
2253,2298c2249
<    filename = sprintf('%s/CppsimView_history.mat',handles.cur_dir);
<    save(filename,'history');
< 
< elseif get(handles.radio_hierarchy,'Value') == 1
< 
<    index_selected = get(handles.listbox_shared,'Value');
<    name_list = get(handles.listbox_shared,'String');
<    name_cell = cellstr(name_list);
<    new_hierarchy_name = char(get(handles.edit_plot_entry,'String'));
< 
<    name_cell{index_selected} = new_hierarchy_name;
< 
<    set(handles.listbox_shared,'String',name_cell);
<  
<    guidata(hObject,handles);
< 
<    parfile = char(get(handles.radio_test,'String'));
<  
<    message_filename = sprintf('%s/%s.hier_v',handles.cur_dir,strtok(parfile,'.'));
< 
<    status = send_string_list_to_file(name_cell,message_filename);
< 
<    if (status == 0)
<       mssg = sprintf('Error using send_string_list_file function');
<       uiwait(msgbox(mssg,'Error using send_string_list_file function','modal'));
<       close_req_function;
<       return
<    end
< 
<    message_filename = sprintf('%s_message.out',strtok(parfile,'.'));
< %   run_program = sprintf('%s/bin/net2code -hier_v %s/%s >! %s/%s',handles.root_dir,handles.cur_dir, strtok(parfile,'.'), handles.cur_dir, message_filename);
<    run_program = sprintf('%s/bin/net2code -hier_v %s/%s',handles.root_dir,handles.cur_dir, strtok(parfile,'.'));
<    [status] = unix(run_program);
<    result = get_output_message(message_filename);
<    handles.cur_message = result; 
< 
<    % radio_messages_Callback(hObject, eventdata, handles);
< 
<    message_filename = sprintf('%s/%s.hier_v',handles.cur_dir,strtok(parfile,'.'));
<    result = get_output_message(message_filename);
<    result_string = result;
< 
<    set(handles.listbox_shared,'String',result_string);
<    guidata(hObject,handles);
< 
< %%% zip
---
>    save CppSimView_history.mat history;
2324c2275
<         plot_fig_filename = sprintf('%s/MatlabGui/CppsimView/cppsimview_plot.fig',handles.root_dir);
---
>         plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
2333c2284
<         set(fHandle,'Name','Plot for CppsimView');
---
>         set(fHandle,'Name','Plot for CppSimView');
2358a2310,2311
>       global error_box_flag
>       error_box_flag = 0;
2365a2319,2323
>       elseif error_box_flag == 0
>           command_string = get(handles.pushbutton_plot,'String');
>           if strcmp(command_string,'Reset Node List') == 1
>              deci_plot(prev_min_x,prev_max_x,4);
>           end
2373a2332
> 
2453,2454c2412
<    filename = sprintf('%s/CppsimView_history.mat',handles.cur_dir);
<    save(filename,'history');
---
>    save CppSimView_history.mat history;
2486,2487c2444,2447
< error_box('This operation is not currently supported on UNIX','Error using Save to Clipboard');
< return;
---
> if strcmp(handles.operating_system,'Linux') == 1
>    error_box('This operation is not currently supported on UNIX','Error using Save to Clipboard');
>    return;
> end
2528c2488
<         plot_fig_filename = sprintf('%s/MatlabGui/CppsimView/cppsimview_plot.fig',handles.root_dir);
---
>         plot_fig_filename = sprintf('%s/MatlabGui/cppsimview_plot.fig',handles.root_dir);
2537c2497
<         set(fHandle,'Name','Plot for CppsimView');
---
>         set(fHandle,'Name','Plot for CppSimView');
2588c2548
< function save_to_file_menu_Callback(hObject, eventdata, handles)
---
> function save_to_eps_file_menu_Callback(hObject, eventdata, handles)
2604a2565
> %     ;'*.fig','Matlab (*.fig)'
2606c2567
<      'Save Plot To File',handles.LastPlotFile);
---
>      'Save Plot To .eps File',handles.LastPlotFile);
2619,2620c2580
< suffix = strtok(filename,'.');
< filename = strcat(filename,'.eps');
---
> filename = strtok(filename,'.');
2621a2582
> filename = strcat(filename,'.eps');
2640d2600
< 
2643c2603
< message_string = sprintf('Color EPS file ''%s'' Saved',filename);
---
> message_string = sprintf('Color .eps file ''%s'' Saved',filename);
2645a2606
> 
2652a2614,2673
> % --------------------------------------------------------------------
> function save_to_fig_file_menu_Callback(hObject, eventdata, handles)
> % hObject    handle to save_to_file_menu (see GCBO)
> % eventdata  reserved - to be defined in a future version of MATLAB
> % handles    structure with handles and user data (see GUIDATA)
> 
> global plot_axes_handle xzoom_flag
> 
> all_figures = get(0,'Children');
> if length(all_figures) == 1
>     return
> end
> 
> [filename,pathname] = uiputfile(...
>     {
> %     '*.eps','Color Postscript (*.eps)'
> %     ;'*.epsc','Color Postscript (*.epsc)'
> %     ;'*.pdf','PDF (*.pdf)'
>      ;'*.fig','Matlab (*.fig)'
>     },...
>      'Save Plot To .fig File',handles.LastPlotFile);
> %  set(handles.figure1,'PaperPositionMode','auto');
> %  set(handles.figure1,'InvertHardcopy','off');
> %  orient(handles.figure1,'landscape');
> % print(handles.figure1,'-depsc','figure.eps')
> 
> if filename == 0
>    return
> end
> if length(filename) == 0
>    return
> end
> 
> filename = strtok(filename,'.');
> 
> filename = strcat(filename,'.fig');
> 
> 
> if isequal([filename,pathname],[0,0])
>    return
> else
>    File = fullfile(pathname,filename);
>    handles.LastPlotFile = File;
>    guidata(hObject,handles);
> end
> 
> 
> % fig_handles = guihandles(handles.fighandle);
> % color_order = [0 0 1; 1 0 0; 0 0.5 0; 0 .75 .75; 1 0 1; 0 1 1; .25 .25 .25];
> % set(fig_handles.figure1,'DefaultAxesColorOrder',color_order);
> % guidata(handles.fighandle,fig_handles);
> % axes(plot_axes_handle);
> 
> % deci_plot(1,1,3);
> 
> saveas(handles.fighandle,handles.LastPlotFile,'fig');
> 
> message_string = sprintf('Matlab .fig file ''%s'' Saved',filename);
> mssg_box(message_string,'Save File Confirmation');
> 
2653a2675,2683
> % color_order = [1 1 0; 1 0 1; 0 1 1; 1 0 0; 0 1 0; 0 0 1; .75 .75 .75];
> % set(fig_handles.figure1,'DefaultAxesColorOrder',color_order);
> % guidata(handles.fighandle,fig_handles);
> % axes(plot_axes_handle);
> 
> % deci_plot(1,1,3);
> 
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2659,2662c2689,2691
<      mssg = sprintf('Error: cannot open netlist file %s\n',netlist);
<      uiwait(msgbox(mssg,'Error opening netlist file','modal'));
<      close_req_function;
<      return
---
>    message = sprintf('error: cannot open netlist file %s\n',netlist);
>    display(message);
>    return
2671a2701
> 
2687,2690c2717
<      mssg = sprintf('Error in get_current_module_filename');
<      uiwait(msgbox(mssg,'Error in get_current_module_filename','modal'));
<      close_req_function;
<      return
---
>      display('error in get_current_module_filename');
2696c2723,2727
<         filename = strcat('/',t);
---
> 	if (path(1) == '/')
>            filename = strcat('/',t);
> 	else
> 	   filename = t;
>         end
2697a2729
>         sue2_filename = '';
2699a2732,2734
>            if strcmp(t,'SueLib') == 1
> 	      sue2_filename = filename;
>            end
2702a2738,2740
>            elseif strcmp(t,strcat(mod_name,'.sue')) == 1
>               filename = sprintf('%s/CadenceLib/%s/%s',sue2_filename,lib_name,mod_name);
>               break;
2721,2724c2759,2761
<      mssg = sprintf('Error: cannot open netlist file %s\n',netlist);
<      uiwait(msgbox(mssg,'Error in opening netlist file','modal'));
<      close_req_function;
<      return
---
>    message = sprintf('error: cannot open netlist file %s\n',netlist);
>    display(message);
>    return
2736c2773
< 	     if flag == 0 && strcmp(t,'CppsimShared') == 1
---
> 	     if flag == 0 && strcmp(t,'CppSimShared') == 1
2751c2788
< 	     root_dir_cppsim = strcat(root_dir_cppsim,'/CppsimShared');
---
> 	     root_dir_cppsim = strcat(root_dir_cppsim,'/CppSimShared');
2773,2776c2810,2812
<     mssg = sprintf('Error: cannot open netlist file %s\n -> Please Netlist Your Current Cell and then rerun cppsimview',filename);
<     uiwait(msgbox(mssg,'Error trying to open netlist file','modal'));
<     close_req_function;
<     return
---
>    temp_string = sprintf('error: cannot open netlist file %s\n',filename);
>    disp(temp_string);
>    return
2843c2879
< function status = check_run_file(cppsim_home,sim_dir,sim_file)
---
> function status = check_run_file(sim_dir,sim_file,handles)
2846,2848c2882,2888
< run_command = sprintf('ps -a >! %s/%s_processes.out',sim_dir,...
<               sim_file);
< [status] = unix(run_command);
---
> if strcmp(handles.operating_system,'Linux') == 1
>    run_command = sprintf('ps -a >! %s_processes.out',sim_file);
>    [status] = unix(run_command);
> else
>    run_command = sprintf('%s/Msys/bin/ps -a > %s_processes.out',handles.root_dir,sim_file);
>    [status] = dos(run_command);
> end
2850c2890,2891
< processes = cellstr(get_output_message(sprintf('%s/%s_processes.out',sim_dir,sim_file)));
---
> 
> processes = cellstr(get_output_message(sprintf('%s_processes.out',sim_file)));
2866a2908,2931
> function newest_file = most_recent_saved_sue_file(cppsim_home)
> 
> suelib_dir = sprintf('%s/Sue2/SueLib',cppsim_home);
> d = dir(suelib_dir);
> 
> max_date = 0;
> newest_file = 'none';
> 
> for i = 1:length(d)
>     if d(i).isdir == 1
>         lib_dir = sprintf('%s/Sue2/SueLib/%s',cppsim_home,d(i).name);
>         cur_lib = dir(lib_dir);
>         for j = 1:length(cur_lib)
>            if cur_lib(j).isdir == 0
>               date_metric = convert_date_to_metric(cur_lib(j).date);
>               if date_metric > max_date
>          	 max_date = date_metric;
>                  newest_file = sprintf('%s/%s',char(d(i).name),char(cur_lib(j).name));
>               end
>            end
>         end
>     end
> end
> newest_file = strtok(newest_file,'.');
2922,2926c2987,2994
< if length(strfind(history.radio_test_string,'.par')) == 0 & ...
<    strcmp(history.radio_test_string,'New Sim File') == 0
<      error_box_for_history('History file was corrupted --- starting a new one','History Corrupted');
<      return;
< end
---
> %if length(strfind(history.radio_test_string,'.par')) == 0 & ...
> %   strcmp(history.radio_test_string,'New Sim File') == 0 & ...
> %   strcmp(history.radio_test_string,'Copy Sim File') == 0 & ...
> %   strcmp(history.radio_test_string,'Paste Sim File') == 0 & ...
> %   strcmp(history.radio_test_string,'Delete Sim File') == 0
> %     error_box_for_history('History file was corrupted --- starting a new one','History Corrupted');
> %     return;
> %end
2935a3004,3011
> if length(strfind(history.radio_test_string,'.hspc')) > 0
>    i = strfind(history.radio_test_string,'.hspc');
>    if i+4 ~= length(history.radio_test_string)
>      error_box_for_history('History file was corrupted --- starting a new one','History Corrupted');
>      return;
>    end
> end
> 
2946,2949c3022,3028
< if length(strfind(history.radio_test_tr0_string,'.tr')) == 0 & ...
<    strcmp(history.radio_test_tr0_string,'No Output File') == 0
<     error_box_for_history('History file was corrupted --- starting a new one','History Corrupted');
<     return;
---
> if (strcmp(history.radio_test_tr0_string,'No Output File') == 0)
>     if (length(strfind(history.radio_test_tr0_string,'.tr')) == 0 & ...
>         length(strfind(history.radio_test_tr0_string,'.raw')) == 0)
>           display history.radio_test_tr0_string
>           error_box_for_history('History file was corrupted --- starting a new one','History Corrupted');
>           return;
>     end
3024a3104,3126
> 
> 
> % --------------------------------------------------------------------
> function change_cppsim_home_Callback(hObject, eventdata, handles)
> % hObject    handle to change_cppsim_home (see GCBO)
> % eventdata  reserved - to be defined in a future version of MATLAB
> % handles    structure with handles and user data (see GUIDATA)
> 
> temp_string = strrep(handles.home,'/','\'); 
> newdirname = uigetfolder_standalone('Choose New CppSim Home Directory',temp_string);
> if newdirname ~= 0
>    newdirname = strrep(newdirname,'\','/'); 
>    newdirname = strrep(newdirname,'C:','c:'); 
>    newdirname = strrep(newdirname,' ',''); 
> 
>    new_cppsim_home_dir_string = sprintf('*** CppSimHome: %s ***',newdirname);
>    set(handles.change_cppsim_home,'Label',new_cppsim_home_dir_string);
>    set(handles.change_cppsim_home,'ForegroundColor','red');
>    handles.home = newdirname;
>    guidata(hObject,handles);
>    
>    pushbutton_sue2_synch_Callback(hObject, eventdata, handles);
> end
