2020-05-04 22:42:15 +00:00
|
|
|
#!/usr/bin/env perl
|
2014-08-29 02:10:39 +00:00
|
|
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
|
|
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
|
|
|
#
|
2020-03-21 15:24:24 +00:00
|
|
|
# Copyright 2003 by Wilson Snyder. This program is free software; you
|
|
|
|
# can redistribute it and/or modify it under the terms of either the GNU
|
2014-08-29 02:10:39 +00:00
|
|
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
# Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2018-05-08 00:42:28 +00:00
|
|
|
scenarios(vlt_all => 1);
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2023-01-08 23:17:24 +00:00
|
|
|
# TODO below might no longer be required as configure checks for -pg
|
2020-06-22 09:13:54 +00:00
|
|
|
if ($ENV{VERILATOR_TEST_NO_GPROF}) {
|
|
|
|
skip("Skipping due to VERILATOR_TEST_NO_GPROF");
|
|
|
|
} else {
|
|
|
|
dotest();
|
|
|
|
}
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2020-06-22 09:13:54 +00:00
|
|
|
ok(1);
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2020-06-22 09:13:54 +00:00
|
|
|
sub dotest {
|
|
|
|
compile(
|
2021-07-07 23:12:52 +00:00
|
|
|
verilator_flags2 => ["--stats --prof-cfuncs"],
|
2020-06-22 09:13:54 +00:00
|
|
|
);
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2020-06-22 09:13:54 +00:00
|
|
|
unlink $_ foreach (glob "$Self->{obj_dir}/gmon.out.*");
|
|
|
|
setenv('GMON_OUT_PREFIX', "$Self->{obj_dir}/gmon.out");
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2020-06-22 09:13:54 +00:00
|
|
|
execute(
|
|
|
|
check_finished => 1,
|
|
|
|
);
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2020-06-22 09:13:54 +00:00
|
|
|
my $gmon_path;
|
|
|
|
$gmon_path = $_ foreach (glob "$Self->{obj_dir}/gmon.out.*");
|
|
|
|
$gmon_path or error("Profiler did not create a gmon.out");
|
|
|
|
(my $gmon_base = $gmon_path) =~ s!.*[/\\]!!;
|
2014-08-29 02:10:39 +00:00
|
|
|
|
2020-06-22 09:13:54 +00:00
|
|
|
run(cmd => ["cd $Self->{obj_dir} && gprof $Self->{VM_PREFIX} $gmon_base > gprof.out"],
|
|
|
|
check_finished => 0);
|
|
|
|
|
|
|
|
run(cmd => ["cd $Self->{obj_dir} && $ENV{VERILATOR_ROOT}/bin/verilator_profcfunc gprof.out > cfuncs.out"],
|
|
|
|
check_finished => 0);
|
|
|
|
|
|
|
|
file_grep("$Self->{obj_dir}/cfuncs.out", qr/Overall summary by/);
|
2021-03-13 17:25:06 +00:00
|
|
|
file_grep("$Self->{obj_dir}/cfuncs.out", qr/VLib + VL_POWSS_QQQ/);
|
|
|
|
file_grep("$Self->{obj_dir}/cfuncs.out", qr/VBlock + t_prof:/);
|
2020-06-22 09:13:54 +00:00
|
|
|
}
|
2014-08-29 02:10:39 +00:00
|
|
|
|
|
|
|
1;
|