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 41

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

Line No. Rev Author Line
1 16 alirezamon
#!/usr/bin/perl -w
2
 
3 25 alirezamon
package ProNOC;
4
 
5
 
6
 
7 16 alirezamon
use Glib qw/TRUE FALSE/;
8
 
9
 
10
use Gtk2;
11
use strict;
12
use warnings;
13
 
14 25 alirezamon
 
15
 
16 16 alirezamon
use lib 'lib/perl';
17
require "widget.pl";
18
require "interface_gen.pl";
19
require "ip_gen.pl";
20
require "soc_gen.pl";
21
require "mpsoc_gen.pl";
22 25 alirezamon
require "emulator.pl";
23 32 alirezamon
require "simulator.pl";
24 38 alirezamon
require "trace_gen.pl";
25 16 alirezamon
 
26 38 alirezamon
use File::Basename;
27 16 alirezamon
 
28
 
29 41 alirezamon
our $VERSION = '1.8.1';
30 16 alirezamon
 
31 25 alirezamon
sub main{
32 41 alirezamon
        # check if envirement variables are defined
33
        my $project_dir   = get_project_dir(); #mpsoc dir addr
34
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/Paths";
35 16 alirezamon
 
36 41 alirezamon
        if (-f  $paths_file){#} && defined $ENV{PRONOC_WORK} ) {
37
                my $paths= do $paths_file;
38
                main_window();
39
 
40
        }
41
        else{
42
                setting(1);
43
        }
44
 
45
}
46 16 alirezamon
 
47 41 alirezamon
sub set_path_env{
48
        my $project_dir   = get_project_dir(); #mpsoc dir addr
49
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/Paths";
50
        my $paths= do $paths_file;
51 16 alirezamon
 
52 41 alirezamon
        my $pronoc_work = $paths->object_get_attribute("PATH","PRONOC_WORK");
53
        my $quartus = $paths->object_get_attribute("PATH","QUARTUS_BIN");
54
        my $modelsim = $paths->object_get_attribute("PATH","MODELSIM_BIN");
55 16 alirezamon
 
56 41 alirezamon
        $ENV{'PRONOC_WORK'}= $pronoc_work if( defined $pronoc_work);
57
        $ENV{'QUARTUS_BIN'}= $quartus if( defined $quartus);
58
        $ENV{'MODELSIM_BIN'}= $modelsim if( defined $modelsim);
59
}
60 16 alirezamon
 
61 25 alirezamon
 
62 41 alirezamon
 
63
sub main_window{
64
 
65
        set_path_env();
66
 
67
 
68
        my($width,$hight)=max_win_size();
69
        set_defualt_font_size();
70
 
71
 
72
 
73
 
74
if ( !defined $ENV{PRONOC_WORK} ) {
75 28 alirezamon
        my $message;
76
        if ( !defined $ENV{PRONOC_WORK}) {
77
                my $dir = Cwd::getcwd();
78
                my $project_dir   = abs_path("$dir/../../mpsoc_work");
79
                $ENV{'PRONOC_WORK'}= $project_dir;
80
                $message= "\n\nWarning: PRONOC_WORK envirement varibale has not been set. The PRONOC_WORK is autumatically set to $ENV{'PRONOC_WORK'}.\n";
81
 
82
        }
83
 
84
 
85
 
86 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});
87 28 alirezamon
 
88 41 alirezamon
        #$message= $message."\n\nPlease add aformentioned variables to ~\.bashrc file e.g: export PRONOC_WORK=[path_to]/mpsoc_work.";
89 25 alirezamon
        message_dialog("$message");
90
 
91 16 alirezamon
}
92 38 alirezamon
my $table = Gtk2::Table->new (1, 3, FALSE);
93 16 alirezamon
 
94
 
95 38 alirezamon
        #________
96
        #radio btn "Generator"  
97
        my $rbtn_generator = Gtk2::RadioToolButton->new (undef);
98 16 alirezamon
 
99 38 alirezamon
        my ($notebook,$noteref) = generate_main_notebook('Generator');
100
        my $window = def_win_size($width-100,$hight-100,"ProNoC");
101
        my $navIco = Gtk2::Gdk::Pixbuf->new_from_file("./icons/ProNoC.png");         # advance1.png");  
102
        $window->set_default_icon($navIco);
103 16 alirezamon
 
104
 
