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/] [lib/] [perl/] [mpsoc_gen.pl] - Blame information for rev 28

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

Line No. Rev Author Line
1 16 alirezamon
#! /usr/bin/perl -w
2
use Glib qw/TRUE FALSE/;
3
use strict;
4
use warnings;
5
 
6
use mpsoc;
7
use soc;
8
use ip;
9
use interface;
10
 
11
use POSIX 'strtol';
12
 
13
use File::Path;
14
use File::Copy;
15
 
16
use Cwd 'abs_path';
17
 
18
 
19
use Gtk2;
20
use Gtk2::Pango;
21
 
22
 
23
 
24
 
25
require "widget.pl";
26
require "mpsoc_verilog_gen.pl";
27 17 alirezamon
require "hdr_file_gen.pl";
28 25 alirezamon
require "readme_gen.pl";
29 28 alirezamon
require "soc_gen.pl";
30 16 alirezamon
 
31 22 alirezamon
sub get_pos{
32
                my ($item,@list)=@_;
33
                my $pos=0;
34
                foreach my $p (@list){
35
                                #print "$p eq $item\n";
36
                                if ($p eq $item){return $pos;}
37
                                $pos++;
38
                }
39
                return undef;
40
 
41
}
42 16 alirezamon
 
43 22 alirezamon
 
44 16 alirezamon
sub noc_param_widget{
45 25 alirezamon
         my ($mpsoc,$name,$param, $default,$type,$content,$info, $table,$row,$show,$attribut1,$ref_delay)=@_;
46 16 alirezamon
         my $label =gen_label_in_left(" $name");
47
         my $widget;
48 25 alirezamon
         my $value=$mpsoc->object_get_attribute($attribut1,$param);
49 16 alirezamon
         if(! defined $value) {
50 25 alirezamon
                        $mpsoc->object_add_attribute($attribut1,$param,$default);
51
                        $mpsoc->object_add_attribute_order($attribut1,$param);
52 16 alirezamon
                        $value=$default;
53
         }
54 28 alirezamon
 
55 16 alirezamon
         if ($type eq "Entry"){
56
                $widget=gen_entry($value);
57
                $widget-> signal_connect("changed" => sub{
58
                        my $new_param_value=$widget->get_text();
59 25 alirezamon
                        $mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
60 28 alirezamon
                        set_gui_status($mpsoc,"ref",$ref_delay) if(defined $ref_delay);
61 25 alirezamon
 
62 16 alirezamon
 
63
                });
64
 
65
 
66
         }
67
         elsif ($type eq "Combo-box"){
68
                 my @combo_list=split(",",$content);
69 25 alirezamon
                 my $pos=get_pos($value, @combo_list) if(defined $value);
70 22 alirezamon
                 if(!defined $pos){
71 25 alirezamon
                        $mpsoc->object_add_attribute($attribut1,$param,$default);
72
                        $pos=get_item_pos($default, @combo_list) if (defined $default);
73 22 alirezamon
 
74
                 }
75 16 alirezamon
                #print " my $pos=get_item_pos($value, @combo_list);\n";
76
                 $widget=gen_combo(\@combo_list, $pos);
77
                 $widget-> signal_connect("changed" => sub{
78
                 my $new_param_value=$widget->get_active_text();
79 25 alirezamon
                 $mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
80 28 alirezamon
                 set_gui_status($mpsoc,"ref",$ref_delay) if(defined $ref_delay);
81 16 alirezamon
 
82
 
83
                 });
84
 
85
         }
86
         elsif  ($type eq "Spin-button"){
87
                  my ($min,$max,$step)=split(",",$content);
88
                  $value=~ s/\D//g;
89
                  $min=~ s/\D//g;
90
                  $max=~ s/\D//g;
91
                  $step=~ s/\D//g;
92
                  $widget=gen_spin($min,$max,$step);
93
                  $widget->set_value($value);
94 24 alirezamon
                  $widget-> signal_connect("value_changed" => sub{
95 16 alirezamon
                  my $new_param_value=$widget->get_value_as_int();
96 25 alirezamon
                  $mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
97 28 alirezamon
                  set_gui_status($mpsoc,"ref",$ref_delay) if(defined $ref_delay);
98 16 alirezamon
 
99
                  });
100
 
101
                 # $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
102
         }
103
 
104
        elsif ( $type eq "Check-box"){
105
                $widget = def_hbox(FALSE,0);
106
                my @check;
107
                for (my $i=0;$i<$content;$i++){
108
                        $check[$i]= Gtk2::CheckButton->new;
109
                }
110
                for (my $i=0;$i<$content;$i++){
111
                        $widget->pack_end(  $check[$i], FALSE, FALSE, 0);
112
 
113
                        my @chars = split("",$value);
114
                        #check if saved value match the size of check box
115
                        if($chars[0] ne $content ) {
116 25 alirezamon
                                $mpsoc->object_add_attribute($attribut1,$param,$default);
117 16 alirezamon
                                $value=$default;
118
                                @chars = split("",$value);
119
                        }
120
                        #set initial value
121
 
122
                        #print "\@chars=@chars\n";
123
                        for (my $i=0;$i<$content;$i++){
124
                                my $loc= (scalar @chars) -($i+1);
125
                                        if( $chars[$loc] eq '1') {$check[$i]->set_active(TRUE);}
126
                                        else {$check[$i]->set_active(FALSE);}
127
                        }
128
 
129
 
130
                        #get new value
131
                        $check[$i]-> signal_connect("toggled" => sub{
132
                                my $new_val="$content\'b";
133
 
134
                                for (my $i=$content-1; $i >= 0; $i--){
135
                                        if($check[$i]->get_active()) {$new_val="${new_val}1" ;}
136
                                        else {$new_val="${new_val}0" ;}
137
                                }
138 25 alirezamon
                                $mpsoc->object_add_attribute($attribut1,$param,$new_val);
139 16 alirezamon
                                #print "\$new_val=$new_val\n";
140 28 alirezamon
                                set_gui_status($mpsoc,"ref",$ref_delay) if(defined $ref_delay);
141 16 alirezamon
                        });
142
                }
143
 
144
 
145
 
146
 
147
        }
148 25 alirezamon
        elsif ( $type eq "DIR_path"){
149
                        $widget =get_dir_in_object ($mpsoc,$attribut1,$param,$value,'ref',10);
150 28 alirezamon
                        set_gui_status($mpsoc,"ref",$ref_delay) if(defined $ref_delay);
151 25 alirezamon
        }
152
 
153
 
154
 
155 16 alirezamon
        else {
156
                 $widget =gen_label_in_left("unsuported widget type!");
157
        }
158
 
159
        my $inf_bt= gen_button_message ($info,"icons/help.png");
160
        if($show==1){
161 28 alirezamon
                attach_widget_to_table ($table,$row,$label,$inf_bt,$widget);
162 16 alirezamon
                $row++;
163
        }
164
    return $row;
165
}
166
 
167 28 alirezamon
sub attach_widget_to_table {
168
        my ($table,$row,$label,$inf_bt,$widget)=@_;
169
        my $tmp=gen_label_in_left(" ");
170
        $table->attach  ($label , 0, 4,  $row,$row+1,'fill','shrink',2,2);
171
        $table->attach  ($inf_bt , 4, 5, $row,$row+1,'fill','shrink',2,2);
172
        $table->attach  ($widget , 5, 9, $row,$row+1,'fill','shrink',2,2);
173
        $table->attach  ($tmp , 9, 10, $row,$row+1,'fill','shrink',2,2);
174
}
175 16 alirezamon
 
176 28 alirezamon
 
177 16 alirezamon
sub initial_default_param{
178
        my $mpsoc=shift;
179
        my @socs=$mpsoc->mpsoc_get_soc_list();
180
        foreach my $soc_name (@socs){
181
                my %param_value;
182
                my $top=$mpsoc->mpsoc_get_soc($soc_name);
183
                my @insts=$top->top_get_all_instances();
184
                my @exceptions=('ni0');
185
                @insts=get_diff_array(\@insts,\@exceptions);
186
                foreach my $inst (@insts){
187
                        my @params=$top->top_get_parameter_list($inst);
188
                        foreach my $p (@params){
189
                                my  ($default,$type,$content,$info,$global_param,$redefine)=$top->top_get_parameter($inst,$p);
190
                                $param_value{$p}=$default;
191
                        }
192
                }
193
                $top->top_add_default_soc_param(\%param_value);
194
        }
195
 
196
}
197
 
198
#############
199
#       get_soc_lists
200
############
201
 
