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 48

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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