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 42

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
        my $ok = def_image_button('icons/select.png','OK');
486
        my $okbox=def_hbox(TRUE,0);
487
        $okbox->pack_start($ok, FALSE, FALSE,0);
488
 
489
 
490
        my $mtable = def_table(10, 1, TRUE);
491
 
492
        $mtable->attach_defaults($scrolled_win,0,1,0,9);
493
        $mtable->attach_defaults($okbox,0,1,9,10);
494
 
495
        $window->add ($mtable);
496
        $window->show_all();
497
 
498
        $ok-> signal_connect("clicked" => sub{
499
                $window->destroy;
500
                #save new values 
501
                if(!defined $tile ) {
502
                        $top->top_add_default_soc_param(\%param_value);
503
                }
504
                else {
505
                        $top->top_add_custom_soc_param(\%param_value,$tile);
506
 
507
                }
508 25 alirezamon
                #set_gui_status($mpsoc,"refresh_soc",1);
509 16 alirezamon
                #$$refresh_soc->clicked;
510
 
511
                });
512
 
513
 
514
 
515
}
516
 
517
 
518
 
519
 
520
 
521
 
522
 
523
################
524
#       tile_set_widget
525
################
526
 
527
sub tile_set_widget{
528 25 alirezamon
        my ($mpsoc,$soc_name,$num,$table,$show,$row)=@_;
529 16 alirezamon
        #my $lable=gen_label_in_left($soc);
530
        my @all_num= $mpsoc->mpsoc_get_soc_tiles_num($soc_name);
531
        my $init=compress_nums(@all_num);
532
        my $entry;
533
        if (defined $init){$entry=gen_entry($init) ;}
534
        else                      {$entry=gen_entry();}
535
        my $set= def_image_button('icons/right.png');
536
        my $remove= def_image_button('icons/cancel.png');
537
        #my $setting= def_image_button('icons/setting.png','setting');
538
 
539
 
540
        my $button = def_colored_button($soc_name,$num);
541
        $button->signal_connect("clicked"=> sub{
542 25 alirezamon
                get_soc_parameter_setting($mpsoc,$soc_name,undef);
543 16 alirezamon
 
544
        });
545
 
546
 
547
        $set->signal_connect("clicked"=> sub{
548
                my $data=$entry->get_text();
549 25 alirezamon
                check_inserted_ip_nums($mpsoc,$soc_name,$data);
550 16 alirezamon
 
551
 
552
 
553
        });
554
        $remove->signal_connect("clicked"=> sub{
555
                $mpsoc->mpsoc_remove_soc($soc_name);
556 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
557 16 alirezamon
 
558
        });
559
 
560
 
561
if($show){
562 38 alirezamon
        $table->attach ( $button, 0, 1, $row,$row+1,'fill','fill',2,2);
563
        $table->attach ( $remove, 1, 2, $row,$row+1,'fill','shrink',2,2);
564
        $table->attach ( $entry , 2, 3, $row,$row+1,'fill','shrink',2,2);
565
        $table->attach ( $set, 3, 4, $row,$row+1,'fill','shrink',2,2);
566 16 alirezamon
 
567
 
568
 
569
        $row++;
570
}
571
 
572
        return $row;
573
 
574
 
575
}
576
 
577
 
578
 
579
 
580
 
581
##################
582
#       defualt_tilles_setting
583
###################
584
 
