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 43

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

Line No. Rev Author Line
1 32 alirezamon
#! /usr/bin/perl -w
2
use Glib qw/TRUE FALSE/;
3
use strict;
4
use warnings;
5 43 alirezamon
use FindBin;
6
use lib $FindBin::Bin;
7
 
8 32 alirezamon
use Gtk2;
9
use Gtk2::Ex::Graph::GD;
10
use GD::Graph::Data;
11
use emulator;
12
use IO::CaptureOutput qw(capture qxx qxy);
13
use GD::Graph::colour qw/:colours/;
14
use Proc::Background;
15
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep  clock_gettime clock_getres clock_nanosleep clock stat );
16
 
17
use File::Basename;
18
use File::Path qw/make_path/;
19
use File::Copy;
20
use File::Find::Rule;
21
 
22
require "widget.pl";
23
require "mpsoc_gen.pl";
24
require "emulator.pl";
25
require "mpsoc_verilog_gen.pl";
26
require "readme_gen.pl";
27 38 alirezamon
require "graph.pl";
28 32 alirezamon
 
29 43 alirezamon
 
30 32 alirezamon
use List::MoreUtils qw(uniq);
31
 
32
 
33
 
34
 
35 43 alirezamon
sub generate_sim_bin_file {
36 32 alirezamon
        my ($simulate,$info_text) =@_;
37 38 alirezamon
 
38
        $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
        $tops{Vtraffic} = "traffic_gen_verilator.v";
45 38 alirezamon
        my $target_dir= "$ENV{PRONOC_WORK}/simulate";
46
 
47 32 alirezamon
        my $dir = Cwd::getcwd();
48
        my $project_dir   = abs_path("$dir/..");
49
        my $src_verilator_dir="$project_dir/src_verilator";
50 38 alirezamon
        my $src_noc_dir="$project_dir/src_noc";
51 32 alirezamon
        my $script_dir="$project_dir/script";
52 38 alirezamon
        my $testbench_file= "$src_verilator_dir/simulator.cpp";
53
 
54 43 alirezamon
        my $target_verilog_dr ="$target_dir/src_verilog";
55 38 alirezamon
        my $obj_dir ="$target_dir/verilator/processed_rtl/obj_dir/";
56
 
57 43 alirezamon
        rmtree("$target_dir/verilator");
58
        rmtree("$target_verilog_dr");
59
        mkpath("$target_verilog_dr/",1,01777);
60 38 alirezamon
 
61
        #copy src_verilator files
62 43 alirezamon
        my @files_list = File::Find::Rule->file()
63
                            ->name( '*.v','*.V','*.sv' )
64
                            ->in( "$src_verilator_dir" );
65
 
66
        #make sure source files have key word 'module' 
67
        my @files;
68
        foreach my $p (@files_list){
69
                push (@files,$p)        if(check_file_has_string($p,'module'));
70
        }
71
        push (@files,$src_noc_dir);
72 38 alirezamon
 
73
 
74 43 alirezamon
        #my @files=(
75
        #       $src_noc_dir,
76
        #       "$src_verilator_dir/noc_connection.sv",
77
        #       "$src_verilator_dir/mesh_torus_noc_connection.sv",                      
78
        #       "$src_verilator_dir/router_verilator.v",
79
        #       "$src_verilator_dir/traffic_gen_verilator.v"            
80
        #);
81 38 alirezamon
 
82 43 alirezamon
        copy_file_and_folders (\@files,$project_dir,$target_verilog_dr);
83 38 alirezamon
 
84 43 alirezamon
 
85 38 alirezamon
        # generate NoC parameter file
86 32 alirezamon
        my ($noc_param,$pass_param)=gen_noc_param_v($simulate);
87 43 alirezamon
        open(FILE,  ">$target_verilog_dr/parameter.v") || die "Can not open: $!";
88 38 alirezamon
        my $fifow=$simulate->object_get_attribute('fpga_param','TIMSTMP_FIFO_NUM');
89 43 alirezamon
        gen_vrouter_param_v($simulate,$target_verilog_dr);
90 38 alirezamon
 
91 43 alirezamon
        #generate routers with different port num               
92 32 alirezamon
 
93 38 alirezamon
        my $result = verilator_compilation (\%tops,$target_dir,$$info_text);
94 32 alirezamon
 
95 38 alirezamon
        if ($result){
96
                add_colored_info($info_text,"Veriator model has been generated successfully!\n",'blue');
97
        }else {
98
                add_colored_info($info_text,"Verilator compilation failed!\n","red");
99
                $simulate->object_add_attribute('status',undef,'programer_failed');
100
                set_gui_status($simulate,"ref",1);
101 43 alirezamon
                print "gen-ended!\n";
102 38 alirezamon
                return;
103 43 alirezamon
        }
104 32 alirezamon
 
105 43 alirezamon
        #copy simulation c header files
106
        @files = File::Find::Rule->file()
107
                            ->name( '*.h')
108
                            ->in( "$src_verilator_dir" );
109 38 alirezamon
 
110
        copy_file_and_folders (\@files,$project_dir,$obj_dir);
111
        copy($testbench_file,"$obj_dir/testbench.cpp");
112 43 alirezamon
 
113 32 alirezamon
        #compile the testbench
114
        my $param_h=gen_noc_param_h($simulate);
115 43 alirezamon
        my $text = gen_sim_parameter_h($param_h,$includ_h,$ne,$nr,$router_p,$fifow);
116
 
117 32 alirezamon
        $param_h =~ s/\d\'b/ /g;
118 38 alirezamon
        open(FILE,  ">$obj_dir/parameter.h") || die "Can not open: $!";
119 43 alirezamon
        print FILE  "$text";
120 32 alirezamon
 
121
        close FILE;
122
 
123 38 alirezamon
 
124
 
125
        $result = run_make_file("$obj_dir/",$$info_text,'lib');
126
 
127
        if ($result ==0){
128
                $simulate->object_add_attribute('status',undef,'programer_failed');
129
                set_gui_status($simulate,"ref",1);
130 43 alirezamon
                print "gen-ended!\n";
131 32 alirezamon
                return;
132 38 alirezamon
        }
133 32 alirezamon
 
134 38 alirezamon
        run_make_file("$obj_dir/",$$info_text);
135
        if ($result ==0){
136
                $simulate->object_add_attribute('status',undef,'programer_failed');
137
                set_gui_status($simulate,"ref",1);
138 43 alirezamon
                print "gen-ended!\n";
139 38 alirezamon
                return;
140
        }
141
 
142
 
143
 
144
 
145
        #my $end = localtime;           
146
 
147 32 alirezamon
 
148
 
149
        #save the binarry file
150 38 alirezamon
        my $bin= "$obj_dir/testbench";
151 32 alirezamon
        my $path=$simulate->object_get_attribute ('sim_param',"BIN_DIR");
152
        my $name=$simulate->object_get_attribute ('sim_param',"SAVE_NAME");
153
 
154 38 alirezamon
        #create project directory if it does not exist
155
        my      ($stdout,$exit)=run_cmd_in_back_ground_get_stdout("mkdir -p $path" );
156 43 alirezamon
        if($exit != 0 ){         print "$stdout\n";  print "gen-ended!\n";       message_dialog($stdout,'error'); return;}
157 32 alirezamon
 
158 38 alirezamon
 
159
 
160 32 alirezamon
        #check if the verilation was successful
161
        if ((-e $bin)==0) {#something goes wrong                 
162 38 alirezamon
        #message_dialog("Verilator compilation was unsuccessful please check the $path/$name.log files for more information",'error'); 
163
        add_colored_info($info_text,"Verilator compilation failed!\n","red");
164
        $simulate->object_add_attribute('status',undef,'programer_failed');
165
                set_gui_status($simulate,"ref",1);
166 43 alirezamon
                print "gen-ended!\n";
167 38 alirezamon
                return;
168 32 alirezamon
        }
169
 
170
 
171
        #copy ($bin,"$path/$name") or  die "Can not copy: $!";
172
        ($stdout,$exit)=run_cmd_in_back_ground_get_stdout("cp -f $bin $path/$name");
173 43 alirezamon
        if($exit != 0 ){         print "$stdout\n";  print "gen-ended!\n";       message_dialog($stdout,'error'); return;}
174 32 alirezamon
 
175
        #save noc info
176
        open(FILE,  ">$path/$name.inf") || die "Can not open: $!";
177
        print FILE perl_file_header("$name.inf");
178
        my %pp;
179
        $pp{'noc_param'}= $simulate->{'noc_param'};
180
        $pp{'sim_param'}= $simulate->{'sim_param'};
181
        print FILE Data::Dumper->Dump([\%pp],["emulate_info"]);
182
        close(FILE) || die "Error closing file: $!";
183 43 alirezamon
 
184
        print "gen-ended successfully!\n";
185 32 alirezamon
        message_dialog("The simulation binary file has been successfully generated in $path!");
186
 
187 38 alirezamon
        $simulate->object_add_attribute('status',undef,'ideal');
188
        set_gui_status($simulate,"ref",1);
189 43 alirezamon
 
190 32 alirezamon
        #make project dir
191
        #my $dir= $simulate->object_get_attribute ("sim_param","BIN_DIR");
192
        #my $name=$simulate->object_get_attribute ("sim_param","SAVE_NAME");    
193
        #my $path= "$dir/$name";
194
        #add_info($info_text, "$src_verilator_dir!\n");
195
        #mkpath("$path",1,01777);
196
}
197
 
