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 43

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

powered by: WebSVN 2.1.0

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