202
sub get_soc_list {
203 25 alirezamon
        my ($mpsoc,$info)=@_;
204 16 alirezamon
 
205 25 alirezamon
 
206
        my $path=$mpsoc->object_get_attribute('setting','soc_path');
207
 
208 18 alirezamon
        $path =~ s/ /\\ /g;
209
        my @socs;
210 16 alirezamon
        my @files = glob "$path/*.SOC";
211
        for my $p (@files){
212
 
213
                # Read
214
                my  $soc = eval { do $p };
215 25 alirezamon
                 if ($@ || !defined $soc){
216
                        add_info(\$info,"**Error reading  $p file: $@\n");
217
                         next;
218
                }
219 16 alirezamon
                my $top=$soc->soc_get_top();
220
                if (defined $top){
221
                        my @instance_list=$top->top_get_all_instances();
222
                        #check if the soc has ni port
223
                        foreach my $instanc(@instance_list){
224
                                my $module=$top->top_get_def_of_instance($instanc,'module');
225
                                if($module eq 'ni')
226
                                {
227 25 alirezamon
                                        my $name=$soc->object_get_attribute('soc_name');
228 16 alirezamon
                                        $mpsoc->mpsoc_add_soc($name,$top);
229
                                        #print" $name\n";
230
                                }
231
                        }
232
 
233
                }
234
 
235
 
236
 
237
 
238
 
239
 
240
 
241
 
242
        }#files
243
 
244
        # initial  default soc parameter
245
        initial_default_param($mpsoc);
246
 
247
 
248
 
249
        return $mpsoc->mpsoc_get_soc_list;
250
 
251
 
252
 
253
}
254
####################
255
# get_conflict_decision
256
###########################
257
sub b_box{
258
# create a new button
259
        my @label=@_;
260
        my $button = Gtk2::Button->new_from_stock(@label);
261
        my $box=def_vbox(FALSE,5);
262
        $box->pack_start($button,   FALSE, FALSE,0);
263
 
264
        return ($box,$button);
265
 
266
}
267
 
268
sub get_conflict_decision{
269 25 alirezamon
        my ($mpsoc,$name,$inserted,$conflicts,$msg)=@_;
270 17 alirezamon
        $msg="\tThe inserted tile number(s) have been mapped previously to \n\t\t\"$msg\".\n\tDo you want to remove the conflicted tiles number(s) in newly \n\tinsterd range or remove them from the previous ones? ";
271 16 alirezamon
 
272
        my $wind=def_popwin_size(100,300,"warning");
273
        my $label= gen_label_in_left($msg);
274
        my $table=def_table(2,6,FALSE);
275
        $table->attach_defaults ($label , 0, 6, 0,1);
276
        $wind->add($table);
277
 
278
        my ($box1,$b1)= b_box("Remove Previous");
279
        my ($box2,$b2)= b_box("Remove Current");
280
        my ($box3,$b3)= b_box("Cancel");
281
 
282
        $table->attach_defaults ($box1 , 0, 1, 1,2);
283
        $table->attach_defaults ($box2 , 3, 4, 1,2);
284
        $table->attach_defaults ($box3 , 5, 6, 1,2);
285
 
286
        $wind->show_all();
287
 
288
        $b1->signal_connect( "clicked"=> sub{ #Remove Previous
289
                my @socs=$mpsoc->mpsoc_get_soc_list();
290
                foreach my $p (@socs){
291
                        if($p ne $name){
292
                                my @taken_tiles=$mpsoc->mpsoc_get_soc_tiles_num($p);
293
                                my @diff=get_diff_array(\@taken_tiles,$inserted);
294
                                $mpsoc->mpsoc_add_soc_tiles_num($p,\@diff) if(scalar @diff  );
295
                                $mpsoc->mpsoc_add_soc_tiles_num($p,undef) if(scalar @diff ==0 );
296
                        }
297
                }
298
                $mpsoc->mpsoc_add_soc_tiles_num($name,$inserted) if(defined $inserted  );
299 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
300 16 alirezamon
                $wind->destroy();
301
 
302
        });
303
 
304
        $b2->signal_connect( "clicked"=> sub{#Remove Current
305
                my @new= get_diff_array($inserted,$conflicts);
306
                $mpsoc->mpsoc_add_soc_tiles_num($name,\@new) if(scalar @new  );
307
                $mpsoc->mpsoc_add_soc_tiles_num($name,undef) if(scalar @new ==0 );
308 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
309 16 alirezamon
                $wind->destroy();
310
 
311
        });
312
 
313
        $b3->signal_connect( "clicked"=> sub{
314
                $wind->destroy();
315
 
316
        });
317
 
318
}
319
 
320
 
321
 
322
#############
323
#       check_inserted_ip_nums
324
##########
325
 
326
 
327
sub check_inserted_ip_nums{
328 25 alirezamon
        my  ($mpsoc,$name,$str)=@_;
329 16 alirezamon
        my @all_num=();
330
        $str= remove_all_white_spaces ($str);
331
 
332
        if($str !~ /^[0-9.:,]+$/){ message_dialog ("The Ip numbers contains invalid character" ); return; }
333
        my @chunks=split(',',$str);
334
        foreach my $p (@chunks){
335
                my @range=split(':',$p);
336
                my $size= scalar @range;
337
                if($size==1){ # its a number
338
                        if ( grep( /^$range[0]$/, @all_num ) ) { message_dialog ("Multiple definition for Ip number $range[0]" ); return; }
339
                        push(@all_num,$range[0]);
340
                }elsif($size ==2){# its a range
341
                        my($min,$max)=@range;
342
                        if($min>$max) {message_dialog ("invalid range: [$p]" ); return;}
343
                        for (my $i=$min; $i<=$max; $i++){
344
                                if ( grep( /^$i$/, @all_num ) ) { message_dialog ("Multiple definition for Ip number $i in $p" ); return; }
345
                                push(@all_num,$i);
346
 
347
                        }
348
 
349
                }else{message_dialog ("invalid range: [$p]" ); return; }
350
 
351
        }
352
        #check if range does not exceed the tile numbers
353 25 alirezamon
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
354
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
355 16 alirezamon
 
356
        my $max_tile_num=$nx*$ny;
357
        my @f=sort { $a <=> $b }  @all_num;
358
        my @l;
359
        foreach my $num (@f){
360
                push(@l,$num) if($num<$max_tile_num);
361
 
362
        }
363
        @all_num=@l;
364
 
365
        #check if any ip number exists in the rest
366
        my $conflicts_msg;
367
        my @conflicts;
368
 
369
 
370
        my @socs=$mpsoc->mpsoc_get_soc_list();
371
        foreach my $p (@socs){
372
                if($p ne $name){
373
                        my @taken_tiles=$mpsoc->mpsoc_get_soc_tiles_num($p);
374
                        my @c=get_common_array(\@all_num,\@taken_tiles);
375
                        if (scalar @c) {
376
                                my $str=join(',', @c);
377 17 alirezamon
                                $conflicts_msg = (defined $conflicts_msg)? "$conflicts_msg\n\t\t $str->$p" : "$str->$p";
378 16 alirezamon
                                @conflicts= (defined $conflicts_msg)? (@conflicts,@c): @c;
379
                        }
380
                }#if
381
        }
382
        if (defined $conflicts_msg) {
383 25 alirezamon
                get_conflict_decision($mpsoc,$name,\@all_num,\@conflicts,$conflicts_msg);
384 16 alirezamon
 
385
        }else {
386
                #save the entered ips
387
                if( scalar @all_num>0){ $mpsoc->mpsoc_add_soc_tiles_num($name,\@all_num);}
388
                else {$mpsoc->mpsoc_add_soc_tiles_num($name,undef);}
389 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
390 16 alirezamon
        }
391
 
392
 
393
 
394
}
395
 
396
 
397
 
398
 
399
#################
400
# get_soc_parameter_setting
401
################
402
 