198
 
199
##########
200 34 alirezamon
#       save_simulation
201 32 alirezamon
##########
202
sub save_simulation {
203
        my ($simulate)=@_;
204
        # read emulation name
205
        my $name=$simulate->object_get_attribute ("simulate_name",undef);
206
        my $s= (!defined $name)? 0 : (length($name)==0)? 0 :1;
207
        if ($s == 0){
208
                message_dialog("Please set Simulation name!");
209
                return 0;
210
        }
211
        # Write object file
212
        open(FILE,  ">lib/simulate/$name.SIM") || die "Can not open: $!";
213
        print FILE perl_file_header("$name.SIM");
214 38 alirezamon
        print FILE Data::Dumper->Dump([\%$simulate],["simulate"]);
215 32 alirezamon
        close(FILE) || die "Error closing file: $!";
216
        message_dialog("Simulation has saved as lib/simulate/$name.SIM!");
217
        return 1;
218
}
219
 
220
#############
221 36 alirezamon
#       load_simulation
222 32 alirezamon
############
223
 
224
sub load_simulation {
225
        my ($simulate,$info)=@_;
226
        my $file;
227
        my $dialog = Gtk2::FileChooserDialog->new(
228
                'Select a File', undef,
229
                'open',
230
                'gtk-cancel' => 'cancel',
231
                'gtk-ok'     => 'ok',
232
                );
233
 
234
        my $filter = Gtk2::FileFilter->new();
235
        $filter->set_name("SIM");
236
        $filter->add_pattern("*.SIM");
237
        $dialog->add_filter ($filter);
238
        my $dir = Cwd::getcwd();
239
        $dialog->set_current_folder ("$dir/lib/simulate");
240
 
241
 
242
        if ( "ok" eq $dialog->run ) {
243
                $file = $dialog->get_filename;
244
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
245
                if($suffix eq '.SIM'){
246 43 alirezamon
                        my ($pp,$r,$err) = regen_object($file);
247
                        if ($r){
248
                                add_info($info,"**Error reading  $file file: $err\n");
249 32 alirezamon
                                 $dialog->destroy;
250
                                return;
251
                        }
252
                        #deactivate running simulations
253
                        $pp->object_add_attribute('status',undef,'ideal');
254 38 alirezamon
                        my @samples =$pp->object_get_attribute_order("samples");
255
                        foreach my $sample (@samples){
256
                                my $st=$pp->object_get_attribute ($sample,"status");
257
                                $pp->object_add_attribute ($sample,"status",'done');# if ($st eq "run");        
258 32 alirezamon
                        }
259
                        clone_obj($simulate,$pp);
260
                        #message_dialog("done!");                               
261
                }
262
     }
263
     $dialog->destroy;
264
}
265
 
266
 
267 38 alirezamon
 
