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 16

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

powered by: WebSVN 2.1.0

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