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