268
sub gen_custom_traffic {
269
        my ($self,$info,$mode)=@_;
270
 
271
        my $table=def_table(20,10,FALSE);
272
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
273
        $scrolled_win->set_policy( "automatic", "automatic" );
274
        $scrolled_win->add_with_viewport($table);
275
        my $row=0;
276
 
277
        #page title     
278
        my $title_l =  "Custom Traffic  Generator";
279
        my $title=gen_label_in_center($title_l);
280
        $table->attach ($title , 0, 10,  $row, $row+1,'expand','shrink',2,2); $row++;
281
        my $separator = Gtk2::HSeparator->new;
282
        $table->attach ($separator , 0, 10 , $row, $row+1,'fill','fill',2,2);    $row++;
283
 
284
        #fileds title
285
        my @positions=(0,1,2,3,4,5,6);
286
        my $col=0;
287
 
288
        my @title=("Traffic name", " Add/Remove "," Edit ");
289
        foreach my $t (@title){
290
                $table->attach (gen_label_in_center($title[$col]), $positions[$col], $positions[$col+1], $row, $row+1,'expand','shrink',2,2);$col++;
291
        }
292
         $row++;
293
 
294
 
295
        #create new traffic
296
        my $add=def_image_button("icons/plus.png", );
297
        $table->attach ($add, $positions[1], $positions[2], $row, $row+1,'expand','shrink',2,2);
298
 
299
        $add->signal_connect("clicked"=> sub{
300
                generate_new_traffic ($self);
301
 
302
        });
303
        return $scrolled_win;
304
 
305
}
306
 
307
 
308
 
309
 
310
 
311
 
312
sub generate_new_traffic {
313
        my $self=shift;
314
 
315
        my $window = def_popwin_size(40,40,"Step 2: Compile",'percent');
316
        my $table = def_table(10, 10, FALSE);
317
 
318
 
319
 
320
        my @info = (
321
        { label=>'Traffic_name', param_name=>'CUSTOM_NAME', type=>"Entry", default_val=>undef, content=>undef, info=>undef, param_parent=>'traffic_param', ref_delay=> undef},
322
        { label=>'Routers per Row', param_name=>'CUSTOM_X', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'traffic_param', ref_delay=>undef},
323
        { label=>"Routers per Column", param_name=>"CUSTOM_Y", type=>"Spin-button", default_val=>2, content=>"1,64,1", info=>undef, param_parent=>'traffic_param',ref_delay=>undef },
324
        );
325
 
326
        my $row=0;
327
        my $col=0;
328
        foreach my $d (@info) {
329
                ($row,$col)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,$col,1, $d->{param_parent}, $d->{ref_delay},undef,"vertical");
330
        }
331
 
332
        $row++;
333
 
334
 
335
 
336
        my $next=def_image_button('icons/run.png','Next');
337
        my $back=def_image_button('icons/left.png','Previous');
338
 
339
        $col=1;
340
        my $i;
341
        for ($i=$row; $i<5; $i++){
342
 
343
                my $temp=gen_label_in_center(" ");
344
                $table->attach_defaults ($temp, 3, 4 , $i, $i+1);
345
        }
346
        $row=$i;
347
 
348
        #$table->attach($back,2,3,9,10,'shrink','shrink',2,2);
349
        $table->attach($next,3,4,$row,$row+1,'shrink','shrink',2,2);
350
 
351
 
352
 
353
        $back-> signal_connect("clicked" => sub{
354
 
355
                $window->destroy;
356
 
357
 
358
        });
359
        $next-> signal_connect("clicked" => sub{
360
 
361
                $window->destroy;
362
 
363
 
364
        });
365
 
366
 
367
 
368
 
369
 
370
        $window->add ($table);
371
        $window->show_all();
372
 
373
 
374
 
375
}
376
 
377
 
378
sub check_hotspot_parameters{
379
        my ($self,$sample)=@_;
380
        my $num=$self->object_get_attribute($sample,"HOTSPOT_NUM");
381
        my $result;
382
        if (defined $num){
383
                my @hotspots;
384
                my $acuum=0;
385
                for (my $i=0;$i<$num;$i++){
386
                        my $w1 = $self->object_get_attribute($sample,"HOTSPOT_CORE_$i");
387
                        if( grep (/^\Q$w1\E$/,@hotspots)){
388
                                $result="Error: Tile $w1 has been selected for Two or more than two hotspot nodes.\n";
389
                        }
390
                        push( @hotspots,$w1);
391
                        my $w2 = $self->object_get_attribute($sample,"HOTSPOT_PERCENT_$i");
392
                        $acuum+=$w2;
393
 
394
                }
395
                if ($acuum > 100){
396
                        $result="Error: The traffic sumation of all hotspot nodes is $acuum. The hotspot sumation must be <=100";
397
 
398
                }
399
        }
400
        return $result;
401
}
402
 
403
 
404
sub get_simulator_noc_configuration{
405
        my ($self,$mode,$sample,$set_win) =@_;
406
 
407
        my $table=def_table(10,2,FALSE);
408
        my $row=0;
409
 
410
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
411
        $scrolled_win->set_policy( "automatic", "automatic" );
412
        $scrolled_win->add_with_viewport($table);
413
 
414
        my $ok = def_image_button('icons/select.png','OK');
415
        my $mtable = def_table(10, 1, TRUE);
416
 
417
        $mtable->attach_defaults($scrolled_win,0,1,0,9);
418
        $mtable-> attach ($ok , 0, 1,  9, 10,'expand','shrink',2,2);
419
 
420
 
421
 
422
        $set_win ->signal_connect (destroy => sub{
423
                $self->object_add_attribute("active_setting",undef,undef);
424
        });
425
 
426
 
427
        my $dir = Cwd::getcwd();
428
        my $open_in       = abs_path("$ENV{PRONOC_WORK}/simulate");
429
 
430
 
431
        attach_widget_to_table ($table,$row,gen_label_in_left(" Search Path:"),gen_button_message ("Select the the Path where the verilator simulation files are located. Different NoC verilated models can be generated using Generate NoC configuration tab.","icons/help.png"),
432
        get_dir_in_object ($self,$sample,"sof_path",undef,'ref_set_win',1,$open_in)); $row++;
433
 
434
        $open_in        = $self->object_get_attribute($sample,"sof_path");
435
 
436
 
437
 
438
        my @files = glob "$open_in/*";
439
        my $exe_files="";
440
        foreach my $file (@files){
441
                #print "$file is executable\n" if( -x $file && -f $file) ;
442
 
443
                if( -x $file && -f $file){
444
                        my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
445
                        $exe_files="$exe_files,$name"
446
 
447
                }
448
 
449
        }
450
 
451
        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"),
452
        gen_combobox_object ($self,$sample, "sof_file", $exe_files, undef, undef, undef)); $row++;
453 43 alirezamon
    my $coltmp=0;