105 38 alirezamon
 my @menu_items = (
106 25 alirezamon
  [ "/_File",            undef,        undef,          0, "<Branch>" ],
107 41 alirezamon
  [ "/File/_Setting",       "<control>O", sub { setting(0); },  0,  undef ],
108 25 alirezamon
  [ "/File/_Quit",       "<control>Q", sub { Gtk2->main_quit },  0, "<StockItem>", 'gtk-quit' ],
109
  [ "/_View",                  undef, undef,         0, "<Branch>" ],
110 38 alirezamon
  [ "/_View/_ProNoC System Generator",  undef,  sub{ open_page($notebook,$noteref,$table,'Generator'); } ,      0,       undef ],
111
  [ "/_View/_ProNoC Simulator",  undef,         sub{ open_page($notebook,$noteref,$table,'Simulator'); } ,      0,       undef ],
112
 
113 25 alirezamon
 
114
 
115 38 alirezamon
  [ "/_Help",           undef,          undef,          0,       "<Branch>" ],
116
  [ "/_Help/_About",    "F1",           \&about ,       0,       undef ],
117
  [ "/_Help/_ProNoC System Overview",   "F2",           \&overview ,    0,       undef ],
118
  [ "/_Help/_ProNoC User Manual",  "F3",                \&user_help,    0,       undef ],
119 25 alirezamon
 
120 17 alirezamon
);
121
 
122
 
123
 
124
 
125
 
126 25 alirezamon
 
127 38 alirezamon
 
128
    my $accel_group = Gtk2::AccelGroup->new;
129
    $window->add_accel_group ($accel_group);
130 25 alirezamon
 
131 38 alirezamon
    my $item_factory = Gtk2::ItemFactory->new ("Gtk2::MenuBar", "<main>",$accel_group);
132 25 alirezamon
 
133 38 alirezamon
    # Set up item factory to go away with the window
134
    $window->{'<main>'} = $item_factory;
135 25 alirezamon
 
136 38 alirezamon
    # create menu items
137
    $item_factory->create_items ($window, @menu_items);
138 25 alirezamon
 
139 38 alirezamon
 
140 25 alirezamon
 
141 38 alirezamon
        $table->attach ($item_factory->get_widget ("<main>"),0, 1, 0,1,,'fill','fill',0,0); #,'expand','shrink',2,2);
142
 
143
    my $tt = Gtk2::Tooltips->new();
144 25 alirezamon
 
145
 
146 38 alirezamon
        #====================================
147
        #The handle box helps in creating a detachable toolbar 
148
        my $hb = Gtk2::HandleBox->new;
149
        #create a toolbar, and do some initial settings
150
        my $toolbar = Gtk2::Toolbar->new;
151
        $toolbar->set_icon_size ('small-toolbar');
152 25 alirezamon
 
153 38 alirezamon
        $toolbar->set_show_arrow (FALSE);
154
 
155
 
156
 
157
 
158
 
159
        $rbtn_generator->set_label ('Generator');
160
        $rbtn_generator->set_icon_widget (def_icon('icons/hardware.png'));
161
        set_tip($rbtn_generator, "ProNoC System Generator");
162
        $toolbar->insert($rbtn_generator,-1);
163
 
164
 
165
 
166
        #________
167
        #radio btn "Simulator"
168
        my $rbtn_simulator = Gtk2::RadioToolButton->new_from_widget($rbtn_generator);
169
        $rbtn_simulator->set_label ('Simulator');
170
        $rbtn_simulator->set_icon_widget (def_icon('icons/simulator.png')) ;
171
 
172
        set_tip($rbtn_simulator, "ProNoC Simulator");
173
        $toolbar->insert($rbtn_simulator,-1);
174
 
175
 
176
 
177
 
178
 
179
        $hb->add($toolbar);
180
        #====================================
181
 
182
        $rbtn_generator->signal_connect('toggled', sub{
183
                open_page($notebook,$noteref,$table,'Generator');
184
 
185
 
186
 
187
        });
188
 
189
        $rbtn_simulator->signal_connect('toggled', sub{
190
                open_page($notebook,$noteref,$table,'Simulator');
191
 
192
 
193
        });
194
 
195
   $table->attach ($hb,0, 1, 0,1,'fill','fill',0,0);
196
   $table->attach_defaults( $notebook, 0, 2, 1,2);
197 25 alirezamon
 
198 38 alirezamon
#$window->add($vbox);
199
$window->add($table);
200 25 alirezamon
 
201
 
202
 
203 17 alirezamon
 
204 16 alirezamon
                $window->set_resizable (1);
205
                $window->show_all();
206
 
207 38 alirezamon
}
208 16 alirezamon
 
209
 
210 38 alirezamon
sub open_page{
211
        my ( $notebook,$noteref,$table,$page_name)=@_;
212
        $notebook->destroy;
213
        ($notebook,$noteref) = generate_main_notebook($page_name);
214
        $table->attach_defaults( $notebook, 0, 2, 1,2);
215
        $table->show_all;
216 16 alirezamon
 
217 38 alirezamon
}
218 16 alirezamon
 