403
sub get_soc_parameter_setting{
404 25 alirezamon
        my ($mpsoc,$soc_name,$tile)=@_;
405 16 alirezamon
 
406
        my $window = (defined $tile)? def_popwin_size(600,400,"Parameter setting for $soc_name located in tile($tile) "):def_popwin_size(600,400,"Default Parameter setting for $soc_name ");
407
        my $table = def_table(10, 7, TRUE);
408
 
409
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
410
        $scrolled_win->set_policy( "automatic", "automatic" );
411
        $scrolled_win->add_with_viewport($table);
412
        my $row=0;
413
 
414
        my $top=$mpsoc->mpsoc_get_soc($soc_name);
415
 
416
        #read soc parameters
417
        my %param_value=(defined $tile) ? $top->top_get_custom_soc_param($tile)  : $top->top_get_default_soc_param();
418
 
419
 
420
 
421
        my @insts=$top->top_get_all_instances();
422
        my @exceptions=('ni0');
423
        @insts=get_diff_array(\@insts,\@exceptions);
424
        foreach my $inst (@insts){
425
                my @params=$top->top_get_parameter_list($inst);
426
                foreach my $p (@params){
427
                        my  ($default,$type,$content,$info,$global_param,$redefine)=$top->top_get_parameter($inst,$p);
428
 
429
                        if ($type eq "Entry"){
430
                                my $entry=gen_entry($param_value{$p});
431
                                $table->attach_defaults ($entry, 3, 6, $row, $row+1);
432
                                $entry-> signal_connect("changed" => sub{$param_value{$p}=$entry->get_text();});
433
                        }
434
                        elsif ($type eq "Combo-box"){
435
                                my @combo_list=split(",",$content);
436 25 alirezamon
                                my $pos=get_item_pos($param_value{$p}, @combo_list) if(defined $param_value{$p});
437 16 alirezamon
                                my $combo=gen_combo(\@combo_list, $pos);
438
                                $table->attach_defaults ($combo, 3, 6, $row, $row+1);
439
                                $combo-> signal_connect("changed" => sub{$param_value{$p}=$combo->get_active_text();});
440
 
441
                        }
442
                        elsif   ($type eq "Spin-button"){
443
                                my ($min,$max,$step)=split(",",$content);
444
                                $param_value{$p}=~ s/\D//g;
445
                                $min=~ s/\D//g;
446
                                $max=~ s/\D//g;
447
                                $step=~ s/\D//g;
448
                                my $spin=gen_spin($min,$max,$step);
449
                                $spin->set_value($param_value{$p});
450
                                $table->attach_defaults ($spin, 3, 4, $row, $row+1);
451 24 alirezamon
                                $spin-> signal_connect("value_changed" => sub{$param_value{$p}=$spin->get_value_as_int();});
452 16 alirezamon
 
453
                 # $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
454
                        }
455
                        my $label =gen_label_in_center($p);
456
                        $table->attach_defaults ($label, 0, 3, $row, $row+1);
457
                        if (defined $info){
458
                        my $info_button=def_image_button('icons/help.png');
459
                        $table->attach_defaults ($info_button, 6, 7, $row, $row+1);
460
                        $info_button->signal_connect('clicked'=>sub{
461
                                message_dialog($info);
462
 
463
                        });
464
 
465
                }
466
 
467
                        $row++;
468
 
469
 
470
                }
471
        }
472
 
473
 
474
 
475
 
476
 
477
 
478
 
479
 
480
 
481
 
482
 
483
 
484
 
485
 
486
 
487
 
488
 
489
 
490
 
491
 
492
 
493 25 alirezamon
 
494 16 alirezamon
        my $ok = def_image_button('icons/select.png','OK');
495
        my $okbox=def_hbox(TRUE,0);
496
        $okbox->pack_start($ok, FALSE, FALSE,0);
497
 
498
 
499
        my $mtable = def_table(10, 1, TRUE);
500
 
501
        $mtable->attach_defaults($scrolled_win,0,1,0,9);
502
        $mtable->attach_defaults($okbox,0,1,9,10);
503
 
504
        $window->add ($mtable);
505
        $window->show_all();
506
 
507
        $ok-> signal_connect("clicked" => sub{
508
                $window->destroy;
509
                #save new values 
510
                if(!defined $tile ) {
511
                        $top->top_add_default_soc_param(\%param_value);
512
                }
513
                else {
514
                        $top->top_add_custom_soc_param(\%param_value,$tile);
515
 
516
                }
517 25 alirezamon
                #set_gui_status($mpsoc,"refresh_soc",1);
518 16 alirezamon
                #$$refresh_soc->clicked;
519
 
520
                });
521
 
522
 
523
 
524
}
525
 
526
 
527
 
528
 
529
 
530
 
531
 
532
################
533
#       tile_set_widget
534
################
535
 
536
sub tile_set_widget{
537 25 alirezamon
        my ($mpsoc,$soc_name,$num,$table,$show,$row)=@_;
538 16 alirezamon
        #my $lable=gen_label_in_left($soc);
539
        my @all_num= $mpsoc->mpsoc_get_soc_tiles_num($soc_name);
540
        my $init=compress_nums(@all_num);
541
        my $entry;
542
        if (defined $init){$entry=gen_entry($init) ;}
543
        else                      {$entry=gen_entry();}
544
        my $set= def_image_button('icons/right.png');
545
        my $remove= def_image_button('icons/cancel.png');
546
        #my $setting= def_image_button('icons/setting.png','setting');
547
 
548
 
549
        my $button = def_colored_button($soc_name,$num);
550
        $button->signal_connect("clicked"=> sub{
551 25 alirezamon
                get_soc_parameter_setting($mpsoc,$soc_name,undef);
552 16 alirezamon
 
553
        });
554
 
555
 
556
        $set->signal_connect("clicked"=> sub{
557
                my $data=$entry->get_text();
558 25 alirezamon
                check_inserted_ip_nums($mpsoc,$soc_name,$data);
559 16 alirezamon
 
560
 
561
 
562
        });
563
        $remove->signal_connect("clicked"=> sub{
564
                $mpsoc->mpsoc_remove_soc($soc_name);
565 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
566 16 alirezamon
 
567
        });
568
 
569
 
570
if($show){
571
        $table->attach_defaults ( $button, 0, 4, $row,$row+1);
572
        $table->attach_defaults ( $remove, 4, 5, $row,$row+1);
573
        $table->attach_defaults ( $entry , 5, 9, $row,$row+1);
574
        $table->attach_defaults ( $set, 9, 10, $row,$row+1);
575
 
576
 
577
 
578
        $row++;
579
}
580
 
581
        return $row;
582
 
583
 
584
}
585
 
586
 
587
 
588
 
589
 
590
##################
591
#       defualt_tilles_setting
592
###################
593
 
