2020-05-04 22:42:15 +00:00
|
|
|
#!/usr/bin/env perl
|
2013-09-03 23:35:32 +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
|
2013-09-03 23:35:32 +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
|
2013-09-03 23:35:32 +00:00
|
|
|
|
2018-05-08 00:42:28 +00:00
|
|
|
scenarios(vlt_all => 1);
|
2013-09-03 23:35:32 +00:00
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
while (1) {
|
|
|
|
# Thi rule requires GNU make > 4.1 (or so, known broken in 3.81)
|
|
|
|
#%__Slow.o: %__Slow.cpp
|
|
|
|
# $(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $<
|
|
|
|
if (make_version() < 4.1) {
|
|
|
|
skip("Test requires GNU Make version >= 4.1");
|
|
|
|
last;
|
|
|
|
}
|
2019-06-19 12:44:40 +00:00
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
compile(
|
|
|
|
v_flags2 => ["--trace --output-split 1 --output-split-cfuncs 1 --exe ../$Self->{main_filename}"],
|
2019-10-08 02:15:43 +00:00
|
|
|
verilator_make_gmake => 0,
|
2019-06-29 12:25:50 +00:00
|
|
|
);
|
2013-09-03 23:35:32 +00:00
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
# We don't use the standard test_regress rules, as want to test the rules
|
|
|
|
# properly build
|
2019-06-30 21:45:42 +00:00
|
|
|
run(logfile => "$Self->{obj_dir}/vlt_gcc.log",
|
|
|
|
tee => $self->{verbose},
|
2019-06-29 12:25:50 +00:00
|
|
|
cmd=>["make",
|
|
|
|
"-C ".$Self->{obj_dir},
|
|
|
|
"-f $Self->{VM_PREFIX}.mk",
|
|
|
|
"-j 4",
|
2020-03-08 13:03:29 +00:00
|
|
|
#"VM_PARALLEL_BUILDS=1", # Check is set by makefile
|
2019-06-29 12:25:50 +00:00
|
|
|
"VM_PREFIX=$Self->{VM_PREFIX}",
|
|
|
|
"TEST_OBJ_DIR=$Self->{obj_dir}",
|
|
|
|
"CPPFLAGS_DRIVER=-D".uc($Self->{name}),
|
|
|
|
($opt_verbose ? "CPPFLAGS_DRIVER2=-DTEST_VERBOSE=1":""),
|
|
|
|
"OPT_FAST=-O2",
|
|
|
|
"OPT_SLOW=-O0",
|
|
|
|
($param{make_flags}||""),
|
|
|
|
]);
|
2018-11-30 01:35:21 +00:00
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
execute(
|
|
|
|
check_finished => 1,
|
|
|
|
);
|
2013-09-03 23:35:32 +00:00
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
check_splits();
|
|
|
|
check_gcc_flags("$Self->{obj_dir}/vlt_gcc.log");
|
2013-09-03 23:35:32 +00:00
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
ok(1);
|
|
|
|
last;
|
|
|
|
}
|
2013-09-03 23:35:32 +00:00
|
|
|
1;
|
|
|
|
|
2019-06-19 12:44:40 +00:00
|
|
|
sub make_version {
|
|
|
|
my $ver = `make --version`;
|
|
|
|
if ($ver =~ /make ([0-9]+\.[0-9]+)/i) {
|
|
|
|
return $1;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-29 12:25:50 +00:00
|
|
|
sub check_splits {
|
|
|
|
my $got1;
|
2019-09-04 10:15:41 +00:00
|
|
|
my $gotSyms1;
|
2019-06-29 12:25:50 +00:00
|
|
|
foreach my $file (glob("$Self->{obj_dir}/*.cpp")) {
|
2019-09-04 10:15:41 +00:00
|
|
|
if ($file =~ /Syms__1/) {
|
|
|
|
$gotSyms1 = 1;
|
|
|
|
} elsif ($file =~ /__1/) {
|
|
|
|
$got1 = 1;
|
|
|
|
}
|
2019-06-29 12:25:50 +00:00
|
|
|
check_cpp($file);
|
|
|
|
}
|
|
|
|
$got1 or error("No __1 split file found");
|
2019-09-04 10:15:41 +00:00
|
|
|
$gotSyms1 or error("No Syms__1 split file found");
|
2019-06-29 12:25:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 01:35:21 +00:00
|
|
|
sub check_cpp {
|
2013-09-03 23:35:32 +00:00
|
|
|
my $filename = shift;
|
|
|
|
my $size = -s $filename;
|
|
|
|
printf " File %6d %s\n", $size, $filename if $Self->{verbose};
|
2018-05-08 00:42:28 +00:00
|
|
|
my $fh = IO::File->new("<$filename") or error("$! $filenme");
|
2013-09-03 23:35:32 +00:00
|
|
|
my @funcs;
|
|
|
|
while (defined (my $line = $fh->getline)) {
|
2018-10-27 14:03:28 +00:00
|
|
|
if ($line =~ /^(void|IData)\s+(.*::.*)/) {
|
|
|
|
my $func = $2;
|
|
|
|
$func =~ s/\(.*$//;
|
|
|
|
print "\tFunc $func\n" if $Self->{verbose};
|
|
|
|
if ($func !~ /::_eval_initial_loop$/
|
|
|
|
&& $func !~ /::__Vconfigure$/
|
|
|
|
&& $func !~ /::trace$/
|
|
|
|
&& $func !~ /::traceInit$/
|
|
|
|
&& $func !~ /::traceFull$/
|
|
|
|
) {
|
|
|
|
push @funcs, $func;
|
|
|
|
}
|
|
|
|
}
|
2013-09-03 23:35:32 +00:00
|
|
|
}
|
|
|
|
if ($#funcs > 0) {
|
2018-05-08 00:42:28 +00:00
|
|
|
error("Split had multiple functions in $filename\n\t".join("\n\t",@funcs));
|
2013-09-03 23:35:32 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 01:35:21 +00:00
|
|
|
|
|
|
|
sub check_gcc_flags {
|
|
|
|
my $filename = shift;
|
|
|
|
my $fh = IO::File->new("<$filename") or error("$! $filenme");
|
|
|
|
while (defined (my $line = $fh->getline)) {
|
|
|
|
chomp $line;
|
2019-12-09 23:53:56 +00:00
|
|
|
print ":log: $line\n" if $Self->{verbose};
|
2018-11-30 01:35:21 +00:00
|
|
|
if ($line =~ /\.cpp/) {
|
2020-05-25 10:35:06 +00:00
|
|
|
my $filetype = ($line =~ /Slow|Syms/) ? "slow":"fast";
|
2018-11-30 01:35:21 +00:00
|
|
|
my $opt = ($line !~ /-O2/) ? "slow":"fast";
|
2018-12-13 03:19:33 +00:00
|
|
|
print "$filetype, $opt, $line\n" if $Self->{verbose};
|
2018-11-30 01:35:21 +00:00
|
|
|
if ($filetype ne $opt) {
|
|
|
|
error("${filetype} file compiled as if was ${opt}: $line");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|