219
 
220 17 alirezamon
sub about {
221
    my $about = Gtk2::AboutDialog->new;
222
    $about->set_authors("Alireza Monemi\n Email: alirezamonemi\@opencores.org");
223 25 alirezamon
    $about->set_version( $VERSION );
224 17 alirezamon
    $about->set_website('http://opencores.org/project,an-fpga-implementation-of-low-latency-noc-based-mpsoc');
225
    $about->set_comments('NoC based MPSoC generator.');
226 25 alirezamon
    $about->set_program_name('ProNoC');
227
 
228 17 alirezamon
    $about->set_license(
229
                 "This program is free software; you can redistribute it\n"
230
                . "and/or modify it under the terms of the GNU General \n"
231
                . "Public License as published by the Free Software \n"
232
                . "Foundation; either version 1, or (at your option)\n"
233
                . "any later version.\n\n"
234
 
235
        );
236 25 alirezamon
        # Add the Hide action to the 'Close' button in the AboutDialog():
237
    $about->signal_connect('response' => sub { $about->hide; });
238
 
239
 
240 17 alirezamon
    $about->run;
241
    $about->destroy;
242
    return;
243
}
244 16 alirezamon
 
245 38 alirezamon
 
246
 
247
sub user_help{
248 17 alirezamon
    my $dir = Cwd::getcwd();
249 38 alirezamon
    my $help="$dir/../../doc/ProNoC_User_manual.pdf";
250 17 alirezamon
    system qq (xdg-open $help);
251
    return;
252
}
253
 
254 38 alirezamon
sub overview{
255 17 alirezamon
    my $dir = Cwd::getcwd();
256 38 alirezamon
    my $help="$dir/../../doc/ProNoC_System_Overview.pdf";
257 17 alirezamon
    system qq (xdg-open $help);
258
    return;
259
 
260
 
261
 
262
}
263
 