585
sub defualt_tilles_setting {
586 25 alirezamon
        my ($mpsoc,$table,$show,$row,$info)=@_;
587 16 alirezamon
 
588
        #title  
589
        my $separator1 = Gtk2::HSeparator->new;
590
        my $separator2 = Gtk2::HSeparator->new;
591
        my $title2=gen_label_in_center("Tile Configuration");
592
        my $box1=def_vbox(FALSE, 1);
593
        $box1->pack_start( $separator1, FALSE, FALSE, 3);
594
        $box1->pack_start( $title2, FALSE, FALSE, 3);
595
        $box1->pack_start( $separator2, FALSE, FALSE, 3);
596 38 alirezamon
        if($show){$table->attach_defaults ($box1 ,0,4, $row,$row+1);$row++;}
597 16 alirezamon
 
598
 
599
 
600
 
601
        my $label = gen_label_in_left("Tiles path:");
602
        my $entry = Gtk2::Entry->new;
603
        my $browse= def_image_button("icons/browse.png");
604 25 alirezamon
        my $file= $mpsoc->object_get_attribute('setting','soc_path');
605 16 alirezamon
        if(defined $file){$entry->set_text($file);}
606
 
607
 
608
        $browse->signal_connect("clicked"=> sub{
609
                my $entry_ref=$_[1];
610
                my $file;
611
 
612
 
613
 
614
 
615
 
616
        my $dialog = Gtk2::FileChooserDialog->new(
617
                'Select tile directory', undef,
618
                #               'open',
619
                'select-folder',
620
                'gtk-cancel' => 'cancel',
621
                'gtk-ok'     => 'ok',
622
                );
623
 
624
 
625
                if ( "ok" eq $dialog->run ) {
626
                        $file = $dialog->get_filename;
627
                        $$entry_ref->set_text($file);
628 25 alirezamon
                        $mpsoc->object_add_attribute('setting','soc_path',$file);
629 16 alirezamon
                        $mpsoc->mpsoc_remove_all_soc();
630 25 alirezamon
                        set_gui_status($mpsoc,"ref",1);
631
                        #check_input_file($file,$socgen,$info);
632 16 alirezamon
                        #print "file = $file\n";
633
                 }
634
                $dialog->destroy;
635
 
636
 
637
 
638
        } , \$entry);
639
 
640
 
641
 
642
 
643
        $entry->signal_connect("activate"=>sub{
644
                my $file_name=$entry->get_text();
645 25 alirezamon
                $mpsoc->object_add_attribute('setting','soc_path',$file_name);
646 16 alirezamon
                $mpsoc->mpsoc_remove_all_soc();
647 25 alirezamon
                set_gui_status($mpsoc,"ref",1);
648
                #check_input_file($file_name,$socgen,$info);
649 16 alirezamon
        });
650
 
651
 
652
 
653
        if($show){
654
                my $tmp=gen_label_in_left(" ");
655 38 alirezamon
                $table->attach  ($label, 0, 1 , $row,$row+1,'fill','shrink',2,2);
656
                $table->attach ($tmp, 1, 2 , $row,$row+1,'fill','shrink',2,2);
657
                $table->attach ($entry, 2, 3 , $row,$row+1,'fill','shrink',2,2);
658
                $table->attach ($browse, 3, 4, $row,$row+1,'fill','shrink',2,2);
659 16 alirezamon
                $row++;
660
        }
661
 
662
 
663
 
664
        my @socs=$mpsoc->mpsoc_get_soc_list();
665
        if( scalar @socs == 0){
666 25 alirezamon
                @socs=get_soc_list($mpsoc,$info);
667 16 alirezamon
 
668
        }
669
        @socs=$mpsoc->mpsoc_get_soc_list();
670
 
671
 
672
 
673
        my $lab1=gen_label_in_center(' Tile name');
674
 
675
        my $lab2=gen_label_help('Define the tile numbers that each IP is mapped to.
676
you can add individual numbers or ranges as follow
677
        eg: 0,2,5:10
678
        ', ' Tile numbers ');
679
        if($show){
680 38 alirezamon
                $table->attach_defaults ($lab1 ,0,1, $row,$row+1);
681
                $table->attach_defaults ($lab2 ,2,3, $row,$row+1);$row++;
682 25 alirezamon
        }
683 16 alirezamon
 
684
        my $soc_num=0;
685
        foreach my $soc_name (@socs){
686 25 alirezamon
                $row=tile_set_widget ($mpsoc,$soc_name,$soc_num,$table,$show,$row);
687
                $soc_num++;
688 16 alirezamon
 
689 25 alirezamon
        }
690 16 alirezamon
        return $row;
691
 
692
}
693
 
694
 
695
 
696
 
697
#######################
698
#   noc_config
699
######################
700
 
701
sub noc_config{
702 25 alirezamon
        my ($mpsoc,$table)=@_;
703
 
704 16 alirezamon
 
705
 
706
        #title  
707 38 alirezamon
        my $row=0;
708 16 alirezamon
        my $title=gen_label_in_center("NoC Configuration");
709 38 alirezamon
        $table->attach ($title , 0, 4,  $row, $row+1,'expand','shrink',2,2); $row++;
710
        my $separator = Gtk2::HSeparator->new;
711
        $table->attach ($separator , 0, 4 , $row, $row+1,'fill','fill',2,2);     $row++;
712 16 alirezamon
 
713
        my $label;
714
        my $param;
715
        my $default;
716
        my $type;
717
        my $content;
718
        my $info;
719
 
720 38 alirezamon
 
721 16 alirezamon
        #parameter start
722
        my $b1;
723 25 alirezamon
        my $show_noc=$mpsoc->object_get_attribute('setting','show_noc_setting');
724
        if(!defined $show_noc){
725
                $show_noc=1;
726
                $mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
727
 
728
        }
729 16 alirezamon
        if($show_noc == 0){
730
                $b1= def_image_button("icons/down.png","NoC Parameters");
731
                $label=gen_label_in_center(' ');
732 38 alirezamon
                $table->attach  ( $label , 2, 3, $row,$row+1 ,'fill','shrink',2,2);
733
                $table->attach  ( $b1 , 0, 2, $row,$row+1,'fill','shrink',2,2);
734
                $row++;
735 16 alirezamon
        }
736
 
737 22 alirezamon
 
738
        #Router type
739
        $label='Router Type';
740
        $param='ROUTER_TYPE';
741
        $default='"VC_BASED"';
742
        $content='"INPUT_QUEUED","VC_BASED"';
743
        $type='Combo-box';
744
    $info="    Input-queued: simple router with low performance and does not support fully adaptive routing.
745
    VC-based routers offer higher performance, fully adaptive routing  and traffic isolation for different packet classes.";
746 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_type',1);
747 25 alirezamon
        my $router_type=$mpsoc->object_get_attribute('noc_type',"ROUTER_TYPE");
748 22 alirezamon
 
749 38 alirezamon
        #topology
750
        $label='Topology';
751
        $param='TOPOLOGY';
752
        $default='"MESH"';
753
        $content='"MESH","TORUS","RING","LINE"';
754
        $type='Combo-box';
755
    $info="NoC topology";
756
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
757 25 alirezamon
 
758 38 alirezamon
        my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
759
 
760 16 alirezamon
        #Routers per row
761
        $label= 'Routers per row';
762
        $param= 'NX';
763
    $default=' 2';
764 38 alirezamon
        $content=($topology eq '"MESH"' || $topology eq '"TORUS"') ? '2,16,1':'2,64,1';
765 16 alirezamon
    $info= 'Number of NoC routers in row (X dimention)';
766
    $type= 'Spin-button';
767 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
768 16 alirezamon
 
769
 
770 38 alirezamon
 
771 16 alirezamon
        #Routers per column
772 38 alirezamon
        if($topology eq '"MESH"' || $topology eq '"TORUS"') {
773
                $label= 'Routers per column';
774
                $param= 'NY';
775
            $default=' 2';
776
                $content='2,16,1';
777
            $info= 'Number of NoC routers in column (Y dimention)';
778
            $type= 'Spin-button';
779
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
780
        } else {
781
                $mpsoc->object_add_attribute('noc_param','NY',1);
782
        }
783
 
784
        #VC number per port
785
        if($router_type eq '"VC_BASED"'){
786 25 alirezamon
                my $v=$mpsoc->object_get_attribute('noc_param','V');
787
                if(defined $v){ $mpsoc->object_add_attribute('noc_param','V',2) if($v eq 1);}
788 22 alirezamon
                $label='VC number per port';
789
                $param='V';
790
                $default='2';
791
                $type='Spin-button';
792
                $content='2,16,1';
793
                $info='Number of Virtual Channel per each router port';
794 28 alirezamon
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
795 22 alirezamon
        } else {
796 25 alirezamon
                $mpsoc->object_add_attribute('noc_param','V',1);
797 38 alirezamon
                $mpsoc->object_add_attribute('noc_param','C',0);
798 22 alirezamon
        }
799
 
800 16 alirezamon
        #buffer width per VC
801 22 alirezamon
        $label=($router_type eq '"VC_BASED"')? 'Buffer flits per VC': "Buffer flits";
802 16 alirezamon
        $param='B';
803
    $default='4';
804
    $content='2,256,1';
805
    $type='Spin-button';
806 22 alirezamon
        $info=($router_type eq '"VC_BASED"')?  'Buffer queue size per VC in flits' : 'Buffer queue size in flits';
807 28 alirezamon
    $row= noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',undef);
808 16 alirezamon
 
809
        #packet payload width
810 42 alirezamon
        $label='Payload width';
811 16 alirezamon
        $param='Fpay';
812
        $default='32';
813
        $content='32,256,32';
814
        $type='Spin-button';
815
    $info="The packet payload width in bits";
816 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,$show_noc,'noc_param',undef);
817 16 alirezamon
 
818
 
819
        #routing algorithm
820
        $label='Routing Algorithm';
821
        $param="ROUTE_NAME";
822
        $type="Combo-box";
823 22 alirezamon
        if($router_type eq '"VC_BASED"'){
824 38 alirezamon
                $content=($topology eq '"MESH"')?  '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","ODD_EVEN","DUATO"' :
825
                                 ($topology eq '"TORUS"')? '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST","TRANC_DUATO"':
826
                                 ($topology eq '"RING"')? '"TRANC_XY"' : '"XY"';
827
 
828 22 alirezamon
 
829
        }else{
830 38 alirezamon
                $content=($topology eq '"MESH"')?  '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","ODD_EVEN"' :
831
                                 ($topology eq '"TORUS"')? '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST"':
832
                                 ($topology eq '"RING"')? '"TRANC_XY"' : '"XY"';
833 22 alirezamon
 
834
 
835
        }
836 38 alirezamon
        $default=($topology eq '"MESH"' || $topology eq '"LINE"' )?  '"XY"':'"TRANC_XY"';
837 16 alirezamon
        $info="Select the routing algorithm: XY(DoR) , partially adaptive (Turn models). Fully adaptive (Duato) ";
838 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
839 16 alirezamon
 
840
 
841 25 alirezamon
        #SSA
842
        $label='SSA Ebable';
843
        $param='SSA_EN';
844
        $default='"NO"';
845
        $content='"YES","NO"';
846
        $type='Combo-box';
847 38 alirezamon
        $info="Enable single cycle latency on packets traversing in the same direction using static straight allocator (SSA)";
848 28 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',undef);
849 25 alirezamon
 
850
 
851 38 alirezamon
 
852 25 alirezamon
 
853 16 alirezamon
        if($show_noc == 1){
854
                $b1= def_image_button("icons/up.png","NoC Parameters");
855 38 alirezamon
                $table->attach  ( $b1 , 0, 2, $row,$row+1,'fill','shrink',2,2);
856
                $row++;
857 16 alirezamon
        }
858
        $b1->signal_connect("clicked" => sub{
859
                $show_noc=($show_noc==1)?0:1;
860 25 alirezamon
                $mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
861
                set_gui_status($mpsoc,"ref",1);
862 16 alirezamon
        });
863
 
864 38 alirezamon
 
865 16 alirezamon
        #advance parameter start
866
        my $advc;
867 25 alirezamon
        my $adv_set=$mpsoc->object_get_attribute('setting','show_adv_setting');
868 16 alirezamon
        if($adv_set == 0){
869
                $advc= def_image_button("icons/down.png","Advance Parameters");
870 38 alirezamon
                $table->attach ( $advc , 0, 2, $row,$row+1,'fill','shrink',2,2);
871
                $row++;
872 16 alirezamon
        }
873
 
874
 
875 38 alirezamon
        #Fully and partially adaptive routing setting
876
        my $route=$mpsoc->object_get_attribute('noc_param',"ROUTE_NAME");
877
        $label="Congestion index";
878
        $param="CONGESTION_INDEX";
879
        $type="Spin-button";
880
        $content="0,12,1";
881
        $info="Congestion index determines how congestion information is collected from neighboring routers. Please refer to the usere manual for more information";
882
        $default=3;
883
        if($route ne '"XY"' and $route ne '"TRANC_XY"' ){
884
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
885
        } else {
886
                $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param',undef);
887
        }
888 16 alirezamon
 
889 38 alirezamon
        #Fully adaptive routing setting
890
        my $v=$mpsoc->object_get_attribute('noc_param',"V");
891
        $label="Select Escap VC";
892
        $param="ESCAP_VC_MASK";
893
        $type="Check-box";
894
        $content=$v;
895
        $default="$v\'b";
896
        for (my $i=1; $i<=$v-1; $i++){$default=  "${default}0";}
897
        $default=  "${default}1";
898
        $info="Select the escap VC for fully adaptive routing.";
899
        if( $route eq '"TRANC_DUATO"' or $route eq '"DUATO"'  ){
900
                 $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set, 'noc_param',undef);
901
         }