454
    ($row,$coltmp)=add_param_widget  ($self, "Traffic Type", "TRAFFIC_TYPE", "Synthetic", 'Combo-box', "Synthetic,Task-graph", undef, $table,$row,undef,1, $sample, 1,'ref_set_win');
455
 
456 38 alirezamon
    my $traffictype=$self->object_get_attribute($sample,"TRAFFIC_TYPE");
457 43 alirezamon
    my $MIN_PCK_SIZE=$self->object_get_attribute($sample,"MIN_PCK_SIZE");
458
 
459 38 alirezamon
 
460 43 alirezamon
 
461
   my $max_pck_num = get_MAX_PCK_NUM();
462
   my $max_sim_clk = get_MAX_SIM_CLKs();
463 38 alirezamon
 
464
        if($traffictype eq "Synthetic"){
465
 
466
                my $min=$self->object_get_attribute($sample,'MIN_PCK_SIZE');
467
                my $max=$self->object_get_attribute($sample,'MAX_PCK_SIZE');
468
                $min=$max=5 if(!defined $min);
469
                my $avg=floor(($min+$max)/2);
470
 
471 43 alirezamon
                my $max_pck_size =       get_MAX_PCK_SIZ();
472
 
473
 
474
                        my $traffics="tornado,transposed 1,transposed 2,bit reverse,bit complement,random,hot spot,shuffle,bit rotation,neighbor";
475 38 alirezamon
                my @synthinfo = (
476
 
477
 
478
                { label=>'Configuration name:', param_name=>'line_name', type=>'Entry', default_val=>$sample, content=>undef, info=>"NoC configration name. This name will be shown in load-latency graph for this configuration", param_parent=>$sample, ref_delay=> undef, new_status=>undef},
479
 
480
 
481
 
482
                { 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'},
483
 
484 43 alirezamon
                { 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'},
485
                { 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'},
486 38 alirezamon
 
487
 
488
 
489
                { label=>"Avg. Packet size:", param_name=>'PCK_SIZE', type=>'Combo-box', default_val=>$avg, content=>"$avg", info=>undef, param_parent=>$sample, ref_delay=>undef},
490
 
491 43 alirezamon
                { 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 numbr 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},
492 38 alirezamon
 
493 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},
494 38 alirezamon
 
495
 
496
 
497
                );
498 43 alirezamon
                my $coltmp=0;
499 38 alirezamon
                foreach my $d (@synthinfo) {
500 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});
501 38 alirezamon
                }
502 43 alirezamon
 
503 38 alirezamon
 
504
                my $traffic=$self->object_get_attribute($sample,"traffic");
505
 
506
                if ($traffic eq 'hot spot'){
507
                        my $htable=def_table(10,2,FALSE);
508
 
509
                        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'};
510 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});
511 38 alirezamon
 
512
                                my $l1=gen_label_help("Defne 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 \%");
513
                                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 \%");
514
                                my $l3=gen_label_help("If it is checked then hot spot node also sends packets to other nodes otherwise it only recieves packets from other nodes","  send enable");
515
 
516
                                $htable->attach  ($l1 , 0, 1,  $row,$row+1,'fill','shrink',2,2);
517
                                $htable->attach  ($l2 , 1, 2,  $row,$row+1,'fill','shrink',2,2);
518
                                $htable->attach  ($l3 , 2,3,  $row,$row+1,'fill','shrink',2,2);
519
                                $row++;
520
 
521
                                my $num=$self->object_get_attribute($sample,"HOTSPOT_NUM");
522
                                for (my $i=0;$i<$num;$i++){
523
                                        my $w1 = gen_spin_object ($self,$sample,"HOTSPOT_CORE_$i","0,256,1", $i,undef,undef);
524
                                        my $w2 = gen_spin_object ($self,$sample,"HOTSPOT_PERCENT_$i","0.1,100,0.1", 0.1,undef,undef);
525
                                        my $w3 = gen_check_box_object ($self,$sample,"HOTSPOT_SEND_EN_$i", 0,undef,undef);
526
                                        $htable->attach  ($w1 , 0, 1,  $row,$row+1,'fill','shrink',2,2);
527
                                        $htable->attach  ($w2 ,1, 2,  $row,$row+1,'fill','shrink',2,2);
528
                                        $htable->attach  ($w3 , 2,3,  $row,$row+1,'fill','shrink',2,2);
529
                                        $row++;
530
 
531
                                }
532
 
533
                                $table->attach  ($htable , 0, 3,  $row,$row+1,'shrink','shrink',2,2); $row++;
534
 
535
 
536
 
537
 
538
 
539
 
540
 
541
                }
542
                my $l= "Define injection ratios. You can define individual ratios seprating by comma (\',\') or define a range of injection ratios with \$min:\$max:\$step format.
543
                        As an example defining 2,3,4:10:2 will result in (2,3,4,6,8,10) injection ratios." ;
544
                my $u=get_injection_ratios ($self,$sample,"ratios");
545
 
546
                attach_widget_to_table ($table,$row,gen_label_in_left(" Injection ratios:"),gen_button_message ($l,"icons/help.png") , $u); $row++;
547
 
548
                $ok->signal_connect("clicked"=> sub{
549
                        #check if sof file has been selected
550
                        my $s=$self->object_get_attribute($sample,"sof_file");
551
                        #check if injection ratios are valid
552
                        my $r=$self->object_get_attribute($sample,"ratios");
553
                        my $h;
554
                        if ($traffic eq 'hot spot'){
555
                                $h=     check_hotspot_parameters($self,$sample);
556
                        }
557
 
558
                        if(defined $s && defined $r && !defined $h) {
559
                                        $set_win->destroy;
560
                                        #$emulate->object_add_attribute("active_setting",undef,undef);
561
                                        set_gui_status($self,"ref",1);
562
                        } else {
563
 
564
                                if(!defined $s){
565
                                        my $m= "Please select NoC verilated file";
566
                                        message_dialog($m);
567
                                } elsif (! defined $r) {
568
                                         message_dialog("Please define valid injection ratio(s)!");
569
                                } else {
570
                                         message_dialog("$h");
571
                                }
572
                        }
573
                });
574
 
575
        }
576
 
577
 
