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 41

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

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

powered by: WebSVN 2.1.0

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