902
        else{
903
                 $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0, 'noc_param',undef);
904
        }
905 32 alirezamon
 
906 16 alirezamon
        # VC reallocation type
907 38 alirezamon
        $label=($router_type eq '"VC_BASED"')? 'VC reallocation type': 'Queue reallocation type';
908
        $param='VC_REALLOCATION_TYPE';
909
    $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";
910
    $default='"NONATOMIC"';
911
    $content='"ATOMIC","NONATOMIC"';
912
    $type='Combo-box';
913
    $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
914 16 alirezamon
 
915
 
916
        #vc/sw allocator type
917 38 alirezamon
        $label = 'VC/SW combination type';
918
        $param='COMBINATION_TYPE';
919
    $default='"COMB_NONSPEC"';
920
    $content='"BASELINE","COMB_SPEC1","COMB_SPEC2","COMB_NONSPEC"';
921
    $type='Combo-box';
922
    $info="The joint VC/ switch allocator type. using canonical combination is not recommanded";
923 32 alirezamon
        if ($router_type eq '"VC_BASED"'){
924 38 alirezamon
            $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
925 32 alirezamon
        } else{
926
                 $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param',undef);
927 22 alirezamon
        }
928
 
929 16 alirezamon
        # Crossbar mux type 
930 38 alirezamon
        $label='Crossbar mux type';
931
        $param='MUX_TYPE';
932
        $default='"BINARY"';
933
        $content='"ONE_HOT","BINARY"';
934
        $type='Combo-box';
935
        $info="Crossbar multiplexer type";
936
    $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
937
 
938
    #class   
939 22 alirezamon
        if($router_type eq '"VC_BASED"'){
940 16 alirezamon
                $label='class number';
941
                $param='C';
942
                $default= 0;
943
                $info='Number of message classes. Each specific class can use different set of VC';
944
                $content='0,16,1';
945
            $type='Spin-button';
946 28 alirezamon
            $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',5);
947 16 alirezamon
 
948
 
949 25 alirezamon
                my $class=$mpsoc->object_get_attribute('noc_param',"C");
950
                my $v=$mpsoc->object_get_attribute('noc_param',"V");
951 16 alirezamon
                $default= "$v\'b";
952
                for (my $i=1; $i<=$v; $i++){
953
                        $default=  "${default}1";
954
                }
955
                #print "\$default=$default\n";
956
                for (my $i=0; $i<=$class-1; $i++){
957
 
958
                         $label="Class $i Permitted VCs";
959
                         $param="Cn_$i";
960
                         $type="Check-box";
961
                         $content=$v;
962
                         $info="Select the permitted VCs which the message class $i can be sent via them.";
963 30 alirezamon
                         $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'class_param',undef);
964 16 alirezamon
                }
965 22 alirezamon
 
966
        }#($router_type eq '"VC_BASED"')
967 16 alirezamon
 
968 22 alirezamon
 
969 16 alirezamon
 
970 38 alirezamon
        #simulation debuge enable     
971
        $label='Debug enable';
972
        $param='DEBUG_EN';
973
    $info= "Add extra verilog code for debuging NoC for simulation";
974
        $default='0';
975
        $content='0,1';
976
        $type='Combo-box';
977
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
978 16 alirezamon
 
979
 
980 38 alirezamon
        #pipeline reg   
981 16 alirezamon
        $label="Add pipeline reg after crossbar";
982
        $param="ADD_PIPREG_AFTER_CROSSBAR";
983
        $type="Check-box";
984
        $content=1;
985
        $default="1\'b0";
986 30 alirezamon
        $info="If enabeled it adds a pipline register at the output port of the router.";
987 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
988 42 alirezamon
 
989
 
990
        #MAX_SBP_NUM = 4 // 
991
        $label="Number of multiple router bypassing ";
992
        $param="MAX_SBP_NUM ";
993
        $type='Spin-button';
994
        $content='0,1,1';
995
        $default=0;
996
        $info="maximum number of routers which a packet can by pass during one clock cycle. Define it as zero will disable bypassing.";
997
        #$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
998
 
999 38 alirezamon
 
1000
        #FIRST_ARBITER_EXT_P_EN
1001
        $label='Swich allocator first level
1002 42 alirezamon
arbiters external priority enable';
1003 38 alirezamon
        $param='FIRST_ARBITER_EXT_P_EN';
1004
        $default= 1;
1005
        $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';
1006
        $content='0,1';
1007
        $type="Combo-box";
1008
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,$adv_set,'noc_param');
1009 16 alirezamon
 
1010
 
1011 38 alirezamon
        #Arbiter type
1012 42 alirezamon
        $label='SW allocator arbitration type';
1013 38 alirezamon
        $param='SWA_ARBITER_TYPE';
1014
        $default='"RRA"';
1015
        $content='"RRA","WRRA"'; #,"WRRA_CLASSIC"';
1016
        $type='Combo-box';
1017
    $info="Switch allocator arbitertion type:
1018
    RRA: Round robin arbiter. Only local fairness in a router.
1019
    WRRA: Weighted round robin arbiter. Results in global fairness in the NoC.
1020
          Switch allocation requests are grated acording to their weight which increases due to contention";
1021
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',1);
1022 25 alirezamon
 
1023 16 alirezamon
 
1024 38 alirezamon
 
1025
    my $arbiter=$mpsoc->object_get_attribute('noc_param',"SWA_ARBITER_TYPE");
1026
    my $wrra_show = ($arbiter ne  '"RRA"' && $adv_set == 1 )? 1 : 0;
1027
        # weight width
1028
        $label='Weight width';
1029
        $param='WEIGHTw';
1030
        $default='4';
1031
        $content='2,7,1';
1032
        $info= 'Maximum weight width';
1033
        $type= 'Spin-button';
1034
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$wrra_show,'noc_param',undef);
1035
 
1036
        #WRRA_CONFIG_INDEX
1037
        $label='Weight configuration index';
1038
        $param='WRRA_CONFIG_INDEX';
1039
        $default='0';
1040
        $content='0,7,1';
1041
        $info= 'WRRA_CONFIG_INDEX:
1042 16 alirezamon
 
1043 38 alirezamon
';
1044
        $type= 'Spin-button';
1045
        #$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$wrra_show,'noc_param',undef);  
1046 16 alirezamon
 
1047 38 alirezamon
 
1048
 
1049 16 alirezamon
        if($adv_set == 1){
1050
                $advc= def_image_button("icons/up.png","Advance Parameters");
1051 38 alirezamon
                $table->attach ( $advc , 0, 2, $row,$row+1,'fill','shrink',2,2);
1052
                $row++;
1053 16 alirezamon
        }
1054
        $advc->signal_connect("clicked" => sub{
1055
                $adv_set=($adv_set==1)?0:1;
1056 25 alirezamon
                $mpsoc->object_add_attribute('setting','show_adv_setting',$adv_set);
1057
                set_gui_status($mpsoc,"ref",1);
1058 16 alirezamon
        });
1059
 
1060
 
1061
        #other fixed parameters       
