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 34

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

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

powered by: WebSVN 2.1.0

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