2020-05-04 22:42:15 +00:00
|
|
|
#!/usr/bin/env perl
|
2010-01-16 01:27:01 +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
|
2010-01-16 01:27:01 +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
|
2010-01-16 01:27:01 +00:00
|
|
|
|
|
|
|
use IO::File;
|
|
|
|
|
2018-05-08 00:42:28 +00:00
|
|
|
scenarios(dist => 1);
|
|
|
|
|
2010-01-16 01:27:01 +00:00
|
|
|
my $root = "..";
|
|
|
|
my $Debug;
|
|
|
|
|
|
|
|
if (!-r "$root/.git") {
|
2018-05-08 00:42:28 +00:00
|
|
|
skip("Not in a git repository");
|
2010-01-16 01:27:01 +00:00
|
|
|
} else {
|
2010-02-01 14:28:53 +00:00
|
|
|
printfll();
|
2014-06-09 01:36:18 +00:00
|
|
|
cstr();
|
2015-06-04 23:37:03 +00:00
|
|
|
vsnprintf();
|
2020-11-19 02:32:16 +00:00
|
|
|
final();
|
2010-02-01 14:28:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ok(1);
|
|
|
|
|
|
|
|
sub printfll {
|
2020-11-19 02:32:16 +00:00
|
|
|
my $files = "src/*.c* src/*.h include/*.c* include/*.h examples/*/*.c* test_regress/t/*.c* test_regress/t/*.h";
|
2010-02-01 14:28:53 +00:00
|
|
|
my $cmd = "cd $root && fgrep -n ll $files | sort";
|
|
|
|
print "C $cmd\n";
|
|
|
|
my $grep = `$cmd`;
|
|
|
|
my %names;
|
|
|
|
foreach my $line (split /\n/, $grep) {
|
2018-10-27 14:03:28 +00:00
|
|
|
next if $line !~ /%[a-z0-9]*ll/;
|
|
|
|
next if $line !~ /\blong\S+long\b/; # Assume a cast
|
|
|
|
print "$line\n";
|
|
|
|
if ($line =~ /^([^:]+)/) {
|
|
|
|
$names{$1} = 1;
|
|
|
|
} else {
|
|
|
|
$names{UNKNOWN} = 1;
|
|
|
|
}
|
2010-02-01 14:28:53 +00:00
|
|
|
}
|
|
|
|
if (keys %names) {
|
2022-01-01 21:04:20 +00:00
|
|
|
error("Files with %ll instead of PRIx64: ", join(' ', sort keys %names));
|
2010-02-01 14:28:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-09 01:36:18 +00:00
|
|
|
sub cstr {
|
2020-11-19 02:32:16 +00:00
|
|
|
my $files = "src/*.c* src/*.h include/*.c* include/*.h examples/*/*.c* test_regress/t/*.c* test_regress/t/*.h";
|
2014-06-09 01:36:18 +00:00
|
|
|
my $cmd = "cd $root && grep -n -P 'c_str|begin|end' $files | sort";
|
|
|
|
print "C $cmd\n";
|
|
|
|
my $grep = `$cmd`;
|
|
|
|
my %names;
|
|
|
|
foreach my $line (split /\n/, $grep) {
|
Introduce model interface class, make $root part or Syms (#3036)
This patch implements #3032. Verilator creates a module representing the
SystemVerilog $root scope (V3LinkLevel::wrapTop). Until now, this was
called the "TOP" module, which also acted as the user instantiated model
class. Syms used to hold a pointer to this root module, but hold
instances of any submodule. This patch renames this root scope module
from "TOP" to "$root", and introduces a separate model class which is
now an interface class. As the root module is no longer the user
interface class, it can now be made an instance of Syms, just like any
other submodule. This allows absolute references into the root module to
avoid an additional pointer indirection resulting in a potential speedup
(about 1.5% on OpenTitan). The model class now also contains all non
design specific generated code (e.g.: eval loops, trace config, etc),
which additionally simplifies Verilator internals.
Please see the updated documentation for the model interface changes.
2021-06-21 14:30:20 +00:00
|
|
|
if ($line =~ /^([^:]+)[^"]*\(\)[a-z0-9_().->]*[.->]+(c_str|r?begin|r?end)\(\)/) {
|
2018-10-27 14:03:28 +00:00
|
|
|
next if $line =~ /lintok-begin-on-ref/;
|
|
|
|
print "$line\n";
|
|
|
|
$names{$1} = 1;
|
|
|
|
}
|
2014-06-09 01:36:18 +00:00
|
|
|
}
|
|
|
|
if (keys %names) {
|
2021-09-08 03:50:28 +00:00
|
|
|
error("Files with potential c_str() lifetime issue: ", join(' ', sort keys %names));
|
2014-06-09 01:36:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 23:37:03 +00:00
|
|
|
sub vsnprintf {
|
2015-06-16 11:13:45 +00:00
|
|
|
# Note do not do test_regress, as VPI files need to compile without verilatedos.h
|
2020-11-19 02:32:16 +00:00
|
|
|
my $files = "src/*.c* src/*.h include/*.c* include/*.h examples/*/*.c*";
|
2015-06-16 11:13:45 +00:00
|
|
|
my $cmd = "cd $root && grep -n -P '(snprintf|vsnprintf)' $files | sort";
|
2015-06-04 23:37:03 +00:00
|
|
|
print "C $cmd\n";
|
|
|
|
my $grep = `$cmd`;
|
|
|
|
my %names;
|
|
|
|
foreach my $line (split /\n/, $grep) {
|
2018-10-27 14:03:28 +00:00
|
|
|
if ($line =~ /\b(snprintf|vsnprintf)\b/) {
|
|
|
|
next if $line =~ /# *define\s*VL_V?SNPRINTF/;
|
|
|
|
print "$line\n";
|
|
|
|
$names{$1} = 1;
|
|
|
|
}
|
2015-06-04 23:37:03 +00:00
|
|
|
}
|
|
|
|
if (keys %names) {
|
2021-09-08 03:50:28 +00:00
|
|
|
error("Files with vsnprintf, use VL_VSNPRINTF: ", join(' ', sort keys %names));
|
2015-06-04 23:37:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 02:32:16 +00:00
|
|
|
sub final {
|
|
|
|
# Note do not do test_regress, as VPI files need to compile without verilatedos.h
|
|
|
|
my $files = "src/*.c* src/*.h include/*.c* include/*.h";
|
|
|
|
my $cmd = "cd $root && grep -n -P '(class)' $files | sort";
|
|
|
|
print "C $cmd\n";
|
|
|
|
my $grep = `$cmd`;
|
|
|
|
my %names;
|
|
|
|
foreach my $line (split /\n/, $grep) {
|
|
|
|
if ($line =~ /:\s*class /) {
|
|
|
|
next if $line =~ /final|VL_NOT_FINAL/;
|
|
|
|
next if $line =~ /{}/; # e.g. 'class Foo {};'
|
|
|
|
next if $line =~ /;/; # e.g. 'class Foo;'
|
|
|
|
print "$line\n";
|
|
|
|
$names{$1} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (keys %names) {
|
2021-09-08 03:50:28 +00:00
|
|
|
error("Files with classes without final/VL_NOT_FINAL: ", join(' ', sort keys %names));
|
2020-11-19 02:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-16 01:27:01 +00:00
|
|
|
1;
|