forked from steveicarus/ivtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vvp_reg.pl
executable file
·224 lines (204 loc) · 6.98 KB
/
vvp_reg.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/perl
#
# Script to handle regression for normal Verilog files.
#
# This script is based on code with the following Copyright.
#
# Copyright (c) 1999 Guy Hutchison (ghutchis@pacbell.net)
#
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
use lib './perl-lib';
use RegressionList;
use Diff;
use Reporting;
use Environment;
#
# Main script
#
my ($suffix, $strict, $with_valg) = &get_args;
my $regress_fn = &get_regress_fn;
&open_report_file;
my $ver = &get_ivl_version($suffix);
my $opt = $strict ? " (strict)" : "";
my $msg = $with_valg ? " (with valgrind)" : "";
&print_rpt("Running compiler/VVP tests for Icarus Verilog " .
"version: $ver$opt$msg.\n");
&print_rpt("-" x 76 . "\n");
&read_regression_list($regress_fn, $ver, $strict ? "std" : "");
&execute_regression($suffix, $strict, $with_valg);
&close_report_file;
#
# execute_regression sequentially compiles and executes each test in
# the regression. It then checks that the output matches the gold file.
#
sub execute_regression {
my $sfx = shift(@_);
my $strict = shift(@_);
my $with_valg = shift(@_);
my ($tname, $total, $passed, $failed, $expected_fail, $not_impl,
$len, $cmd, $ivl_args, $vvp_args, $diff_file);
$total = 0;
$passed = 0;
$failed = 0;
$expected_fail = 0;
$not_impl = 0;
$len = 0;
foreach $tname (@testlist) {
$len = length($tname) if (length($tname) > $len);
}
# Make sure we have a log and work directory.
if (! -d 'log') {
mkdir 'log' or die "Error: unable to create log directory.\n";
}
if (! -d 'work') {
mkdir 'work' or die "Error: unable to create work directory.\n";
}
if ($strict) {
$ivl_args = "-gstrict-expr-width";
$vvp_args = "-compatible";
} else {
$ivl_args = "-D__ICARUS_UNSIZED__";
$vvp_args = "";
}
foreach $tname (@testlist) {
my ($pass_type);
next if ($tname eq ""); # Skip test that have been replaced.
$total++;
&print_rpt(sprintf("%${len}s: ", $tname));
if ($diff{$tname} ne "" and -e $diff{$tname}) {
unlink $diff{$tname} or
die "Error: unable to remove old diff file $diff{$tname}.\n";
}
if (-e "log/$tname.log") {
unlink "log/$tname.log" or
die "Error: unable to remove old log file log/$tname.log.\n";
}
if ($testtype{$tname} eq "NI") {
&print_rpt("Not Implemented.\n");
$not_impl++;
next;
}
#
# Build up the iverilog command line and run it.
#
$pass_type = 0;
$cmd = $with_valg ? "valgrind --trace-children=yes " : "";
$cmd .= "iverilog$sfx -o vsim $ivl_args $args{$tname}";
$cmd .= " -s $testmod{$tname}" if ($testmod{$tname} ne "");
$cmd .= " -t null" if ($testtype{$tname} eq "CN");
$cmd .= " ./$srcpath{$tname}/$tname.v > log/$tname.log 2>&1";
# print "$cmd\n";
if (system("$cmd")) {
if ($testtype{$tname} eq "CE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
&print_rpt("==> Failed - CE (core dump).\n");
$failed++;
next;
} else {
$pass_type = 1;
}
} else {
&print_rpt("==> Failed - running iverilog.\n");
$failed++;
next;
}
} else {
if ($testtype{$tname} eq "CE") {
&print_rpt("==> Failed - CE (no error reported).\n");
$failed++;
next;
}
}
if ($testtype{$tname} eq "CO") {
&print_rpt("Passed - CO.\n");
$passed++;
next;
}
if ($testtype{$tname} eq "CN") {
&print_rpt("Passed - CN.\n");
$passed++;
next;
}
$cmd = $with_valg ? "valgrind --leak-check=full " .
"--show-reachable=yes " : "";
$cmd .= "vvp$sfx vsim $vvp_args $plargs{$tname} >> log/$tname.log 2>&1";
# print "$cmd\n";
if ($pass_type == 0 and system("$cmd")) {
if ($testtype{$tname} eq "RE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
&print_rpt("==> Failed - RE (core dump).\n");
$failed++;
next;
} else {
$pass_type = 2;
}
} else {
&print_rpt("==> Failed - running vvp.\n");
$failed++;
next;
}
}
if ($diff{$tname} ne "") {
$diff_file = $diff{$tname}
} else {
if ($pass_type == 1) {
&print_rpt("Passed - CE.\n");
$passed++;
next;
} elsif ($pass_type == 2) {
&print_rpt("Passed - RE.\n");
$passed++;
next;
}
$diff_file = "log/$tname.log";
}
# print "diff $gold{$tname}, $diff_file, $offset{$tname}\n";
if (diff($gold{$tname}, $diff_file, $offset{$tname})) {
if ($testtype{$tname} eq "EF") {
&print_rpt("Passed - expected fail.\n");
$expected_fail++;
next;
}
&print_rpt("==> Failed -");
if ($pass_type == 1) {
&print_rpt(" CE -");
} elsif ($pass_type == 2) {
&print_rpt(" RE -");
}
&print_rpt(" output does not match gold file.\n");
$failed++;
next;
}
if ($pass_type == 1) {
&print_rpt("Passed - CE.\n");
} elsif ($pass_type == 2) {
&print_rpt("Passed - RE.\n");
} else {
&print_rpt("Passed.\n");
}
$passed++;
} continue {
if ($tname ne "") {
system("rm -f ./vsim && rm -rf ivl_vhdl_work") and
die "Error: failed to remove temporary file.\n";
}
}
&print_rpt("=" x 76 . "\n");
&print_rpt("Test results:\n Total=$total, Passed=$passed, Failed=$failed,".
" Not Implemented=$not_impl, Expected Fail=$expected_fail\n");
}