1062
 
1063 38 alirezamon
 
1064
 
1065
 
1066 16 alirezamon
 
1067 25 alirezamon
 
1068 16 alirezamon
 
1069
        # AVC_ATOMIC_EN
1070
        $label='AVC_ATOMIC_EN';
1071
        $param='AVC_ATOMIC_EN';
1072
        $default= 0;
1073
        $info='AVC_ATOMIC_EN';
1074
        $content='0,1';
1075
        $type="Combo-box";
1076 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param');
1077 16 alirezamon
 
1078
 
1079
        #ROUTE_SUBFUNC
1080
        $label='ROUTE_SUBFUNC';
1081
        $param='ROUTE_SUBFUNC';
1082
        $default= '"XY"';
1083
        $info='ROUTE_SUBFUNC';
1084
        $content='"XY"';
1085
        $type="Combo-box";
1086 25 alirezamon
        $row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param');
1087 16 alirezamon
 
1088 25 alirezamon
        return $row;
1089
}
1090
 
1091
 
1092
 
1093
 
1094
 
1095
 
1096
 
1097
 
1098
 
1099
 
1100
 
1101
 
1102
 
1103
 
1104
 
1105
 
1106
 
1107
 
1108
 
1109
 
1110
#######################
1111
#   get_config
1112
######################
1113
 
1114
sub get_config{
1115
        my ($mpsoc,$info)=@_;
1116
        my $table=def_table(20,10,FALSE);#      my ($row,$col,$homogeneous)=@_;
1117 34 alirezamon
        #my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1118
        #$scrolled_win->set_policy( "automatic", "automatic" );
1119
        #$scrolled_win->add_with_viewport($table);
1120 25 alirezamon
 
1121
        #noc_setting
1122
        my $row=noc_config ($mpsoc,$table);
1123
 
1124
 
1125 16 alirezamon
        #tile setting 
1126
        my $tile_set;
1127 25 alirezamon
        my $show=$mpsoc->object_get_attribute('setting','show_tile_setting');
1128
 
1129 16 alirezamon
        if($show == 0){
1130
                $tile_set= def_image_button("icons/down.png","Tiles setting");
1131 38 alirezamon
                $table->attach ( $tile_set , 0, 2, $row,$row+1,'fill','shrink',2,2);
1132
                $row++;
1133 16 alirezamon
 
1134
        }
1135
 
1136
 
1137
 
1138
 
1139
 
1140 25 alirezamon
        $row=defualt_tilles_setting($mpsoc,$table,$show,$row,$info);
1141 16 alirezamon
 
1142
 
1143
 
1144
 
1145
 
1146
 
1147
 
1148
 
1149
        #end tile setting
1150
        if($show == 1){
1151
                $tile_set= def_image_button("icons/up.png","Tiles setting");
1152 38 alirezamon
                $table->attach ( $tile_set , 0, 2, $row,$row+1,'fill','shrink',2,2);
1153
                $row++;
1154 16 alirezamon
        }
1155
        $tile_set->signal_connect("clicked" => sub{
1156
                $show=($show==1)?0:1;
1157 25 alirezamon
                $mpsoc->object_add_attribute('setting','show_tile_setting',$show);
1158
                set_gui_status($mpsoc,"ref",1);
1159 16 alirezamon
 
1160
 
1161
        });
1162
 
1163
 
1164
 
1165
 
1166 38 alirezamon
        #for(my $i=$row; $i<25; $i++){
1167
                #my $empty_col=gen_label_in_left(' ');
1168
                #$table->attach_defaults ($empty_col , 0, 1, $i,$i+1);
1169 16 alirezamon
 
1170 38 alirezamon
        #}
1171 16 alirezamon
 
1172
 
1173
 
1174
 
1175
 
1176
 
1177 34 alirezamon
return  $table;
1178 16 alirezamon
 
1179
}
1180
 
1181
 
1182
#############
1183
#
1184
###########
1185
 
1186 28 alirezamon
 
1187
 
1188
 
1189
sub gen_all_tiles{
1190
        my ($mpsoc,$info, $hw_dir,$sw_dir)=@_;
1191
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
1192
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
1193
        my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
1194
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
1195 16 alirezamon
 
1196 28 alirezamon
 
1197
 
1198 42 alirezamon
        #remove old rtl files that were copied by ProNoC
1199
        my $old_file_ref= eval { do "$hw_dir/file_list" };
1200
        if (defined $old_file_ref){
1201
                remove_file_and_folders($old_file_ref,$target_dir);
1202
        }
1203 28 alirezamon
        my @generated_tiles;
1204 42 alirezamon
        unlink "$hw_dir/file_list";
1205 28 alirezamon
 
1206
        #print "nx=$nx,ny=$ny\n";
1207
        for (my $y=0;$y<$ny;$y++){for (my $x=0; $x<$nx;$x++){
1208
 
1209
                my $tile_num= $y*$nx+$x;
1210
                #print "$tile_num\n";
1211
                my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile_num);
1212 42 alirezamon
                next if(!defined $soc_name);
1213
 
1214
 
1215 28 alirezamon
                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 42 alirezamon
                        move ("$hw_dir/$soc_name.v","$hw_dir/tiles/");
1244
                        my @tmp= ("$hw_dir/tiles/$soc_name.v");
1245
                        add_to_project_file_list(\@tmp,"$hw_dir/tiles",$hw_dir);
1246 28 alirezamon
 
1247
                }
1248
 
1249
 
1250
        }}
1251
 
1252
 
1253 16 alirezamon
}
1254
 
1255 28 alirezamon
 
1256 16 alirezamon
################
1257
#       generate_soc
1258
#################
1259
 
1260
sub generate_soc_files{
1261
        my ($mpsoc,$soc,$info)=@_;
1262 25 alirezamon
        my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
1263
        my $soc_name=$soc->object_get_attribute('soc_name');
1264 34 alirezamon
 
1265
        # copy all files in project work directory
1266
        my $dir = Cwd::getcwd();
1267
        my $project_dir   = abs_path("$dir/../../");
1268
        #make target dir
1269
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
1270
        mkpath("$target_dir/src_verilog/lib/",1,0755);
1271
        mkpath("$target_dir/src_verilog/tiles/",1,0755);
1272
        mkpath("$target_dir/sw",1,0755);
1273
 
1274
        my ($file_v,$tmp)=soc_generate_verilog($soc,"$target_dir/sw");
1275 16 alirezamon
 
1276
        # Write object file
1277
        open(FILE,  ">lib/soc/$soc_name.SOC") || die "Can not open: $!";
1278 25 alirezamon
        print FILE perl_file_header("$soc_name.SOC");
1279 38 alirezamon
        print FILE Data::Dumper->Dump([\%$soc],['soc']);
1280 16 alirezamon
        close(FILE) || die "Error closing file: $!";
1281
 
1282
        # Write verilog file
1283
        open(FILE,  ">lib/verilog/$soc_name.v") || die "Can not open: $!";
1284
        print FILE $file_v;
1285
        close(FILE) || die "Error closing file: $!";
1286
 
1287
 
1288
 
1289
 
1290 34 alirezamon
 
1291 16 alirezamon
 
1292
    #copy hdl codes in src_verilog
1293
 
1294 18 alirezamon
    my ($hdl_ref,$warnings)= get_all_files_list($soc,"hdl_files");
1295 16 alirezamon
    foreach my $f(@{$hdl_ref}){
1296 18 alirezamon
 
1297 16 alirezamon
        my $n="$project_dir$f";
1298
         if (-f "$n") {
1299
                        copy ("$n","$target_dir/src_verilog/lib");
1300
         }elsif(-f "$f" ){
1301
                        copy ("$f","$target_dir/src_verilog/lib");
1302
 
1303
         }
1304
 
1305
 
1306
    }
1307 42 alirezamon
    show_info(\$info,$warnings)                 if(defined $warnings);
1308
 
1309
    #save project hdl file/folder list
1310
    my @new_file_ref;
1311
                foreach my $f(@{$hdl_ref}){
1312
                        my ($name,$path,$suffix) = fileparse("$f",qr"\..[^.]*$");
1313
                        push(@new_file_ref,"$target_dir/src_verilog/lib/$name$suffix");
1314
        }
1315
    open(FILE,  ">$target_dir/src_verilog/file_list") || die "Can not open: $!";
1316
        print FILE Data::Dumper->Dump([\@new_file_ref],['files']);
1317
        close(FILE) || die "Error closing file: $!";
1318 16 alirezamon
 
1319
                #my @pathes=("$dir/../src_peripheral","$dir/../src_noc","$dir/../src_processor");
1320
                #foreach my $p(@pathes){
1321
                #       find(
1322
                #               sub {
1323
                #                       return unless ( -f $_ );
1324
                #                       $_ =~ /\.v$/ && copy( $File::Find::name, "$target_dir/src_verilog/lib/" );
1325
                #               },
1326
                #       $p
1327
                        #       );
1328
                #}
1329
 
1330
 
1331 18 alirezamon
                move ("$dir/lib/verilog/$soc_name.v","$target_dir/src_verilog/tiles/");
1332 16 alirezamon
                copy_noc_files($project_dir,"$target_dir/src_verilog/lib");
1333
 
1334
 
1335
                # Write header file
1336 38 alirezamon
                        generate_header_file($soc,$project_dir,$target_dir,$target_dir,$dir);
1337 16 alirezamon
 
1338
 
1339
 
1340
 
1341 24 alirezamon
 
1342 18 alirezamon
                        #use File::Copy::Recursive qw(dircopy);
1343
                        #dircopy("$dir/../src_processor/aeMB/compiler","$target_dir/sw/") or die("$!\n");
1344 16 alirezamon
 
1345
 
1346
                        my $msg="SoC \"$soc_name\" has been created successfully at $target_dir/ ";
1347
 
1348
 
1349
 
1350
 
1351
return $msg;
1352
}
1353
 