578
        if($traffictype eq "Task-graph"){
579
 
580
                my @custominfo = (
581
                #{ label=>"Verilated Model", param_name=>'sof_file', type=>'Combo-box', default_val=>undef, content=>$exe_files, info=>"Select the the verilator simulation file. Different NoC simulators can be generated using Generate NoC configuration tab.", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
582
 
583
                { label=>'Configuration name:', param_name=>'line_name', type=>'Entry', default_val=>$sample, content=>undef, info=>"NoC configration name. This name will be shown in load-latency graph for this configuration", param_parent=>$sample, ref_delay=> undef, new_status=>undef},
584
 
585
                { 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'},
586
 
587 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},
588 38 alirezamon
                );
589
 
590
                foreach my $d (@custominfo) {
591 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});
592
 
593
                }
594 38 alirezamon
 
595
 
596
                my $open_in  = "$ENV{'PRONOC_WORK'}/traffic_pattern";
597
 
598
 
599
 
600
                 my $num=$self->object_get_attribute($sample,"TRAFFIC_FILE_NUM");
601
                 for (my $i=0; $i<$num; $i++){
602
                        attach_widget_to_table ($table,$row,gen_label_in_left("traffic pattern file $i:"),gen_button_message ("Select the the traffic pattern input file.","icons/help.png"), get_file_name_object ($self,$sample,"traffic_file$i",undef,$open_in)); $row++;
603
                 }
604
 
605
                $ok->signal_connect("clicked"=> sub{
606
                        #check if sof file has been selected
607
                        my $s=$self->object_get_attribute($sample,"sof_file");
608
                        if(!defined $s){
609
                                        message_dialog("Please select NoC verilated file");
610
                                        return;
611
                        }
612
 
613
                        #check if traffic files have been selected
614
                        for (my $i=0; $i<$num; $i++){
615
                                my $f=$self->object_get_attribute($sample,"traffic_file$i");
616
                                if(!defined $f){
617
                                        my $m= "Please select traffic_file$i";
618
                                        message_dialog($m);
619
                                        return;
620
                                }
621
 
622
                        }
623
                        $set_win->destroy;
624
                        set_gui_status($self,"ref",1);
625
 
626
                });
627
 
628
 
629
        }
630
 
631
 
632
 
633
        $set_win->add ($mtable);
634
        $set_win->show_all();
635
 
636
 
637
}
638
 
639
 
640
 
641 32 alirezamon
############
642 38 alirezamon
#       run_simulator
643
###########
644
 
645
sub run_simulator {
646
        my ($simulate,$info)=@_;
647
        #return if(!check_samples($emulate,$info));
648
        $simulate->object_add_attribute('status',undef,'run');
649
        set_gui_status($simulate,"ref",1);
650
        show_info($info, "Start Simulation\n");
651
        my $name=$simulate->object_get_attribute ("simulate_name",undef);
652
 
653
        #unlink $log; # remove old log file
654
 
655
        my @samples =$simulate->object_get_attribute_order("samples");
656
        foreach my $sample (@samples){
657
                my $status=$simulate->object_get_attribute ($sample,"status");
658
                next if($status ne "run");
659
                next if(!check_sim_sample($simulate,$sample,$info));
660
                my $traffictype=$simulate->object_get_attribute($sample,"TRAFFIC_TYPE");
661
                run_synthetic_simulation($simulate,$info,$sample,$name) if($traffictype eq "Synthetic");
662
                run_custom_simulation($simulate,$info,$sample,$name) if($traffictype eq "Task-graph");
663
 
664
 
665
        }
666
 
667
        add_info($info, "Simulation is done!\n");
668 43 alirezamon
        printf "Simulation is done!\n";
669 38 alirezamon
        $simulate->object_add_attribute('status',undef,'ideal');
670
        set_gui_status($simulate,"ref",1);
671
}
672
 
673
 
674
sub run_synthetic_simulation {
675
        my ($simulate,$info,$sample,$name)=@_;
676
        my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
677
        my $r= $simulate->object_get_attribute($sample,"ratios");
678
        my @ratios=@{check_inserted_ratios($r)};
679
        #$emulate->object_add_attribute ("sample$i","status","run");
680 43 alirezamon
        my $bin=get_sim_bin_path($simulate,$sample,$info);
681 38 alirezamon
 
682
        #load traffic configuration
683
        my $patern=$simulate->object_get_attribute ($sample,'traffic');
684
        my $MIN_PCK_SIZE=$simulate->object_get_attribute ($sample,"MIN_PCK_SIZE");
685
        my $MAX_PCK_SIZE=$simulate->object_get_attribute ($sample,"MAX_PCK_SIZE");
686
        my $PCK_NUM_LIMIT=$simulate->object_get_attribute ($sample,"PCK_NUM_LIMIT");
687
        my $SIM_CLOCK_LIMIT=$simulate->object_get_attribute ($sample,"SIM_CLOCK_LIMIT");
688
 
689
 
690
        #hotspot 
691
        my $hotspot="";
692
        if($patern eq "hot spot"){
693
                $hotspot="-h \" ";
694
                my $num=$simulate->object_get_attribute($sample,"HOTSPOT_NUM");
695
                if (defined $num){
696
                        $hotspot="$hotspot $num";
697
 
698
                        for (my $i=0;$i<$num;$i++){
699
                                my $w1 = $simulate->object_get_attribute($sample,"HOTSPOT_CORE_$i");
700
                                my $w2 = $simulate->object_get_attribute($sample,"HOTSPOT_PERCENT_$i");
701
                                $w2=$w2*10;
702
                                my $w3 = $simulate->object_get_attribute($sample,"HOTSPOT_SEND_EN_$i");
703
                                $hotspot="$hotspot,$w1,$w3,$w2";
704
                        }
705
 
706
                }
707
 
708
                $hotspot="$hotspot \"";
709
 
710
        }
711
 
712
 
713
 
714
        foreach  my $ratio_in (@ratios){
715
                #my $r= $ratio_in * MAX_RATIO/100;
716
                add_info($info, "Run $bin with  injection ratio of $ratio_in \% \n");
717
                my $cmd="$bin -t \"$patern\"  -s $MIN_PCK_SIZE -m $MAX_PCK_SIZE  -n  $PCK_NUM_LIMIT  -c $SIM_CLOCK_LIMIT   -i $ratio_in -p \"100,0,0,0,0\"  $hotspot";
718
                        add_info($info, "$cmd \n");
719
                        my $time_strg = localtime;
720
                        append_text_to_file($log,"started at:$time_strg\n"); #save simulation output
721
                        my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout("$cmd");
722
                        if($exit){
723
                                add_info($info, "Error in running simulation: $stderr \n");
724
                                $simulate->object_add_attribute ($sample,"status","failed");
725
                                $simulate->object_add_attribute('status',undef,'ideal');
726
                                return;
727
                        }
728
 
729
                        append_text_to_file($log,$stdout); #save simulation output
730
                        $time_strg = localtime;
731
                        append_text_to_file($log,"Ended at:$time_strg\n"); #save simulation output
732
 
733
                        #my @q =split  (/average latency =/,$stdout);
734
                        #my $d=$q[1];
735
                        #@q =split  (/\n/,$d);
736
                        #my $avg=$q[0];
737
                        my $avg_latency =capture_number_after("average latency =",$stdout);
738 42 alirezamon
                        my $sd_latency =capture_number_after("standard_dev =",$stdout);
739 38 alirezamon
                        my $avg_thput =capture_number_after("Avg throughput is:",$stdout);
740
                        my $total_time =capture_number_after("simulation clock cycles:",$stdout);
741
 
742
                        my %packet_rsvd_per_core = capture_cores_data("total number of received packets:",$stdout);
743
                        my %worst_rsvd_delay_per_core = capture_cores_data('worst-case-delay of received pckets \(clks\):',$stdout);
744
                        my %packet_sent_per_core = capture_cores_data("total number of sent packets:",$stdout);
745
                        my %worst_sent_delay_per_core = capture_cores_data('worst-case-delay of sent pckets \(clks\):',$stdout);
746
                        #my $avg = sprintf("%.1f", $avg);
747
 
748
 
749
                next if (!defined $avg_latency);
750
                        update_result($simulate,$sample,"latency_result",$ratio_in,$avg_latency);
751 42 alirezamon
                        update_result($simulate,$sample,"sd_latency_result",$ratio_in,$sd_latency);
752 38 alirezamon
                        update_result($simulate,$sample,"throughput_result",$ratio_in,$avg_thput);
753
                        update_result($simulate,$sample,"exe_time_result",$ratio_in,$total_time);
754
                        foreach my $p (sort keys %packet_rsvd_per_core){
755
                                update_result($simulate,$sample,"packet_rsvd_result",$ratio_in,$p,$packet_rsvd_per_core{$p} );
756
                                update_result($simulate,$sample,"worst_delay_rsvd_result",$ratio_in,$p,$worst_rsvd_delay_per_core{$p});
757
                                update_result($simulate,$sample,"packet_sent_result",$ratio_in,$p,$packet_sent_per_core{$p} );
758
                                update_result($simulate,$sample,"worst_delay_sent_result",$ratio_in,$p,$worst_sent_delay_per_core{$p});
759
                        }
760
                        set_gui_status($simulate,"ref",2);
761
 
762
 
763
 
764
 
765
                }
766
                $simulate->object_add_attribute ($sample,"status","done");
767
 
768
 
769
}
770
 
