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 46

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

powered by: WebSVN 2.1.0

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