594
sub defualt_tilles_setting {
595 25 alirezamon
        my ($mpsoc,$table,$show,$row,$info)=@_;
596 16 alirezamon
 
597
        #title  
598
        my $separator1 = Gtk2::HSeparator->new;
599
        my $separator2 = Gtk2::HSeparator->new;
600
        my $title2=gen_label_in_center("Tile Configuration");
601
        my $box1=def_vbox(FALSE, 1);
602
        $box1->pack_start( $separator1, FALSE, FALSE, 3);
603
        $box1->pack_start( $title2, FALSE, FALSE, 3);
604
        $box1->pack_start( $separator2, FALSE, FALSE, 3);
605
        if($show){$table->attach_defaults ($box1 ,0,10, $row,$row+1);$row++;}
606
 
607
 
608
 
609
 
610
        my $label = gen_label_in_left("Tiles path:");
611
        my $entry = Gtk2::Entry->new;
612
        my $browse= def_image_button("icons/browse.png");
613 25 alirezamon
        my $file= $mpsoc->object_get_attribute('setting','soc_path');
614 16 alirezamon
        if(defined $file){$entry->set_text($file);}
615
 
616
 
617
        $browse->signal_connect("clicked"=> sub{
618
                my $entry_ref=$_[1];
619
                my $file;
620
 
621
 
622
 
623
 
624
 
625
        my $dialog = Gtk2::FileChooserDialog->new(
626
                'Select tile directory', undef,
627
                #               'open',
628
                'select-folder',
629
                'gtk-cancel' => 'cancel',
630
                'gtk-ok'     => 'ok',
631
                );
632
 
633
 
634
                if ( "ok" eq $dialog->run ) {
635
                        $file = $dialog->get_filename;
636
                        $$entry_ref->set_text($file);
637 25 alirezamon
                        $mpsoc->object_add_attribute('setting','soc_path',$file);
638 16 alirezamon
                        $mpsoc->mpsoc_remove_all_soc();
639 25 alirezamon
                        set_gui_status($mpsoc,"ref",1);
640
                        #check_input_file($file,$socgen,$info);
641 16 alirezamon
                        #print "file = $file\n";
642
                 }
643
                $dialog->destroy;
644
 
645
 
646
 
647
        } , \$entry);
648
 
649
 
650
 
651
 
652
        $entry->signal_connect("activate"=>sub{
653
                my $file_name=$entry->get_text();
654 25 alirezamon
                $mpsoc->object_add_attribute('setting','soc_path',$file_name);
655 16 alirezamon
                $mpsoc->mpsoc_remove_all_soc();
656 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
657
                #check_input_file($file_name,$socgen,$info);
658 16 alirezamon
        });
659
 
660
 
661
 
662
        if($show){
663
                my $tmp=gen_label_in_left(" ");
664
                $table->attach_defaults ($label, 0, 4 , $row,$row+1);
665
                $table->attach_defaults ($tmp, 4, 5 , $row,$row+1);
666
                $table->attach_defaults ($entry, 5, 9 , $row,$row+1);
667
                $table->attach_defaults ($browse, 9, 10, $row,$row+1);
668
                $row++;
669
        }
670
 
671
 
672
 
673
        my @socs=$mpsoc->mpsoc_get_soc_list();
674
        if( scalar @socs == 0){
675 25 alirezamon
                @socs=get_soc_list($mpsoc,$info);
676 16 alirezamon
 
677
        }
678
        @socs=$mpsoc->mpsoc_get_soc_list();
679
 
680
 
681
 
682
        my $lab1=gen_label_in_center(' Tile name');
683
 
684
        my $lab2=gen_label_help('Define the tile numbers that each IP is mapped to.
685
you can add individual numbers or ranges as follow
686
        eg: 0,2,5:10
687
        ', ' Tile numbers ');
688
        if($show){
689
                $table->attach_defaults ($lab1 ,0,3, $row,$row+1);
690
                $table->attach_defaults ($lab2 ,5,10, $row,$row+1);$row++;
691 25 alirezamon
        }
692 16 alirezamon
 
693
        my $soc_num=0;
694
        foreach my $soc_name (@socs){
695 25 alirezamon
                $row=tile_set_widget ($mpsoc,$soc_name,$soc_num,$table,$show,$row);
696
                $soc_num++;
697 16 alirezamon
 
698 25 alirezamon
        }
699 16 alirezamon
        return $row;
700
 
701
}
702
 
703
 
704
 
705
 
706
#######################
707
#   noc_config
708
######################
709
 
710
sub noc_config{
711 25 alirezamon
        my ($mpsoc,$table)=@_;
712
 
713 16 alirezamon
 
714
 
715
        #title  
716
        my $title=gen_label_in_center("NoC Configuration");
717
        my $box=def_vbox(FALSE, 1);
718
        $box->pack_start( $title, FALSE, FALSE, 3);
719
        my $separator = Gtk2::HSeparator->new;
720
        $box->pack_start( $separator, FALSE, FALSE, 3);
721
        $table->attach_defaults ($box , 0, 10, 0,1);
722
 
723
        my $label;
724
        my $param;
725
        my $default;
726
        my $type;
727
        my $content;
728
        my $info;
729
        my $row=1;
730
 
731
        #parameter start
732
        my $b1;
733 25 alirezamon
        my $show_noc=$mpsoc->object_get_attribute('setting','show_noc_setting');
734
        if(!defined $show_noc){
735
                $show_noc=1;
736
                $mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
737
 
738
        }
739 16 alirezamon
        if($show_noc == 0){
740
                $b1= def_image_button("icons/down.png","NoC Parameters");
741
                $label=gen_label_in_center(' ');
742
                $table->attach_defaults ( $label , 2, 10, $row,$row+1);
743
                $table->attach_defaults ( $b1 , 0, 4, $row,$row+1);$row++;
744
        }
745
 
746 22 alirezamon
 
747
        #Router type
748
        $label='Router Type';
749
        $param='ROUTER_TYPE';
750
        $default='"VC_BASED"';
751
        $content='"INPUT_QUEUED","VC_BASED"';
752
        $type='Combo-box';
753
    $info="    Input-queued: simple router with low performance and does not support fully adaptive routing.
754
    VC-based routers offer higher performance, fully adaptive routing  and traffic isolation for different packet classes.";
755 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_type',1);
756 25 alirezamon
        my $router_type=$mpsoc->object_get_attribute('noc_type',"ROUTER_TYPE");
757 22 alirezamon
 
758 25 alirezamon
 
759 16 alirezamon
 
760
        #Routers per row
761
        $label= 'Routers per row';
762
        $param= 'NX';
763
    $default=' 2';
764
        $content='2,16,1';
765
    $info= 'Number of NoC routers in row (X dimention)';
766
    $type= 'Spin-button';
767 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
768 16 alirezamon
 
769
 
770
 
771
        #Routers per column
772
        $label= 'Routers per column';
773
        $param= 'NY';
774
    $default=' 2';
775
        $content='2,16,1';
776
    $info= 'Number of NoC routers in column (Y dimention)';
777
    $type= 'Spin-button';
778 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
779 16 alirezamon
 
780 22 alirezamon
        if($router_type eq '"VC_BASED"'){
781
                #VC number per port
782 25 alirezamon
                my $v=$mpsoc->object_get_attribute('noc_param','V');
783
                if(defined $v){ $mpsoc->object_add_attribute('noc_param','V',2) if($v eq 1);}
784 22 alirezamon
                $label='VC number per port';
785
                $param='V';
786
                $default='2';
787
                $type='Spin-button';
788
                $content='2,16,1';
789
                $info='Number of Virtual Channel per each router port';
790 28 alirezamon
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
791 22 alirezamon
        } else {
792 25 alirezamon
                $mpsoc->object_add_attribute('noc_param','V',1);
793
                $mpsoc->object_add_attribute('noc_param','C',0);
794 22 alirezamon
 
795
 
796
        }
797
 
798 16 alirezamon
        #buffer width per VC
799 22 alirezamon
        $label=($router_type eq '"VC_BASED"')? 'Buffer flits per VC': "Buffer flits";
800 16 alirezamon
        $param='B';
801
    $default='4';
802
    $content='2,256,1';
803
    $type='Spin-button';
804 22 alirezamon
        $info=($router_type eq '"VC_BASED"')?  'Buffer queue size per VC in flits' : 'Buffer queue size in flits';
805 28 alirezamon
    $row= noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',undef);
806 16 alirezamon
 
807
        #packet payload width
808
        $label='payload width';
809
        $param='Fpay';
810
        $default='32';
811
        $content='32,256,32';
812
        $type='Spin-button';
813
    $info="The packet payload width in bits";
814 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,$show_noc,'noc_param',undef);
815 16 alirezamon
 
816
        #topology
817
        $label='Topology';
818
        $param='TOPOLOGY';
819
        $default='"MESH"';
820
        $content='"MESH","TORUS"';
821
        $type='Combo-box';
822
    $info="NoC topology";
823 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
824 16 alirezamon
 
825
        #routing algorithm
826 25 alirezamon
        my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
827 16 alirezamon
        $label='Routing Algorithm';
828
        $param="ROUTE_NAME";
829
        $type="Combo-box";
830 22 alirezamon
        if($router_type eq '"VC_BASED"'){
831
                $content=($topology eq '"MESH"')?  '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","DUATO"' :
832
                                                    '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST","TRANC_DUATO"';
833
 
834
        }else{
835
                $content=($topology eq '"MESH"')?  '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST"' :
836
                                                    '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST"';
837
 
838
 
839
        }
840 16 alirezamon
        $default=($topology eq '"MESH"')?  '"XY"':'"TRANC_XY"';
841
        $info="Select the routing algorithm: XY(DoR) , partially adaptive (Turn models). Fully adaptive (Duato) ";
842 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
843 16 alirezamon
 
844
 
845 25 alirezamon
        #SSA
846
        $label='SSA Ebable';
847
        $param='SSA_EN';
848
        $default='"NO"';
849
        $content='"YES","NO"';
850
        $type='Combo-box';
851 28 alirezamon
        $info="Enable single cycle latency on packets traversing in the same direction using static straight allocator (SSA)";
852
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',undef);
853 25 alirezamon
 
854
 
855
 
856
 
857
 
858 16 alirezamon
        if($show_noc == 1){
859
                $b1= def_image_button("icons/up.png","NoC Parameters");
860
                $table->attach_defaults ( $b1 , 0, 2, $row,$row+1);$row++;
861
        }
862
        $b1->signal_connect("clicked" => sub{
863
                $show_noc=($show_noc==1)?0:1;
864 25 alirezamon
                $mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
865
                set_gui_status($mpsoc,"ref",1);
866 16 alirezamon
 
867
        });
868
 
869
        #advance parameter start
870
        my $advc;
871 25 alirezamon
        my $adv_set=$mpsoc->object_get_attribute('setting','show_adv_setting');
872 16 alirezamon
        if($adv_set == 0){
873
                $advc= def_image_button("icons/down.png","Advance Parameters");
874
                $table->attach_defaults ( $advc , 0, 4, $row,$row+1);$row++;
875
 
876
        }
877
 
878
 
879
 
880
        #Fully and partially adaptive routing setting
881 25 alirezamon
                my $route=$mpsoc->object_get_attribute('noc_param',"ROUTE_NAME");
882 16 alirezamon
                if($route ne '"XY"' and $route ne '"TRANC_XY"' ){
883
                        $label="Congestion index";
884
                        $param="CONGESTION_INDEX";
885
                        $type="Spin-button";
886
                        $content="0,12,1";
887
                        $info="Congestion index determines how congestion information is collected from neighboring routers. Please refer to the usere manual for more information";
888 22 alirezamon
                    $default=3;
889 28 alirezamon
                        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
890 16 alirezamon
 
891
                }
892 22 alirezamon
                #Fully adaptive routing setting
893
                if( $route eq '"TRANC_DUATO"' or $route eq '"DUATO"'  ){
894 25 alirezamon
                         my $v=$mpsoc->object_get_attribute('noc_param',"V");
895 22 alirezamon
                         $label="Select Escap VC";
896
                         $param="ESCAP_VC_MASK";
897
                         $type="Check-box";
898
                         $content=$v;
899
                         $default="$v\'b";
900
                         for (my $i=1; $i<=$v-1; $i++){$default=  "${default}0";}
901
                         $default=  "${default}1";
902
 
903 16 alirezamon
 
904 22 alirezamon
                         $info="Select the escap VC for fully adaptive routing.";
905 28 alirezamon
                         $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set, 'noc_param',undef);
906 22 alirezamon
 
907
                 }
908
 
909 16 alirezamon
        # VC reallocation type
910 22 alirezamon
                $label=($router_type eq '"VC_BASED"')? 'VC reallocation type': 'Queue reallocation type';
911 16 alirezamon
                $param='VC_REALLOCATION_TYPE';
912 22 alirezamon
                $info="VC reallocation type: If set as atomic only empty VCs can be allocated for new packets. Whereas, in non-atomic a non-empty VC which has received the last packet tail flit can accept a new  packet";
913 16 alirezamon
                $default='"NONATOMIC"';
914
                $content='"ATOMIC","NONATOMIC"';
915
                $type='Combo-box';