1354
 
1355 34 alirezamon
sub generate_mpsoc_lib_file {
1356
        my ($mpsoc,$info) = @_;
1357
        my $name=$mpsoc->object_get_attribute('mpsoc_name');
1358
        $mpsoc->mpsoc_remove_all_soc_tops();
1359
        open(FILE,  ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
1360
        print FILE perl_file_header("$name.MPSOC");
1361 38 alirezamon
        print FILE Data::Dumper->Dump([\%$mpsoc],['mpsoc']);
1362 34 alirezamon
        close(FILE) || die "Error closing file: $!";
1363
        get_soc_list($mpsoc,$info);
1364
 
1365
}
1366
 
1367
 
1368 16 alirezamon
################
1369
#       generate_mpsoc
1370
#################
1371
 
1372
sub generate_mpsoc{
1373 42 alirezamon
        my ($mpsoc,$info,$show_sucess_msg)=@_;
1374 25 alirezamon
        my $name=$mpsoc->object_get_attribute('mpsoc_name');
1375 34 alirezamon
        my $error = check_verilog_identifier_syntax($name);
1376
        if ( defined $error ){
1377
                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");
1378 28 alirezamon
                return 0;
1379
        }
1380
        my $size= (defined $name)? length($name) :0;
1381
        if ($size ==0) {
1382
                message_dialog("Please define the MPSoC name!");
1383
                return 0;
1384
        }
1385
 
1386
        # make target dir
1387
        my $dir = Cwd::getcwd();
1388
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
1389
        my $hw_dir      = "$target_dir/src_verilog";
1390
        my $sw_dir      = "$target_dir/sw";
1391
 
1392
        mkpath("$hw_dir/lib/",1,0755);
1393
        mkpath("$hw_dir/tiles",1,0755);
1394
        mkpath("$sw_dir",1,0755);
1395
 
1396
 
1397
        #generate/copy all tiles HDL/SW codes
1398
        gen_all_tiles($mpsoc,$info, $hw_dir,$sw_dir );
1399
 
1400
        #copy all NoC HDL files
1401
 
1402
        my @files = glob( "$dir/../src_noc/*.v" );
1403
        copy_file_and_folders(\@files,$dir,"$hw_dir/lib/");
1404
 
1405
 
1406
 
1407 34 alirezamon
        my ($file_v,$top_v)=mpsoc_generate_verilog($mpsoc,$sw_dir);
1408 28 alirezamon
 
1409
 
1410
 
1411
        # Write object file
1412 34 alirezamon
        generate_mpsoc_lib_file($mpsoc,$info);
1413 16 alirezamon
 
1414 28 alirezamon
        # Write verilog file
1415
        open(FILE,  ">lib/verilog/$name.v") || die "Can not open: $!";
1416
        print FILE $file_v;
1417
        close(FILE) || die "Error closing file: $!";
1418 16 alirezamon
 
1419 28 alirezamon
        my $l=autogen_warning().get_license_header("${name}_top.v");
1420
        open(FILE,  ">lib/verilog/${name}_top.v") || die "Can not open: $!";
1421
        print FILE "$l\n$top_v";
1422
        close(FILE) || die "Error closing file: $!";
1423 16 alirezamon
 
1424 28 alirezamon
 
1425
 
1426 16 alirezamon
 
1427 28 alirezamon
    #gen_socs($mpsoc,$info);
1428
    move ("$dir/lib/verilog/$name.v","$target_dir/src_verilog/");
1429
    move ("$dir/lib/verilog/${name}_top.v","$target_dir/src_verilog/");
1430
 
1431
    #generate makefile
1432
    open(FILE,  ">$sw_dir/Makefile") || die "Can not open: $!";
1433
        print FILE mpsoc_sw_make();
1434
        close(FILE) || die "Error closing file: $!";
1435
 
1436
        #generate prog_mem
1437
    open(FILE,  ">$sw_dir/program.sh") || die "Can not open: $!";
1438
        print FILE mpsoc_mem_prog();
1439
        close(FILE) || die "Error closing file: $!";
1440
 
1441
 
1442
 
1443
 
1444 42 alirezamon
    message_dialog("MPSoC \"$name\" has been created successfully at $target_dir/ " ) if($show_sucess_msg);
1445 16 alirezamon
 
1446
 
1447 28 alirezamon
 
1448 16 alirezamon
return 1;
1449
}
1450
 
1451 28 alirezamon
sub mpsoc_sw_make {
1452
         my $make='
1453
 SUBDIRS := $(wildcard */.)
1454
 all: $(SUBDIRS)
1455
 $(SUBDIRS):
1456
        $(MAKE) -C $@
1457 16 alirezamon
 
1458 28 alirezamon
 .PHONY: all $(SUBDIRS)
1459
 
1460
 clean:
1461
        $(MAKE) -C $(CODE_DIR) clean
1462
';
1463
return $make;
1464
 
1465
}
1466 16 alirezamon
 
1467
 
1468 28 alirezamon
sub mpsoc_mem_prog {
1469
         my $string='
1470
#!/bin/sh
1471
 
1472
 
1473 38 alirezamon
#JTAG_INTFC="$PRONOC_WORK/toolchain/bin/JTAG_INTFC"
1474
source ./jtag_intfc.sh
1475 28 alirezamon
 
1476 38 alirezamon
 
1477 28 alirezamon
#reset and disable cpus, then release the reset but keep the cpus disabled
1478
 
1479 38 alirezamon
$JTAG_INTFC -n 127  -d  "I:1,D:2:3,D:2:2,I:0"
1480 28 alirezamon
 
1481
# jtag instruction
1482
#       0: bypass
1483
#       1: getting data
1484
# jtag data :
1485
#       bit 0 is reset
1486
#       bit 1 is disable
1487
# I:1  set jtag_enable  in active mode
1488
# D:2:3 load jtag_enable data register with 0x3 reset=1 disable=1
1489
# D:2:2 load jtag_enable data register with 0x2 reset=0 disable=1
1490
# I:0  set jtag_enable  in bypass mode
1491
 
1492
 
1493
 
1494
#programe the memory
1495
for i in $(ls -d */); do
1496 42 alirezamon
        echo "Enter ${i%%/}"
1497 29 alirezamon
        cd ${i%%/}
1498
        sh write_memory.sh
1499
        cd ..
1500 28 alirezamon
done
1501
 
1502
#Enable the cpu
1503 38 alirezamon
$JTAG_INTFC -n 127  -d  "I:1,D:2:0,I:0"
1504 28 alirezamon
# I:1  set jtag_enable  in active mode
1505
# D:2:0 load jtag_enable data register with 0x0 reset=0 disable=0
1506
# I:0  set jtag_enable  in bypass mode
1507
';
1508
return $string;
1509
 
1510
}
1511
 
1512
 
1513 16 alirezamon
sub get_tile_LIST{
1514 25 alirezamon
        my ($mpsoc,$x,$y,$soc_num,$row,$table)=@_;
1515 16 alirezamon
        my $instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
1516
        if(!defined $instance_name){
1517
                $mpsoc->mpsoc_set_default_ip($soc_num);
1518
                $instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
1519
 
1520
        }
1521
 
1522
        #ipname
1523
        my $col=0;
1524
        my $label=gen_label_in_left("IP_$soc_num($x,$y)");
1525
        $table->attach_defaults ( $label, $col, $col+1 , $row, $row+1);$col+=2;
1526
        #instance name
1527
        my $entry=gen_entry($instance_name);
1528
        $table->attach_defaults ( $entry, $col, $col+1 , $row, $row+1);$col+=2;
1529
        $entry->signal_connect( 'changed'=> sub{
1530
                my $new_instance=$entry->get_text();
1531
                $mpsoc->mpsoc_set_ip_inst_name($soc_num,$new_instance);
1532 25 alirezamon
                set_gui_status($mpsoc,"ref",20);
1533 16 alirezamon
                print "changed to  $new_instance\n ";
1534
 
1535
        });
1536
 
1537
 
1538
        #combo box
1539
        my @list=('A','B');
1540
        my $combo=gen_combo(\@list,0);
1541
        $table->attach_defaults ( $combo, $col, $col+1 , $row, $row+1);$col+=2;
1542
        #setting
1543
        my $setting= def_image_button("icons/setting.png","Browse");
1544
        $table->attach_defaults ( $setting, $col, $col+1 , $row, $row+1);$col+=2;
1545
 
1546
 
1547
}
1548
 
1549
 
1550
 
1551
 
1552
##########
1553
#
1554
#########
1555
 
1556
sub gen_tiles_LIST{
1557 25 alirezamon
        my ($mpsoc)=@_;
1558 16 alirezamon
 
1559 25 alirezamon
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
1560
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
1561 16 alirezamon
 
1562
        # print "($nx,$ny);\n";
1563
        my $table=def_table($nx*$ny,4,FALSE);#  my ($row,$col,$homogeneous)=@_;
1564
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1565
        $scrolled_win->set_policy( "automatic", "automatic" );
1566
        $scrolled_win->add_with_viewport($table);
1567
 
1568
 
1569
    my @titles=("IP_num(x,y)","Instance name","IP module name","setting");
1570
        my $col=0;
1571
    my $row=0;
1572
        foreach my$p(@titles){
1573
                my $label=gen_label_in_left($p);
1574
            $table->attach_defaults ($label, $col, $col+1 , $row, $row+1);$col++;
1575
                my $sepv = Gtk2::VSeparator->new;
1576
                $table->attach_defaults ($sepv, $col , $col+1 ,0 , 2*($nx*$ny)+2 );$col++;
1577
 
1578
        }$row+=2;
1579
 
1580
 
1581
        $col=0;
1582
        for (my $y=0;$y<$ny;$y++){
1583
 
1584
 
1585
 
1586
                for (my $x=0; $x<$nx;$x++){
1587
                        my $soc_num= $y*$nx+$x;
1588
                        my $seph = Gtk2::HSeparator->new;
1589
                        $table->attach_defaults ($seph, 0, 8 , $row, $row+1);$row++;
1590 25 alirezamon
                        get_tile($mpsoc,$x,$y,$soc_num,$row,$table);$row++;
1591 16 alirezamon
 
1592
 
1593
 
1594
 
1595
        }}
1596
        my $seph = Gtk2::HSeparator->new;
1597
        $table->attach_defaults ($seph, 0, 8 , $row, $row+1);$row++;
1598
 
1599
   while( $row<30){
1600
                my $label=gen_label_in_left(' ');
1601
            $table->attach_defaults ($label, $col, $col+1 , $row, $row+1);$row++;
1602
 
1603
 
1604
 
1605
        }
1606
 
1607
 
1608
        return $scrolled_win;
1609
}
1610
 
1611
 
1612
 
1613
 
1614
 
1615
 
1616
 
1617
 
1618
 
1619
sub get_tile{
1620 25 alirezamon
        my ($mpsoc,$tile,$x,$y)=@_;
1621 16 alirezamon
 
1622
 
1623
        my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile);
1624
 
1625
        my $button;
1626 38 alirezamon
        my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
1627
        my $cordibate =  ($topology eq '"RING"' || $topology eq '"LINE"' ) ? "" : "($x,$y)";
1628 16 alirezamon
        if( defined $soc_name){
1629
                my $setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
1630 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) ;
1631 16 alirezamon
        }else {
1632 38 alirezamon
                $button =def_colored_button("Tile $tile ${cordibate}\n",50) if(! defined $soc_name);
1633 16 alirezamon
        }
