OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [ProNoC.pl] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 alirezamon
#!/usr/bin/perl 
2 25 alirezamon
package ProNOC;
3
 
4
 
5 48 alirezamon
 
6
 
7
 
8 43 alirezamon
#add home dir in perl 5.6
9
use FindBin;
10
use lib $FindBin::Bin;
11 48 alirezamon
use constant::boolean;
12 25 alirezamon
 
13 43 alirezamon
 
14 16 alirezamon
use strict;
15
use warnings;
16
 
17 48 alirezamon
 
18
use lib 'lib/perl';
19
use Consts;
20
 
21
 
22 43 alirezamon
use Getopt::Long;
23 48 alirezamon
use base 'Class::Accessor::Fast';
24 25 alirezamon
 
25 54 alirezamon
our %glob_setting;
26
$glob_setting{'FONT_SIZE'}='default';
27
$glob_setting{'ICON_SIZE'}='default';
28
$glob_setting{'DSPLY_X'}  ='default';
29
$glob_setting{'DSPLY_Y'}  ='default';
30 25 alirezamon
 
31 48 alirezamon
BEGIN {
32
    my $module = (Consts::GTK_VERSION==2) ? 'Gtk2' : 'Gtk3';
33
    my $file = $module;
34
    $file =~ s[::][/]g;
35
    $file .= '.pm';
36
    require $file;
37
    $module->import;
38
}
39
 
40
 
41
require "widget.pl";
42
require "readme_gen.pl";
43 16 alirezamon
require "interface_gen.pl";
44
require "ip_gen.pl";
45
require "soc_gen.pl";
46
require "mpsoc_gen.pl";
47 25 alirezamon
require "emulator.pl";
48 32 alirezamon
require "simulator.pl";
49 38 alirezamon
require "trace_gen.pl";
50 48 alirezamon
require "network_maker.pl";
51
require "uart.pl";
52
require "run_time_jtag_debug.pl";
53
require "gdown.pl"; # google drive downlouder
54 16 alirezamon
 
55 38 alirezamon
use File::Basename;
56 16 alirezamon
 
57
 
58
 
59 48 alirezamon
use POSIX qw(locale_h);
60
use locale;
61
setlocale(LC_CTYPE, "en_US.UTF-8");#set numeric format to dot english
62 43 alirezamon
 
63 48 alirezamon
select(STDERR);
64
$| = 1;
65
select(STDOUT); # default
66
$| = 1;
67
 
68
 
69
 
70 25 alirezamon
sub main{
71 54 alirezamon
        # check if environment variables are defined
72
        #STDERR->autoflush ;
73 41 alirezamon
        my $project_dir   = get_project_dir(); #mpsoc dir addr
74
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/Paths";
75
        if (-f  $paths_file){#} && defined $ENV{PRONOC_WORK} ) {
76
                my $paths= do $paths_file;
77 54 alirezamon
 
78
                set_gui_setting($paths);
79
 
80 48 alirezamon
                main_window();
81 41 alirezamon
        }
82
        else{
83 48 alirezamon
                show_setting(1);
84
        }
85 41 alirezamon
}
86 16 alirezamon
 
87
 
88
 
89
 
90 25 alirezamon
 