916 28 alirezamon
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
917 16 alirezamon
 
918
 
919
 
920
 
921 22 alirezamon
        if ($router_type eq '"VC_BASED"'){
922 16 alirezamon
        #vc/sw allocator type
923
                $label = 'VC/SW combination type';
924
                $param='COMBINATION_TYPE';
925 22 alirezamon
                $default='"COMB_NONSPEC"';
926 16 alirezamon
                $content='"BASELINE","COMB_SPEC1","COMB_SPEC2","COMB_NONSPEC"';
927
                $type='Combo-box';
928
                $info="The joint VC/ switch allocator type. using canonical combination is not recommanded";
929 28 alirezamon
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
930 16 alirezamon
 
931 22 alirezamon
        }
932
 
933 16 alirezamon
        # Crossbar mux type 
934
                $label='Crossbar mux type';
935
                $param='MUX_TYPE';
936
                $default='"BINARY"';
937
                $content='"ONE_HOT","BINARY"';
938
                $type='Combo-box';
939
                $info="Crossbar multiplexer type";
940 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
941 16 alirezamon
 
942 22 alirezamon
        if($router_type eq '"VC_BASED"'){
943 16 alirezamon
        #class
944
                $label='class number';
945
                $param='C';
946
                $default= 0;
947
                $info='Number of message classes. Each specific class can use different set of VC';
948
                $content='0,16,1';
949
            $type='Spin-button';
950 28 alirezamon
            $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',5);
951 16 alirezamon
 
952
 
953 25 alirezamon
                my $class=$mpsoc->object_get_attribute('noc_param',"C");
954
                my $v=$mpsoc->object_get_attribute('noc_param',"V");
955 16 alirezamon
                $default= "$v\'b";
956
                for (my $i=1; $i<=$v; $i++){
957
                        $default=  "${default}1";
958
                }
959
                #print "\$default=$default\n";
960
                for (my $i=0; $i<=$class-1; $i++){
961
 
962
                         $label="Class $i Permitted VCs";
963
                         $param="Cn_$i";
964
                         $type="Check-box";
965
                         $content=$v;
966
                         $info="Select the permitted VCs which the message class $i can be sent via them.";
967 28 alirezamon
                         $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
968 16 alirezamon
 
969
 
970
                }
971
 
972
 
973 22 alirezamon
 
974
        }#($router_type eq '"VC_BASED"')
975 16 alirezamon
 
976 22 alirezamon
 
977 16 alirezamon
 
978
         #simulation debuge enable     
979
                $label='Debug enable';
980
                $param='DEBUG_EN';
981
                $info= "Add extra verilog code for debuging NoC for simulation";
982
                $default='0';
983
                $content='0,1';
984
                $type='Combo-box';
985 25 alirezamon
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
986 16 alirezamon
 
987
 
988
 
989
 
990
 
991
        $label="Add pipeline reg after crossbar";
992
        $param="ADD_PIPREG_AFTER_CROSSBAR";
993
        $type="Check-box";
994
        $content=1;
995
        $default="1\'b0";
996
        $info="If ebabled it adds a pipline register at the output port of the router.";
997 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
998 16 alirezamon
 
999
 
1000 25 alirezamon
 
1001 16 alirezamon
 
1002
 
1003
 
1004
        if($adv_set == 1){
1005
                $advc= def_image_button("icons/up.png","Advance Parameters");
1006
                $table->attach_defaults ( $advc , 0, 4, $row,$row+1);$row++;
1007
        }
1008
        $advc->signal_connect("clicked" => sub{
1009
                $adv_set=($adv_set==1)?0:1;
1010 25 alirezamon
                $mpsoc->object_add_attribute('setting','show_adv_setting',$adv_set);
1011
                set_gui_status($mpsoc,"ref",1);
1012 16 alirezamon
        });
1013
 
1014
 
1015
        #other fixed parameters       
1016
 
1017
 
1018
        #FIRST_ARBITER_EXT_P_EN
1019
        $label='FIRST_ARBITER_EXT_P_EN';
1020
        $param='FIRST_ARBITER_EXT_P_EN';
1021
        $default= 0;
1022
        $info='FIRST_ARBITER_EXT_P_EN';
1023
        $content='0,1';
1024
        $type="Combo-box";
1025 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,0,'noc_param');
1026 16 alirezamon
 
1027 25 alirezamon
 
1028 16 alirezamon
 
1029
        # AVC_ATOMIC_EN
1030
        $label='AVC_ATOMIC_EN';
1031
        $param='AVC_ATOMIC_EN';
1032
        $default= 0;
1033
        $info='AVC_ATOMIC_EN';
1034
        $content='0,1';
1035
        $type="Combo-box";
1036 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param');
1037 16 alirezamon
 
1038
 
1039
        #ROUTE_SUBFUNC
1040
        $label='ROUTE_SUBFUNC';
1041
        $param='ROUTE_SUBFUNC';
1042
        $default= '"XY"';
1043
        $info='ROUTE_SUBFUNC';
1044
        $content='"XY"';
1045
        $type="Combo-box";
1046 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param');
1047 16 alirezamon
 
1048 25 alirezamon
        return $row;
1049
}
1050
 
1051
 
1052
 
1053
 
1054
 
1055
 
1056
 
1057
 
1058
 
1059
 
1060
 
1061
 
1062
 
1063
 
1064
 
1065
 
1066
 
1067
 
1068
 
1069
 
1070
#######################
1071
#   get_config
1072
######################
1073
 
1074
sub get_config{
1075
        my ($mpsoc,$info)=@_;
1076
        my $table=def_table(20,10,FALSE);#      my ($row,$col,$homogeneous)=@_;
1077
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1078
        $scrolled_win->set_policy( "automatic", "automatic" );
1079
        $scrolled_win->add_with_viewport($table);
1080
 
1081
        #noc_setting
1082
        my $row=noc_config ($mpsoc,$table);
1083
 
1084
 
1085 16 alirezamon
        #tile setting 
1086
        my $tile_set;
1087 25 alirezamon
        my $show=$mpsoc->object_get_attribute('setting','show_tile_setting');
1088
 
1089 16 alirezamon
        if($show == 0){
1090
                $tile_set= def_image_button("icons/down.png","Tiles setting");
1091
                $table->attach_defaults ( $tile_set , 0, 4, $row,$row+1);$row++;
1092
 
1093
        }
1094
 
1095
 
1096
 
1097
 
1098
 
1099 25 alirezamon
        $row=defualt_tilles_setting($mpsoc,$table,$show,$row,$info);
1100 16 alirezamon
 
1101
 
1102
 
1103
 
1104
 
1105
 
1106
 
1107
 
1108
        #end tile setting
1109
        if($show == 1){
1110
                $tile_set= def_image_button("icons/up.png","Tiles setting");
1111
                $table->attach_defaults ( $tile_set , 0, 1, $row,$row+1);$row++;
1112
        }
1113
        $tile_set->signal_connect("clicked" => sub{
1114
                $show=($show==1)?0:1;
1115 25 alirezamon
                $mpsoc->object_add_attribute('setting','show_tile_setting',$show);
1116
                set_gui_status($mpsoc,"ref",1);
1117 16 alirezamon
 
1118
 
1119
        });
1120
 
1121
 
1122
 
1123
 
1124
        for(my $i=$row; $i<25; $i++){
1125
                my $empty_col=gen_label_in_left(' ');
1126
                $table->attach_defaults ($empty_col , 0, 1, $i,$i+1);
1127
 
1128
        }
1129
 
1130
 
1131
 
1132
 
1133
 
1134
 
1135
return  $scrolled_win;
1136
 
1137
}
1138
 
1139
 
1140
#############
1141
#
1142
###########
1143
 
1144 28 alirezamon
 
1145
 
1146
 
1147
sub gen_all_tiles{
1148
        my ($mpsoc,$info, $hw_dir,$sw_dir)=@_;
1149
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
1150
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
1151
        my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
1152
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
1153 16 alirezamon
 
1154 28 alirezamon
 
1155
 
1156
 
1157
 
1158
        my @generated_tiles;
1159
 
1160
        #print "nx=$nx,ny=$ny\n";
1161
        for (my $y=0;$y<$ny;$y++){for (my $x=0; $x<$nx;$x++){
1162
 
1163
                my $tile_num= $y*$nx+$x;
1164
                #print "$tile_num\n";
1165
                my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile_num);
1166
                my $path=$mpsoc->object_get_attribute('setting','soc_path');
1167
                $path=~ s/ /\\ /g;
1168
                my $p = "$path/$soc_name.SOC";
1169 16 alirezamon
                my  $soc = eval { do $p };
1170 25 alirezamon
                if ($@ || !defined $soc){
1171
                        show_info(\$info,"**Error reading  $p file: $@\n");
1172
                       next;
1173
                }
1174 16 alirezamon
 
1175 28 alirezamon
                #update core id
1176
                $soc->object_add_attribute('global_param','CORE_ID',$tile_num);
1177 16 alirezamon
 
1178 28 alirezamon
                my $sw_path     = "$sw_dir/tile$tile_num";
1179
                #print "$sw_path\n";
1180
                if( grep (/^$soc_name$/,@generated_tiles)){ # This soc is generated before only create the software file
1181
                        generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,0,0);
1182
                }else{
1183
                        generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,0,1);
1184
                        move ("$hw_dir/$soc_name.v","$hw_dir/tiles/");
1185
 
1186
                }
