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/] [simulator.pl] - Blame information for rev 56

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 alirezamon
#! /usr/bin/perl -w
2 48 alirezamon
use constant::boolean;
3 32 alirezamon
use strict;
4
use warnings;
5 43 alirezamon
use FindBin;
6
use lib $FindBin::Bin;
7
 
8 48 alirezamon
 
9
 
10 32 alirezamon
use GD::Graph::Data;
11
use emulator;
12
use GD::Graph::colour qw/:colours/;
13
 
14
use File::Basename;
15
use File::Path qw/make_path/;
16
use File::Copy;
17
use File::Find::Rule;
18
 
19
require "widget.pl";
20
require "mpsoc_gen.pl";
21
require "emulator.pl";
22
require "mpsoc_verilog_gen.pl";
23
require "readme_gen.pl";
24 38 alirezamon
require "graph.pl";
25 32 alirezamon
 
26 43 alirezamon
 
27 32 alirezamon
use List::MoreUtils qw(uniq);
28
 
29
 
30
 
31
 
32 43 alirezamon
sub generate_sim_bin_file {
33 32 alirezamon
        my ($simulate,$info_text) =@_;
34 48 alirezamon
        #check simulator envirement
35
        my $simulator =$simulate->object_get_attribute("Simulator");
36
        #TODO generate .sim file only for modelsim simulator
37
 
38 38 alirezamon
        $simulate->object_add_attribute('status',undef,'run');
39
        set_gui_status($simulate,"ref",1);
40
 
41 43 alirezamon
        my ($nr,$ne,$router_p,$ref_tops,$includ_h)= get_noc_verilator_top_modules_info($simulate);
42
        my %tops = %{$ref_tops};
43
 
44 48 alirezamon
        $tops{Vtraffic} = "--top-module traffic_gen_top";
45
        $tops{Vpck_inj} = "--top-module packet_injector_verilator";
46 38 alirezamon
        my $target_dir= "$ENV{PRONOC_WORK}/simulate";
47
 
48 54 alirezamon
 
49
        my $project_dir   = get_project_dir()."/mpsoc/";
50 32 alirezamon
        my $src_verilator_dir="$project_dir/src_verilator";
51 48 alirezamon
        my $src_c="$project_dir/src_c";
52
        my $src_noc_dir="$project_dir/rtl/src_noc";
53 32 alirezamon
        my $script_dir="$project_dir/script";
54 38 alirezamon
        my $testbench_file= "$src_verilator_dir/simulator.cpp";
55
 
56 43 alirezamon
        my $target_verilog_dr ="$target_dir/src_verilog";
57 48 alirezamon
        my $obj_dir ="$target_dir/verilator/obj_dir/";
58 38 alirezamon
 
59 43 alirezamon
        rmtree("$target_dir/verilator");
60
        rmtree("$target_verilog_dr");
61
        mkpath("$target_verilog_dr/",1,01777);
62 38 alirezamon
 
63
        #copy src_verilator files
64 43 alirezamon
        my @files_list = File::Find::Rule->file()
65
                            ->name( '*.v','*.V','*.sv' )
66
                            ->in( "$src_verilator_dir" );
67
 
68
        #make sure source files have key word 'module' 
69
        my @files;
70
        foreach my $p (@files_list){
71
                push (@files,$p)        if(check_file_has_string($p,'module'));
72
        }
73
        push (@files,$src_noc_dir);
74 48 alirezamon
        push (@files,"$project_dir/rtl/arbiter.v");
75
        push (@files,"$project_dir/rtl/main_comp.v");
76 54 alirezamon
        push (@files,"$project_dir/rtl/pronoc_def.v");
77 38 alirezamon
 
78 48 alirezamon
 
79 43 alirezamon
        #my @files=(
80
        #       $src_noc_dir,
81
        #       "$src_verilator_dir/noc_connection.sv",
82
        #       "$src_verilator_dir/mesh_torus_noc_connection.sv",                      
83
        #       "$src_verilator_dir/router_verilator.v",
84
        #       "$src_verilator_dir/traffic_gen_verilator.v"            
85
        #);
86 38 alirezamon
 
87 48 alirezamon
        copy_file_and_folders (\@files,$project_dir,$target_verilog_dr);
88
        copy_file_and_folders (\@files,$project_dir,"$target_dir/modelsim/src_verilog/");
89 38 alirezamon
 
90 48 alirezamon
        my $target_modelsim_dr ="$target_dir/modelsim/src_modelsim";
91
        my $src_modelsim_dir="$project_dir/rtl/src_modelsim";
92
        rmtree("$target_modelsim_dr");
93
        mkpath("$target_modelsim_dr/",1,01777);
94 43 alirezamon
 
95 48 alirezamon
        #copy src_verilator files
96
        @files_list = File::Find::Rule->file()
97
                            ->name( '*.v','*.V','*.sv' )
98
                            ->in( "$src_modelsim_dir" );
99
 
100
        #make sure source files have key word 'module' 
101
        @files=();
102
        foreach my $p (@files_list){
103
                push (@files,$p)        if(check_file_has_string($p,'module'));
104
        }
105
        copy_file_and_folders (\@files,$project_dir,$target_modelsim_dr);
106
 
107 54 alirezamon
 
108 48 alirezamon
 
109
 
110
        #check if we have a custom topology 
111
        my $topology=$simulate->object_get_attribute('noc_param','TOPOLOGY');
112
        if ($topology eq '"CUSTOM"'){
113
                my $name=$simulate->object_get_attribute('noc_param','CUSTOM_TOPOLOGY_NAME');
114
                $name=~s/["]//gs;
115
                my $dir1=  get_project_dir()."/mpsoc/rtl/src_topolgy/$name";
116
                my $dir2=  get_project_dir()."/mpsoc/rtl/src_topolgy/common";
117
                my @files = File::Find::Rule->file()
118
                            ->name( '*.v','*.V','*.sv' )
119
                            ->in( "$dir1" );
120
                copy_file_and_folders (\@files,$project_dir,$target_verilog_dr);
121
                copy_file_and_folders (\@files,$project_dir,"$target_dir/modelsim/src_verilog/");
122
 
123
                @files = File::Find::Rule->file()
124
                            ->name( '*.v','*.V','*.sv' )
125
                            ->in( "$dir2" );
126
 
127
                copy_file_and_folders (\@files,$project_dir,$target_verilog_dr);
128
                copy_file_and_folders (\@files,$project_dir,"$target_dir/modelsim/src_verilog/");
129
 
130
 
131
 
132
        }
133 38 alirezamon
        # generate NoC parameter file
134 48 alirezamon
        #my ($noc_param,$pass_param)=gen_noc_param_v($simulate);
135
        #open(FILE,  ">$target_verilog_dr/parameter.v") || die "Can not open: $!";
136 38 alirezamon
        my $fifow=$simulate->object_get_attribute('fpga_param','TIMSTMP_FIFO_NUM');
137 48 alirezamon
        gen_noc_localparam_v_file($simulate,"$target_verilog_dr/src_noc");
138 38 alirezamon
 
139 43 alirezamon
        #generate routers with different port num
140 48 alirezamon
        my $cpu_num = $simulate->object_get_attribute('compile', 'cpu_num');
141
        my $result = verilator_compilation (\%tops,$target_dir,$info_text,$cpu_num);
142 32 alirezamon
 
143
 
144 38 alirezamon
        if ($result){
145
                add_colored_info($info_text,"Veriator model has been generated successfully!\n",'blue');
146
        }else {
147
                add_colored_info($info_text,"Verilator compilation failed!\n","red");
148 48 alirezamon
                $simulate->object_add_attribute('status',undef,'programmer_failed');
149 38 alirezamon
                set_gui_status($simulate,"ref",1);
150 43 alirezamon
                print "gen-ended!\n";
151 38 alirezamon
                return;
152 43 alirezamon
        }
153 32 alirezamon
 
154 54 alirezamon
        my $r;
155
        #copy nettrace synful
156
        dircopy("$src_c/netrace-1.0","$obj_dir/netrace-1.0") or $r=$!;
157
        dircopy("$src_c/synfull","$obj_dir/synful") or $r=$!;
158
        add_colored_info($info_text,"ERROR: $r\n","red") if(defined $r ) ;
159
 
160
 
161 43 alirezamon
        #copy simulation c header files
162
        @files = File::Find::Rule->file()
163
                            ->name( '*.h')
164
                            ->in( "$src_verilator_dir" );
165 38 alirezamon
 
166
        copy_file_and_folders (\@files,$project_dir,$obj_dir);
167
        copy($testbench_file,"$obj_dir/testbench.cpp");
168 43 alirezamon
 
169 54 alirezamon
 
170 48 alirezamon
 
171 32 alirezamon
        #compile the testbench
172
        my $param_h=gen_noc_param_h($simulate);
173 43 alirezamon
        my $text = gen_sim_parameter_h($param_h,$includ_h,$ne,$nr,$router_p,$fifow);
174
 
175 54 alirezamon
 
176 38 alirezamon
        open(FILE,  ">$obj_dir/parameter.h") || die "Can not open: $!";
177 43 alirezamon
        print FILE  "$text";
178 32 alirezamon
 
179
        close FILE;
180
 
181 38 alirezamon
 
182
 
183 48 alirezamon
        #$result = run_make_file("$obj_dir/",$info_text,'lib');
184
        my $lib_num=0;
185
        add_colored_info($info_text,"Makefie will use the maximum number of $cpu_num core(s) in parallel for compilation\n",'green');
186
        my $length=scalar (keys %tops);
187
        my $cmd="";
188
        foreach my $top (sort keys %tops) {
189
                $cmd.= "lib$lib_num & ";
190
                $lib_num++;
191
                if( $lib_num % $cpu_num == 0 || $lib_num == $length){
192
                        $cmd.="wait\n";
193
                        $result = run_make_file("$obj_dir/",$info_text,$cmd);
194
                        if ($result ==0){
195
                                $simulate->object_add_attribute('status',undef,'programmer_failed');
196
                                set_gui_status($simulate,"ref",1);
197
                                print "gen-ended!\n";
198
                                return;
199
                        }
200
                        $cmd="";
201
                }else {
202
                        $cmd.=" make ";
203
                }
204
        }
205
 
206
 
207 38 alirezamon
 
208 32 alirezamon
 
209 48 alirezamon
        run_make_file("$obj_dir/",$info_text);
210 38 alirezamon
        if ($result ==0){
211 48 alirezamon
                $simulate->object_add_attribute('status',undef,'programmer_failed');
212 38 alirezamon
                set_gui_status($simulate,"ref",1);
213 43 alirezamon
                print "gen-ended!\n";
214 38 alirezamon
                return;
215
        }
216
 
217
 
218
 
219
 
220
        #my $end = localtime;
221
 
222 32 alirezamon
 
223
 
224
        #save the binarry file
225 38 alirezamon
        my $bin= "$obj_dir/testbench";
226 32 alirezamon
        my $path=$simulate->object_get_attribute ('sim_param',"BIN_DIR");
227
        my $name=$simulate->object_get_attribute ('sim_param',"SAVE_NAME");
228
 
229 38 alirezamon
        #create project directory if it does not exist
230
        my      ($stdout,$exit)=run_cmd_in_back_ground_get_stdout("mkdir -p $path" );
231 43 alirezamon
        if($exit != 0 ){        print "$stdout\n";  print "gen-ended!\n";       message_dialog($stdout,'error'); return;}
232 32 alirezamon
 
233 38 alirezamon
 
234
 
235 32 alirezamon
        #check if the verilation was successful
236
        if ((-e $bin)==0) {#something goes wrong
237 38 alirezamon
        #message_dialog("Verilator compilation was unsuccessful please check the $path/$name.log files for more information",'error');
238
        add_colored_info($info_text,"Verilator compilation failed!\n","red");
239 48 alirezamon
        $simulate->object_add_attribute('status',undef,'programmer_failed');
240 38 alirezamon
                set_gui_status($simulate,"ref",1);
241 43 alirezamon
                print "gen-ended!\n";
242 38 alirezamon
                return;
243 32 alirezamon
        }
244
 
245
 
246
        #copy ($bin,"$path/$name") or  die "Can not copy: $!";
247
        ($stdout,$exit)=run_cmd_in_back_ground_get_stdout("cp -f $bin $path/$name");
248 43 alirezamon
        if($exit != 0 ){        print "$stdout\n";  print "gen-ended!\n";       message_dialog($stdout,'error'); return;}
249 32 alirezamon
 
250
        #save noc info
251
        open(FILE,  ">$path/$name.inf") || die "Can not open: $!";
252
        print FILE perl_file_header("$name.inf");
253
        my %pp;
254
        $pp{'noc_param'}= $simulate->{'noc_param'};
255
        $pp{'sim_param'}= $simulate->{'sim_param'};
256
        print FILE Data::Dumper->Dump([\%pp],["emulate_info"]);
257
        close(FILE) || die "Error closing file: $!";
258 43 alirezamon
 
259
        print "gen-ended successfully!\n";
260 32 alirezamon
        message_dialog("The simulation binary file has been successfully generated in $path!");
261
 
262 38 alirezamon
        $simulate->object_add_attribute('status',undef,'ideal');
263
        set_gui_status($simulate,"ref",1);
264 43 alirezamon
 
265 32 alirezamon
        #make project dir
266
        #my $dir= $simulate->object_get_attribute ("sim_param","BIN_DIR");
267
        #my $name=$simulate->object_get_attribute ("sim_param","SAVE_NAME");
268
        #my $path= "$dir/$name";
269
        #add_info($info_text, "$src_verilator_dir!\n");
270
        #mkpath("$path",1,01777);
271
}
272
 
273
 
274 48 alirezamon
 
275
 
276
 
277
 
278 32 alirezamon
##########
279 34 alirezamon
#       save_simulation
280 32 alirezamon
##########
281
sub save_simulation {
282
        my ($simulate)=@_;
283
        # read emulation name
284
        my $name=$simulate->object_get_attribute ("simulate_name",undef);
285
        my $s= (!defined $name)? 0 : (length($name)==0)? 0 :1;
286
        if ($s == 0){
287
                message_dialog("Please set Simulation name!");
288
                return 0;
289
        }
290
        # Write object file
291
        open(FILE,  ">lib/simulate/$name.SIM") || die "Can not open: $!";
292
        print FILE perl_file_header("$name.SIM");
293 38 alirezamon
        print FILE Data::Dumper->Dump([\%$simulate],["simulate"]);
294 32 alirezamon
        close(FILE) || die "Error closing file: $!";
295
        message_dialog("Simulation has saved as lib/simulate/$name.SIM!");
296
        return 1;
297
}
298
 
299
#############
300 36 alirezamon
#       load_simulation
301 32 alirezamon
############
302
 
303
sub load_simulation {
304
        my ($simulate,$info)=@_;
305
        my $file;
306 48 alirezamon
        my $dialog =  gen_file_dialog (undef, 'SIM');
307
 
308 32 alirezamon
        my $dir = Cwd::getcwd();
309
        $dialog->set_current_folder ("$dir/lib/simulate");
310
 
311
 
312
        if ( "ok" eq $dialog->run ) {
313
                $file = $dialog->get_filename;
314
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
315
                if($suffix eq '.SIM'){
316 43 alirezamon
                        my ($pp,$r,$err) = regen_object($file);
317
                        if ($r){
318 48 alirezamon
                                add_colored_info($info,"**Error reading $file file: $err\n",'red');
319
                                $dialog->destroy;
320 32 alirezamon
                                return;
321
                        }
322
                        #deactivate running simulations
323
                        $pp->object_add_attribute('status',undef,'ideal');
324 38 alirezamon
                        my @samples =$pp->object_get_attribute_order("samples");
325
                        foreach my $sample (@samples){
326
                                my $st=$pp->object_get_attribute ($sample,"status");
327
                                $pp->object_add_attribute ($sample,"status",'done');# if ($st eq "run");        
328 32 alirezamon
                        }
329
                        clone_obj($simulate,$pp);
330
                        #message_dialog("done!");                               
331
                }
332
     }
333
     $dialog->destroy;
334
}
335
 
336
 
337 38 alirezamon
 
338
 
339
sub check_hotspot_parameters{
340
        my ($self,$sample)=@_;
341
        my $num=$self->object_get_attribute($sample,"HOTSPOT_NUM");
342
        my $result;
343
        if (defined $num){
344
                my @hotspots;
345
                my $acuum=0;
346
                for (my $i=0;$i<$num;$i++){
347
                        my $w1 = $self->object_get_attribute($sample,"HOTSPOT_CORE_$i");
348
                        if( grep (/^\Q$w1\E$/,@hotspots)){
349
                                $result="Error: Tile $w1 has been selected for Two or more than two hotspot nodes.\n";
350
                        }
351
                        push( @hotspots,$w1);
352
                        my $w2 = $self->object_get_attribute($sample,"HOTSPOT_PERCENT_$i");
353
                        $acuum+=$w2;
354
 
355
                }
356
                if ($acuum > 100){
357 48 alirezamon
                        $result="Error: The traffic summation of all hotspot nodes is $acuum. The hotspot summation must be <=100";
358 38 alirezamon
 
359
                }
360
        }
361
        return $result;
362
}
363
 
364 48 alirezamon
sub get_district_avg {
365
        my ($self,$sample)=@_;
366
        my $vt=$self->object_get_attribute($sample,"DISCRETE_RANGE");
367
        $vt =  "2,3,4,5" unless (defined $vt);
368
        my $pt=$self->object_get_attribute($sample,"PROBEB_RANGE");
369
        $pt= "25,25,25,25" unless (defined $pt);
370
 
371
        my $avg=0;
372
        my @valus = split(',',$vt);
373
        my @probs = split(',',$pt);
374
        my $i=0;
375
        my $sum=0;
376
        my $min=10000000;
377
        my $max=0;
378
        foreach my $v (@valus) {
379
                return ("-","The $v is not numeric value") unless (is_integer($v));
380
                $sum+=  $probs[$i];
381
                $avg+=$v*$probs[$i];
382
                $i++;
383
                $min=$v if($min>$v);
384
                $max=$v if($max<$v);
385
        }
386
        return ("-","The summation of probebilities are $sum which is not equal 100.") if($sum!=100);
387
        $avg/=100;
388
 
389
        $self->object_add_attribute ($sample,"MIN_PCK_SIZE",$min);
390
        $self->object_add_attribute ($sample,"MAX_PCK_SIZE",$max);
391
        return ($avg,undef);
392
}
393 38 alirezamon
 
394
sub get_simulator_noc_configuration{
395 48 alirezamon
        my ($self,$mode,$sample,$set_win) =@_;
396
 
397
        my $table=def_table(10,2,FALSE);
398 38 alirezamon
        my $row=0;
399
 
400 54 alirezamon
 
401
        my $scrolled_win = add_widget_to_scrolled_win ($table,gen_scr_win_with_adjst($self,'noc_conf_scr_win'));
402 38 alirezamon
 
403 48 alirezamon
        my $ok = def_image_button('icons/select.png','_OK',FALSE,1);
404
        my $import   = def_image_button('icons/import.png','I_mport',FALSE,1);
405
        my $save   = def_image_button('icons/save.png','_Export',FALSE,1);
406
 
407
        $save ->signal_connect("clicked"=> sub{
408
                my $dialog=save_file_dialog  ("Enter configuration file name",'conf');
409
                #$dialog->set_current_folder ($open_in) if(defined  $open_in);
410
                if ( "ok" eq $dialog->run ) {
411
                        my      $file = $dialog->get_filename;
412
                        my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
413
                        my $t=$self->object_get_attribute($sample);
414
                        open(FILE,  ">$path/${name}.conf") || die "Can not open: $!";
415
                        print FILE Data::Dumper->Dump([\$t],['config']);
416
                        close FILE;
417
                }
418
                $dialog->destroy();
419
        });
420
 
421
        $import ->signal_connect("clicked"=> sub{
422
                my $dialog=save_file_dialog  ("Enter configuration file name",'conf');
423
                #$dialog->set_current_folder ($open_in) if(defined  $open_in);
424
                if ( "ok" eq $dialog->run ) {
425
                        my      $file = $dialog->get_filename;
426
                        my $pp= do $file ;
427
                    my $status=1;
428
                    $status=0 if $@;
429
                        message_dialog("Error reading: $@") if $@;
430
                        if ($status==1){
431
                                $self->object_add_attribute ("$sample",undef,$$pp);
432
                                set_gui_status($self,'ref_set_win',1);
433
                        }
434
                }
435
                $dialog->destroy();
436
        });
437
 
438
 
439
 
440
        my $mtable = def_table(10, 3, TRUE);
441 38 alirezamon
 
442 48 alirezamon
        $mtable->attach_defaults($scrolled_win,0,3,0,9);
443
        $mtable-> attach ($ok , 1, 2,  9, 10,'expand','shrink',2,2);
444
        $mtable-> attach ($import , 0, 1,  9, 10,'expand','shrink',2,2);
445
        $mtable-> attach ($save , 2, 3,  9, 10,'expand','shrink',2,2);
446 38 alirezamon
 
447
 
448
 
449
        $set_win ->signal_connect (destroy => sub{
450
                $self->object_add_attribute("active_setting",undef,undef);
451 48 alirezamon
 
452 38 alirezamon
        });
453
 
454
 
455
        my $dir = Cwd::getcwd();
456
        my $open_in       = abs_path("$ENV{PRONOC_WORK}/simulate");
457
 
458
 
459 48 alirezamon
        attach_widget_to_table ($table,$row,gen_label_in_left(" Search Path:"),gen_button_message ("Select the Path where the verilator simulation files are located. Different NoC verilated models can be generated using Generate NoC configuration tab.","icons/help.png"),
460 38 alirezamon
        get_dir_in_object ($self,$sample,"sof_path",undef,'ref_set_win',1,$open_in)); $row++;
461
 
462
        $open_in        = $self->object_get_attribute($sample,"sof_path");
463
 
464
 
465
 
466
        my @files = glob "$open_in/*";
467
        my $exe_files="";
468
        foreach my $file (@files){
469 48 alirezamon
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
470
                if($suffix eq '.inf'){
471
                        $exe_files="$exe_files,$name";
472
                }
473 38 alirezamon
        }
474 54 alirezamon
        my $model_obj = gen_combobox_object ($self,$sample, "sof_file", $exe_files, undef,'ref_set_win',1);
475 38 alirezamon
        attach_widget_to_table ($table,$row,gen_label_in_left(" Verilated Model:"),gen_button_message ("Select the verilator simulation file. Different NoC simulators can be generated using Generate NoC configuration tab.","icons/help.png"),
476 54 alirezamon
        $model_obj); $row++;
477
 
478
    my $cast_type=  '"UNICAST"';
479
 
480
    #get simulation parameters here                        
481
        my $s=$self->object_get_attribute($sample,"sof_file");
482
        if (defined $s){
483
                my ($infobox,$info)= create_txview();
484
                my $sof=get_sim_bin_path($self,$sample,$info);
485
                my ($name,$path,$suffix) = fileparse("$sof",qr"\..[^.]*$");
486
                my $sof_info= "$path$name.inf";
487
 
488
                my $pp= do $sof_info ;
489
                my $p=$pp->{'noc_param'};
490
                $cast_type = $p->{'CAST_TYPE'};
491
                $cast_type=  '"UNICAST"' if (!defined $cast_type);
492
        }
493
 
494
   my $trf_info = "Select of the following traffic models:
495
   1- Synthetic
496
   2- Task-graph :
497
       The task graph traffic pattern can be generated
498
       using ProNoC trace generator
499
   3- Netrace:
500
       Dependency-Tracking Trace-Based Network-on-Chip
501
       Simulation. For downloading the trace files and more
502
       information refere to https://www.cs.utexas.edu/~netrace/
503
   4- SynFull:
504
       Synthetic Traffic Models Capturing a Full Range
505
       of Cache Coherent Behaviour
506
       https://github.com/mariobadr/synfull-isca
507
";
508 48 alirezamon
 
509 43 alirezamon
    my $coltmp=0;
510 54 alirezamon
    ($row,$coltmp)=add_param_widget  ($self, "Traffic Type", "TRAFFIC_TYPE", "Synthetic", 'Combo-box', "Synthetic,Task-graph,SynFull,Netrace", $trf_info, $table,$row,undef,1, $sample, 1,'ref_set_win');
511 43 alirezamon
 
512 38 alirezamon
    my $traffictype=$self->object_get_attribute($sample,"TRAFFIC_TYPE");
513 43 alirezamon
    my $MIN_PCK_SIZE=$self->object_get_attribute($sample,"MIN_PCK_SIZE");
514
 
515 38 alirezamon
 
516 43 alirezamon
 
517
   my $max_pck_num = get_MAX_PCK_NUM();
518
   my $max_sim_clk = get_MAX_SIM_CLKs();
519 48 alirezamon
 
520
   my $pck_info = "Select how injected packet size are selected.
521
                random-range:    The injected packet size is randomly selected between given minimum and maximum packet size.
522
                random-discrete: The injected packet size is randomly selected among given district valuse.";
523 38 alirezamon
 
524
        if($traffictype eq "Synthetic"){
525
 
526
                my $min=$self->object_get_attribute($sample,'MIN_PCK_SIZE');
527
                my $max=$self->object_get_attribute($sample,'MAX_PCK_SIZE');
528 48 alirezamon
                $min=5 if(!defined $min);
529
                $max=5 if(!defined $max);
530
                $max= $min if($max< $min);
531 38 alirezamon
                my $avg=floor(($min+$max)/2);
532 48 alirezamon
                my $msg;
533 43 alirezamon
                my $max_pck_size =       get_MAX_PCK_SIZ();
534
 
535 48 alirezamon
                my $NE;
536
                my ($infobox,$info)= create_txview();
537 43 alirezamon
 
538 48 alirezamon
 
539
                my $traffics="tornado,transposed 1,transposed 2,bit reverse,bit complement,random,hot spot,shuffle,bit rotation,neighbor,custom";
540 38 alirezamon
                my @synthinfo = (
541
 
542
 
543 48 alirezamon
                { label=>'Configuration name:', param_name=>'line_name', type=>'Entry', default_val=>$sample, content=>undef, info=>"NoC configuration name. This name will be shown in load-latency graph for this configuration", param_parent=>$sample, ref_delay=> undef, new_status=>undef},
544 38 alirezamon
 
545
 
546 48 alirezamon
 
547
                { label=>"Total packet number limit:", param_name=>'PCK_NUM_LIMIT', type=>'Spin-button', default_val=>200000, content=>"2,$max_pck_num,1", info=>"Simulation will stop when total number of sent packets by all nodes reaches packet number limit  or total simulation clock reach its limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
548 38 alirezamon
 
549 48 alirezamon
                { label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,$max_sim_clk,1", info=>"Each node stops sending packets when it reaches packet number limit  or simulation clock number limit", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
550 38 alirezamon
 
551 48 alirezamon
                { label=>"Traffic name", param_name=>'traffic', type=>'Combo-box', default_val=>'random', content=>$traffics, info=>"Select traffic pattern", param_parent=>$sample, ref_delay=>1, new_status=>'ref_set_win'},
552 38 alirezamon
 
553 48 alirezamon
                { label=>"Packet size (#flit)", param_name=>'PCK_SIZ_SEL', type=>'Combo-box', default_val=>'random-range', content=>"random-range,random-discrete", info=>$pck_info, param_parent=>$sample, ref_delay=>1, new_status=>'ref_set_win'},
554 38 alirezamon
 
555
                );
556 43 alirezamon
                my $coltmp=0;
557 48 alirezamon
 
558 38 alirezamon
                foreach my $d (@synthinfo) {
559 48 alirezamon
 
560 43 alirezamon
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
561 48 alirezamon
 
562 38 alirezamon
                }
563 48 alirezamon
 
564
                my $t=$self->object_get_attribute($sample,"PCK_SIZ_SEL");
565
                if($t eq 'random-range' ){
566 43 alirezamon
 
567 48 alirezamon
                        @synthinfo = (
568
                        { label=>"Min pck size :", param_name=>'MIN_PCK_SIZE', type=>'Spin-button', default_val=>5, content=>"1,$max,1", info=>"Minimum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
569
                        { label=>"Max pck size :", param_name=>'MAX_PCK_SIZE', type=>'Spin-button', default_val=>5, content=>"$min,$max_pck_size,1", info=>"Maximum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
570
                        { label=>"Avg. Packet size:", param_name=>'PCK_SIZE', type=>'Fixed', default_val=>$avg, content=>"$avg", info=>undef, param_parent=>$sample, ref_delay=>undef},
571
                        );
572
 
573
                }else{
574
                        #$self->object_add_attribute ($sample,"MIN_PCK_SIZE",2);#will be updated by get_district_avg  
575
                        my $vt=$self->object_get_attribute($sample,"DISCRETE_RANGE");
576
                        $vt =  "2,3,4,5" unless (defined $vt);
577
                        my $pt=$self->object_get_attribute($sample,"PROBEB_RANGE");
578
                        $pt= "25,25,25,25" unless (defined $pt);
579
 
580
                        #($avg,$msg) = get_district_avg($self,$sample);
581
 
582
 
583
                        @synthinfo = (
584
                        { label=>"pck size discrete range: ", param_name=>'DISCRETE_RANGE', type=>'Entry', default_val=>$vt, content=>undef, info=>"Set discrete set of number as packet size separated by \",\" (v1,v2,v3 ..). The injected packet size is randomly selected among these discrete values", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
585
                    { label=>"pck size probebility(%): ", param_name=>'PROBEB_RANGE'  , type=>'Entry', default_val=>$pt, content=>undef, info=>"Set the probability  separated by \",\" (p1,p2,p3 ..). The probabilities pi must satisfy two requirements: every probability pi is a number between 0 and 100, and the sum of all the probabilities is 100.", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
586
                   # { label=>"Avg. Packet size:", param_name=>'PCK_SIZE', type=>'Fixed', default_val=>$avg, content=>"$avg", info=>undef, param_parent=>$sample, ref_delay=>undef}, 
587
                        );
588
 
589
 
590
                }
591
 
592
                foreach my $d (@synthinfo){
593
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
594
                }
595
                if(defined $msg){
596
                                my $error= def_image_button("icons/cancel.png");
597
                                $table->attach  ($error , 6, 7,  $row-1,$row,'shrink','shrink',2,2);
598
                }
599
 
600 38 alirezamon
 
601
                my $traffic=$self->object_get_attribute($sample,"traffic");
602 48 alirezamon
 
603
                my $st =  check_sim_sample($self,$sample,$info);
604
                if ($st==0){
605
                                $NE=100;
606
                }else{
607
                        my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($self,$sample);
608
                        my ($NEe, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
609
                        $NE=$NEe;
610
                }
611
 
612
 
613
                if ($traffic eq 'custom'){
614
 
615
 
616
                        my $htable=def_table(10,2,FALSE);
617
 
618
                        my $d= { label=>'number of active nodes:', param_name=>'CUSTOM_SRC_NUM', type=>'Spin-button', default_val=>1,  content=>"1,$NE,1", info=>"Number of active nodes which injects packets to the NoC",                       param_parent=>$sample, ref_delay=> 1, new_status=>'ref_set_win'};
619
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
620
                        my $num=$self->object_get_attribute($sample,"CUSTOM_SRC_NUM");
621
                        $htable->attach ( gen_label_in_left ("Source "), 0, 1,  $row,$row+1,'fill','shrink',2,2);
622
                        $htable->attach ( gen_label_in_left (" -> "), 1, 2,  $row,$row+1,'fill','shrink',2,2);
623
                        $htable->attach ( gen_label_in_left ("Destination"), 2, 3,  $row,$row+1,'fill','shrink',2,2);
624
 
625
                        $row++;
626
 
627
 
628
                        my $tiles="0";
629
                        for (my $i=1;$i<$NE;$i++){$tiles.=",$i";}
630
 
631
 
632
                        for (my $i=0;$i<$num;$i++){
633
                                my $w1 = gen_combobox_object ($self,$sample,"SRC_$i",$tiles, $i,undef,undef);
634
                                my $w2 = gen_combobox_object ($self,$sample,"DST_$i",$tiles, $i+1,undef,undef);
635
                                $htable->attach  ($w1 , 0, 1,  $row,$row+1,'shrink','shrink',2,2);
636
                                $htable->attach  ($w2 , 2, 3,  $row,$row+1,'shrink','shrink',2,2);
637
                                $row++;
638
 
639
                        }
640
                        $table->attach  ($htable , 0, 3,  $row,$row+1,'shrink','shrink',2,2); $row++;
641
 
642
                }
643
 
644
 
645 54 alirezamon
                if ($cast_type ne '"UNICAST"'){
646
                        my $min=$self->object_get_attribute($sample,'MCAST_PCK_SIZ_MIN');
647
                        my $max=$self->object_get_attribute($sample,'MCAST_PCK_SIZ_MAX');
648
                        $min=5 if(!defined $min);
649
                        $max=5 if(!defined $max);
650
                        $max= $min if($max< $min);
651
 
652
 
653
                        my $s = ($cast_type eq '"BROADCAST_FULL"' || $cast_type eq '"BROADCAST_PARTIAL"')? "Broadcast" :  "Milticast";
654
                        my $info1= "Define the percentage ratio of $s traffic towards Unicast traffic";
655
                        my $info2= "Define how destinations is selected in Multicast packets";
656
                        ($row,$coltmp)=add_param_widget  ($self, "$s Node Select"  , "MCAST_TRAFFIC_TYPE" , "Uniform-Random",  'Combo-box', "Uniform-Random", $info1, $table,$row,undef,1, $sample);
657
                        ($row,$coltmp)=add_param_widget  ($self, "$s Traffic Ratio", "MCAST_TRAFFIC_RATIO", 5 , 'Spin-button',  "0,100,1"  , $info2, $table,$row,undef,1, $sample);
658
 
659
                        ($row,$coltmp)=add_param_widget  ($self, "$s min pck size", "MCAST_PCK_SIZ_MIN", 5 , 'Spin-button',  "1,$max,1"  , $info2, $table,$row,undef,1, $sample,1,'ref_set_win');
660
 
661
                        ($row,$coltmp)=add_param_widget  ($self, "$s max pck size", "MCAST_PCK_SIZ_MAX", 5 , 'Spin-button',  "$min,100,1"  , $info2, $table,$row,undef,1, $sample,1,'ref_set_win');
662
 
663
 
664
 
665
                }
666
 
667
 
668
 
669
 
670 48 alirezamon
                my $d= { label=>'number of message class:', param_name=>'MESSAGE_CLASS', type=>'Spin-button', default_val=>0,  content=>"0,256,1", info=>"Number of packet message classes. Each message class can be configured to use specefic subset of avilable VCs",                          param_parent=>$sample, ref_delay=> 1, new_status=>'ref_set_win'};
671
                ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
672
                my $num=$self->object_get_attribute($sample,"MESSAGE_CLASS");
673
                if($num>0){
674
                        my $htable=def_table(10,2,FALSE);
675
                        $htable->attach ( gen_label_in_left ("Class num "), 0, 1,  $row,$row+1,'fill','shrink',2,2);
676
                        $htable->attach ( gen_label_in_left (" - "), 1, 2,  $row,$row+1,'fill','shrink',2,2);
677
                        $htable->attach ( gen_label_in_left ("Traffic(%)"), 2, 3,  $row,$row+1,'fill','shrink',2,2);
678
                        $row++;
679
 
680
                        for (my $i=0;$i<$num;$i++){
681
                                $htable->attach ( gen_label_in_left ("$i"), 0, 1,  $row,$row+1,'fill','shrink',2,2);
682
                                my $w1 = gen_spin_object ($self,$sample,"CLASS_$i","0,100,1", 100/$num,undef,undef);
683
                                $htable->attach ( $w1, 2, 3,  $row,$row+1,'fill','shrink',2,2);
684
                                $row++;
685
                        }
686
                        $table->attach  ($htable , 0, 3,  $row,$row+1,'shrink','shrink',2,2); $row++;
687
                }
688
 
689
 
690 38 alirezamon
 
691
                if ($traffic eq 'hot spot'){
692
                        my $htable=def_table(10,2,FALSE);
693
 
694
                        my $d= { label=>'number of Hot Spot nodes:', param_name=>'HOTSPOT_NUM', type=>'Spin-button', default_val=>1,  content=>"1,256,1", info=>"Number of hot spot nodes in the network",                        param_parent=>$sample, ref_delay=> 1, new_status=>'ref_set_win'};
695 43 alirezamon
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
696 38 alirezamon
 
697 48 alirezamon
                                my $l1=gen_label_help("Define the tile number which is  hotspt. All other nodes will send [Hot Spot traffic percentage] of their traffic to this node","  Hot Spot tile number \%");
698 38 alirezamon
                                my $l2=gen_label_help("If it is set as \"n\" then each node sends n % of its traffic to each hotspot node","  Hot Spot traffic \%");
699 48 alirezamon
                                my $l3=gen_label_help("If it is checked then hot spot node also sends packets to other nodes otherwise it only receives packets from other nodes","  send enable");
700 38 alirezamon
 
701
                                $htable->attach  ($l1 , 0, 1,  $row,$row+1,'fill','shrink',2,2);
702
                                $htable->attach  ($l2 , 1, 2,  $row,$row+1,'fill','shrink',2,2);
703
                                $htable->attach  ($l3 , 2,3,  $row,$row+1,'fill','shrink',2,2);
704
                                $row++;
705
 
706
                                my $num=$self->object_get_attribute($sample,"HOTSPOT_NUM");
707
                                for (my $i=0;$i<$num;$i++){
708
                                        my $w1 = gen_spin_object ($self,$sample,"HOTSPOT_CORE_$i","0,256,1", $i,undef,undef);
709
                                        my $w2 = gen_spin_object ($self,$sample,"HOTSPOT_PERCENT_$i","0.1,100,0.1", 0.1,undef,undef);
710
                                        my $w3 = gen_check_box_object ($self,$sample,"HOTSPOT_SEND_EN_$i", 0,undef,undef);
711
                                        $htable->attach  ($w1 , 0, 1,  $row,$row+1,'fill','shrink',2,2);
712
                                        $htable->attach  ($w2 ,1, 2,  $row,$row+1,'fill','shrink',2,2);
713
                                        $htable->attach  ($w3 , 2,3,  $row,$row+1,'fill','shrink',2,2);
714
                                        $row++;
715
 
716
                                }
717
 
718
                                $table->attach  ($htable , 0, 3,  $row,$row+1,'shrink','shrink',2,2); $row++;
719
 
720
 
721
 
722
 
723
 
724
 
725
 
726
                }
727 48 alirezamon
                my $l= "Define injection ratios. You can define individual ratios separating by comma (\',\') or define a range of injection ratios with \$min:\$max:\$step format.
728 38 alirezamon
                        As an example defining 2,3,4:10:2 will result in (2,3,4,6,8,10) injection ratios." ;
729
                my $u=get_injection_ratios ($self,$sample,"ratios");
730
 
731
                attach_widget_to_table ($table,$row,gen_label_in_left(" Injection ratios:"),gen_button_message ($l,"icons/help.png") , $u); $row++;
732
 
733
                $ok->signal_connect("clicked"=> sub{
734
                        #check if sof file has been selected
735
                        my $s=$self->object_get_attribute($sample,"sof_file");
736
                        #check if injection ratios are valid
737
                        my $r=$self->object_get_attribute($sample,"ratios");
738 54 alirezamon
 
739 38 alirezamon
                        my $h;
740 48 alirezamon
 
741
                        my $t=$self->object_get_attribute($sample,"PCK_SIZ_SEL");
742
                        unless ($t eq 'random-range' ){
743
                                ($avg,$msg) = get_district_avg($self,$sample);
744
                                if(defined $msg){
745
                                message_dialog($msg);
746
                                return;
747
                                }
748
                        }
749
 
750 38 alirezamon
                        if ($traffic eq 'hot spot'){
751
                                $h=     check_hotspot_parameters($self,$sample);
752 48 alirezamon
                        }
753 38 alirezamon
 
754 54 alirezamon
                        my $v;
755
                        if(defined $r ){
756
                                        $v=check_inserted_ratios($r);
757
                        }
758
 
759
                        if(defined $s && defined $r && defined $v && !defined $h) {
760 48 alirezamon
                                        #$set_win->destroy;
761
                                        $set_win->hide();
762
                                        $self->object_add_attribute("active_setting",undef,undef);
763 38 alirezamon
                                        set_gui_status($self,"ref",1);
764
                        } else {
765
 
766
                                if(!defined $s){
767
                                        my $m= "Please select NoC verilated file";
768
                                        message_dialog($m);
769
                                } elsif (! defined $r) {
770
                                         message_dialog("Please define valid injection ratio(s)!");
771 54 alirezamon
                                } elsif (defined $h){
772 38 alirezamon
                                         message_dialog("$h");
773
                                }
774
                        }
775
                });
776
 
777
        }
778
 
779
 
780
        if($traffictype eq "Task-graph"){
781
 
782
                my @custominfo = (
783 48 alirezamon
                #{ label=>"Verilated Model", param_name=>'sof_file', type=>'Combo-box', default_val=>undef, content=>$exe_files, info=>"Select the verilator simulation file. Different NoC simulators can be generated using Generate NoC configuration tab.", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
784 38 alirezamon
 
785 48 alirezamon
                { label=>'Configuration name:', param_name=>'line_name', type=>'Entry', default_val=>$sample, content=>undef, info=>"NoC configuration name. This name will be shown in load-latency graph for this configuration", param_parent=>$sample, ref_delay=> undef, new_status=>undef},
786 38 alirezamon
 
787
                { label=>"Number of Files", param_name=>"TRAFFIC_FILE_NUM", type=>'Spin-button', default_val=>1, content=>"1,100,1", info=>"Select number of input files", param_parent=>$sample, ref_delay=>1, new_status=>'ref_set_win'},
788
 
789 43 alirezamon
                { label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,$max_sim_clk,1", info=>"Each node stops sending packets when it reaches packet number limit  or simulation clock number limit", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
790 38 alirezamon
                );
791
 
792
                foreach my $d (@custominfo) {
793 43 alirezamon
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
794
 
795
                }
796 38 alirezamon
 
797
 
798
                my $open_in  = "$ENV{'PRONOC_WORK'}/traffic_pattern";
799
 
800
 
801
 
802
                 my $num=$self->object_get_attribute($sample,"TRAFFIC_FILE_NUM");
803
                 for (my $i=0; $i<$num; $i++){
804 48 alirezamon
                        attach_widget_to_table ($table,$row,gen_label_in_left("traffic pattern file $i:"),gen_button_message ("Select the traffic pattern input file. Any custom traffic based on application task graphs can be generated using ProNoC Trace Generator tool.","icons/help.png"), get_file_name_object ($self,$sample,"traffic_file$i",undef,$open_in)); $row++;
805 38 alirezamon
                 }
806
 
807 48 alirezamon
 
808
 
809
 
810
 
811 38 alirezamon
                $ok->signal_connect("clicked"=> sub{
812
                        #check if sof file has been selected
813
                        my $s=$self->object_get_attribute($sample,"sof_file");
814
                        if(!defined $s){
815
                                        message_dialog("Please select NoC verilated file");
816
                                        return;
817
                        }
818
 
819
                        #check if traffic files have been selected
820
                        for (my $i=0; $i<$num; $i++){
821
                                my $f=$self->object_get_attribute($sample,"traffic_file$i");
822
                                if(!defined $f){
823
                                        my $m= "Please select traffic_file$i";
824
                                        message_dialog($m);
825
                                        return;
826
                                }
827
 
828
                        }
829 48 alirezamon
                        #$set_win->destroy;
830
                        $set_win->hide();
831
                        $self->object_add_attribute("active_setting",undef,undef);
832 38 alirezamon
                        set_gui_status($self,"ref",1);
833
 
834
                });
835
 
836
 
837
        }
838
 
839
 
840 54 alirezamon
        if($traffictype eq "SynFull"){
841
                #get the synful model names
842
                my $models_dir  = get_project_dir()."/mpsoc/src_c/synfull/generated-models/";
843
                my ($flist)=get_file_list_by_extention ("$models_dir",".model");
844
 
845
 
846
                my $model_obj = gen_combobox_object ($self,$sample, "MODEL_NAME", $flist, undef,undef,undef);
847
                attach_widget_to_table ($table,$row,gen_label_in_left(" Traffic Model name:"),gen_button_message ("Select an application traffic model.","icons/help.png"),
848
                $model_obj); $row++;
849
 
850
 
851
 
852
                my @custominfo = (
853
                { label=>"Synful Flit-size:(Bytes)", param_name=>'SYNFUL_FLITw', type=>'Spin-button', default_val=>4, content=>"4,72,4", info=>"The synful flit size in Byte. It defines the number of flits that should be set to ProNoC for each synful packets. The ProNoC packet size is :
854
                \t Ceil( synful packet size/synful flit size).  ", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
855
                { label=>'Configuration name:', param_name=>'line_name', type=>'Entry', default_val=>$sample, content=>undef, info=>"NoC configuration name. This name will be shown in load-latency graph for this configuration", param_parent=>$sample, ref_delay=> undef, new_status=>undef},
856
            { label=>"Total packet number limit:", param_name=>'PCK_NUM_LIMIT', type=>'Spin-button', default_val=>200000, content=>"2,$max_pck_num,1", info=>"Simulation will stop when total number of sent packets by all nodes reaches packet number limit  or total simulation clock reach its limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
857
                { label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,$max_sim_clk,1", info=>"Each node stops sending packets when it reaches packet number limit  or simulation clock number limit", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
858
                { label=>"Markov Chain Random seed:", param_name=>'RND_SEED', type=>'Spin-button', default_val=>53432145, content=>"0,999999999,1", info=>"The seed valus is passe to synfull random number generator.", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
859
                { label=>"Exit at steady state:", param_name=>'EXIT_STEADY', type=>'Check-box', default_val=>0, content=>"1", info=>"Exit the simulation when it reaches to a steady state.", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
860
 
861
 
862
 
863
                );
864
 
865
 
866
 
867
                foreach my $d (@custominfo) {
868
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
869
 
870
                }
871
 
872
                $ok->signal_connect("clicked"=> sub{
873
                        #check if sof file has been selected
874
                        my $s=$self->object_get_attribute($sample,"MODEL_NAME");
875
                        if(!defined $s){
876
                                        message_dialog("Please select a SynFull traffic model");
877
                                        return;
878
                        }
879
 
880
 
881
                        #$set_win->destroy;
882
                        $set_win->hide();
883
                        $self->object_add_attribute("active_setting",undef,undef);
884
                        set_gui_status($self,"ref",1);
885
 
886
                });
887
 
888
 
889
 
890
        }#SynFull
891
 
892
 
893
        if($traffictype eq "Netrace"){
894
                #get the synful model names
895
                my $models_dir  = "$ENV{PRONOC_WORK}/simulate/netrace";
896
                my ($flist)=get_file_list_by_extention ("$models_dir",".bz2");
897
 
898
                my $model_obj = gen_combobox_object ($self,$sample, "MODEL_NAME", $flist, undef,undef,undef);
899
                my $download=def_image_button("icons/download.png",'Download');
900
                my $box =def_hbox(FALSE, 0);
901
                $box->pack_start( $model_obj , 1,1, 0);
902
                $box->pack_start( $download, 0, 1, 3);
903
 
904
                attach_widget_to_table ($table,$row,gen_label_in_left(" Trace name:"),gen_button_message ("Select a netrace trace file. You can download traces using download button.","icons/help.png"),
905
                $box);
906
 
907
 
908
                $row++;
909
 
910
 
911
 
912
                my @custominfo = (
913
                { label=>'Configuration name:', param_name=>'line_name', type=>'Entry', default_val=>$sample, content=>undef, info=>"NoC configuration name. This name will be shown in load-latency graph for this configuration", param_parent=>$sample, ref_delay=> undef, new_status=>undef},
914
            { label=>"Total packet number limit:", param_name=>'PCK_NUM_LIMIT', type=>'Spin-button', default_val=>200000, content=>"2,$max_pck_num,1", info=>"Simulation will stop when total number of sent packets by all nodes reaches packet number limit  or total simulation clock reach its limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
915
                #{ label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,$max_sim_clk,1", info=>"Each node stops sending packets when it reaches packet number limit  or simulation clock number limit", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
916
                { label=>"ignore dependencies:", param_name=>'IGNORE_DPNDCY', type=>'Check-box', default_val=>0, content=>"1", info=>"Ignore dependency between packets", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
917
                { label=>"Enable reader throttling:", param_name=>'READER_THRL', type=>'Check-box', default_val=>0, content=>"1", info=>"If Reader throttling is enabled, simulators offloads much of the work of reading and tracking packets to the Netrace reader,
918
which simplifies the code in the network simulator.", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
919
                { label=>"trace file start region:", param_name=>'START_RGN', type=>'Spin-button', default_val=>0, content=>"0,10000,1", info=>undef, param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
920
                { label=>"Netrace to Pronoc clk ratio:", param_name=>'SPEED_UP', type=>'Spin-button', default_val=>1, content=>"1,99,1", info=>"The ratio of netrace frequency to pronoc.The higher value results in higher injection ratio to the NoC. Default is one\n", param_parent=>$sample, ref_delay=>undef,  new_status=>undef},
921
 
922
 
923
 
924
 
925
 
926
 
927
                );
928
 
929
 
930
 
931
                foreach my $d (@custominfo) {
932
                        ($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
933
 
934
                }
935
 
936
                $ok->signal_connect("clicked"=> sub{
937
                        #check if sof file has been selected
938
                        my $s=$self->object_get_attribute($sample,"MODEL_NAME");
939
                        if(!defined $s){
940
                                        message_dialog("Please select a SynFull traffic model");
941
                                        return;
942
                        }
943
 
944
 
945
                        #$set_win->destroy;
946
                        $set_win->hide();
947
                        $self->object_add_attribute("active_setting",undef,undef);
948
                        set_gui_status($self,"ref",1);
949
 
950
                });
951
 
952
                $download->signal_connect("clicked"=> sub{ download_netrace("$models_dir")      });
953
 
954
 
955
 
956
        }#netrace
957
 
958
 
959
 
960
 
961
 
962
 
963 48 alirezamon
        add_widget_to_scrolled_win ($mtable,$set_win);
964 38 alirezamon
 
965
        $set_win->show_all();
966
 
967
 
968
}
969
 
970
 
971
 
972 32 alirezamon
############
973 38 alirezamon
#       run_simulator
974
###########
975
 
976
sub run_simulator {
977
        my ($simulate,$info)=@_;
978
        #return if(!check_samples($emulate,$info));
979
        $simulate->object_add_attribute('status',undef,'run');
980
        set_gui_status($simulate,"ref",1);
981
        show_info($info, "Start Simulation\n");
982
        my $name=$simulate->object_get_attribute ("simulate_name",undef);
983
 
984
        #unlink $log; # remove old log file
985
 
986
        my @samples =$simulate->object_get_attribute_order("samples");
987
        foreach my $sample (@samples){
988
                my $status=$simulate->object_get_attribute ($sample,"status");
989
                next if($status ne "run");
990
                next if(!check_sim_sample($simulate,$sample,$info));
991
                my $traffictype=$simulate->object_get_attribute($sample,"TRAFFIC_TYPE");
992 54 alirezamon
                if($traffictype eq "Synthetic") {run_synthetic_simulation($simulate,$info,$sample,$name);}
993
                elsif($traffictype eq "Task-graph"){run_task_simulation($simulate,$info,$sample,$name) ;}
994
                else {run_trace_simulation($simulate,$info,$sample,$name);}
995 38 alirezamon
 
996
        }
997
 
998
        add_info($info, "Simulation is done!\n");
999 43 alirezamon
        printf "Simulation is done!\n";
1000 38 alirezamon
        $simulate->object_add_attribute('status',undef,'ideal');
1001
        set_gui_status($simulate,"ref",1);
1002
}
1003
 
1004
 
1005
sub run_synthetic_simulation {
1006
        my ($simulate,$info,$sample,$name)=@_;
1007 48 alirezamon
 
1008
 
1009
        my %traffic= (
1010
        'tornado' => 'TORNADO',
1011
        'transposed 1' => "TRANSPOSE1",
1012
        'transposed 2' => "TRANSPOSE2",
1013
        'bit reverse'  => "BIT_REVERSE",
1014
        'bit complement' => "BIT_COMPLEMENT",
1015
        'random' => "RANDOM",
1016
        'hot spot' => "HOTSPOT",
1017
        'shuffle' => "SHUFFLE",
1018
        'bit rotation' => "BIT_ROTATE",
1019
        'neighbor' => "NEIGHBOR",
1020
        'custom' => "CUSTOM"
1021
        );
1022
 
1023
        my $simulator =$simulate->object_get_attribute("Simulator");
1024 38 alirezamon
        my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
1025 48 alirezamon
        my $out_path ="$ENV{PRONOC_WORK}/simulate/";
1026 38 alirezamon
        my $r= $simulate->object_get_attribute($sample,"ratios");
1027
        my @ratios=@{check_inserted_ratios($r)};
1028
        #$emulate->object_add_attribute ("sample$i","status","run");
1029 43 alirezamon
        my $bin=get_sim_bin_path($simulate,$sample,$info);
1030 38 alirezamon
 
1031
        #load traffic configuration
1032 48 alirezamon
        my $patern=$simulate->object_get_attribute ($sample,'traffic');
1033
        my $PCK_NUM_LIMIT=$simulate->object_get_attribute ($sample,"PCK_NUM_LIMIT");
1034
        my $SIM_CLOCK_LIMIT=$simulate->object_get_attribute ($sample,"SIM_CLOCK_LIMIT");
1035 38 alirezamon
        my $MIN_PCK_SIZE=$simulate->object_get_attribute ($sample,"MIN_PCK_SIZE");
1036
        my $MAX_PCK_SIZE=$simulate->object_get_attribute ($sample,"MAX_PCK_SIZE");
1037
 
1038
 
1039
        #hotspot 
1040 48 alirezamon
        my $custom="";
1041
        my $custom_sv="";
1042
        if ($patern eq 'custom'){
1043
                $custom="";
1044
                my $num=$simulate->object_get_attribute($sample,"CUSTOM_SRC_NUM");
1045
                $custom_sv.="localparam CUSTOM_NODE_NUM=$num;\n\twire [NEw-1 : 0] custom_traffic_t   [NE-1 : 0];\n\twire [NE-1 : 0] custom_traffic_en;\n";
1046
                        my @srcs;
1047
                for (my $i=0;$i<$num; $i++){
1048
                        my $src = $simulate->object_get_attribute($sample,"SRC_$i");
1049
                        my $dst = $simulate->object_get_attribute($sample,"DST_$i");
1050
 
1051
                        $custom.=($i==0)? "-H \"$src,$dst" : ",$src,$dst";
1052
 
1053
                }
1054
                my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($simulate,$sample);
1055
                my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
1056
 
1057
                for (my $i=0;$i<$NE; $i++){
1058
                        my ($src,$dst) = custom_traffic_dest ($simulate,$sample,$i);
1059
                        $custom_sv.="\tassign custom_traffic_t[$src]=$dst;\n";
1060
                        $custom_sv.="\tassign custom_traffic_en[$src]=";
1061
                        $custom_sv.=($dst==-1)? "1'b0;//off \n" : "1'b1;\n"
1062
                }
1063
                $custom.="\"";
1064
 
1065
        }
1066
        else{
1067
                $custom_sv.="localparam CUSTOM_NODE_NUM=0;\n\twire [NEw-1 : 0] custom_traffic_t   [NE-1 : 0];\n\twire [NE-1 : 0] custom_traffic_en;
1068
                ";
1069
        }
1070 54 alirezamon
        #multicast
1071
        my $mcast="";
1072
        my $mcast_sv="";
1073
        my $p= $simulate->object_get_attribute ($sample,"noc_info");
1074
    my $cast_type=$p->{"CAST_TYPE"};
1075
        if ($cast_type ne '"UNICAST"'){
1076
                #$self->object_get_attribute ($sample,  "MCAST_TRAFFIC_TYPE");
1077
                my $mr   = $simulate->object_get_attribute  ($sample,  "MCAST_TRAFFIC_RATIO");
1078
                my $mmax = $simulate->object_get_attribute  ($sample,  "MCAST_PCK_SIZ_MAX");
1079
                my $mmin = $simulate->object_get_attribute  ($sample,  "MCAST_PCK_SIZ_MIN");
1080
 
1081
                $mcast = "-u \"$mr,$mmin,$mmax\"";
1082
                $mcast_sv.= "localparam MCAST_TRAFFIC_RATIO =   $mr;\n";
1083
                $mcast_sv.= "localparam MCAST_PCK_SIZ_MAX =     $mmax;\n";
1084
                $mcast_sv.= "localparam MCAST_PCK_SIZ_MIN =     $mmin;\n";
1085
        }else {
1086
                $mcast_sv.= "localparam MCAST_TRAFFIC_RATIO =   0;\n";
1087
                $mcast_sv.= "localparam MCAST_PCK_SIZ_MAX =     0;\n";
1088
                $mcast_sv.= "localparam MCAST_PCK_SIZ_MIN =     0;\n";
1089
        }
1090 48 alirezamon
 
1091 54 alirezamon
 
1092
 
1093
 
1094
 
1095 48 alirezamon
        my $classes;
1096
        my $num=$simulate->object_get_attribute($sample,"MESSAGE_CLASS");
1097
        $classes.="-p 100" if($num==0);
1098
        for (my $i=0;$i<$num;$i++){
1099
                my $w1 = $simulate->object_get_attribute($sample,"CLASS_$i");
1100
                $classes.= ($i==0)?  "-p $w1" : ",$w1" ;
1101
 
1102
        }
1103
 
1104
        my $discrete_sv="";
1105 38 alirezamon
        my $hotspot="";
1106 48 alirezamon
        my $hotspot_sv="";
1107 38 alirezamon
        if($patern eq "hot spot"){
1108
                $hotspot="-h \" ";
1109
                my $num=$simulate->object_get_attribute($sample,"HOTSPOT_NUM");
1110
                if (defined $num){
1111 48 alirezamon
                        $hotspot.=" $num";
1112 38 alirezamon
 
1113 48 alirezamon
                        $hotspot_sv.="localparam HOTSPOT_NODE_NUM=$num;\n\thotspot_t  hotspot_info [HOTSPOT_NODE_NUM-1 : 0];\n";
1114
                        my $acum=0;
1115
 
1116 38 alirezamon
                        for (my $i=0;$i<$num;$i++){
1117
                                my $w1 = $simulate->object_get_attribute($sample,"HOTSPOT_CORE_$i");
1118
                                my $w2 = $simulate->object_get_attribute($sample,"HOTSPOT_PERCENT_$i");
1119
                                $w2=$w2*10;
1120
                                my $w3 = $simulate->object_get_attribute($sample,"HOTSPOT_SEND_EN_$i");
1121 48 alirezamon
                                $hotspot.=",$w1,$w3,$w2";
1122
                                $acum+=$w2;
1123
 
1124
                                $hotspot_sv.="
1125
        assign  hotspot_info[$i].ip_num=$w1;
1126
        assign  hotspot_info[$i].send_enable=$w3;
1127
        assign  hotspot_info[$i].percentage=$acum;      // $w2
1128
";                      }
1129 38 alirezamon
 
1130
                }
1131
 
1132 48 alirezamon
                $hotspot.=" \"";
1133 38 alirezamon
 
1134
        }
1135 48 alirezamon
        else{ $hotspot_sv.="localparam HOTSPOT_NODE_NUM = 0;\n\thotspot_t  hotspot_info [0:0];\n" }
1136
 
1137
        my $pck_size;
1138
        my $t=$simulate->object_get_attribute($sample,"PCK_SIZ_SEL");
1139
        if($t eq 'random-range' ){
1140
 
1141
                $pck_size = "-m \"R,$MIN_PCK_SIZE,$MAX_PCK_SIZE\"";
1142
                $discrete_sv="\t localparam DISCRETE_PCK_SIZ_NUM=1;
1143
\t rnd_discrete_t rnd_discrete [DISCRETE_PCK_SIZ_NUM-1:0];\n";
1144
 
1145
        }else{
1146
                my $vt=$simulate->object_get_attribute($sample,"DISCRETE_RANGE");
1147
                my $pt=$simulate->object_get_attribute($sample,"PROBEB_RANGE");
1148
                $pck_size = "-m \"D,$vt,P,$pt\"";
1149
                my @injects = split(',',$vt);
1150
                my @probs = split(',',$pt);
1151
                my $i=0;
1152
                my $sum=0;
1153
                for my $v (@injects) {
1154
                        $sum+=$probs[$i];
1155
                        $discrete_sv.= "\t assign rnd_discrete[$i].value= $v;\n";
1156
                        $discrete_sv.= "\t assign rnd_discrete[$i].percentage= $sum;\n";
1157
                        $i++;
1158
                }
1159
                $discrete_sv="\t localparam DISCRETE_PCK_SIZ_NUM=$i;
1160
\t rnd_discrete_t rnd_discrete [DISCRETE_PCK_SIZ_NUM-1: 0];\n".$discrete_sv;
1161
        }
1162
 
1163
        my $modelsim_bin=  $ENV{MODELSIM_BIN};
1164 53 alirezamon
        my $vsim = (! defined $modelsim_bin)? "vsim" : "$modelsim_bin/vsim";
1165
 
1166
 
1167
 
1168 48 alirezamon
 
1169
        my $cpu_num = $simulate->object_get_attribute('compile', 'cpu_num');
1170
        $cpu_num = 1 if (!defined $cpu_num);
1171
 
1172
        my $thread_num = $simulate->object_get_attribute('compile', 'thread_num');
1173
        $thread_num = 1 if (!defined $thread_num);
1174
 
1175
        if ($simulator ne 'Verilator'){
1176
                for (my $i=0; $i<$cpu_num; $i++  ){
1177
                        my $out="$out_path/modelsim/work$i";
1178
                        rmtree("$out");
1179
                        mkpath("$out",1,01777);
1180
        my $vsim = ($simulator eq 'Modelsim')? "vsim -c": "vsim";
1181
                        gen_noc_localparam_v_file($simulate,"$out",$sample);
1182
                        my $param="
1183
// simulation parameter setting
1184
 
1185
`ifdef INCLUDE_SIM_PARAM
1186
        localparam
1187
                TRAFFIC=\"$traffic{$patern}\",
1188
                PCK_SIZ_SEL=\"$t\",
1189
                AVG_LATENCY_METRIC= \"HEAD_2_TAIL\",
1190
                //simulation min and max packet size. The injected packet take a size randomly selected between min and max value
1191
                MIN_PACKET_SIZE=$MIN_PCK_SIZE,
1192
                MAX_PACKET_SIZE=$MAX_PCK_SIZE,
1193
                STOP_PCK_NUM=$PCK_NUM_LIMIT,
1194
                STOP_SIM_CLK=$SIM_CLOCK_LIMIT;
1195 54 alirezamon
 
1196 48 alirezamon
 
1197
        $hotspot_sv
1198
 
1199
        $custom_sv
1200
 
1201 54 alirezamon
        $mcast_sv
1202
 
1203 48 alirezamon
$discrete_sv
1204
 
1205
                parameter INJRATIO=90;
1206
`endif
1207
                        ";
1208
                        save_file("$out/sim_param.sv",$param);
1209 38 alirezamon
 
1210 48 alirezamon
 
1211
                        #Get the list of  all verilog files in src_verilog folder
1212
                        my @files = File::Find::Rule->file()
1213
                        ->name( '*.v','*.V','*.sv' )
1214
                        ->in( "$out_path/modelsim/src_verilog" );
1215 38 alirezamon
 
1216 48 alirezamon
                        #get list of all verilog files in src_sim folder 
1217
                my @sim_files = File::Find::Rule->file()
1218
                        ->name( '*.v','*.V','*.sv' )
1219
                        ->in( "$out_path/modelsim/src_modelsim" );
1220
                        push (@files, @sim_files);
1221
                        my $tt =create_file_list("$out_path/modelsim",\@files,'modelsim');
1222
                        $tt="+incdir+./ \n$tt";
1223
                        save_file("$out/file_list.f",  "$tt");
1224
                        my $tcl="#!/usr/bin/tclsh
1225
 
1226
 
1227
transcript on
1228
if {[file exists rtl_work]} {
1229
        vdel -lib rtl_work -all
1230
}
1231
vlib rtl_work
1232
vmap work rtl_work
1233
 
1234
 
1235
vlog  +acc=rn  -F $out/file_list.f
1236
 
1237
$vsim -t 1ps  -L rtl_work -L work -voptargs=\"+acc\"  testbench_noc
1238
 
1239
add wave *
1240
view structure
1241
view signals
1242
run -all
1243
quit
1244
";
1245
 
1246
                        save_file ("$out/model.tcl",$tcl);
1247
 
1248 53 alirezamon
                        my $cmd="cd $out; rm -Rf rtl_work; $vsim -do $out/model.tcl ";
1249 48 alirezamon
                        save_file ("$out/run.sh",'#!/bin/bash'."
1250
                        sed -i \"s/ INJRATIO=\[\[:digit:\]\]\\+/ INJRATIO=\$1/\" $out/sim_param.sv
1251
                        ".$cmd);
1252
                        add_info($info, "model.tcl is created in $out\n");
1253
                }#for           
1254
        }
1255
 
1256
 
1257
 
1258
        my @paralel_ratio;
1259
        my $total=scalar @ratios;
1260
        my $jobs=0;
1261
        my $c=0;
1262
        my $cmds="";
1263
 
1264
 
1265 38 alirezamon
        foreach  my $ratio_in (@ratios){
1266
                #my $r= $ratio_in * MAX_RATIO/100;
1267 48 alirezamon
                my $cmd;
1268
 
1269
                if ($simulator eq 'Modelsim'){
1270
                        add_info($info, "Run $bin with  injection ratio of $ratio_in \% \n");
1271
                        my $out="$out_path/modelsim/work$c";
1272 54 alirezamon
                        $cmd="  xterm -e bash -c '      cd $out; sed -i \"s/ INJRATIO=\[\[:digit:\]\]\\+/ INJRATIO=$ratio_in/\" $out/sim_param.sv; rm -Rf rtl_work; $vsim -c -do $out/model.tcl -l $out_path/sim_out$ratio_in;' &\n     ";
1273 48 alirezamon
 
1274
                }elsif ($simulator eq 'Modelsim gui'){
1275
                        add_info($info, "Run $bin with  injection ratio of $ratio_in \% \n");
1276
                        my $out="$out_path/modelsim/work$c";
1277 54 alirezamon
                        $cmd="cd $out; sed -i \"s/ INJRATIO=\[\[:digit:\]\]\\+/ INJRATIO=$ratio_in/\" $out/sim_param.sv;  rm -Rf rtl_work; $vsim -do $out/model.tcl -l $out_path/sim_out$ratio_in;      ";
1278 48 alirezamon
 
1279
                }else{
1280
                        add_info($info, "Run $bin with  injection ratio of $ratio_in \% \n");
1281 54 alirezamon
                        $cmd="$bin -t \"$patern\" $pck_size -T $thread_num -n $PCK_NUM_LIMIT -c $SIM_CLOCK_LIMIT -i $ratio_in $classes $hotspot $custom $mcast > $out_path/sim_out$ratio_in & ";
1282 48 alirezamon
 
1283
                }
1284
                $cmds .=$cmd;
1285 38 alirezamon
                        add_info($info, "$cmd \n");
1286 48 alirezamon
 
1287 38 alirezamon
                        my $time_strg = localtime;
1288 48 alirezamon
                        #append_text_to_file($log,"started at:$time_strg\n"); #save simulation output
1289
                        $jobs++;
1290 38 alirezamon
 
1291 48 alirezamon
                        push (@paralel_ratio,$ratio_in);
1292
                        $c++;
1293
                        if($jobs % $cpu_num ==0 || $jobs == $total){
1294
 
1295
                                #run paralle simulation                         
1296
                                        my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout("$cmds\n wait\n");
1297
                                        if($exit || (length $stderr >4)){
1298
                                                        add_colored_info($info, "Error in running simulation: $stderr \n",'red');
1299
                                                        $simulate->object_add_attribute ($sample,"status","failed");
1300
                                                        $simulate->object_add_attribute('status',undef,'ideal');
1301
                                                        return;
1302
                                         }
1303
 
1304
                                #save results
1305
                                for (my $i=0; $i<$c; $i++){
1306
                                        my $r      = $paralel_ratio[$i];
1307
 
1308
                                        my @errors = unix_grep("$out_path/sim_out$r","ERROR:");
1309
                                        if (scalar @errors  ){
1310
                                                add_colored_info($info, "Error in running simulation: @errors \n",'red');
1311
                                                $simulate->object_add_attribute ($sample,"status","failed");
1312
                                                $simulate->object_add_attribute('status',undef,'ideal');
1313
                                                return;
1314
                                        }
1315
 
1316
 
1317
                                        my $stdout = load_file("$out_path/sim_out$r");
1318
 
1319
                                        extract_and_update_noc_sim_statistic ($simulate,$sample,$r,$stdout);
1320
 
1321
 
1322
                                }
1323
 
1324
                                $cmds="";
1325
                                @paralel_ratio=();
1326
                                $c=0;
1327
 
1328
                                set_gui_status($simulate,"ref",2);
1329
                        }
1330
 
1331
                }#@ratios       
1332 38 alirezamon
 
1333
                $simulate->object_add_attribute ($sample,"status","done");
1334
 
1335 48 alirezamon
}
1336
 
1337 54 alirezamon
 
1338
sub extract_st_by_name{
1339
        my($st_name, $stdout)=@_;
1340
 
1341
        my @results = split($st_name,$stdout);
1342 48 alirezamon
        my %statistcs;
1343 54 alirezamon
        my @lines = split("\n",$results[1]);
1344 48 alirezamon
        my @names;
1345
        my $i=0;
1346
        foreach my $line (@lines){
1347
                $line=remove_all_white_spaces($line);
1348
                $line =~ s/^#//g; #remove # from beginig of each line in modelsim 
1349 54 alirezamon
                if($i==0) {
1350
                        $i++;
1351
                        next;
1352
                }
1353
                elsif($i==1){
1354
                        #first line is statsitic names
1355
                        @names=split(",",$line);
1356
                        $i++;
1357
                        next;
1358
                }elsif(length($line)>1) {
1359 48 alirezamon
                        my @fileds=split(",",$line);
1360
                        my $j=0;
1361
                        #print ("ff :@fileds\n");
1362
                        foreach my $f (@fileds){
1363
                                unless($j==0){
1364 54 alirezamon
                                        $statistcs{$fileds[0]}{$names[$j]}=$f;
1365 48 alirezamon
                                }
1366
                                $j++;
1367
                        }
1368 54 alirezamon
                        $i++;
1369
                }else{ #empty line end of endp statistic
1370
                        last;
1371 48 alirezamon
                }
1372 54 alirezamon
 
1373 48 alirezamon
        }
1374
        #print Dumper(\%statistcs);
1375 54 alirezamon
        return  %statistcs;
1376
}
1377
 
1378
 
1379
 
1380
sub extract_and_update_noc_sim_statistic {
1381
        my ($simulate,$sample,$ratio_in,$stdout)=@_;
1382
 
1383 38 alirezamon
 
1384 48 alirezamon
 
1385
        my $total_time =capture_number_after("Simulation clock cycles:",$stdout);
1386
 
1387 54 alirezamon
        my %statistcs = extract_st_by_name("Endpoints Statistics:",$stdout);
1388
 
1389
        return if (!defined $statistcs{"total"}{'avg_latency_pck'});
1390 48 alirezamon
        update_result($simulate,$sample,"latency_result",$ratio_in,$statistcs{"total"}{'avg_latency_pck'});
1391
        update_result($simulate,$sample,"latency_flit_result",$ratio_in,$statistcs{"total"}{'avg_latency_flit'});
1392
        update_result($simulate,$sample,"sd_latency_result",$ratio_in,$statistcs{"total"}{'avg.std_dev'});
1393
        update_result($simulate,$sample,"throughput_result",$ratio_in,$statistcs{"total"}{'avg_throughput(%)'});
1394
        update_result($simulate,$sample,"exe_time_result",$ratio_in,$total_time);
1395
        update_result($simulate,$sample,"worst_latency_result",$ratio_in,$statistcs{"total"}{'sent_stat.worst_latency'});
1396
        update_result($simulate,$sample,"latency_perhop_result",$ratio_in,$statistcs{"total"}{'avg_latency_per_hop'});
1397
        update_result($simulate,$sample,"min_latency_result",,$ratio_in,$statistcs{"total"}{'sent_stat.min_latency'});
1398
        update_result($simulate,$sample,"injected_pck_total",,$ratio_in,$statistcs{"total"}{'sent_stat.pck_num'});
1399
        update_result($simulate,$sample,"injected_flit_total",,$ratio_in,$statistcs{"total"}{'sent_stat.flit_num'});
1400
        foreach my $p (sort keys %statistcs){
1401
                next unless (is_integer($p));
1402
                update_result($simulate,$sample,"packet_rsvd_result",$ratio_in,$p,$statistcs{$p}{'rsvd_stat.pck_num'});
1403
                update_result($simulate,$sample,"worst_delay_rsvd_result",$ratio_in,$p,$statistcs{$p}{'rsvd_stat.worst_latency'});
1404
                update_result($simulate,$sample,"packet_sent_result",$ratio_in,$p,$statistcs{$p}{'sent_stat.pck_num'} );
1405
                update_result($simulate,$sample,"worst_delay_sent_result",$ratio_in,$p,$statistcs{$p}{'sent_stat.worst_latency'});
1406 54 alirezamon
                update_result($simulate,$sample,"flit_rsvd_result",$ratio_in,$p,$statistcs{$p}{'rsvd_stat.flit_num'});
1407
                update_result($simulate,$sample,"flit_sent_result",$ratio_in,$p,$statistcs{$p}{'sent_stat.flit_num'});
1408 48 alirezamon
        }
1409 54 alirezamon
 
1410
        my %st1 = extract_st_by_name("Endp_to_Endp flit_num:",$stdout);
1411
        update_result($simulate,$sample,"endp-endp-flit_result",$ratio_in,\%st1);
1412
 
1413
        my %st2 = extract_st_by_name("Endp_to_Endp pck_num:",$stdout);
1414
        update_result($simulate,$sample,"endp-endp-pck_result",$ratio_in,\%st2);
1415
 
1416
        my %st3 = extract_st_by_name("Routers' statistics:",$stdout);
1417
        foreach my $p (sort keys %st3){
1418
                update_result($simulate,$sample,"flit_per_router_result",$ratio_in,$p,$st3{$p}{'flit_in'});
1419
                update_result($simulate,$sample,"packet_per_router_result",$ratio_in,$p,$st3{$p}{'pck_in'});
1420 55 alirezamon
                my $tmp= ($st3{$p}{'flit_in'}==0)? 0 : ($st3{$p}{'flit_in_buffered'}*100) / $st3{$p}{'flit_in'};
1421 54 alirezamon
                #print " $tmp= ($st3{$p}{'flit_in_buffered'}*100) / $st3{$p}{'flit_in'};\n";
1422
                update_result($simulate,$sample,"flit_buffered_router_ratio",$ratio_in,$p,$tmp);
1423 55 alirezamon
                $tmp= ($st3{$p}{'flit_in'}==0)? 0 : ($st3{$p}{'flit_in_bypassed'}*100) / $st3{$p}{'flit_in'};
1424 54 alirezamon
                update_result($simulate,$sample,"flit_bypass_router_ratio",$ratio_in,$p,$tmp);
1425
 
1426
        }
1427
 
1428
        #my $p= $simulate->object_get_attribute ($sample,"noc_info");    
1429
   # my $TOPOLOGY=$p->{"TOPOLOGY"};
1430
        #print "$TOPOLOGY\n";
1431
 
1432
 
1433 38 alirezamon
}
1434
 
1435
 
1436 48 alirezamon
sub run_task_simulation{
1437 38 alirezamon
        my ($simulate,$info,$sample,$name)=@_;
1438
        my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
1439
        my $SIM_CLOCK_LIMIT=$simulate->object_get_attribute ($sample,"SIM_CLOCK_LIMIT");
1440 43 alirezamon
 
1441
        my $bin=get_sim_bin_path($simulate,$sample,$info);
1442
 
1443 38 alirezamon
        my $dir = Cwd::getcwd();
1444
        my $project_dir   = abs_path("$dir/../.."); #mpsoc directory address
1445
        $bin= "$project_dir/$bin"   if(!(-f $bin));
1446
        my $num=$simulate->object_get_attribute($sample,"TRAFFIC_FILE_NUM");
1447 48 alirezamon
 
1448
        my $cpu_num = $simulate->object_get_attribute('compile', 'cpu_num');
1449
        $cpu_num = 1 if (!defined $cpu_num);
1450
 
1451
        my @paralel_ratio;
1452
        my $total=$num;
1453
        my $jobs=0;
1454
        my $c=0;
1455
        my $cmds="";
1456
        my $out_path ="$ENV{PRONOC_WORK}/simulate/";
1457
 
1458 38 alirezamon
        for (my $i=0; $i<$num; $i++){
1459
                 my $f=$simulate->object_get_attribute($sample,"traffic_file$i");
1460
                 add_info($info, "Run $bin for $f  file \n");
1461 48 alirezamon
                 my $cmd="$bin -c $SIM_CLOCK_LIMIT -f  \"$f\" > $out_path/sim_out$i & ";
1462
                 $cmds .=$cmd;
1463 38 alirezamon
                 add_info($info, "$cmd \n");
1464 48 alirezamon
                 $jobs++;
1465
                 push (@paralel_ratio,$i);
1466
                 $c++;
1467
                 if($jobs % $cpu_num ==0 || $jobs == $total){
1468
                        #run paralle simulation
1469
                        my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout("$cmds\n wait\n");
1470
                        #print "($stdout,$exit,$stderr)\n";
1471
                        if($exit || (length $stderr >4)){
1472
                                add_colored_info($info, "Error in running simulation: $stderr \n",'red');
1473 38 alirezamon
                                $simulate->object_add_attribute ($sample,"status","failed");
1474
                                $simulate->object_add_attribute('status',undef,'ideal');
1475
                                return;
1476 48 alirezamon
                         }
1477
 
1478 38 alirezamon
 
1479 48 alirezamon
 
1480
 
1481
                        #save results
1482
                        for (my $j=0; $j<$c; $j++){
1483
                                my $r      = $paralel_ratio[$j];
1484
                                my $stdout = load_file("$out_path/sim_out$r");
1485
                                my @errors = unix_grep("$out_path/sim_out$r","ERROR:");
1486
                                if (scalar @errors  ){
1487
                                                add_colored_info($info, "Error in running simulation: @errors \n",'red');
1488
                                                $simulate->object_add_attribute ($sample,"status","failed");
1489
                                                $simulate->object_add_attribute('status',undef,'ideal');
1490
                                                return;
1491
                                }
1492
 
1493
                                extract_and_update_noc_sim_statistic ($simulate,$sample,$r,$stdout);
1494
                        }
1495
 
1496
                        $cmds="";
1497
                        @paralel_ratio=();
1498
                        $c=0;
1499
                        set_gui_status($simulate,"ref",2);
1500
                }
1501
 
1502
        }#for i
1503 38 alirezamon
 
1504
        $simulate->object_add_attribute ($sample,"status","done");
1505
}
1506
 
1507
 
1508
 
1509 54 alirezamon
 
1510
sub run_trace_simulation{
1511
        my ($simulate,$info,$sample,$name)=@_;
1512
        my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
1513
 
1514
 
1515
        my $bin=get_sim_bin_path($simulate,$sample,$info);
1516
 
1517
 
1518
        my $project_dir   = get_project_dir();
1519
        $bin= "$project_dir/$bin"   if(!(-f $bin));
1520
 
1521
 
1522
        my $cpu_num = $simulate->object_get_attribute('compile', 'cpu_num');
1523
        $cpu_num = 1 if (!defined $cpu_num);
1524
 
1525
        my @paralel_ratio;
1526
 
1527
        my $jobs=0;
1528
        my $c=0;
1529
        my $cmds="";
1530
        my $out_path ="$ENV{PRONOC_WORK}/simulate/";
1531
        my $thread_num = $simulate->object_get_attribute('compile', 'thread_num');
1532
        $thread_num = 1 if (!defined $thread_num);
1533
 
1534
        my $model= $simulate->object_get_attribute($sample,'MODEL_NAME');
1535
 
1536
        add_info($info, "Run $bin for $model model \n");
1537
 
1538
        my $cmd="$bin -T $thread_num ";
1539
        my $traffictype=$simulate->object_get_attribute($sample,"TRAFFIC_TYPE");
1540
        if($traffictype eq "Netrace"){
1541
                my $PCK_NUM_LIMIT=$simulate->object_get_attribute ($sample,"PCK_NUM_LIMIT");
1542
                my $IGNORE_DPNDCY=$simulate->object_get_attribute ($sample,"IGNORE_DPNDCY");
1543
                my $READER_THRL=$simulate->object_get_attribute ($sample,"READER_THRL");
1544
                my $START_RGN=$simulate->object_get_attribute ($sample,"START_RGN");
1545
                my $SPEED_UP=$simulate->object_get_attribute ($sample,"SPEED_UP");
1546
 
1547
                my $models_dir  = "$ENV{PRONOC_WORK}/simulate/netrace";
1548
 
1549
                $cmd .="-F $models_dir/$model.bz2 -n $PCK_NUM_LIMIT -r $START_RGN  -v 0 -s $SPEED_UP";
1550
                $cmd .=" -l " if ($READER_THRL eq "1\'b1" );
1551
                $cmd .=" -d " if ($IGNORE_DPNDCY eq "1\'b1");
1552
 
1553
 
1554
 
1555
 
1556
 
1557
        }else{#synful
1558
                my $SIM_CLOCK_LIMIT=$simulate->object_get_attribute ($sample,"SIM_CLOCK_LIMIT");
1559
                my $PCK_NUM_LIMIT=$simulate->object_get_attribute ($sample,"PCK_NUM_LIMIT");
1560
                my $RND_SEED=$simulate->object_get_attribute ($sample,"RND_SEED");
1561
                my $EXIT_STEADY=$simulate->object_get_attribute ($sample,"EXIT_STEADY");
1562
                my $FLITw=$simulate->object_get_attribute ($sample,"SYNFUL_FLITw");
1563
 
1564
 
1565
                my $models_dir  = get_project_dir()."/mpsoc/src_c/synfull/generated-models/";
1566
                $cmd .=" -S $models_dir/$model.model -n $PCK_NUM_LIMIT -r $RND_SEED -c $SIM_CLOCK_LIMIT -v 0 -w $FLITw";
1567
                $cmd .=" -s " if ($EXIT_STEADY eq "1\'b1");
1568
 
1569
 
1570
 
1571
        }
1572
        $cmd .=" > $out_path/sim_out";
1573
        add_info($info, "$cmd \n");
1574
 
1575
        my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout("$cmd\n wait\n");
1576
        if($exit || (length $stderr >4)){
1577
                add_colored_info($info, "Error in running simulation: $stderr \n",'red');
1578
                $simulate->object_add_attribute ($sample,"status","failed");
1579
                $simulate->object_add_attribute('status',undef,'ideal');
1580
                return;
1581
         }
1582
 
1583
 
1584
 
1585
        $stdout = load_file("$out_path/sim_out");
1586
        my @errors = unix_grep("$out_path/sim_out","ERROR:");
1587
        if (scalar @errors  ){
1588
                add_colored_info($info, "Error in running simulation: @errors \n",'red');
1589
                $simulate->object_add_attribute ($sample,"status","failed");
1590
                $simulate->object_add_attribute('status',undef,'ideal');
1591
                return;
1592
        }
1593
 
1594
        extract_and_update_noc_sim_statistic ($simulate,$sample,0,$stdout);
1595
 
1596
 
1597
        set_gui_status($simulate,"ref",2);
1598
 
1599
 
1600
        $simulate->object_add_attribute ($sample,"status","done");
1601
}
1602
 
1603
 
1604
 
1605
 
1606 38 alirezamon
##########
1607
# check_sample
1608
##########
1609
 
1610 43 alirezamon
sub get_sim_bin_path {
1611 38 alirezamon
        my ($self,$sample,$info)=@_;
1612
        my $bin_path=$self->object_get_attribute ($sample,"sof_path");
1613 43 alirezamon
        unless (-d $bin_path){
1614
                my $path= $self->object_get_attribute ("sim_param","BIN_DIR");
1615
                if(-d $path){
1616 48 alirezamon
                        add_colored_info($info, "Warning: The given path ($bin_path) for searching $sample bin file does not exist. The system search in default $path instead.\n",'green');
1617 43 alirezamon
                        $bin_path=$path;
1618
                }
1619
        }
1620 48 alirezamon
        my $bin_file=$self->object_get_attribute ($sample,"sof_file");
1621
        $bin_file = "-" if(!defined $bin_file);
1622 38 alirezamon
        my $sof="$bin_path/$bin_file";
1623 43 alirezamon
        return $sof;
1624
}
1625
 
1626
sub check_sim_sample{
1627
        my ($self,$sample,$info)=@_;
1628
        my $status=1;
1629
        my $sof=get_sim_bin_path($self,$sample,$info);
1630
 
1631 38 alirezamon
        # ckeck if sample have sof file
1632
        if(!defined $sof){
1633 43 alirezamon
                add_colored_info($info, "Error: bin file has not set for $sample!\n",'red');
1634 38 alirezamon
                $self->object_add_attribute ($sample,"status","failed");
1635
                $status=0;
1636
        } else {
1637
                # ckeck if bin file has info file 
1638
                my ($name,$path,$suffix) = fileparse("$sof",qr"\..[^.]*$");
1639
                my $sof_info= "$path$name.inf";
1640
                if(!(-f $sof_info)){
1641 48 alirezamon
                        add_colored_info($info, "Could not find $name.inf file in $path. An information file is required for each sof file containing the device name and  NoC configuration. Press F3 for more help.\n",'red');
1642 38 alirezamon
                        $self->object_add_attribute ($sample,"status","failed");
1643
                        $status=0;
1644
                }else { #add info
1645
                        my $pp= do $sof_info ;
1646
 
1647
                        my $p=$pp->{'noc_param'};
1648
 
1649
                        $status=0 if $@;
1650
                        message_dialog("Error reading: $@") if $@;
1651
                        if ($status==1){
1652
                                $self->object_add_attribute ($sample,"noc_info",$p) ;
1653
 
1654
 
1655
                        }
1656
                }
1657
        }
1658 43 alirezamon
        #check if sample min packet size matches in simulation 
1659
 
1660
        my $p= $self->object_get_attribute ($sample,"noc_info");
1661
    my $HW_MIN_PCK_SIZE=$p->{"MIN_PCK_SIZE"};
1662 48 alirezamon
    my $HW_PCK_TYPE=$p->{"PCK_TYPE"};
1663 43 alirezamon
    my $SIM_MIN_PCK_SIZE=$self->object_get_attribute ($sample,"MIN_PCK_SIZE");
1664 48 alirezamon
    my $SIM_MAX_PCK_SIZE=$self->object_get_attribute ($sample,"MAX_PCK_SIZE");
1665 43 alirezamon
   if(!defined $HW_MIN_PCK_SIZE){
1666
        $HW_MIN_PCK_SIZE= 2;
1667
        #print "undef\n";       
1668
    }
1669 48 alirezamon
    $HW_PCK_TYPE = "MULTI_FLIT" if(~defined $HW_PCK_TYPE);
1670 43 alirezamon
        if($HW_MIN_PCK_SIZE>$SIM_MIN_PCK_SIZE){
1671
                add_colored_info($info, "Error: The minimum simulation packet size of $SIM_MIN_PCK_SIZE flit(s) is smaller than $HW_MIN_PCK_SIZE which is defined in generating verilog model of NoC!\n",'red');
1672
                $self->object_add_attribute ($sample,"status","failed");
1673
                $status=0;
1674 48 alirezamon
        }
1675
        if( $HW_PCK_TYPE eq '"SINGLE_FLIT"' && $SIM_MAX_PCK_SIZE !=1){
1676
                #print "$HW_PCK_TYPE  \n"; 
1677
                add_colored_info($info, "Error: The maximum packet size is set as $SIM_MAX_PCK_SIZE however, the selected NoC model only support single-flit packet injection! Please redefine it to one\n",'red');
1678
 
1679
                $self->object_add_attribute ($sample,"status","failed");
1680
                $status=0;
1681
        }
1682
 
1683 38 alirezamon
        return $status;
1684
}
1685
 
1686 48 alirezamon
sub noc_sim_ctrl{
1687
        my ($simulate,$info)=@_;
1688
 
1689
        my $generate = def_image_button('icons/forward.png','R_un all',FALSE,1);
1690
        my $open = def_image_button('icons/browse.png',"_Load",FALSE,1);
1691
        my $save = def_image_button('icons/save.png','Sav_e',FALSE,1);
1692
        my $save_all_results = def_image_button('icons/copy.png',"E_xtract all results",FALSE,1);
1693
        my $cpus=select_parallel_process_num($simulate);
1694
        my ($object,$attribute1,$attribute2,$content,$default,$status,$timeout)=@_;
1695
 
1696
        my $compiler =def_pack_hbox('FALSE',0, gen_label_in_center('Simulator:'), gen_combobox_object($simulate,'Simulator',undef,"Modelsim gui,Modelsim,Verilator","Verilator",'ref',1));
1697
 
1698
 
1699
        my $entry = gen_entry_object($simulate,'simulate_name',undef,undef,undef,undef);
1700
        my $entrybox=gen_label_info(" Save as:",$entry);
1701
        $entrybox->pack_start( $save, FALSE, FALSE, 0);
1702
 
1703
        my $simulator =$simulate->object_get_attribute("Simulator");
1704
 
1705
 
1706
        my $thread=select_parallel_thread_num($simulate);
1707
 
1708
 
1709
        my $table = def_table (1, 12, FALSE);
1710
        $table->attach ($open,          0, 1, 0,1,'expand','shrink',2,2);
1711
        $table->attach ($compiler, 1, 2, 0,1,'expand','shrink',2,2);
1712
 
1713
        $table->attach ($cpus,          2, 4, 0,1,'expand','shrink',2,2);
1714
        if($simulator eq "Verilator"){
1715
                $table->attach ($thread, 4, 5, 0,1,'expand','shrink',2,2);
1716
        }
1717
 
1718
        $table->attach ($entrybox,      5, 7, 0,1,'expand','shrink',2,2);
1719
        $table->attach ($save_all_results, 7, 8, 0,1,'shrink','shrink',2,2);
1720
        $table->attach ($generate,      8, 9, 0,1,'expand','shrink',2,2);
1721
 
1722
        $generate-> signal_connect("clicked" => sub{
1723
                my @samples =$simulate->object_get_attribute_order("samples");
1724
                foreach my $sample (@samples){
1725
                        $simulate->object_add_attribute ("$sample","status","run");
1726
                }
1727
                run_simulator($simulate,$info);
1728
                #set_gui_status($emulate,"ideal",2);
1729 38 alirezamon
 
1730 48 alirezamon
        });
1731 38 alirezamon
 
1732 48 alirezamon
#       $wb-> signal_connect("clicked" => sub{ 
1733
#               wb_address_setting($mpsoc);
1734
#       
1735
#       });
1736 43 alirezamon
 
1737 48 alirezamon
        $open-> signal_connect("clicked" => sub{
1738
 
1739
                load_simulation($simulate,$info);
1740
                #print Dumper($simulate);
1741
                set_gui_status($simulate,"ref",5);
1742
 
1743
        });
1744
 
1745
        $save-> signal_connect("clicked" => sub{
1746
                save_simulation($simulate);
1747
                set_gui_status($simulate,"ref",5);
1748
 
1749
 
1750
        });
1751
 
1752
        $save_all_results-> signal_connect("clicked" => sub{
1753
                #Get the path where to save all the simulation results
1754
                my $open_in = $simulate->object_get_attribute ('sim_param','BIN_DIR');
1755
        get_dir_name($simulate,"Select the target directory","sim_param","ALL_RESULT_DIR",$open_in,'ref',1);
1756
                $simulate->object_add_attribute ("graph_save","save_all_result",1);
1757
 
1758
        });
1759
 
1760
 
1761 55 alirezamon
        return add_widget_to_scrolled_win($table,gen_scr_win_with_adjst($simulate,"ctrl_sc_win"));
1762 48 alirezamon
 
1763
}
1764
 
1765
 
1766 38 alirezamon
############
1767 32 alirezamon
#    main
1768
############
1769
sub simulator_main{
1770
 
1771
        add_color_to_gd();
1772
        my $simulate= emulator->emulator_new();
1773
        set_gui_status($simulate,"ideal",0);
1774 38 alirezamon
 
1775 32 alirezamon
 
1776 48 alirezamon
        my $main_table = def_table (25, 12, FALSE);
1777
        $main_table->show_all;
1778
        my ($infobox,$info)= create_txview();
1779 32 alirezamon
 
1780 43 alirezamon
 
1781 32 alirezamon
 
1782 38 alirezamon
my @pages =(
1783 54 alirezamon
        {page_name=>" Average/Total ", page_num=>0},
1784
        {page_name=>" Per node ", page_num=>1},
1785
        #{page_name=>" Worst-Case Delay ",page_num=>2},
1786
        #{page_name=>" Execution Time ",page_num=>3},
1787
        {page_name=>" Heat-Map. ",page_num=>4},
1788 38 alirezamon
);
1789
 
1790
 
1791
 
1792
my @charts = (
1793 48 alirezamon
        { type=>"2D_line", page_num=>0, graph_name=> "Avg. packet Latency", result_name => "latency_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Avg. Packet Latency (clock)', Z_Title=>undef, Y_Max=>100},
1794
        { type=>"2D_line", page_num=>0, graph_name=> "Avg. flit Latency", result_name => "latency_flit_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Avg. Flit Latency (clock)', Z_Title=>undef, Y_Max=>100},
1795
        { type=>"2D_line", page_num=>0, graph_name=> "Avg. flit Latency per hop", result_name => "latency_perhop_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Avg. Flit Latency per hop (clock)', Z_Title=>undef, Y_Max=>100},
1796
    { type=>"2D_line", page_num=>0, graph_name=> "Avg. throughput", result_name => "throughput_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Avg. Throughput (flits/clock (%))', Z_Title=>undef,Y_Max=>100},
1797
        { type=>"2D_line", page_num=>0, graph_name=> "Avg. SD latency", result_name => "sd_latency_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Latency Standard Deviation (clock)', Z_Title=>undef},
1798
        { type=>"2D_line", page_num=>0, graph_name=> "Worst pck latency (clk)", result_name => "worst_latency_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Worst Packet Latency (clock)', Z_Title=>undef},
1799
        { type=>"2D_line", page_num=>0, graph_name=> "Min pck latency (clk)", result_name => "min_latency_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Minimum Packet Latency (clock)', Z_Title=>undef},
1800
        { type=>"2D_line", page_num=>0, graph_name=> "Total injected pck", result_name =>"injected_pck_total" , X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Total Injected packets', Z_Title=>undef},
1801
        { type=>"2D_line", page_num=>0, graph_name=> "Total injected flit",result_name =>"injected_flit_total", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Total Injected Fslits', Z_Title=>undef},
1802 54 alirezamon
        { type=>"2D_line", page_num=>0, graph_name=> "Execuation Cycles", result_name => "exe_time_result",X_Title=>'Desired Avg. Injected Load Per Router (flits/clock (%))' , Y_Title=>'Total Simulation Time (clk)', Z_Title=>undef},
1803 48 alirezamon
 
1804
 
1805
 
1806 54 alirezamon
        { type=>"3D_bar",  page_num=>1, graph_name=> "Received packets per Endp", result_name => "packet_rsvd_result", X_Title=>'Endpoint ID' , Y_Title=>'Received Packets Per Endpoint', Z_Title=>undef},
1807
        { type=>"3D_bar",  page_num=>1, graph_name=> "Sent packets per Endp", result_name => "packet_sent_result", X_Title=>'Endpoint ID' , Y_Title=>'Sent Packets Per Endpoint', Z_Title=>undef},
1808
        { type=>"3D_bar",  page_num=>1, graph_name=> "Received flits per Endp", result_name => "flit_rsvd_result", X_Title=>'Endpoint ID' , Y_Title=>'Received Flits Per Endpoint', Z_Title=>undef},
1809
        { type=>"3D_bar",  page_num=>1, graph_name=> "Sent flits per Endp", result_name => "flit_sent_result", X_Title=>'Endpoint ID' , Y_Title=>'Sent Packets Flits Endpoint', Z_Title=>undef},
1810
        { type=>"3D_bar",  page_num=>1, graph_name=> "Flits per Router", result_name => "flit_per_router_result", X_Title=>'Router ID' , Y_Title=>'Received Flits Per Router', Z_Title=>undef},
1811
        { type=>"3D_bar",  page_num=>1, graph_name=> "Packets per Router", result_name => "packet_per_router_result", X_Title=>'Router ID' , Y_Title=>'Received Packets Per Router', Z_Title=>undef},
1812
        { type=>"3D_bar",  page_num=>1, graph_name=> "Worst Received pck latency per Endp", result_name => "worst_delay_rsvd_result",X_Title=>'Endpoint ID' , Y_Title=>'Worst-Case Delay (clk)', Z_Title=>undef},
1813
        { type=>"3D_bar",  page_num=>1, graph_name=> "Worst Sent pck latency per Endp", result_name => "worst_delay_sent_result",X_Title=>'Endpoint ID' , Y_Title=>'Worst-Case Delay (clk)', Z_Title=>undef},
1814 32 alirezamon
 
1815 54 alirezamon
        { type=>"3D_bar",  page_num=>1, graph_name=> "Buffered Flit in Ratio Per Router", result_name => "flit_buffered_router_ratio",X_Title=>'Router ID' , Y_Title=>'Flit in buffered in router/Flit in (%)', Z_Title=>undef},
1816
        { type=>"3D_bar",  page_num=>1, graph_name=> "Bypassed Flit in Ratio Per Router", result_name => "flit_bypass_router_ratio",X_Title=>'Router ID' , Y_Title=>'Flit in bypassed in router/Flit in (%)', Z_Title=>undef},
1817
 
1818
 
1819
 
1820
 
1821
 
1822
 
1823
 
1824
 
1825
 
1826
 
1827
 
1828
 
1829
        { type=>"Heat-map", page_num=>4, graph_name=> "Select", result_name => "undef",X_Title=>'-' , Y_Title=> undef, Z_Title=>undef},
1830
        { type=>"Heat-map", page_num=>4, graph_name=> "Endp-2-Endp Flit-num", result_name => "endp-endp-flit_result",X_Title=>'total flit number sent from an endpoint to another' , Y_Title=> undef, Z_Title=>undef},
1831
        { type=>"Heat-map", page_num=>4, graph_name=> "Endp-2-Endp Packet-num", result_name => "endp-endp-pck_result",X_Title=>'total packet number sent from an endpoint to another' , Y_Title=> undef, Z_Title=>undef},
1832
 
1833
 
1834 38 alirezamon
        );
1835 32 alirezamon
 
1836
 
1837 48 alirezamon
        my ($conf_box,$set_win)=process_notebook_gen($simulate,$info,"simulate",undef,@charts);
1838
        my $chart   =gen_multiple_charts  ($simulate,\@pages,\@charts,0.4);
1839 32 alirezamon
 
1840
 
1841
 
1842
        $main_table->set_row_spacings (4);
1843
        $main_table->set_col_spacings (1);
1844
 
1845 48 alirezamon
 
1846 32 alirezamon
        #my  $device_win=show_active_dev($soc,$soc,$infc,$soc_state,\$refresh,$info);
1847
 
1848
 
1849
 
1850
 
1851
        my $image = get_status_gif($simulate);
1852 48 alirezamon
        my $ctrl  = noc_sim_ctrl ($simulate,$info);
1853 32 alirezamon
 
1854 38 alirezamon
        my $v1=gen_vpaned($conf_box,.45,$image);
1855
        my $v2=gen_vpaned($infobox,.2,$chart);
1856
        my $h1=gen_hpaned($v1,.4,$v2);
1857 32 alirezamon
 
1858
 
1859
 
1860 38 alirezamon
        $main_table->attach_defaults ($h1  , 0, 12, 0,24);
1861 48 alirezamon
        $main_table->attach ($ctrl, 0,12, 24,25,'fill','fill',2,2);
1862 38 alirezamon
 
1863 55 alirezamon
        my $sc_win=add_widget_to_scrolled_win($main_table);
1864 32 alirezamon
 
1865
 
1866 48 alirezamon
        #check soc status every 0.5 second. refresh device table if there is any changes 
1867 32 alirezamon
        Glib::Timeout->add (100, sub{
1868
 
1869
                my ($state,$timeout)= get_gui_status($simulate);
1870
 
1871
                if ($timeout>0){
1872
                        $timeout--;
1873
                        set_gui_status($simulate,$state,$timeout);
1874 38 alirezamon
                        return TRUE;
1875 32 alirezamon
 
1876
                }
1877 38 alirezamon
                if($state eq "ideal"){
1878
                        return TRUE;
1879
 
1880
                }
1881
 
1882
 
1883
 
1884
                #refresh GUI
1885 48 alirezamon
 
1886 55 alirezamon
 
1887 48 alirezamon
                $ctrl->destroy();
1888 38 alirezamon
                $conf_box->destroy();
1889
                $chart->destroy();
1890
                $image->destroy();
1891
                $image = get_status_gif($simulate);
1892 48 alirezamon
                ($conf_box,$set_win)=process_notebook_gen($simulate,$info,"simulate",$set_win,@charts);
1893
                $chart = gen_multiple_charts  ($simulate,\@pages,\@charts,0.4);
1894
                $ctrl  = noc_sim_ctrl ($simulate,$info);
1895
                $main_table->attach ($ctrl,0, 12, 24,25,'fill','fill',2,2);
1896 56 alirezamon
                $v1 -> pack1($conf_box, TRUE, TRUE);
1897 38 alirezamon
                $v1 -> pack2($image, TRUE, TRUE);
1898
                $v2 -> pack2($chart, TRUE, TRUE);
1899 48 alirezamon
 
1900
 
1901
 
1902
 
1903 38 alirezamon
                $conf_box->show_all();
1904
                $main_table->show_all();
1905
                set_gui_status($simulate,"ideal",0);
1906
 
1907 55 alirezamon
 
1908 32 alirezamon
                return TRUE;
1909
 
1910
        } );
1911
 
1912
 
1913 43 alirezamon
 
1914
 
1915 48 alirezamon
 
1916 32 alirezamon
 
1917 55 alirezamon
        return $sc_win;
1918 32 alirezamon
 
1919
 
1920
 
1921 48 alirezamon
}
1922 32 alirezamon
 
1923 48 alirezamon
sub custom_traffic_dest{
1924
        my ($self,$sample,$core_num)    =@_;
1925 32 alirezamon
 
1926 48 alirezamon
        my $num=$self->object_get_attribute($sample,"CUSTOM_SRC_NUM");
1927
    for (my $i=0;$i<$num;$i++){
1928
                        my $src = $self->object_get_attribute($sample,"SRC_$i");
1929
                        my $dst = $self->object_get_attribute($sample,"DST_$i");
1930
                        return  ($core_num,$dst) if($src == $core_num);
1931
    }
1932
        return ($core_num, -1);#off     
1933
}
1934 32 alirezamon
 
1935 54 alirezamon
sub download_netrace{
1936
        my ($path) =@_;
1937
        #create path if it is not exist
1938
        unless (-d $path){
1939
                mkpath("$path",1,01777);
1940
        }
1941
        my $window = def_popwin_size(30,85,"Netrace download",'percent');
1942
        my $table = def_table(1, 1, FALSE);
1943
        my $scrolled_win = add_widget_to_scrolled_win($table);
1944
 
1945
 
1946
my @links =(
1947
{ label=>"blackscholes simlarge (907M) ",name=>"blackscholes_64c_simlarge.tra.bz2" ,url=>"https://www.cs.utexas.edu/~netrace/download/blackscholes_64c_simlarge.tra.bz2"},
1948
{ label=>"blackscholes simmedium (182M)",name=>"blackscholes_64c_simmedium.tra.bz2",url=>"https://www.cs.utexas.edu/~netrace/download/blackscholes_64c_simmedium.tra.bz2"},
1949
{ label=>"blackscholes simsmall (55M)  ",name=>"blackscholes_64c_simsmall.tra.bz2" ,url=>"https://www.cs.utexas.edu/~netrace/download/blackscholes_64c_simsmall.tra.bz2"},
1950
{ label=>"bodytrack simlarge (3.5G)    ",name=>"bodytrack_64c_simlarge.tra.bz2"    ,url=>"https://www.cs.utexas.edu/~netrace/download/bodytrack_64c_simlarge.tra.bz2"},
1951
{ label=>"canneal simmedium (3.5G)     ",name=>"canneal_64c_simmedium.tra.bz2"     ,url=>"https://www.cs.utexas.edu/~netrace/download/canneal_64c_simmedium.tra.bz2"},
1952
{ label=>"dedup simmedium (4.1G)       ",name=>"dedup_64c_simmedium.tra.bz2"       ,url=>"https://www.cs.utexas.edu/~netrace/download/dedup_64c_simmedium.tra.bz2"},
1953
{ label=>"ferret simmedium (2.7G)      ",name=>"ferret_64c_simmedium.tra.bz2"      ,url=>"https://www.cs.utexas.edu/~netrace/download/ferret_64c_simmedium.tra.bz2"},
1954
{ label=>"fluidanimate simlarge (1.8G) ",name=>"fluidanimate_64c_simlarge.tra.bz2" ,url=>"https://www.cs.utexas.edu/~netrace/download/fluidanimate_64c_simlarge.tra.bz2"},
1955
{ label=>"fluidanimate simmedium (677M)",name=>"fluidanimate_64c_simmedium.tra.bz2",url=>"https://www.cs.utexas.edu/~netrace/download/fluidanimate_64c_simmedium.tra.bz2"},
1956
{ label=>"fluidanimate simsmall (317M) ",name=>"fluidanimate_64c_simsmall.tra.bz2" ,url=>"https://www.cs.utexas.edu/~netrace/download/fluidanimate_64c_simsmall.tra.bz2"},
1957
{ label=>"swaptions simlarge (3.0G)    ",name=>"swaptions_64c_simlarge.tra.bz2"    ,url=>"https://www.cs.utexas.edu/~netrace/download/swaptions_64c_simlarge.tra.bz2"},
1958
{ label=>"vips simmedium (3.1G)        ",name=>"vips_64c_simmedium.tra.bz2"        ,url=>"https://www.cs.utexas.edu/~netrace/download/vips_64c_simmedium.tra.bz2"},
1959
{ label=>"x264 simmedium (5.1G)        ",name=>"x264_64c_simmedium.tra.bz2"        ,url=>"https://www.cs.utexas.edu/~netrace/download/x264_64c_simmedium.tra.bz2"},
1960
{ label=>"x264 simsmall (1.2G)         ",name=>"x264_64c_simsmall.tra.bz2"         ,url=>"https://www.cs.utexas.edu/~netrace/download/x264_64c_simsmall.tra.bz2"},
1961
);
1962
 
1963
        my $row=0;
1964
 
1965
 
1966
        foreach my $d (@links){
1967
                my $srow=$row;
1968
                $table-> attach (gen_label_in_left($d->{label}) , 0, 1,  $row,$row+1,'expand','shrink',2,2);
1969
                my $file="$path/$d->{name}";
1970
                if (-f $file){
1971
 
1972
                }else{
1973
                        my $download=def_image_button("icons/download.png",'Download');
1974
                        $table-> attach ($download , 2, 3,  $row,$row+1,'expand','shrink',2,2);
1975
                        $download->signal_connect("clicked"=> sub{
1976
                                        $download ->set_sensitive (FALSE);
1977
                                        my $load= show_gif("icons/load.gif");
1978
                                    $table->attach ($load, 1, 2, $srow,$srow+ 1,'shrink','shrink',0,0);
1979
                                    $load->show_all;
1980
                                        my $o=$d->{name};
1981
                                        download_from_google_drive("$d->{url}" ,"$path/$o"  );
1982
                                        $load->destroy;
1983
                                        $download->destroy if (-f $file);
1984
                        });
1985
                }
1986
                $row++;
1987
        }
1988
 
1989
 
1990
 
1991
 
1992
 
1993
$window ->add($scrolled_win);
1994
$window->show_all;
1995
 
1996 55 alirezamon
}

powered by: WebSVN 2.1.0

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