91 41 alirezamon
sub main_window{
92
 
93
        set_path_env();
94
 
95
        my($width,$hight)=max_win_size();
96 54 alirezamon
        #print "($width,$hight)\n";
97
 
98 41 alirezamon
        set_defualt_font_size();
99 43 alirezamon
 
100
        if ( !defined $ENV{PRONOC_WORK} ) {
101 28 alirezamon
        my $message;
102
        if ( !defined $ENV{PRONOC_WORK}) {
103
                my $dir = Cwd::getcwd();
104
                my $project_dir   = abs_path("$dir/../../mpsoc_work");
105
                $ENV{'PRONOC_WORK'}= $project_dir;
106
                $message= "\n\nWarning: PRONOC_WORK envirement varibale has not been set. The PRONOC_WORK is autumatically set to $ENV{'PRONOC_WORK'}.\n";
107
 
108
        }
109
 
110
 
111
 
112 41 alirezamon
        #$message= $message."Warning: QUARTUS_BIN environment variable has not been set. It is required only for working with NoC emulator." if(!defined $ENV{QUARTUS_BIN});
113 28 alirezamon
 
114 41 alirezamon
        #$message= $message."\n\nPlease add aformentioned variables to ~\.bashrc file e.g: export PRONOC_WORK=[path_to]/mpsoc_work.";
115 25 alirezamon
        message_dialog("$message");
116
 
117 16 alirezamon
}
118
 
119 43 alirezamon
        my $table = def_table(1,3,FALSE);
120
 
121 16 alirezamon
 
122 38 alirezamon
        #________
123
        #radio btn "Generator"  
124 48 alirezamon
 
125 16 alirezamon
 
126 38 alirezamon
        my ($notebook,$noteref) = generate_main_notebook('Generator');
127 48 alirezamon
 
128
 
129 38 alirezamon
        my $window = def_win_size($width-100,$hight-100,"ProNoC");
130 48 alirezamon
        set_pronoc_icon($window);
131 16 alirezamon
 
132
 
133 38 alirezamon
 my @menu_items = (
134 25 alirezamon
  [ "/_File",            undef,        undef,          0, "<Branch>" ],
135 48 alirezamon
  [ "/File/_Setting",       "<control>O", sub { show_setting(0); },  0,  undef ],
136
  [ "/File/_Restart",  "<control>R", sub { restart_Pronoc(); },  0,  undef ],
137
  [ "/File/_Quit",       "<control>Q", sub { gui_quite(); },  0, "<StockItem>", 'gtk-quit' ],
138
 
139
  [ "/Tools",            undef,        undef,          0, "<Branch>" ],
140
  [ "/Tools/_UART Terminal", "<control>U", sub { uart(0); },  0,  undef ],
141
  [ "/Tools/Run time JTAG debuger", "<control>P", sub { source_probe(0); },  0,  undef ],
142
  [ "/Tools/Add New Altera FPGA Board", undef, sub { add_altera_board(); },  0,  undef ],
143
  [ "/Tools/Add New XILINX FPGA Board", undef, sub { add_xilinx_board(); },  0,  undef ],
144
 
145
 
146 25 alirezamon
  [ "/_View",                  undef, undef,         0, "<Branch>" ],
147 48 alirezamon
  [ "/View/_ProNoC System Generator",  "<control>1",    sub{ ($notebook,$noteref)=open_page($notebook,$noteref,$table,'Generator'); } , 0,       undef ],
148
  [ "/View/_ProNoC Simulator",  "<control>2",   sub{ ($notebook,$noteref)=open_page($notebook,$noteref,$table,'Simulator'); } , 0,       undef ],
149
  [ "/View/_ProNoC Network maker",  "<control>3",       sub{ ($notebook,$noteref)=open_page($notebook,$noteref,$table,'Networkgen'); } ,        0,       undef ],
150 38 alirezamon
 
151 48 alirezamon
 
152 25 alirezamon
 
153
 
154 38 alirezamon
  [ "/_Help",           undef,          undef,          0,       "<Branch>" ],
155 48 alirezamon
  [ "/Help/_About",     "F1",           sub{about(Consts::VERSION,$window)} ,   0,       undef ],
156
  [ "/Help/_ProNoC System Overview",    "F2",           \&overview ,    0,       undef ],
157
  [ "/Help/_ProNoC User Manual",  "F3",         \&user_help,    0,       undef ],
158 25 alirezamon
 
159 17 alirezamon
);
160 38 alirezamon
 
161 48 alirezamon
        my $menubar=gen_MenuBar($window,@menu_items);
162
        $table->attach ($menubar,0, 1, 0,1,,'fill','fill',0,0); #,'expand','shrink',2,2);
163
 
164
 
165 25 alirezamon
 
166
 
167 48 alirezamon
 
168
 
169
 
170
        my $rbtn_generator = gen_radiobutton (undef,'Generator','icons/hardware.png','ProNoC System Generator');
171
        my $rbtn_simulator = gen_radiobutton ($rbtn_generator,'Simulator','icons/simulator.png', "ProNoC Simulator");
172
        my $rbtn_networkgen= gen_radiobutton ($rbtn_generator,'Network maker','icons/diagram.png', "ProNoC Topology Maker");
173
 
174
 
175 25 alirezamon
 
176 48 alirezamon
        my $dt=creating_detachable_toolbar($rbtn_generator,$rbtn_simulator,$rbtn_networkgen);
177
 
178 38 alirezamon
        $rbtn_generator->signal_connect('toggled', sub{
179 48 alirezamon
                ($notebook,$noteref)=open_page($notebook,$noteref,$table,'Generator');
180 38 alirezamon
        });
181
 
182
        $rbtn_simulator->signal_connect('toggled', sub{
183 48 alirezamon
                ($notebook,$noteref)=open_page($notebook,$noteref,$table,'Simulator');
184 38 alirezamon
        });
185 43 alirezamon
 
186 48 alirezamon
        $rbtn_networkgen->signal_connect('toggled', sub{
187
                ($notebook,$noteref)=open_page($notebook,$noteref,$table,'Networkgen');
188
        });
189 38 alirezamon
 
190 48 alirezamon
   $table->attach ($dt,1, 2, 0,1,'shrink','fill',0,0);
191
 
192
 
193
 
194 38 alirezamon
   $table->attach_defaults( $notebook, 0, 2, 1,2);
195 25 alirezamon
 
196 43 alirezamon
        $window->add($table);
197
        $window->set_resizable (1);
198
        $window->show_all();
199 38 alirezamon
}
200 16 alirezamon
 
201
 
202 38 alirezamon
sub open_page{
203
        my ( $notebook,$noteref,$table,$page_name)=@_;
204
        $notebook->destroy;
205 48 alirezamon
 
206 38 alirezamon
        ($notebook,$noteref) = generate_main_notebook($page_name);
207
        $table->attach_defaults( $notebook, 0, 2, 1,2);
208
        $table->show_all;
209 48 alirezamon
        return ($notebook,$noteref);
210 16 alirezamon
 
211 38 alirezamon
}
212 16 alirezamon
 
213
 
214 38 alirezamon
sub user_help{
215 17 alirezamon
    my $dir = Cwd::getcwd();
216 38 alirezamon
    my $help="$dir/../../doc/ProNoC_User_manual.pdf";
217 17 alirezamon
    system qq (xdg-open $help);
218
    return;
219
}
220
 
221 38 alirezamon
sub overview{
222 17 alirezamon
    my $dir = Cwd::getcwd();
223 38 alirezamon
    my $help="$dir/../../doc/ProNoC_System_Overview.pdf";
224 17 alirezamon
    system qq (xdg-open $help);
225
    return;
226
}
227
 