1187
 
1188
 
1189
        }}
1190
 
1191
 
1192 16 alirezamon
}
1193
 
1194 28 alirezamon
 
1195 16 alirezamon
################
1196
#       generate_soc
1197
#################
1198
 
1199
sub generate_soc_files{
1200
        my ($mpsoc,$soc,$info)=@_;
1201 25 alirezamon
        my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
1202
        my $soc_name=$soc->object_get_attribute('soc_name');
1203
        my ($file_v,$tmp)=soc_generate_verilog($soc);
1204 16 alirezamon
 
1205
        # Write object file
1206
        open(FILE,  ">lib/soc/$soc_name.SOC") || die "Can not open: $!";
1207 25 alirezamon
        print FILE perl_file_header("$soc_name.SOC");
1208 28 alirezamon
        print FILE Data::Dumper->Dump([\%$soc],['mpsoc']);
1209 16 alirezamon
        close(FILE) || die "Error closing file: $!";
1210
 
1211
        # Write verilog file
1212
        open(FILE,  ">lib/verilog/$soc_name.v") || die "Can not open: $!";
1213
        print FILE $file_v;
1214
        close(FILE) || die "Error closing file: $!";
1215
 
1216
 
1217
 
1218
 
1219
        # copy all files in project work directory
1220
        my $dir = Cwd::getcwd();
1221 28 alirezamon
        my $project_dir   = abs_path("$dir/../../");
1222 16 alirezamon
        #make target dir
1223 28 alirezamon
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
1224 16 alirezamon
        mkpath("$target_dir/src_verilog/lib/",1,0755);
1225
        mkpath("$target_dir/src_verilog/tiles/",1,0755);
1226
        mkpath("$target_dir/sw",1,0755);
1227
 
1228
    #copy hdl codes in src_verilog
1229
 
1230 18 alirezamon
    my ($hdl_ref,$warnings)= get_all_files_list($soc,"hdl_files");
1231 16 alirezamon
    foreach my $f(@{$hdl_ref}){
1232 18 alirezamon
 
1233 16 alirezamon
        my $n="$project_dir$f";
1234
         if (-f "$n") {
1235
                        copy ("$n","$target_dir/src_verilog/lib");
1236
         }elsif(-f "$f" ){
1237
                        copy ("$f","$target_dir/src_verilog/lib");
1238
 
1239
         }
1240
 
1241
 
1242
    }
1243
                        show_info(\$info,$warnings)                     if(defined $warnings);
1244
 
1245
 
1246
                #my @pathes=("$dir/../src_peripheral","$dir/../src_noc","$dir/../src_processor");
1247
                #foreach my $p(@pathes){
1248
                #       find(
1249
                #               sub {
1250
                #                       return unless ( -f $_ );
1251
                #                       $_ =~ /\.v$/ && copy( $File::Find::name, "$target_dir/src_verilog/lib/" );
1252
                #               },
1253
                #       $p
1254
                        #       );
1255
                #}
1256
 
1257
 
1258 18 alirezamon
                move ("$dir/lib/verilog/$soc_name.v","$target_dir/src_verilog/tiles/");
1259 16 alirezamon
                copy_noc_files($project_dir,"$target_dir/src_verilog/lib");
1260
 
1261
 
1262
                # Write header file
1263 24 alirezamon
                        generate_header_file($soc,$project_dir,$target_dir,$dir);
1264 16 alirezamon
 
1265
 
1266
 
1267
 
1268 24 alirezamon
 
1269 18 alirezamon
                        #use File::Copy::Recursive qw(dircopy);
1270
                        #dircopy("$dir/../src_processor/aeMB/compiler","$target_dir/sw/") or die("$!\n");
1271 16 alirezamon
 
1272
 
1273
                        my $msg="SoC \"$soc_name\" has been created successfully at $target_dir/ ";
1274
 
1275
 
1276
 
1277
 
1278
return $msg;
1279
}
1280
 
1281
 
1282
################
1283
#       generate_mpsoc
1284
#################
1285
 