1634
 
1635
        $button->signal_connect("clicked" => sub{
1636 34 alirezamon
                my $window = def_popwin_size(40,40,"Parameter setting for Tile $tile ",'percent');
1637 16 alirezamon
                my $table = def_table(6, 2, TRUE);
1638
 
1639
                my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1640
                $scrolled_win->set_policy( "automatic", "automatic" );
1641
                $scrolled_win->add_with_viewport($table);
1642
                my $row=0;
1643
                my ($soc_name,$g,$t)=$mpsoc->mpsoc_get_tile_soc_name($tile);
1644
 
1645
 
1646
                my @socs=$mpsoc->mpsoc_get_soc_list();
1647
                my @list=(' ',@socs);
1648
                my $pos=(defined $soc_name)? get_scolar_pos($soc_name,@list): 0;
1649
                my $combo=gen_combo(\@list, $pos);
1650 42 alirezamon
                my $lable=gen_label_in_left("  Processing tile name:");
1651 16 alirezamon
                $table->attach_defaults($lable,0,3,$row,$row+1);
1652
                $table->attach_defaults($combo,3,7,$row,$row+1);$row++;
1653
                my $separator1 = Gtk2::HSeparator->new;
1654
                $table->attach_defaults($separator1,0,7,$row,$row+1);$row++;
1655
 
1656
                my $ok = def_image_button('icons/select.png','OK');
1657
                my $okbox=def_hbox(TRUE,0);
1658
                $okbox->pack_start($ok, FALSE, FALSE,0);
1659
 
1660
 
1661
 
1662
                my $param_setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
1663
                @list=('Default','Custom');
1664
                $pos=(defined $param_setting)? get_scolar_pos($param_setting,@list): 0;
1665
                my $nn=(defined $soc_name)? $soc_name : 'soc';
1666 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);
1667 16 alirezamon
                my $lable2=gen_label_in_left("  Parameter Setting:");
1668
                $table->attach_defaults($lable2,0,3,$row,$row+1);
1669
                $table->attach_defaults($box2,3,7,$row,$row+1);$row++;
1670
                $combo2->signal_connect('changed'=>sub{
1671
                        my $in=$combo2->get_active_text();
1672
                        $mpsoc->mpsoc_set_tile_param_setting($tile,$in);
1673
 
1674
 
1675
                });
1676
 
1677
 
1678
 
1679
 
1680
 
1681
                $combo->signal_connect('changed'=>sub{
1682
                        my $new_soc=$combo->get_active_text();
1683
                        if ($new_soc eq ' '){
1684
                                #unconnect tile
1685
                                $mpsoc->mpsoc_set_tile_free($tile);
1686
                        }else {
1687
                                $mpsoc->mpsoc_set_tile_soc_name($tile,$new_soc);
1688
                        }
1689
 
1690
 
1691
 
1692
                });
1693
 
1694
 
1695
 
1696
 
1697
 
1698
 
1699
                my $mtable = def_table(10, 1, TRUE);
1700
 
1701
                $mtable->attach_defaults($scrolled_win,0,1,0,9);
1702
                $mtable->attach_defaults($okbox,0,1,9,10);
1703
 
1704
                $window->add ($mtable);
1705
                $window->show_all();
1706
 
1707
                $ok-> signal_connect("clicked" => sub{
1708
                        $window->destroy;
1709 25 alirezamon
                        set_gui_status($mpsoc,"refresh_soc",1);
1710 16 alirezamon
                        my $soc_name=$combo->get_active_text();
1711
                        my $setting=$combo2->get_active_text();
1712
                        if ($soc_name ne ' ' && $setting ne 'Default'){
1713 25 alirezamon
                        get_soc_parameter_setting ($mpsoc,$soc_name,$tile);
1714 16 alirezamon
 
1715
                        }
1716
                        #save new values 
1717
                        #$top->top_add_default_soc_param(\%param_value);
1718 25 alirezamon
                        #set_gui_status($mpsoc,"refresh_soc",1);
1719 16 alirezamon
                        #$$refresh_soc->clicked;
1720
 
1721
                        });
1722
 
1723
        });