771
 
772
 
773
sub run_custom_simulation{
774
        my ($simulate,$info,$sample,$name)=@_;
775
        my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
776
        my $SIM_CLOCK_LIMIT=$simulate->object_get_attribute ($sample,"SIM_CLOCK_LIMIT");
777 43 alirezamon
 
778
        my $bin=get_sim_bin_path($simulate,$sample,$info);
779
 
780 38 alirezamon
        my $dir = Cwd::getcwd();
781
        my $project_dir   = abs_path("$dir/../.."); #mpsoc directory address
782
        $bin= "$project_dir/$bin"   if(!(-f $bin));
783
        my $num=$simulate->object_get_attribute($sample,"TRAFFIC_FILE_NUM");
784
        for (my $i=0; $i<$num; $i++){
785
                 my $f=$simulate->object_get_attribute($sample,"traffic_file$i");
786
                 add_info($info, "Run $bin for $f  file \n");
787
                 my $cmd="$bin  -c      $SIM_CLOCK_LIMIT  -f \"$project_dir/$f\"";
788
                 add_info($info, "$cmd \n");
789
                 my $time_strg = localtime;
790
                 append_text_to_file($log,"started at:$time_strg\n"); #save simulation output   
791
 
792
                 my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout("$cmd");
793
                 if($exit){
794
                                add_info($info, "Error in running simulation: $stderr \n");
795
                                $simulate->object_add_attribute ($sample,"status","failed");
796
                                $simulate->object_add_attribute('status',undef,'ideal');
797
                                return;
798
                 }
799
                 append_text_to_file($log,$stdout); #save simulation output
800
                        $time_strg = localtime;
801
                        append_text_to_file($log,"Ended at:$time_strg\n"); #save simulation output
802
 
803
                        #my @q =split  (/average latency =/,$stdout);
804
                        #my $d=$q[1];
805
                        #@q =split  (/\n/,$d);
806
                        #my $avg=$q[0];
807
                        my $avg_latency =capture_number_after("average latency =",$stdout);
808 42 alirezamon
                        my $sd_latency =capture_number_after("standard_dev =",$stdout);
809 38 alirezamon
                        my $avg_thput =capture_number_after("Avg throughput is:",$stdout);
810
                        my %packet_rsvd_per_core = capture_cores_data("total number of received packets:",$stdout);
811
                        my %worst_rsvd_delay_per_core = capture_cores_data('worst-case-delay of received pckets \(clks\):',$stdout);
812
                        my %packet_sent_per_core = capture_cores_data("total number of sent packets:",$stdout);
813
                        my %worst_sent_delay_per_core = capture_cores_data('worst-case-delay of sent pckets \(clks\):',$stdout);
814
                        my $total_time =capture_number_after("simulation clock cycles:",$stdout);
815
                        #my $avg = sprintf("%.1f", $avg);
816
 
817
 
818
                next if (!defined $avg_latency);
819
                        update_result($simulate,$sample,"latency_result",$i,$avg_latency);
820 42 alirezamon
                        update_result($simulate,$sample,"sd_latency_result",$i,$sd_latency);
821 38 alirezamon
                        update_result($simulate,$sample,"throughput_result",$i,$avg_thput);
822
                        update_result($simulate,$sample,"exe_time_result",$i,$total_time);
823
                        foreach my $p (sort keys %packet_rsvd_per_core){
824
                                update_result($simulate,$sample,"packet_rsvd_result",$i,$p,$packet_rsvd_per_core{$p} );
825
                                update_result($simulate,$sample,"worst_delay_rsvd_result",$i,$p,$worst_rsvd_delay_per_core{$p});
826
                                update_result($simulate,$sample,"packet_sent_result",$i,$p,$packet_sent_per_core{$p} );
827
                                update_result($simulate,$sample,"worst_delay_sent_result",$i,$p,$worst_sent_delay_per_core{$p});
828
                        }
829
                        set_gui_status($simulate,"ref",2);
830
 
831
 
832
 
833
        }
834
 
835
 
836
        $simulate->object_add_attribute ($sample,"status","done");
837
}
838
 