1286
sub generate_mpsoc{
1287
        my ($mpsoc,$info)=@_;
1288 25 alirezamon
        my $name=$mpsoc->object_get_attribute('mpsoc_name');
1289 28 alirezamon
        if ( $name =~ /\W+/ ){
1290
                message_dialog('The mpsoc name must not contain any non-word character:("./\()\':,.;<>~!@#$%^&*|+=[]{}`~?-")!")');
1291
                return 0;
1292
        }
1293
        my $size= (defined $name)? length($name) :0;
1294
        if ($size ==0) {
1295
                message_dialog("Please define the MPSoC name!");
1296
                return 0;
1297
        }
1298
 
1299
        # make target dir
1300
        my $dir = Cwd::getcwd();
1301
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
1302
        my $hw_dir      = "$target_dir/src_verilog";
1303
        my $sw_dir      = "$target_dir/sw";
1304
 
1305
        mkpath("$hw_dir/lib/",1,0755);
1306
        mkpath("$hw_dir/tiles",1,0755);
1307
        mkpath("$sw_dir",1,0755);
1308
 
1309
 
1310
        #generate/copy all tiles HDL/SW codes
1311
        gen_all_tiles($mpsoc,$info, $hw_dir,$sw_dir );
1312
 
1313
        #copy all NoC HDL files
1314
 
1315
        my @files = glob( "$dir/../src_noc/*.v" );
1316
        copy_file_and_folders(\@files,$dir,"$hw_dir/lib/");
1317
 
1318
 
1319
 
1320
        my ($file_v,$top_v)=mpsoc_generate_verilog($mpsoc);
1321
 
1322
 
1323
 
1324
        # Write object file
1325
        open(FILE,  ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
1326
        print FILE perl_file_header("$name.MPSOC");
1327
        print FILE Data::Dumper->Dump([\%$mpsoc],[$name]);
1328
        close(FILE) || die "Error closing file: $!";
1329 16 alirezamon
 
1330 28 alirezamon
        # Write verilog file
1331
        open(FILE,  ">lib/verilog/$name.v") || die "Can not open: $!";
1332
        print FILE $file_v;
1333
        close(FILE) || die "Error closing file: $!";
1334 16 alirezamon
 
1335 28 alirezamon
        my $l=autogen_warning().get_license_header("${name}_top.v");
1336
        open(FILE,  ">lib/verilog/${name}_top.v") || die "Can not open: $!";
1337
        print FILE "$l\n$top_v";
1338
        close(FILE) || die "Error closing file: $!";
1339 16 alirezamon
 
1340 28 alirezamon
 
1341
 
1342 16 alirezamon
 
1343 28 alirezamon
    #gen_socs($mpsoc,$info);
1344
    move ("$dir/lib/verilog/$name.v","$target_dir/src_verilog/");
1345
    move ("$dir/lib/verilog/${name}_top.v","$target_dir/src_verilog/");
1346
 
1347
    #generate makefile
1348
    open(FILE,  ">$sw_dir/Makefile") || die "Can not open: $!";
1349
        print FILE mpsoc_sw_make();
1350
        close(FILE) || die "Error closing file: $!";
1351
 
1352
        #generate prog_mem
1353
    open(FILE,  ">$sw_dir/program.sh") || die "Can not open: $!";
1354
        print FILE mpsoc_mem_prog();
1355
        close(FILE) || die "Error closing file: $!";
1356
 
1357
 
1358
 
1359
 
1360
    message_dialog("SoC \"$name\" has been created successfully at $target_dir/ " );
1361 16 alirezamon
 
1362
 
1363 28 alirezamon
 
1364 16 alirezamon
return 1;
1365
}
1366
 
1367 28 alirezamon
sub mpsoc_sw_make {
1368
         my $make='
1369
 SUBDIRS := $(wildcard */.)
1370
 all: $(SUBDIRS)
1371
 $(SUBDIRS):
1372
        $(MAKE) -C $@
1373 16 alirezamon
 
1374 28 alirezamon
 .PHONY: all $(SUBDIRS)
1375
 
1376
 clean:
1377
        $(MAKE) -C $(CODE_DIR) clean
1378
';
1379
return $make;
1380
 
1381
}
1382 16 alirezamon
 
1383
 
1384 28 alirezamon
sub mpsoc_mem_prog {
1385
         my $string='
1386
#!/bin/sh
1387
 
1388
 
1389
JTAG_MAIN="$PRONOC_WORK/toolchain/bin/jtag_main"
1390
 
1391
#reset and disable cpus, then release the reset but keep the cpus disabled
1392
 
1393
$JTAG_MAIN -n 127  -d  "I:1,D:2:3,D:2:2,I:0"
1394
 
1395
# jtag instruction
1396
#       0: bypass
1397
#       1: getting data
1398
# jtag data :
1399
#       bit 0 is reset
1400
#       bit 1 is disable
1401
# I:1  set jtag_enable  in active mode
1402
# D:2:3 load jtag_enable data register with 0x3 reset=1 disable=1
1403
# D:2:2 load jtag_enable data register with 0x2 reset=0 disable=1
1404
# I:0  set jtag_enable  in bypass mode
1405
 
1406
 
1407
 
1408
#programe the memory
1409
for i in $(ls -d */); do
1410
        sh ${i%%/}/write_memory.sh
1411
done
1412
 
1413
#Enable the cpu
1414
$JTAG_MAIN -n 127  -d  "I:1,D:2:0,I:0"
1415
# I:1  set jtag_enable  in active mode
1416
# D:2:0 load jtag_enable data register with 0x0 reset=0 disable=0
1417
# I:0  set jtag_enable  in bypass mode
1418
';
1419
return $string;
1420
 
1421
}
1422
 
1423
 
1424 16 alirezamon
sub get_tile_LIST{
1425 25 alirezamon
        my ($mpsoc,$x,$y,$soc_num,$row,$table)=@_;
1426 16 alirezamon
        my $instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
1427
        if(!defined $instance_name){
1428
                $mpsoc->mpsoc_set_default_ip($soc_num);
1429
                $instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
1430
 
1431
        }
1432
 
1433
        #ipname
1434
        my $col=0;
1435
        my $label=gen_label_in_left("IP_$soc_num($x,$y)");
1436
        $table->attach_defaults ( $label, $col, $col+1 , $row, $row+1);$col+=2;
1437
        #instance name
1438
        my $entry=gen_entry($instance_name);
1439
        $table->attach_defaults ( $entry, $col, $col+1 , $row, $row+1);$col+=2;
1440
        $entry->signal_connect( 'changed'=> sub{
1441
                my $new_instance=$entry->get_text();
1442
                $mpsoc->mpsoc_set_ip_inst_name($soc_num,$new_instance);
1443 25 alirezamon
                set_gui_status($mpsoc,"ref",20);
1444 16 alirezamon
                print "changed to  $new_instance\n ";
1445
 
1446
        });
1447
 
1448
 
1449
        #combo box
1450
        my @list=('A','B');
1451
        my $combo=gen_combo(\@list,0);
1452
        $table->attach_defaults ( $combo, $col, $col+1 , $row, $row+1);$col+=2;
1453
        #setting
1454
        my $setting= def_image_button("icons/setting.png","Browse");
1455
        $table->attach_defaults ( $setting, $col, $col+1 , $row, $row+1);$col+=2;
1456
 
1457
 
1458
}
1459
 
1460
 
1461
 
1462
 
1463
##########
1464
#
1465
#########
1466
 
1467
sub gen_tiles_LIST{
1468 25 alirezamon
        my ($mpsoc)=@_;
1469 16 alirezamon
 
1470 25 alirezamon
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
1471
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
1472 16 alirezamon
 
1473
        # print "($nx,$ny);\n";
1474
        my $table=def_table($nx*$ny,4,FALSE);#  my ($row,$col,$homogeneous)=@_;
1475
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1476
        $scrolled_win->set_policy( "automatic", "automatic" );
1477
        $scrolled_win->add_with_viewport($table);
1478
 
1479
 
1480
    my @titles=("IP_num(x,y)","Instance name","IP module name","setting");
1481
        my $col=0;
1482
    my $row=0;
1483
        foreach my$p(@titles){
1484
                my $label=gen_label_in_left($p);
1485
            $table->attach_defaults ($label, $col, $col+1 , $row, $row+1);$col++;
1486
                my $sepv = Gtk2::VSeparator->new;
1487
                $table->attach_defaults ($sepv, $col , $col+1 ,0 , 2*($nx*$ny)+2 );$col++;
1488
 
1489
        }$row+=2;
1490
 
1491
 
1492
        $col=0;
1493
        for (my $y=0;$y<$ny;$y++){
1494
 
1495
 
1496
 
1497
                for (my $x=0; $x<$nx;$x++){
1498
                        my $soc_num= $y*$nx+$x;
1499
                        my $seph = Gtk2::HSeparator->new;
1500
                        $table->attach_defaults ($seph, 0, 8 , $row, $row+1);$row++;
1501 25 alirezamon
                        get_tile($mpsoc,$x,$y,$soc_num,$row,$table);$row++;
1502 16 alirezamon
 
1503
 
1504
 
1505
 
1506
        }}
1507
        my $seph = Gtk2::HSeparator->new;
1508
        $table->attach_defaults ($seph, 0, 8 , $row, $row+1);$row++;
1509
 
1510
   while( $row<30){
1511
                my $label=gen_label_in_left(' ');
1512
            $table->attach_defaults ($label, $col, $col+1 , $row, $row+1);$row++;
1513
 
1514
 
1515
 
1516
        }
1517
 
1518
 
1519
        return $scrolled_win;
1520
}
1521
 
1522
 
1523
 
1524
 
1525
 
1526
 
1527
 
1528
 
1529
 
1530
sub get_tile{
1531 25 alirezamon
        my ($mpsoc,$tile,$x,$y)=@_;
1532 16 alirezamon
 
1533
 
1534
        my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile);
1535
 
1536
        my $button;
1537
        if( defined $soc_name){
1538
                my $setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
1539
                $button=($setting eq 'Custom')? def_colored_button("Tile $tile ($x,$y)*\n$soc_name",$num) :     def_colored_button("Tile $tile ($x,$y)\n$soc_name",$num) ;
1540
        }else {
1541
                $button =def_colored_button("Tile $tile ($x,$y)\n",50) if(! defined $soc_name);
1542
        }
1543
 
1544
        $button->signal_connect("clicked" => sub{
1545
                my $window = def_popwin_size(400,400,"Parameter setting for Tile $tile ");
1546
                my $table = def_table(6, 2, TRUE);
1547
 
1548
                my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1549
                $scrolled_win->set_policy( "automatic", "automatic" );
1550
                $scrolled_win->add_with_viewport($table);
1551
                my $row=0;
1552
                my ($soc_name,$g,$t)=$mpsoc->mpsoc_get_tile_soc_name($tile);
1553
 
1554
 
1555
                my @socs=$mpsoc->mpsoc_get_soc_list();
1556
                my @list=(' ',@socs);
1557
                my $pos=(defined $soc_name)? get_scolar_pos($soc_name,@list): 0;
1558
                my $combo=gen_combo(\@list, $pos);
1559
                my $lable=gen_label_in_left("  SoC name:");
1560
                $table->attach_defaults($lable,0,3,$row,$row+1);
1561
                $table->attach_defaults($combo,3,7,$row,$row+1);$row++;
1562
                my $separator1 = Gtk2::HSeparator->new;
1563
                $table->attach_defaults($separator1,0,7,$row,$row+1);$row++;
1564
 
1565
                my $ok = def_image_button('icons/select.png','OK');
1566
                my $okbox=def_hbox(TRUE,0);
1567
                $okbox->pack_start($ok, FALSE, FALSE,0);
1568
 
1569
 
1570
 
1571
                my $param_setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
1572
                @list=('Default','Custom');
1573
                $pos=(defined $param_setting)? get_scolar_pos($param_setting,@list): 0;
1574
                my $nn=(defined $soc_name)? $soc_name : 'soc';
1575 25 alirezamon
                my ($box2,$combo2)=gen_combo_help("Defualt: the tail will get  defualt parameter setting of $nn.\n Custom: it will allow custom parameter  setting for this tile only." , \@list, $pos);
1576 16 alirezamon
                my $lable2=gen_label_in_left("  Parameter Setting:");
1577
                $table->attach_defaults($lable2,0,3,$row,$row+1);
1578
                $table->attach_defaults($box2,3,7,$row,$row+1);$row++;
1579
                $combo2->signal_connect('changed'=>sub{
1580
                        my $in=$combo2->get_active_text();
1581
                        $mpsoc->mpsoc_set_tile_param_setting($tile,$in);
1582
 
1583
 
1584
                });
1585
 
1586
 
1587
 
1588
 
1589
 
1590
                $combo->signal_connect('changed'=>sub{
1591
                        my $new_soc=$combo->get_active_text();
1592
                        if ($new_soc eq ' '){
1593
                                #unconnect tile
1594
                                $mpsoc->mpsoc_set_tile_free($tile);
1595
                        }else {
1596
                                $mpsoc->mpsoc_set_tile_soc_name($tile,$new_soc);
1597
                        }
1598
 
1599
 
1600
 
1601
                });
1602
 
1603
 
1604
 
1605
 
1606
 
1607
 
1608
                my $mtable = def_table(10, 1, TRUE);
1609
 
1610
                $mtable->attach_defaults($scrolled_win,0,1,0,9);
1611
                $mtable->attach_defaults($okbox,0,1,9,10);
1612
 
1613
                $window->add ($mtable);
1614
                $window->show_all();
1615
 
1616
                $ok-> signal_connect("clicked" => sub{
1617
                        $window->destroy;
1618 25 alirezamon
                        set_gui_status($mpsoc,"refresh_soc",1);
1619 16 alirezamon
                        my $soc_name=$combo->get_active_text();
1620
                        my $setting=$combo2->get_active_text();
1621
                        if ($soc_name ne ' ' && $setting ne 'Default'){
1622 25 alirezamon
                        get_soc_parameter_setting ($mpsoc,$soc_name,$tile);
1623 16 alirezamon
 
1624
                        }
1625
                        #save new values 
1626
                        #$top->top_add_default_soc_param(\%param_value);
1627 25 alirezamon
                        #set_gui_status($mpsoc,"refresh_soc",1);
1628 16 alirezamon
                        #$$refresh_soc->clicked;
1629
 
1630
                        });
1631
 
1632
        });
1633
 
1634
 
1635
        #$button->show_all;
1636
        return $button;
1637
 
1638
 
1639
}
1640
 