1724
 
1725
 
1726
        #$button->show_all;
1727
        return $button;
1728
 
1729
 
1730
}
1731
 
1732
 
1733
 
1734
 
1735
 
1736
 
1737
 
1738
 
1739
##########
1740
#
1741
#########
1742
 
1743
sub gen_tiles{
1744 25 alirezamon
        my ($mpsoc)=@_;
1745 16 alirezamon
 
1746 25 alirezamon
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
1747
        my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
1748 16 alirezamon
 
1749
        #print "($nx,$ny);\n";
1750
        my $table=def_table($nx,$ny,FALSE);#    my ($row,$col,$homogeneous)=@_;
1751 38 alirezamon
 
1752 16 alirezamon
 
1753
 
1754
 
1755
 
1756
 
1757
 
1758
        for (my $y=0;$y<$ny;$y++){
1759
                for (my $x=0; $x<$nx;$x++){
1760
                        my $tile_num=($nx*$y)+ $x;
1761 25 alirezamon
                        my $tile=get_tile($mpsoc,$tile_num,$x,$y);
1762 16 alirezamon
                #print "($x,$y);\n";
1763
                $table->attach_defaults ($tile, $x, $x+1 , $y, $y+1);
1764
 
1765
 
1766
        }}
1767 38 alirezamon
        return $table;
1768
}
1769 16 alirezamon
 
1770
 
1771
 
1772 38 alirezamon
 
1773
 
1774
 
1775 34 alirezamon
sub software_edit_mpsoc {
1776
        my $self=shift;
1777
        my $name=$self->object_get_attribute('mpsoc_name');
1778
        if (length($name)==0){
1779
                message_dialog("Please define the MPSoC name!");
1780
                return ;
1781
        }
1782 42 alirezamon
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
1783
        my $sw  = "$target_dir/sw";
1784 34 alirezamon
        my ($app,$table,$tview) = software_main($sw);
1785 16 alirezamon
 
1786 34 alirezamon
 
1787 42 alirezamon
 
1788 16 alirezamon
 
1789 34 alirezamon
        my $make = def_image_button('icons/gen.png','Compile');
1790 42 alirezamon
        my $prog= def_image_button('icons/write.png','Program the memories');
1791 34 alirezamon
 
1792
 
1793
 
1794 42 alirezamon
        $table->attach ($make,5, 6, 1,2,'shrink','shrink',0,0);
1795
        $table->attach ($prog,9, 10, 1,2,'shrink','shrink',0,0);
1796
 
1797 16 alirezamon
 
1798 34 alirezamon
        $make -> signal_connect("clicked" => sub{
1799
                $app->do_save();
1800 41 alirezamon
                append_to_textview($tview,' ');
1801 34 alirezamon
                run_make_file($sw,$tview);
1802 16 alirezamon
 
1803 34 alirezamon
        });
1804 42 alirezamon
 
1805
        #Programe the board 
1806
        $prog-> signal_connect("clicked" => sub{
1807
                my $error = 0;
1808
                my $bash_file="$sw/program.sh";
1809
                my $jtag_intfc="$sw/jtag_intfc.sh";
1810
 
1811
                add_info(\$tview,"Programe the board using quartus_pgm and $bash_file file\n");
1812
                #check if the programming file exists
1813
                unless (-f $bash_file) {
1814
                        add_colored_info(\$tview,"\tThe $bash_file does not exists! \n", 'red');
1815
                        $error=1;
1816
                }
1817
                #check if the jtag_intfc.sh file exists
1818
                unless (-f $jtag_intfc) {
1819
                        add_colored_info(\$tview,"\tThe $jtag_intfc does not exists!. Press the compile button and select your FPGA board first to generate $jtag_intfc file\n", 'red');
1820
                        $error=1;
1821
                }
1822
 
1823
                return if($error);
1824
                my $command = "cd $sw; sh program.sh";
1825
                add_info(\$tview,"$command\n");
1826
                my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout($command);
1827
                if(length $stderr>1){
1828
                        add_colored_info(\$tview,"$stderr\n",'red');
1829
                        add_colored_info(\$tview,"Memory was not programed successfully!\n",'red');
1830
                }else {
1831 16 alirezamon
 
1832 42 alirezamon
                        if($exit){
1833
                                add_colored_info(\$tview,"$stdout\n",'red');
1834
                                add_colored_info(\$tview,"Memory was not programed successfully!\n",'red');
1835
                        }else{
1836
                                add_info(\$tview,"$stdout\n");
1837
                                add_colored_info(\$tview,"Memory is programed successfully!\n",'blue');
1838
 
1839
                        }
1840
 
1841
                }
1842
        });
1843
 
1844 34 alirezamon
}
1845 16 alirezamon
 
1846
 
1847 34 alirezamon
 
1848 38 alirezamon
#############
1849
#       load_mpsoc
1850
#############
1851 34 alirezamon
 
1852 38 alirezamon
sub load_mpsoc{
1853
        my ($mpsoc,$info)=@_;
1854
        my $file;
1855
        my $dialog = Gtk2::FileChooserDialog->new(
1856
                'Select a File', undef,
1857
                'open',
1858
                'gtk-cancel' => 'cancel',
1859
                'gtk-ok'     => 'ok',
1860
                );
1861 34 alirezamon
 
1862 38 alirezamon
        my $filter = Gtk2::FileFilter->new();
1863
        $filter->set_name("MPSoC");
1864
        $filter->add_pattern("*.MPSOC");
1865
        $dialog->add_filter ($filter);
1866
                my $dir = Cwd::getcwd();
1867
        $dialog->set_current_folder ("$dir/lib/mpsoc")  ;
1868
        my @newsocs=$mpsoc->mpsoc_get_soc_list();
1869
        add_info(\$info,'');
1870
        if ( "ok" eq $dialog->run ) {
1871
                $file = $dialog->get_filename;
1872
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
1873
                if($suffix eq '.MPSOC'){
1874
                        my $pp= eval { do $file };
1875
                        if ($@ || !defined $pp){
1876
                                add_info(\$info,"**Error: cannot open $file file: $@\n");
1877
                                 $dialog->destroy;
1878
                                return;
1879
                        }
1880
 
1881 34 alirezamon
 
1882 38 alirezamon
                        clone_obj($mpsoc,$pp);
1883
                        #read save mpsoc socs
1884
                        my @oldsocs=$mpsoc->mpsoc_get_soc_list();
1885
                        #add exsiting SoCs and add them to mpsoc
1886
 
1887
                        my $error;
1888
                        #print "old: @oldsocs\n new @newsocs \n"; 
1889
                        foreach my $p (@oldsocs) {
1890
                                #print "$p\n";
1891
                                my @num= $mpsoc->mpsoc_get_soc_tiles_num($p);
1892
                                if (scalar @num && ( grep (/^$p$/,@newsocs)==0)){
1893
                                        my $m="Processing tile $p that has been used for ties  @num but is not located in librray anymore\n";
1894
                                        $error = (defined $error ) ? "$error $m" : $m;
1895
                                }
1896
                                $mpsoc->mpsoc_remove_soc ($p) if (grep (/^$p$/,@newsocs)==0);
1897
 
1898 34 alirezamon
 
1899 38 alirezamon
                        }
1900
                        @newsocs=get_soc_list($mpsoc,$info); # add all existing socs
1901
                        add_info(\$info,"**Error:  \n $error\n") if(defined $error);
1902
 
1903
                        set_gui_status($mpsoc,"load_file",0);
1904
 
1905
                }
1906
     }
1907
     $dialog->destroy;
1908
}
1909
 