228 48 alirezamon
sub show_setting{
229 41 alirezamon
        my $reset=shift;
230
        my $project_dir   = get_project_dir(); #mpsoc dir addr
231
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/Paths";
232 32 alirezamon
 
233 41 alirezamon
        __PACKAGE__->mk_accessors(qw{
234
        PRONOC_WORK
235
        });
236
        my $self;
237
        if (-f  $paths_file ){
238
                $self= do $paths_file;
239
        }else{
240
                $self = __PACKAGE__->new();
241
 
242
        }
243
 
244
 
245 48 alirezamon
        my $old_pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
246
        my $old_quartus = $self->object_get_attribute("PATH","QUARTUS_BIN");
247
        my $old_modelsim = $self->object_get_attribute("PATH","MODELSIM_BIN");
248
        make_undef_as_string(\$old_pronoc_work,\$old_quartus,\$old_modelsim);
249
 
250 41 alirezamon
        my $table=def_table(10,10,FALSE);
251 48 alirezamon
        my $set_win=def_popwin_size(50,80,"Configuration setting",'percent');
252
 
253
        my $scrolled_win = add_widget_to_scrolled_win($table);
254
 
255
 
256 41 alirezamon
        my $row=0; my $col=0;
257
 
258 48 alirezamon
        #title1         
259
        my $title1=gen_label_in_center("Path setting");
260
        $table->attach ($title1 , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
261
        add_Hsep_to_table($table, 0, 10 , $row); $row++;
262
    $table->attach_defaults (get_path_envirement_gui($self,$set_win,$reset) , 0, 10 , $row, $row+1);     $row++;
263
 
264
 
265 32 alirezamon
 
266 48 alirezamon
        #title2         
267
        my $title2=gen_label_in_center("Toolchain");
268
        $table->attach ($title2 , 0, 5,  $row, $row+1,'expand','shrink',2,2);
269
        $table->attach (gen_label_in_center("ORCC EDK"), 5, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
270 41 alirezamon
 
271
 
272 48 alirezamon
 
273
        add_Hsep_to_table($table, 0, 10 , $row); $row++;
274 41 alirezamon
 
275 48 alirezamon
        #check which toolchain is available in the system
276
        my @f1=("/bin/mb-g++","/bin/mb-objcopy");
277
        my @f2=("/bin/lm32-elf-gcc","/bin/lm32-elf-ld","/bin/lm32-elf-objcopy","/bin/lm32-elf-objdump","/lm32-elf/lib","/lib/gcc/lm32-elf/4.5.3");
278
        my @f3=("/bin/or1k-elf-gcc","/bin/or1k-elf-ld","/bin/or1k-elf-objcopy","/bin/or1k-elf-objdump","/lib/gcc/or1k-elf/5.2.0");
279
 
280
        my @tool = (
281
        { label=>"aeMB", tooldir=>"aemb", files=>\@f1, size=>'21 MB', path=>'https://drive.google.com/file/d/1PT7lliPzhqsVl2Xq2bJsFuKu83Vk1ee4/view?usp=sharing' },
282
        { label=>"lm32", tooldir=>"lm32", files=>\@f2, size=>'57 MB', path=>'https://drive.google.com/file/d/1ly32nItfQwBNxhTjDd5xoi7kXPPQjZz7/view?usp=sharing' },
283
        { label=>"or1k-elf", tooldir=>"or1k-elf", files=>\@f3, size=>'219 MB', path=>'https://drive.google.com/file/d/1AeV3oeSltZ_aEqHcd419kfeI8EtHmUwr/view?usp=sharing' },
284
        );
285 41 alirezamon
 
286 48 alirezamon
        my @f4=("/dropins","/plugins");
287
    my @f5=("/AddArray", "/Communication", "/HelloWorld", "/README.md","/StreamBlocks");
288 43 alirezamon
 
289 48 alirezamon
        my @tool2 = (
290
        { label=>"eclipse-orcc", tooldir=>"eclipse-orcc", files=>\@f4, size=>'208 MB', path=>'https://drive.google.com/file/d/1YAOAyAk8PA6LXwIPz3aIy-Mongh__WBW/view?usp=sharing' },
291
        { label=>"orcc-apps", tooldir=>"orc-apps", files=>\@f5, size=>'28 MB', path=>'https://drive.google.com/file/d/1Qs4rxcSr-E5H4lYaxawqczTHfCPPCo4V/view?usp=sharing' },
292
        #{ label=>"or1k-elf", tooldir=>"or1k-elf", files=>\@f3, size=>'219 MB', path=>'https://drive.google.com/file/d/1AeV3oeSltZ_aEqHcd419kfeI8EtHmUwr/view?usp=sharing' },
293
        );
294 43 alirezamon
 
295 48 alirezamon
        $table->attach_defaults (check_toolchains($self,$set_win,$reset,"toolchain",@tool) , 0, 5 , $row, $row+1);
296
        add_Vsep_to_table($table, 5, $row,$row+1);
297
        $table->attach_defaults (check_toolchains($self,$set_win,$reset,"orcc",@tool2) , 5, 10 , $row, $row+1);
298
 
299
        $row++;
300
        #title3
301
        $table->attach (gen_label_in_center("Tools") , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
302
        add_Hsep_to_table($table, 0, 10 , $row); $row++;
303
 
304 43 alirezamon
        #check which toolchain is available in the system
305 48 alirezamon
        $table->attach_defaults (check_tools($self,$set_win,$reset) , 0, 10 , $row, $row+1);$row++;
306 43 alirezamon
 
307 48 alirezamon
        #title4
308
        $table->attach (gen_label_in_center("GUI setting") , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
309
        add_Hsep_to_table($table, 0, 10 , $row); $row++;
310
        $table->attach_defaults (get_gui_setting($self,$set_win,$reset) , 0, 10 , $row, $row+1);$row++;
311 43 alirezamon
 
312 41 alirezamon
        my $ok = def_image_button('icons/select.png','OK');
313 48 alirezamon
        my $mtable = def_table(10, 1, FALSE);
314 41 alirezamon
 
315
        $mtable->attach_defaults($scrolled_win,0,1,0,9);
316
        $mtable-> attach ($ok , 0, 1,  9, 10,'expand','shrink',2,2);
317
 
318
        $set_win->add ($mtable);
319
        $set_win->show_all();
320
 
321
 
322 48 alirezamon
 
323 41 alirezamon
        $ok->signal_connect("clicked"=> sub{
324
                #save setting
325
                open(FILE,  ">$paths_file") || die "Can not open: $!";
326
                print FILE perl_file_header("Paths");
327
                print FILE Data::Dumper->Dump([\%$self],['setting']);
328
                close(FILE) || die "Error closing file: $!";
329
                my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
330
                my $quartus = $self->object_get_attribute("PATH","QUARTUS_BIN");
331
                my $modelsim = $self->object_get_attribute("PATH","MODELSIM_BIN");
332 48 alirezamon
                make_undef_as_string(\$pronoc_work,\$quartus,\$modelsim);
333 41 alirezamon
 
334 43 alirezamon
                if(($old_pronoc_work ne $pronoc_work) || !defined $ENV{PRONOC_WORK}){
335
                        mkpath("$pronoc_work/emulate",1,01777) unless -d "$pronoc_work/emulate";
336
                        mkpath("$pronoc_work/simulate",1,01777) unless -d "$pronoc_work/simulate";
337 48 alirezamon
                        mkpath("$pronoc_work/tmp",1,01777) unless -d "$pronoc_work/tmp";
338
                        mkpath("$pronoc_work/toolchain",1,01777) unless -d "$pronoc_work/toolchain";
339
 
340 43 alirezamon
                }
341
 
342 48 alirezamon
 
343
 
344 41 alirezamon
                set_path_env();
345 48 alirezamon
                if($old_pronoc_work ne $pronoc_work ){
346
                        update_bashrc_file($self,$old_pronoc_work,$old_quartus,$old_modelsim);
347
                }
348 41 alirezamon
 
349 48 alirezamon
                my  ($file_path,$text)=@_;
350 41 alirezamon
                $set_win->destroy;
351 48 alirezamon
 
352 54 alirezamon
                my %new_setting = %{$self->object_get_attribute('GUI_SETTING')};
353
                my $eq=1;
354
                foreach my $k (sort keys %new_setting){
355
                        $eq= 0 if        $new_setting{$k} ne $glob_setting{$k};
356
                }
357
 
358
                if($eq ==0){
359 48 alirezamon
                        restart_Pronoc ();
360
                }
361
 
362 41 alirezamon
                main_window() if($reset);
363 48 alirezamon
 
364
 
365
 
366
 
367 41 alirezamon
 
368
        });
369
 
370
}
371
 
372 48 alirezamon
sub restart_Pronoc {
373
        exec($^X, $0, @ARGV);# reset ProNoC to apply changes    
374
}
375
 
376
 
377
sub get_path_envirement_gui {
378
        my($self,$set_win,$reset)=@_;
379
        my $table = def_table(10, 1, FALSE);
380
        my $row=0;
381
        my $col=0;
382
        my $project_dir   = get_project_dir(); #mpsoc dir addr
383
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/Paths";
384
        my $old_pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
385
        my $old_quartus = $self->object_get_attribute("PATH","QUARTUS_BIN");
386
        my $old_modelsim = $self->object_get_attribute("PATH","MODELSIM_BIN");
387
        make_undef_as_string(\$old_pronoc_work,\$old_quartus,\$old_modelsim);
388
 
389
 
390
 
391
        my $pronoc_w_row=0;
392
        my @paths = (
393
        { label=>"PRONOC_WORK", param_name=>"PRONOC_WORK", type=>"DIR_path", default_val=>"$project_dir/mpsoc_work", content=>undef, info=>"Define the working directory where the projects' files will be created", param_parent=>'PATH',ref_delay=>undef },
394
        { label=>"QUARTUS_BIN", param_name=>"QUARTUS_BIN", type=>"DIR_path", default_val=>undef, content=>undef, info=>"Define the path to QuartusII compiler bin directory.  Setting of this variable is optional and is needed if you are going to use Altera FPGAs for implementation or emulation", param_parent=>'PATH',ref_delay=>undef },
395
        { label=>"VIVADO_BIN",  param_name=>"VIVADO_BIN", type=>"DIR_path", default_val=>undef, content=>undef, info=>"Define the path to Xilinx/Vivado compiler bin directory.  Setting of this variable is optional and is needed if you are going to use Xilinx FPGAs for implementation or emulation", param_parent=>'PATH',ref_delay=>undef },
396
        { label=>"SDK_BIN"      ,       param_name=>"SDK_BIN", type=>"DIR_path", default_val=>undef, content=>undef, info=>"Define the path to Xilinx/SDK/bin directory. Setting of this variable is optional and is needed if you are going to use Xilinx FPGAs for implementation or emulation", param_parent=>'PATH',ref_delay=>undef },
397
        { label=>"MODELSIM_BIN",param_name=>"MODELSIM_BIN", type=>"DIR_path", default_val=>undef, content=>undef, info=>"Define the path to Modelsim simulator bin directory.  Setting of this variable is optional and is needed if you have installed Modelsim simulator and you want ProNoC to auto-generate the
398
simulation models using Modelsim software", param_parent=>'PATH',ref_delay=>undef },
399
                );
400
 
401
        foreach my $d (@paths) {
402
                #$mpsoc,$name,$param, $default,$type,$content,$info, $table,$row,$column,$show,$attribut1,$ref_delay,$new_status,$loc
403
                my $widget;
404
                ($row,$col)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,$col,1, $d->{param_parent}, $d->{ref_delay},undef,"vertical");
405
 
406
        }
407
        #add apply buton for work dir
408
        my $apply=def_image_button("icons/enter.png",'Apply');
409
        $table->attach ($apply , 4, 5,  $pronoc_w_row, $pronoc_w_row+1,'fill','shrink',2,2); $row++;
410
        $apply->signal_connect("clicked"=> sub{
411
                        my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
412
                        make_undef_as_string(\$pronoc_work);
413
                        if(($old_pronoc_work ne $pronoc_work)){
414
                                open(FILE,  ">$paths_file") || die "Can not open: $!";
415
                                print FILE perl_file_header("Paths");
416
                                print FILE Data::Dumper->Dump([\%$self],['setting']);
417
                                close(FILE) || die "Error closing file: $!";
418
                                mkpath("$pronoc_work/emulate",1,01777) unless -d "$pronoc_work/emulate";
419
                                mkpath("$pronoc_work/simulate",1,01777) unless -d "$pronoc_work/simulate";
420
                                mkpath("$pronoc_work/tmp",1,01777) unless -d "$pronoc_work/tmp";
421
                                mkpath("$pronoc_work/toolchain",1,01777) unless -d "$pronoc_work/toolchain";
422
                                update_bashrc_file($self,$old_pronoc_work,$old_quartus,$old_modelsim);
423
 
424
                        }
425
                        set_path_env();
426
                    $set_win->destroy;
427
                        show_setting($reset);
428
        });
429
        return $table;
430
}
431
 
432
 
433
sub update_bashrc_file {
434
        my ($self,$old_pronoc_work,$old_quartus,$old_modelsim)=@_;
435
        my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
436
        my $quartus = $self->object_get_attribute("PATH","QUARTUS_BIN");
437
        my $modelsim = $self->object_get_attribute("PATH","MODELSIM_BIN");
438
 
439
        my $response =  yes_no_dialog("ProNoC variable has been changed. Do you want to update ~/.bashrc file with new ones?");
440
        if ($response eq 'yes') {
441
                        make_undef_as_string(\$pronoc_work,\$quartus,\$modelsim);
442
                                append_text_to_file ("$ENV{HOME}/.bashrc", "\nexport PRONOC_WORK=$pronoc_work\n") if(($old_pronoc_work ne $pronoc_work) || !defined $ENV{PRONOC_WORK});
443
                                #append_text_to_file ("$ENV{HOME}/.bashrc", "export QUARTUS_BIN=$quartus\n") if($old_quartus ne $quartus) ;
444
                                #append_text_to_file ("$ENV{HOME}/.bashrc", "export MODELSIM_BIN=$modelsim\n") if($old_modelsim ne $modelsim) ;
445
 
446
 
447
 
448
        }
449
 
450
}
451
 
452
 
453
 
454
 
455 43 alirezamon
sub check_toolchains{
456 48 alirezamon
        my ($self,$set_win,$reset,$root,@tool)=@_;
457
        my $table = def_table(10, 1, FALSE);
458
    my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
459
        mkpath("$pronoc_work/$root",1,01777) unless -d "$pronoc_work/$root";
460 43 alirezamon
 
461
 
462
        my $row =0;
463 48 alirezamon
        my $download_st=0;
464
        my $i=0;
465 43 alirezamon
        foreach my $d (@tool) {
466 48 alirezamon
                my $index=$i;
467
                $i++;
468 43 alirezamon
                my $exist=1;
469
                my $miss="";
470
                my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
471
                my $tooldir=$d->{tooldir};
472
                my @files=@{$d->{files}};
473 48 alirezamon
                my $tool_path="$pronoc_work/$root/$tooldir";
474 43 alirezamon
                unless (-d $tool_path){
475
                        $exist=0;
476
                        $miss=$miss." $tool_path is missing\n";
477
                }else{
478
                        foreach my $f (@files){
479
 
480
                                my $file_path= "$tool_path/$f";
481
                                unless ( -f $file_path || -d $file_path){
482
                                        $exist=0;
483
                                        $miss=$miss." $file_path file is missing\n";
484
                                }
485
                        }
486
                }
487
                if ($exist==0){
488 48 alirezamon
                        my $col=0;
489 43 alirezamon
                        my $w=def_image_button("icons/warning.png",$d->{label});
490
                        $w->signal_connect("clicked" => sub {message_dialog($miss);});
491 48 alirezamon
                        $table->attach ($w , $col, $col+1,  $row, $row+1,'shrink','shrink',2,2);  $col++;
492
                        $table->attach (gen_label_in_center("Size: $d->{size}") , $col, $col+1,  $row, $row+1,'shrink','shrink',2,2);  $col++;
493
                        my $dowload=def_image_button("icons/download.png",'Download Now');
494
                        $table->attach ($dowload , $col, $col+1,  $row, $row+1,'shrink','shrink',2,2);  $col++;
495
                        my $srow=       $row;
496
                        $dowload ->signal_connect("clicked" => sub {
497
                                $dowload ->set_sensitive (FALSE);
498
                                $download_st = $download_st | (1 << $index);
499
                                my $load= show_gif("icons/load.gif");
500
                                $table->attach ($load, $col, $col+1, $srow,$srow+ 1,'shrink','shrink',0,0);  $col++;
501
                                $load->show_all;
502
                                my $filename="$pronoc_work/$root/$d->{label}.zip";
503
                                my $target="$pronoc_work/$root/$d->{label}";
504
                                #download the file from google drive
505
                                download_from_google_drive("$d->{path}" ,"$filename"  );
506
                                #unzip the file
507
                                my $cmd= "unzip $pronoc_work/$root/$d->{label}.zip -d $pronoc_work/$root/";
508
                                return if(run_cmd_message_dialog_errors($cmd));
509
                                $load->destroy;
510
                                #remove zip file
511
                                unlink "$pronoc_work/$root/$d->{label}.zip";
512
                                $download_st = $download_st & ~(1 << $index);
513
 
514
                                if ($download_st==0){
515
                                        $cmd = "chmod +x -Rf $pronoc_work/$root/";
516
                                        return if(run_cmd_message_dialog_errors($cmd));
517
                                        $set_win->destroy;
518
                                        show_setting($reset);
519
                                }
520
                        });
521
 
522
                        $row++;
523 43 alirezamon
                }else{
524
                        my $w=def_image_label("icons/button_ok.png",$d->{label});
525
                        $table->attach ($w , 0, 1,  $row, $row+1,'shrink','shrink',2,2); $row++;
526
                }
527
 
528
        }
529
        return $table;
530
}
531
 
532
 
533 48 alirezamon
 
534
 
535
 
536
 
537
 
538
sub Dir_isEmpty {
539
    return 0 unless -d $_[0];
540
    opendir my $dh, $_[0] or die $!;
541
    my $count = () = readdir $dh;    # gets count thru ()
542
    return $count - 2;     #maybe not the best way of removing . and .
543
}
544
 
545
sub get_gui_setting{
546
        my ($self,$set_win,$reset)=@_;
547
        my $table = def_table(10, 1, FALSE);
548
 
549 54 alirezamon
        my $w="default";
550
        for (my $i=100;$i<3000;$i+=100) {$w.= ",$i";}
551 48 alirezamon
 
552
        my @gui=(
553 54 alirezamon
        { label=>'Font size:', param_name=>'FONT_SIZE', type=>'Combo-box', default_val=> $glob_setting{'FONT_SIZE'},
554 48 alirezamon
          content=>"default,5,6,7,8,9,10,11,12,13,14,15", info=>undef,
555
          param_parent=>"GUI_SETTING", ref_delay=> undef, new_status=>undef},
556 54 alirezamon
 
557
        { label=>'ICON size:', param_name=>'ICON_SIZE', type=>'Combo-box', default_val=> $glob_setting{'ICON_SIZE'},
558 48 alirezamon
          content=>"default,11,14,17,20,23,26,29,32,35,38,41", info=>undef,
559 54 alirezamon
          param_parent=>"GUI_SETTING", ref_delay=> undef, new_status=>undef},
560
 
561
 
562
        { label=>'Display width:', param_name=>'DSPLY_X', type=>'Combo-box', default_val=> $glob_setting{'DSPLY_X'},
563
          content=>"$w", info=>undef,
564
          param_parent=>"GUI_SETTING", ref_delay=> undef, new_status=>undef},
565
 
566
 
567
        { label=>'Display height:', param_name=>'DSPLY_Y', type=>'Combo-box', default_val=> $glob_setting{'DSPLY_Y'},
568
          content=>"$w", info=>undef,
569
          param_parent=>"GUI_SETTING", ref_delay=> undef, new_status=>undef},
570 48 alirezamon
 
571
        );
572
 
573
        my $row=0;
574
        my $col=0;
575
        foreach my $d ( @gui) {
576
                my $w;
577
                ($row,$col,$w)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,$col,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status},'Horizental');
578
 
579
        }
580
 
581
        return $table;
582
 
583
 
584
}
585
 
586
 
587
 
588
sub check_tools{
589
        my ($self,$set_win,$reset)=@_;
590
        my $table = def_table(10, 1, FALSE);
591
        my $row=0;
592
        my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
593
        my $label1;
594
        if (Dir_isEmpty("$pronoc_work/toolchain/bin") == 0){
595
                $label1=def_image_label("icons/warning.png","The tools directory is empty! You need to run the Make tools first.");
596
 
597
        }else{
598
                $label1=gen_label_in_left("Regenerate ProNoC tools");
599
 
600
        }
601
        $table->attach ($label1 , 0, 1,  $row, $row+1,'shrink','shrink',2,2);
602
 
603
        my $make=def_image_button('icons/setting2.png','Make tools');
604
        $table->attach ($make , 1, 2,  $row, $row+1,'shrink','shrink',2,2); $row++;
605
        my $srow = $row;
606
        $make ->signal_connect("clicked" => sub {
607
                #unzip the file
608
                $make ->set_sensitive (FALSE);
609
                my $load= show_gif("icons/load.gif");
610
                $table->attach ($load, 2, 3, $srow,$srow+ 1,'shrink','shrink',0,0);
611
                                my $project_dir   = get_project_dir(); #mpsoc dir addr
612
                                my $cmd= "xterm -hold -e bash -c \' cd $project_dir/mpsoc/src_c; make; echo \"\n\nPlease close this window to continue .....\n\n\"\'";
613
                                return if(run_cmd_message_dialog_errors($cmd));
614
                                $load->destroy;
615
                                $set_win->destroy;
616
                                show_setting($reset);
617
 
618
        });
619
 
620
 
621
        return $table;
622
 
623
}
624
 
625
sub uart {
626
        uart_main();
627
}
628
 
629
sub source_probe{
630
        source_probe_main();
631
}
632
 
633
 
634
sub global_param{
635
        my $project_dir   = get_project_dir(); #mpsoc dir addr
636
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/glob_params";
637
 
638
        __PACKAGE__->mk_accessors(qw{
639
        PRONOC_WORK
640
        });
641
        my $self;
642
        if (-f  $paths_file ){
643
                $self= do $paths_file;
644
        }else{
645
                $self = __PACKAGE__->new();
646
        }
647
 
648
 
649
 
650
 
651
        my $table1=def_table(10,10,FALSE);
652
        my $set_win=def_popwin_size(60,80,"Configuration setting",'percent');
653
        my $scrolled_win= add_widget_to_scrolled_win($table1);
654
 
655
 
656
        my $row=0; my $col=0;
657
        #title1         
658
        my $title1=gen_label_in_center("Global Parameters setting");
659
        $table1->attach ($title1 , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
660
        add_Hsep_to_table($table1, 0, 10 , $row);        $row++;
661
 
662
 
663
    my @parameters = object_get_attribute_order($self,'Parameters');
664
        my $ok = def_image_button('icons/select.png','OK');
665
 
666
 
667
 
668
        foreach my $p (@parameters) {
669
                        my $name = object_get_attribute($self,$p,'name');
670
                        my $default = object_get_attribute($self,$p,'default');
671
                        my $type= object_get_attribute($self,$p,'type');
672
                        my $content= object_get_attribute($self,$p,'content');
673
                        my $info= object_get_attribute($self,$p,'info');
674
                        add_param_widget($self,$name,$p, $default,$type,$content,$info, $table1,$row,$col,1,'Parameters',0,undef,undef);
675
                        my $remove= def_image_button("icons/cancel.png","remove");
676
                        $table1->attach ($remove, 4, 5, $row, $row+1,'expand','shrink',2,2);
677
                        $row++;
678
                        $remove->signal_connect (clicked => sub{
679
                                delete $self->{$p};
680
                                object_remove_attribute_order($self,'Parameters',$p);
681
                                object_remove_attribute($self,'Parameters',$p);
682
                                $ok->clicked;
683
                                global_param();
684
                        });
685
        }
686
 
687
        $row=0;  $col=0;
688
        my $table2=def_table(10,10,FALSE);
689
        #title1         
690
        $title1=gen_label_in_center("Add new Global Parameter");
691
        $table2->attach ($title1 , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
692
        add_Hsep_to_table($table2, 0, 10 , $row);        $row++;
693
        my $scrolled_win2= add_widget_to_scrolled_win($table2);
694
 
695
        my @widget_type_list=("Fixed","Entry","Combo-box","Spin-button");
696
    my $type_info="Define the parameter type:
697
 
698
Fixed: The parameter is fixed and get the default value. Users can not see or change the parameter value.
699
 
700
Entry: The parameter value is received via entry. The user can type anything.
701
 
702
Combo-box: The parameter value can be selected from a list of predefined value.
703
 
704
Spin-button: The parameter is numeric and will be obtained using spin button.";
705
        my $content_info='
706
For Fixed and Entry leave it empty.
707
For Combo box define the parameters which must be shown in combo box as: "PAEAMETER1","PARAMETER2"...,"PARAMETERn".
708
For Spin button define it as "minimum, maximum, step" e.g 0,10,1.';
709
        my $param_info='Define how parameter is included in the top module containig this IP core.';
710
 
711
 
712
        #title
713
        my @title;
714
        $title[0]=gen_label_in_center("Parameter name");
715
        $title[1]=gen_label_in_center("Default value");
716
        $title[2]=gen_label_help($type_info,"Widget type");
717
        $title[3]=gen_label_help($content_info,"Widget content");
718
        $title[4]=gen_label_help("You can add aditional information about this parameter.","info");
719
        $title[5]=gen_label_in_center("add/remove");
720
 
721
 
722
        foreach my $t (@title){
723
                $table2->attach ($t, $col, $col+1, $row, $row+1,'expand','shrink',2,2); $col++;
724
 
725
        }
726
        $row++;$col=0;
727
 
728
        my $param_name= gen_entry();
729
        my $default_entry= gen_entry();
730
        my $widget_type_combo=gen_combo(\@widget_type_list, 0);
731
        my $content_entry= gen_entry( );
732
        my $info=def_image_button("icons/add_info.png");
733
        my $add= def_image_button("icons/plus.png","add");
734
 
735
        $table2->attach ($param_name, $col, $col+1, $row, $row+1,'expand','shrink',2,2);$col++;
736
        $table2->attach ($default_entry, $col, $col+1, $row, $row+1,'expand','shrink',2,2);$col++;
737
        $table2->attach ($widget_type_combo, $col, $col+1, $row, $row+1,'expand','shrink',2,2);$col++;
738
        $table2->attach ($content_entry, $col, $col+1, $row, $row+1,'expand','shrink',2,2);$col++;
739
        $table2->attach ($info, $col, $col+1, $row, $row+1,'expand','shrink',2,2);$col++;
740
        $table2->attach ($add, $col, $col+1, $row, $row+1,'expand','shrink',2,2);$col++;
741
        my $sinfo;
742
        $info->signal_connect (clicked => sub{
743
                        get_param_info($self,\$sinfo);
744
                });
745
 
746
        $add->signal_connect (clicked => sub{
747
                my $param= $param_name->get_text();
748
                $param=remove_all_white_spaces($param);
749
 
750
                if( length($param) ){
751
                                my $default=$default_entry->get_text();
752
                                my $type=$widget_type_combo->get_active_text();
753
                                my $content=$content_entry->get_text();
754
 
755
                                object_add_attribute($self,$param,'name',$param);
756
                            object_add_attribute($self,$param,'default',$default);
757
                            object_add_attribute($self,$param,'type',$type);
758
                            object_add_attribute($self,$param,'content',$content);
759
                            object_add_attribute($self,$param,'info',$sinfo);
760
                                object_add_attribute_order($self,'Parameters',$param);
761
                                $ok->clicked;
762
                                global_param();
763
                }
764
 
765
 
766
        });
767
 
768
 
769
 
770
 
771
 
772
        my $mtable = def_table(10, 1, FALSE);
773
    my $v2=gen_vpaned($scrolled_win,.55,$scrolled_win2);
774
        $mtable->attach_defaults($v2,0,1,0,9);
775
 
776
        $mtable-> attach ($ok , 0, 1,  9, 10,'expand','shrink',2,2);
777
 
778
        $set_win->add ($mtable);
779
        $set_win->show_all();
780
 
781
 
782
 
783
        $ok->signal_connect("clicked"=> sub{
784
                #save setting
785
                open(FILE,  ">$paths_file") || die "Can not open: $!";
786
                print FILE perl_file_header("Paths");
787
                print FILE Data::Dumper->Dump([\%$self],['glob']);
788
                close(FILE) || die "Error closing file: $!";
789
 
790
 
791
 
792
 
793
 
794
                $set_win->destroy;
795
 
796
 
797
        });
798
 
799
 
800
 
801
 
802
 
803
 
804
}
805
 
806
 
807
 
808
 
809
 
810
 
811
 
812
sub add_altera_board{
813
 
814
        __PACKAGE__->mk_accessors(qw{
815
        PRONOC_WORK
816
        });
817
        my $self= __PACKAGE__->new();
818
 
819
 
820
 
821
        add_new_fpga_board($self,undef,undef,undef,undef,'Altera');
822
 
823
}
824
 
825
sub add_xilinx_board{
826
                __PACKAGE__->mk_accessors(qw{
827
        PRONOC_WORK
828
        });
829
        my $self= __PACKAGE__->new();
830
 
831
        add_new_fpga_board($self,undef,undef,undef,undef,'Xilinx');
832
 
833
 
834
}
835
 
836
 
837 38 alirezamon
sub generate_main_notebook {
838
        my $mode =shift;
839
 
840 48 alirezamon
        my $notebook = gen_notebook();
841 38 alirezamon
        $notebook->show_all;
842
        if($mode eq 'Generator'){
843
                my $intfc_gen=  intfc_main();
844 48 alirezamon
                my $label1=def_image_label("icons/intfc.png"," _Interface generator ",1);
845
                $notebook->append_page ($intfc_gen,$label1);
846
                $label1->show_all;
847 32 alirezamon
 
848 48 alirezamon
                my $ipgen= ipgen_main();
849
                my $label2=def_image_label("icons/ip.png"," I_P generator ",1);
850
                $notebook->append_page ($ipgen,$label2);
851
                $label2->show_all;
852 17 alirezamon
 
853 48 alirezamon
                my $socgen= socgen_main();
854
                my $label3=def_image_label("icons/tile.png"," P_rocessing tile generator ",1);
855
                $notebook->append_page ($socgen,$label3 );
856
                $label3->show_all;
857 17 alirezamon
 
858 48 alirezamon
                my $mpsocgen =  mpsocgen_main();
859
                my $label4=def_image_label("icons/noc.png"," _NoC based MPSoC generator ",1);
860
                $notebook->append_page ($mpsocgen,$label4);
861
                $label4->show_all;
862 38 alirezamon
 
863
 
864 43 alirezamon
        } elsif($mode eq 'Networkgen'){
865
 
866
                my $networkgen = network_maker_main();
867 48 alirezamon
                my $label5=def_image_label("icons/trace.png"," Network Maker ");
868
                $notebook->append_page ($networkgen,$label5);
869
                $label5->show_all;
870 43 alirezamon
 
871
 
872
        }else{
873 48 alirezamon
 
874 38 alirezamon
 
875
 
876 43 alirezamon
 
877 48 alirezamon
                my $simulator = simulator_main();
878
                my $label2=def_image_label("icons/sim.png"," _NoC simulator ",1);
879 38 alirezamon
 
880
 
881 48 alirezamon
                $notebook->append_page ($simulator,$label2);
882
                $label2->show_all;
883 38 alirezamon
                $simulator->show_all;
884 17 alirezamon
 
885 48 alirezamon
                my $emulator = emulator_main();
886
                my $label3=def_image_label("icons/emul.png"," _NoC emulator ",1);
887
                $notebook->append_page ($emulator,$label3);
888
                $label3->show_all;
889
                $emulator->show_all;
890 38 alirezamon
 
891 48 alirezamon
                my $trace_gen= trace_gen_main('task');
892
                my $label1=def_image_label("icons/trace.png"," _Trace generator ",1);
893
 
894
                set_tip($label1, "Generate trace file from application task graph");
895 38 alirezamon
 
896 48 alirezamon
                $notebook->append_page ($trace_gen,$label1);
897
                $label1->show_all;
898
                $trace_gen->show_all;
899 38 alirezamon
 
900 48 alirezamon
 
901 38 alirezamon
        }
902 48 alirezamon
                my $scrolled_win = add_widget_to_scrolled_win($notebook);
903 38 alirezamon
 
904 43 alirezamon
                return ($scrolled_win,$notebook);
905 25 alirezamon
}
906
 
907
 
908
 
909 38 alirezamon
 
910 48 alirezamon
        gtk_gui_run(\&main);
911 38 alirezamon
 
912
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.