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 30

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

powered by: WebSVN 2.1.0

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