264 41 alirezamon
sub setting{
265
        my $reset=shift;
266
        my $project_dir   = get_project_dir(); #mpsoc dir addr
267
        my $paths_file= "$project_dir/mpsoc/perl_gui/lib/Paths";
268 32 alirezamon
 
269 41 alirezamon
        __PACKAGE__->mk_accessors(qw{
270
        PRONOC_WORK
271
        });
272
        my $self;
273
        if (-f  $paths_file ){
274
                $self= do $paths_file;
275
        }else{
276
                $self = __PACKAGE__->new();
277
 
278
        }
279
 
280
 
281
        my $table=def_table(10,10,FALSE);
282
        my $set_win=def_popwin_size(40,80,"Configuration setting",'percent');
283
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
284
        $scrolled_win->set_policy( "automatic", "automatic" );
285
        $scrolled_win->add_with_viewport($table);
286
        my $row=0; my $col=0;
287
 
288
        #title          
289
        my $title=gen_label_in_center("setting");
290
        $table->attach ($title , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
291
        my $separator = Gtk2::HSeparator->new;
292
        $table->attach ($separator , 0, 10 , $row, $row+1,'fill','fill',2,2);    $row++;
293 32 alirezamon
 
294 41 alirezamon
        my @paths = (
295
        { 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 },
296
        { 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 },
297
        { 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
298
simulation models using Modelsim software", param_parent=>'PATH',ref_delay=>undef },
299
                );
300
 
301
 
302
        foreach my $d (@paths) {
303
                #$mpsoc,$name,$param, $default,$type,$content,$info, $table,$row,$column,$show,$attribut1,$ref_delay,$new_status,$loc
304
                ($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");
305
        }
306
 
307
 
308
        my $ok = def_image_button('icons/select.png','OK');
309
        my $mtable = def_table(10, 1, TRUE);
310
 
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
        my $old_pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
318
        my $old_quartus = $self->object_get_attribute("PATH","QUARTUS_BIN");
319
        my $old_modelsim = $self->object_get_attribute("PATH","MODELSIM_BIN");
320
 
321
        $ok->signal_connect("clicked"=> sub{
322
                #save setting
323
                open(FILE,  ">$paths_file") || die "Can not open: $!";
324
                print FILE perl_file_header("Paths");
325
                print FILE Data::Dumper->Dump([\%$self],['setting']);
326
                close(FILE) || die "Error closing file: $!";
327
                my $pronoc_work = $self->object_get_attribute("PATH","PRONOC_WORK");
328
                my $quartus = $self->object_get_attribute("PATH","QUARTUS_BIN");
329
                my $modelsim = $self->object_get_attribute("PATH","MODELSIM_BIN");
330
                make_undef_as_string(\$old_pronoc_work,\$old_quartus,\$old_modelsim,\$pronoc_work,\$quartus,\$modelsim);
331
 
332
                append_text_to_file ("$ENV{HOME}/.bashrc", "\nexport PRONOC_WORK=$pronoc_work\n") if(($old_pronoc_work ne $pronoc_work) || !defined $ENV{PRONOC_WORK}) ;
333
                append_text_to_file ("$ENV{HOME}/.bashrc", "export QUARTUS_BIN=$quartus\n") if($old_quartus ne $quartus) ;
334
                append_text_to_file ("$ENV{HOME}/.bashrc", "export MODELSIM_BIN=$modelsim\n") if($old_modelsim ne $modelsim) ;
335
                set_path_env();
336
                if(($old_pronoc_work ne $pronoc_work) || $old_quartus ne $quartus ||$old_modelsim ne $modelsim){
337
 
338
 
339
 
340
        }
341
 
342
        my  ($file_path,$text)=@_;
343
                $set_win->destroy;
344
                main_window() if($reset);
345
 
346
        });
347
 
348
}
349
 
350 38 alirezamon
sub generate_main_notebook {
351
        my $mode =shift;
352
 
353
        my $notebook = Gtk2::Notebook->new;
354
        $notebook->show_all;
355
        if($mode eq 'Generator'){
356
                my $intfc_gen=  intfc_main();
357
                my $lable1=def_image_label("icons/intfc.png"," Interface generator ");
358
                $notebook->append_page ($intfc_gen,$lable1);#Gtk2::Label->new_with_mnemonic ("  _Interface generator  "));
359
                $lable1->show_all;
360 32 alirezamon
 
361 38 alirezamon
                my $ipgen=ipgen_main();
362
                my $lable2=def_image_label("icons/ip.png"," IP generator ");
363
                $notebook->append_page ($ipgen,$lable2);#Gtk2::Label->new_with_mnemonic ("  _IP generator  "));
364
                $lable2->show_all;
365 17 alirezamon
 
366 38 alirezamon
                my $socgen=socgen_main();
367
                my $lable3=def_image_label("icons/tile.png"," Processing tile generator ");
368
                $notebook->append_page ($socgen,$lable3 );#,Gtk2::Label->new_with_mnemonic ("  _Processing tile generator  "));
369
                $lable3->show_all;
370 17 alirezamon
 
371 38 alirezamon
                my $mpsocgen =mpsocgen_main();
372
                my $lable4=def_image_label("icons/noc.png"," NoC based MPSoC generator ");
373
                $notebook->append_page ($mpsocgen,$lable4);#Gtk2::Label->new_with_mnemonic ("  _NoC based MPSoC generator  ")); 
374
                $lable4->show_all;
375
 
376
 
377
        } else{
378
 
379
 
380
                my $trace_gen= trace_gen_main();
381
                my $lable1=def_image_label("icons/trace.png"," Trace generator ");
382
                #my $lb=Gtk2::Label->new_with_mnemonic (" _Trace generator   ");
383
                set_tip($lable1, "Generate trace file from application task graph");
384
 
385
                $notebook->append_page ($trace_gen,$lable1);
386
                $lable1->show_all;
387
                $trace_gen->show_all;
388
 
389
                my $simulator =simulator_main();
390
                my $lable2=def_image_label("icons/sim.png"," NoC simulator ");
391
 
392
                $notebook->append_page ($simulator,$lable2);#Gtk2::Label->new_with_mnemonic (" _NoC simulator   "));            
393
                $lable2->show_all;
394
                $simulator->show_all;
395 17 alirezamon
 
396 38 alirezamon
                my $emulator =emulator_main();
397
                my $lable3=def_image_label("icons/emul.png"," NoC emulator ");
398
                $notebook->append_page ($emulator,$lable3);#Gtk2::Label->new_with_mnemonic (" _NoC emulator"));                         
399
                $lable3->show_all;
400
                $emulator->show_all;
401
 
402
 
403
 
404
        }
405
 
406
                my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
407
                $scrolled_win->set_policy( "automatic", "automatic" );
408
                $scrolled_win->add_with_viewport($notebook);
409
                $scrolled_win->show_all;
410
 
411
 
412
                return ($scrolled_win,$notebook);
413
 
414 25 alirezamon
}
415
 
416
 
417
 
418 38 alirezamon
 
419
 
420
 
421
 
422
 
423
 
424
 
425
 
426 16 alirezamon
Gtk2->init;
427
main;
428
Gtk2->main();

powered by: WebSVN 2.1.0

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