1910 16 alirezamon
############
1911
#    main
1912
############
1913
sub mpsocgen_main{
1914
 
1915
        my $infc = interface->interface_new();
1916
        my $soc = ip->lib_new ();
1917
        my $mpsoc= mpsoc->mpsoc_new();
1918
 
1919 38 alirezamon
 
1920 25 alirezamon
        set_gui_status($mpsoc,"ideal",0);
1921
 
1922 16 alirezamon
        my $main_table = Gtk2::Table->new (25, 12, FALSE);
1923
 
1924
        # The box which holds the info, warning, error ...  mesages
1925
        my ($infobox,$info)= create_text();
1926 38 alirezamon
 
1927 25 alirezamon
        my $noc_conf_box=get_config ($mpsoc,$info);
1928
        my $noc_tiles=gen_tiles($mpsoc);
1929 16 alirezamon
 
1930 34 alirezamon
        my $scr_conf = new Gtk2::ScrolledWindow (undef, undef);
1931
        $scr_conf->set_policy( "automatic", "automatic" );
1932
        $scr_conf->add_with_viewport($noc_conf_box);
1933 38 alirezamon
 
1934
        my $scr_tile = new Gtk2::ScrolledWindow (undef, undef);
1935
        $scr_tile->set_policy( "automatic", "automatic" );
1936
        $scr_tile->add_with_viewport($noc_tiles);
1937 16 alirezamon
 
1938
        $main_table->set_row_spacings (4);
1939
        $main_table->set_col_spacings (1);
1940
 
1941 38 alirezamon
 
1942
        my $generate = def_image_button('icons/gen.png','Generate RTL');
1943 16 alirezamon
        my $open = def_image_button('icons/browse.png','Load MPSoC');
1944 38 alirezamon
        my $compile  = def_image_button('icons/gate.png','Compile RTL');
1945 34 alirezamon
        my $software = def_image_button('icons/binary.png','Software');
1946 26 alirezamon
        my $entry=gen_entry_object($mpsoc,'mpsoc_name',undef,undef,undef,undef);
1947 25 alirezamon
        my $entrybox=labele_widget_info(" MPSoC name:",$entry);
1948 16 alirezamon
 
1949 38 alirezamon
        my $h1=gen_hpaned($scr_conf,.3,$scr_tile);
1950
        my $v2=gen_vpaned($h1,.55,$infobox);
1951 34 alirezamon
 
1952
        $main_table->attach_defaults ($v2  , 0, 12, 0,24);
1953 25 alirezamon
        $main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
1954 16 alirezamon
        $main_table->attach_defaults ($entrybox,3, 7, 24,25);
1955 34 alirezamon
        $main_table->attach ($generate, 8, 9, 24,25,'expand','shrink',2,2);
1956
        $main_table->attach ($software, 9, 10, 24,25,'expand','shrink',2,2);
1957
        $main_table->attach ($compile, 10, 12, 24,25,'expand','shrink',2,2);
1958 16 alirezamon
 
1959 38 alirezamon
 
1960 16 alirezamon
 
1961
 
1962
        #check soc status every 0.5 second. referesh device table if there is any changes 
1963
        Glib::Timeout->add (100, sub{
1964 25 alirezamon
                my ($state,$timeout)= get_gui_status($mpsoc);
1965
 
1966 16 alirezamon
 
1967
                if ($timeout>0){
1968
                        $timeout--;
1969 25 alirezamon
                        set_gui_status($mpsoc,$state,$timeout);
1970 34 alirezamon
                }elsif ($state eq 'save_project'){
1971
                        # Write object file
1972
                        my $name=$mpsoc->object_get_attribute('mpsoc_name');
1973
                        open(FILE,  ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
1974
                        print FILE perl_file_header("$name.MPSOC");
1975
                        print FILE Data::Dumper->Dump([\%$mpsoc],[$name]);
1976
                        close(FILE) || die "Error closing file: $!";
1977
                        set_gui_status($mpsoc,"ideal",0);
1978 16 alirezamon
                }
1979
                elsif( $state ne "ideal" ){
1980 38 alirezamon
                        $noc_conf_box->destroy();
1981
                        $noc_conf_box=get_config ($mpsoc,$info);
1982
                        $scr_conf->add_with_viewport($noc_conf_box);
1983
                        $noc_tiles->destroy();
1984
                        $noc_tiles=gen_tiles($mpsoc);
1985
                        $scr_tile->add_with_viewport($noc_tiles);
1986
                        $h1 -> pack1($scr_conf, TRUE, TRUE);
1987
                        $h1 -> pack2($scr_tile, TRUE, TRUE);
1988
                        $v2-> pack1($h1, TRUE, TRUE);
1989
                        $h1->show_all;
1990
                        $main_table->show_all();
1991 25 alirezamon
                        my $saved_name=$mpsoc->object_get_attribute('mpsoc_name');
1992 16 alirezamon
                        if(defined $saved_name) {$entry->set_text($saved_name);}
1993 25 alirezamon
                        set_gui_status($mpsoc,"ideal",0);
1994 16 alirezamon
 
1995 25 alirezamon
 
1996 16 alirezamon
                }
1997
                return TRUE;
1998
 
1999
        } );
2000
 
2001
 
2002
        $generate-> signal_connect("clicked" => sub{
2003 42 alirezamon
                generate_mpsoc($mpsoc,$info,1);
2004 38 alirezamon
                set_gui_status($mpsoc,"refresh_soc",1);
2005 16 alirezamon
 
2006
        });
2007
 
2008
 
2009
        $open-> signal_connect("clicked" => sub{
2010 25 alirezamon
                set_gui_status($mpsoc,"ref",5);
2011
                load_mpsoc($mpsoc,$info);
2012 16 alirezamon
 
2013 34 alirezamon
        });
2014
 
2015
 
2016
        $compile -> signal_connect("clicked" => sub{
2017 38 alirezamon
                $mpsoc->object_add_attribute('compile','compilers',"QuartusII,Verilator,Modelsim");
2018 34 alirezamon
                my $name=$mpsoc->object_get_attribute('mpsoc_name');
2019
                if (length($name)==0){
2020
                        message_dialog("Please define the MPSoC name!");
2021
                        return ;
2022
                }
2023
                my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
2024
                my $top_file    = "$target_dir/src_verilog/${name}_top.v";
2025
                if (-f $top_file){
2026 42 alirezamon
                        generate_mpsoc($mpsoc,$info,0);
2027 34 alirezamon
                        select_compiler($mpsoc,$name,$top_file,$target_dir);
2028
                } else {
2029
                        message_dialog("Cannot find $top_file file. Please run RTL Generator first!");
2030
                        return;
2031
                }
2032 16 alirezamon
        });
2033 34 alirezamon
 
2034
        $software -> signal_connect("clicked" => sub{
2035
                software_edit_mpsoc($mpsoc);
2036 16 alirezamon
 
2037 34 alirezamon
        });
2038
 
2039 16 alirezamon
 
2040
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
2041
                $sc_win->set_policy( "automatic", "automatic" );
2042
                $sc_win->add_with_viewport($main_table);
2043
 
2044
        return $sc_win;
2045
 
2046
 
2047
}
2048
 
2049
 
2050
 
2051
 
2052
 
2053
 
2054
 
2055
 

powered by: WebSVN 2.1.0

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