839
 
840
 
841
##########
842
# check_sample
843
##########
844
 
845 43 alirezamon
sub get_sim_bin_path {
846 38 alirezamon
        my ($self,$sample,$info)=@_;
847
        my $bin_path=$self->object_get_attribute ($sample,"sof_path");
848 43 alirezamon
        unless (-d $bin_path){
849
                my $path= $self->object_get_attribute ("sim_param","BIN_DIR");
850
                if(-d $path){
851
                        add_colored_info($info, "Warning: The given path ($bin_path) for searcing $sample bin file does not exist. The system search in default $path instead.\n",'green');
852
                        $bin_path=$path;
853
                }
854
        }
855 38 alirezamon
        my $bin_file=$self->object_get_attribute ($sample,"sof_file");
856
        my $sof="$bin_path/$bin_file";
857 43 alirezamon
        return $sof;
858
}
859
 
860
sub check_sim_sample{
861
        my ($self,$sample,$info)=@_;
862
        my $status=1;
863
        my $sof=get_sim_bin_path($self,$sample,$info);
864
 
865 38 alirezamon
        # ckeck if sample have sof file
866
        if(!defined $sof){
867 43 alirezamon
                add_colored_info($info, "Error: bin file has not set for $sample!\n",'red');
868 38 alirezamon
                $self->object_add_attribute ($sample,"status","failed");
869
                $status=0;
870
        } else {
871
                # ckeck if bin file has info file 
872
                my ($name,$path,$suffix) = fileparse("$sof",qr"\..[^.]*$");
873
                my $sof_info= "$path$name.inf";
874
                if(!(-f $sof_info)){
875 43 alirezamon
                        add_info($info, "Could not find $name.inf file in $path. An information file is required for each sof file containig the device name and  NoC configuration. Press F3 for more help.\n");
876 38 alirezamon
                        $self->object_add_attribute ($sample,"status","failed");
877
                        $status=0;
878
                }else { #add info
879
                        my $pp= do $sof_info ;
880
 
881
                        my $p=$pp->{'noc_param'};
882
 
883
                        $status=0 if $@;
884
                        message_dialog("Error reading: $@") if $@;
885
                        if ($status==1){
886
                                $self->object_add_attribute ($sample,"noc_info",$p) ;
887
 
888
 
889
                        }
890
                }
891
        }
892 43 alirezamon
        #check if sample min packet size matches in simulation 
893
 
894
        my $p= $self->object_get_attribute ($sample,"noc_info");
895
    my $HW_MIN_PCK_SIZE=$p->{"MIN_PCK_SIZE"};
896
    my $SIM_MIN_PCK_SIZE=$self->object_get_attribute ($sample,"MIN_PCK_SIZE");
897
   if(!defined $HW_MIN_PCK_SIZE){
898
        $HW_MIN_PCK_SIZE= 2;
899
        #print "undef\n";       
900
    }
901
        if($HW_MIN_PCK_SIZE>$SIM_MIN_PCK_SIZE){
902
                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');
903
                $self->object_add_attribute ($sample,"status","failed");
904
                $status=0;
905
        }
906
        #print "$HW_MIN_PCK_SIZE>$SIM_MIN_PCK_SIZE\n";                  
907 38 alirezamon
        return $status;
908
}
909
 
910
 
911
 
912 43 alirezamon
 
