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 32

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

powered by: WebSVN 2.1.0

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