1641
 
1642
 
1643
 
1644
 
1645
 
1646
 
1647
 
1648
##########
1649
#
1650
#########
1651
 
1652
sub gen_tiles{
1653 25 alirezamon
        my ($mpsoc)=@_;
1654 16 alirezamon
 
1655 25 alirezamon
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
1656
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
1657 16 alirezamon
 
1658
        #print "($nx,$ny);\n";
1659
        my $table=def_table($nx,$ny,FALSE);#    my ($row,$col,$homogeneous)=@_;
1660
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1661
        $scrolled_win->set_policy( "automatic", "automatic" );
1662
        $scrolled_win->add_with_viewport($table);
1663
 
1664
 
1665
 
1666
 
1667
 
1668
 
1669
        for (my $y=0;$y<$ny;$y++){
1670
                for (my $x=0; $x<$nx;$x++){
1671
                        my $tile_num=($nx*$y)+ $x;
1672 25 alirezamon
                        my $tile=get_tile($mpsoc,$tile_num,$x,$y);
1673 16 alirezamon
                #print "($x,$y);\n";
1674
                $table->attach_defaults ($tile, $x, $x+1 , $y, $y+1);
1675
 
1676
 
1677
        }}
1678
 
1679
 
1680
 
1681
 
1682
 
1683
 
1684
 
1685
 
1686
 
1687
 
1688
 
1689
############
1690
#    main
1691
############
1692
sub mpsocgen_main{
1693
 
1694
        my $infc = interface->interface_new();
1695
        my $soc = ip->lib_new ();
1696
        #my $soc = soc->soc_new();
1697
 
1698
        my $mpsoc= mpsoc->mpsoc_new();
1699
 
1700 25 alirezamon
        set_gui_status($mpsoc,"ideal",0);
1701
 
1702 16 alirezamon
        # main window
1703
        #my $window = def_win_size(1000,800,"Top");
1704
        #  The main table containg the lib tree, selected modules and info section 
1705
        my $main_table = Gtk2::Table->new (25, 12, FALSE);
1706
 
1707
        # The box which holds the info, warning, error ...  mesages
1708
        my ($infobox,$info)= create_text();
1709
 
1710
 
1711
        my $refresh = Gtk2::Button->new_from_stock('ref');
1712
 
1713
 
1714 25 alirezamon
        my $noc_conf_box=get_config ($mpsoc,$info);
1715
        my $noc_tiles=gen_tiles($mpsoc);
1716 16 alirezamon
 
1717
 
1718
 
1719
        $main_table->set_row_spacings (4);
1720
        $main_table->set_col_spacings (1);
1721
 
1722 25 alirezamon
        #my  $device_win=show_active_dev($soc,$soc,$infc,\$refresh,$info);
1723 16 alirezamon
 
1724
 
1725
        my $generate = def_image_button('icons/gen.png','Generate');
1726
 
1727
 
1728
 
1729 25 alirezamon
 
1730 16 alirezamon
        my $open = def_image_button('icons/browse.png','Load MPSoC');
1731
 
1732
 
1733 26 alirezamon
        my $entry=gen_entry_object($mpsoc,'mpsoc_name',undef,undef,undef,undef);
1734 25 alirezamon
        my $entrybox=labele_widget_info(" MPSoC name:",$entry);
1735 16 alirezamon
 
1736
 
1737 25 alirezamon
 
1738 16 alirezamon
        #$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
1739 25 alirezamon
        $main_table->attach_defaults ($noc_conf_box , 0, 4, 0, 22);
1740
        $main_table->attach_defaults ($noc_tiles , 4, 12, 0, 22);
1741
        $main_table->attach_defaults ($infobox  , 0, 12, 22,24);
1742
        $main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
1743 16 alirezamon
        $main_table->attach_defaults ($entrybox,3, 7, 24,25);
1744
 
1745 25 alirezamon
        $main_table->attach ($generate, 10, 12, 24,25,'expand','shrink',2,2);
1746 16 alirezamon
 
1747
 
1748
        #referesh the mpsoc generator 
1749
        $refresh-> signal_connect("clicked" => sub{
1750
                $noc_conf_box->destroy();
1751 25 alirezamon
                $noc_conf_box=get_config ($mpsoc,$info);
1752
                $main_table->attach_defaults ($noc_conf_box , 0, 4, 0, 22);
1753 16 alirezamon
                $noc_conf_box->show_all();
1754
 
1755
 
1756
 
1757
                $noc_tiles->destroy();
1758 25 alirezamon
                $noc_tiles=gen_tiles($mpsoc);
1759
                $main_table->attach_defaults ($noc_tiles , 4, 12, 0, 22);
1760 16 alirezamon
 
1761
                $main_table->show_all();
1762
 
1763
 
1764
        });
1765
 
1766
 
1767
 
1768
        #check soc status every 0.5 second. referesh device table if there is any changes 
1769
        Glib::Timeout->add (100, sub{
1770 25 alirezamon
                my ($state,$timeout)= get_gui_status($mpsoc);
1771
 
1772 16 alirezamon
 
1773
                if ($timeout>0){
1774
                        $timeout--;
1775 25 alirezamon
                        set_gui_status($mpsoc,$state,$timeout);
1776 16 alirezamon
                }
1777
                elsif( $state ne "ideal" ){
1778
                        $refresh->clicked;
1779 25 alirezamon
                        my $saved_name=$mpsoc->object_get_attribute('mpsoc_name');
1780 16 alirezamon
                        if(defined $saved_name) {$entry->set_text($saved_name);}
1781 25 alirezamon
                        set_gui_status($mpsoc,"ideal",0);
1782 16 alirezamon
 
1783 25 alirezamon
 
1784 16 alirezamon
                }
1785
                return TRUE;
1786
 
1787
        } );
1788
 
1789
 
1790
        $generate-> signal_connect("clicked" => sub{
1791
                generate_mpsoc($mpsoc,$info);
1792
                $refresh->clicked;
1793
 
1794
        });
1795
 
1796
#       $wb-> signal_connect("clicked" => sub{ 
1797
#               wb_address_setting($mpsoc);
1798
#       
1799
#       });
1800
 
1801
        $open-> signal_connect("clicked" => sub{
1802 25 alirezamon
                set_gui_status($mpsoc,"ref",5);
1803
                load_mpsoc($mpsoc,$info);
1804 16 alirezamon
 
1805
        });
1806
 
1807
 
1808
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
1809
                $sc_win->set_policy( "automatic", "automatic" );
1810
                $sc_win->add_with_viewport($main_table);
1811
 
1812
        return $sc_win;
1813
 
1814
 
1815
}
1816
 
1817
 
1818
 
1819
 
1820
        return $scrolled_win;
1821
}
1822
 
1823
 
1824
 
1825
 
1826
#############
1827
#       load_mpsoc
1828
#############
1829
 
1830
sub load_mpsoc{
1831 25 alirezamon
        my ($mpsoc,$info)=@_;
1832 16 alirezamon
        my $file;
1833
        my $dialog = Gtk2::FileChooserDialog->new(
1834
                'Select a File', undef,
1835
                'open',
1836
                'gtk-cancel' => 'cancel',
1837
                'gtk-ok'     => 'ok',
1838
                );
1839
 
1840
        my $filter = Gtk2::FileFilter->new();
1841
        $filter->set_name("MPSoC");
1842
        $filter->add_pattern("*.MPSOC");
1843
        $dialog->add_filter ($filter);
1844
                my $dir = Cwd::getcwd();
1845
        $dialog->set_current_folder ("$dir/lib/mpsoc")  ;
1846
 
1847
 
1848
        if ( "ok" eq $dialog->run ) {
1849
                $file = $dialog->get_filename;
1850
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
1851
                if($suffix eq '.MPSOC'){
1852
                        my $pp= eval { do $file };
1853 25 alirezamon
                        if ($@ || !defined $pp){
1854
                                show_info(\$info,"**Error reading  $file file: $@\n");
1855
                                 $dialog->destroy;
1856
                                return;
1857
                        }
1858
 
1859
 
1860 16 alirezamon
                        clone_obj($mpsoc,$pp);
1861 25 alirezamon
                        set_gui_status($mpsoc,"load_file",0);
1862
 
1863 16 alirezamon
                }
1864
     }
1865
     $dialog->destroy;
1866
 
1867
 
1868
 
1869
 
1870
 
1871
}
1872
 
1873
 

powered by: WebSVN 2.1.0

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