913 38 alirezamon
############
914 32 alirezamon
#    main
915
############
916
sub simulator_main{
917
 
918
        add_color_to_gd();
919
        my $simulate= emulator->emulator_new();
920
        set_gui_status($simulate,"ideal",0);
921 38 alirezamon
 
922 32 alirezamon
 
923
        my $main_table = Gtk2::Table->new (25, 12, FALSE);
924
        my ($infobox,$info)= create_text();
925
 
926 43 alirezamon
 
927 32 alirezamon
 
928 38 alirezamon
my @pages =(
929
        {page_name=>" Avg. throughput/latency", page_num=>0},
930
        {page_name=>" Injected Packet ", page_num=>1},
931
        {page_name=>" Worst-Case Delay ",page_num=>2},
932
        {page_name=>" Executaion Time ",page_num=>3},
933
);
934
 
935
 
936
 
937
my @charts = (
938 42 alirezamon
        { type=>"2D_line", page_num=>0, graph_name=> "Throughput", result_name => "throughput_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Avg. Throughput (flits/clock (%))', Z_Title=>undef},
939
        { type=>"2D_line", page_num=>0, graph_name=> "Avg. Latency", result_name => "latency_result", X_Title=> 'Desired Avg. Injected Load Per Router (flits/clock (%))', Y_Title=>'Avg. Latency (clock)', Z_Title=>undef, Y_Max=>100},
940
        { type=>"2D_line", page_num=>0, graph_name=> "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},
941 38 alirezamon
        { type=>"3D_bar",  page_num=>1, graph_name=> "Received", result_name => "packet_rsvd_result", X_Title=>'Core ID' , Y_Title=>'Received Packets Per Router', Z_Title=>undef},
942
        { type=>"3D_bar",  page_num=>1, graph_name=> "Sent", result_name => "packet_sent_result", X_Title=>'Core ID' , Y_Title=>'Sent Packets Per Router', Z_Title=>undef},
943
        { type=>"3D_bar",  page_num=>2, graph_name=> "Received", result_name => "worst_delay_rsvd_result",X_Title=>'Core ID' , Y_Title=>'Worst-Case Delay (clk)', Z_Title=>undef},
944
        { type=>"3D_bar",  page_num=>2, graph_name=> "Sent", result_name => "worst_delay_sent_result",X_Title=>'Core ID' , Y_Title=>'Worst-Case Delay (clk)', Z_Title=>undef},
945
        { type=>"2D_line", page_num=>3, graph_name=> "-", result_name => "exe_time_result",X_Title=>'Desired Avg. Injected Load Per Router (flits/clock (%))' , Y_Title=>'Total Simulation Time (clk)', Z_Title=>undef},
946 32 alirezamon
 
947 38 alirezamon
        );
948 32 alirezamon
 
949
 
950 38 alirezamon
        my ($conf_box,$set_win)=process_notebook_gen($simulate,\$info,"simulate",@charts);
951
        my $chart   =gen_multiple_charts  ($simulate,\@pages,\@charts);
952 32 alirezamon
 
953
 
954
 
955
        $main_table->set_row_spacings (4);
956
        $main_table->set_col_spacings (1);
957
 
958
        #my  $device_win=show_active_dev($soc,$soc,$infc,$soc_state,\$refresh,$info);
959
 
960
 
961 43 alirezamon
        my $generate = def_image_button('icons/forward.png','R_un all',FALSE,1);
962
        my $open = def_image_button('icons/browse.png',"_Load",FALSE,1);
963
        my $save = def_image_button('icons/save.png','Sav_e',FALSE,1);
964
        my $save_all_results = def_image_button('icons/copy.png',"E_xtract all results",FALSE,1);
965 32 alirezamon
 
966
 
967
 
968 43 alirezamon
        my ($entrybox,$entry) = def_h_labeled_entry('Save as:',undef);
969 32 alirezamon
 
970 43 alirezamon
 
971 32 alirezamon
        $entrybox->pack_end($save,   FALSE, FALSE,0);
972
 
973
 
974
        #$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
975
        my $image = get_status_gif($simulate);
976
 
977
 
978
 
979
 
980 38 alirezamon
        my $v1=gen_vpaned($conf_box,.45,$image);
981
        my $v2=gen_vpaned($infobox,.2,$chart);
982
        my $h1=gen_hpaned($v1,.4,$v2);
983 32 alirezamon
 
984
 
985
 
986 38 alirezamon
        $main_table->attach_defaults ($h1  , 0, 12, 0,24);
987 43 alirezamon
        $main_table->attach ($open,0, 2, 24,25,'expand','shrink',2,2);
988
        #$main_table->attach ($diagram, 2, 4, 24,25,'expand','shrink',2,2);
989
        $main_table->attach ($entrybox,4, 7, 24,25,'expand','shrink',2,2);
990
        $main_table->attach ($save_all_results, 7, 8, 24,25,'shrink','shrink',2,2);
991
        $main_table->attach ($generate, 8, 9, 24,25,'expand','shrink',2,2);
992 38 alirezamon
 
993 43 alirezamon
        $entry->signal_connect( 'changed'=> sub{
994
                my $name=$entry->get_text();
995
                $simulate->object_add_attribute ("simulate_name",undef,$name);
996
        });
997 32 alirezamon
 
998
 
999
        #check soc status every 0.5 second. referesh device table if there is any changes 
1000
        Glib::Timeout->add (100, sub{
1001
 
1002
                my ($state,$timeout)= get_gui_status($simulate);
1003
 
1004
                if ($timeout>0){
1005
                        $timeout--;
1006
                        set_gui_status($simulate,$state,$timeout);
1007 38 alirezamon
                        return TRUE;
1008 32 alirezamon
 
1009
                }
1010 38 alirezamon
                if($state eq "ideal"){
1011
                        return TRUE;
1012
 
1013
                }
1014
 
1015
                if($state eq 'ref_set_win'){
1016 32 alirezamon
 
1017
                        my $s=$simulate->object_get_attribute("active_setting",undef);
1018
                        $set_win->destroy();
1019
                        $simulate->object_add_attribute("active_setting",undef,$s);
1020
                }
1021 38 alirezamon
 
1022
 
1023
                #refresh GUI
1024
                my $name=$simulate->object_get_attribute ("simulate_name",undef);
1025
                $entry->set_text($name) if(defined $name);
1026
 
1027
                $conf_box->destroy();
1028
                $chart->destroy();
1029
                $image->destroy();
1030
                $image = get_status_gif($simulate);
1031
                ($conf_box,$set_win)=process_notebook_gen($simulate,\$info,"simulate",@charts);
1032
                $chart = gen_multiple_charts  ($simulate,\@pages,\@charts);
1033
                $v1 -> pack1($conf_box, TRUE, TRUE);
1034
                $v1 -> pack2($image, TRUE, TRUE);
1035
                $v2 -> pack2($chart, TRUE, TRUE);
1036
                $conf_box->show_all();
1037
                $main_table->show_all();
1038
                set_gui_status($simulate,"ideal",0);
1039
 
1040 32 alirezamon
                return TRUE;
1041
 
1042
        } );
1043
 
1044
 
1045 43 alirezamon
 
1046
 
1047 32 alirezamon
        $generate-> signal_connect("clicked" => sub{
1048 38 alirezamon
                my @samples =$simulate->object_get_attribute_order("samples");
1049
                foreach my $sample (@samples){
1050
                        $simulate->object_add_attribute ("$sample","status","run");
1051 32 alirezamon
                }
1052
                run_simulator($simulate,\$info);
1053
                #set_gui_status($emulate,"ideal",2);
1054
 
1055
        });
1056
 
1057
#       $wb-> signal_connect("clicked" => sub{ 
1058
#               wb_address_setting($mpsoc);
1059
#       
1060
#       });
1061
 
1062
        $open-> signal_connect("clicked" => sub{
1063
 
1064
                load_simulation($simulate,\$info);
1065 38 alirezamon
                #print Dumper($simulate);
1066 32 alirezamon
                set_gui_status($simulate,"ref",5);
1067
 
1068
        });
1069
 
1070
        $save-> signal_connect("clicked" => sub{
1071
                save_simulation($simulate);
1072
                set_gui_status($simulate,"ref",5);
1073
 
1074
 
1075
        });
1076 43 alirezamon
 
1077
        $save_all_results-> signal_connect("clicked" => sub{
1078
                #Get the path where to save all the simulation results
1079
                my $open_in = $simulate->object_get_attribute ('sim_param','BIN_DIR');
1080
        get_dir_name($simulate,"Select the target directory","sim_param","ALL_RESULT_DIR",$open_in,'ref',1);
1081
                $simulate->object_add_attribute ("graph_save","save_all_result",1);
1082
 
1083
        });
1084 32 alirezamon
 
1085
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
1086
                $sc_win->set_policy( "automatic", "automatic" );
1087
                $sc_win->add_with_viewport($main_table);
1088
 
1089
        return $sc_win;
1090
 
1091
 
1092
}

powered by: WebSVN 2.1.0

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