Tests: Support atsim and cleanup verilator-only tests

This commit is contained in:
Wilson Snyder 2010-03-18 12:03:08 -04:00
parent bcea39a858
commit 7ea8b54210
44 changed files with 201 additions and 52 deletions

59
nodist/invoke_atsim Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/perl -w
# See copyright, etc in below POD section.
######################################################################
require 5.006_001;
use strict;
#======================================================================
# main
delete $ENV{MODULE_VERSION};
_setup_modules();
module('add','axiom-athdl');
exec('atsim',@ARGV);
#######################################################################
# Modules package
sub _setup_modules {
# Load the 'module' command into the environment
my $init = "$ENV{MODULESHOME}/init/perl";
(-f $init) or die "%Error: Script not found: $init,";
require $init;
}
#######################################################################
__END__
=pod
=head1 NAME
invoke_atsim - Invoke tool under "modules" command
=head1 SYNOPSIS
invoke_atsim {ncv arguments}
=head1 DESCRIPTION
=head1 DISTRIBUTION
Copyright 2005-2010 by Wilson Snyder. This package is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License Version 3 or the Perl Artistic License
Version 2.0.
=head1 AUTHORS
Wilson Snyder <wsnyder@wsnyder.org>
=head1 SEE ALSO
=cut
######################################################################
### Local Variables:
### compile-command: "./invoke_atsim -help"
### End:

View File

@ -40,6 +40,7 @@ our @Orig_ARGV = @ARGV;
our @Orig_ARGV_Sw; foreach (@Orig_ARGV) { push @Orig_ARGV_Sw, $_ if /^-/ && !/^-j/; }
$Debug = 0;
my $opt_atsim;
my $opt_benchmark;
my @opt_tests;
my $opt_gdb;
@ -61,6 +62,7 @@ Getopt::Long::config ("pass_through");
if (! GetOptions (
"benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; },
"debug" => \&debug,
"atsim|athdl!"=> \$opt_atsim,
"gdb!" => \$opt_gdb,
"gdbbt!" => \$opt_gdbbt,
"gdbsim!" => \$opt_gdbsim,
@ -86,7 +88,7 @@ $opt_jobs = calc_jobs() if defined $opt_jobs && $opt_jobs==0;
$Fork->max_proc($opt_jobs);
if (!$opt_iv && !$opt_vcs && !$opt_nc && !$opt_vlt) {
if (!$opt_atsim && !$opt_iv && !$opt_vcs && !$opt_nc && !$opt_vlt) {
$opt_vlt = 1;
}
@ -101,6 +103,7 @@ my $leftcnt=0; my $okcnt=0; my $failcnt=0; my $skcnt=0;
my @fails;
foreach my $testpl (@opt_tests) {
one_test(pl_filename => $testpl, atsim=>1) if $opt_atsim;
one_test(pl_filename => $testpl, iv=>1) if $opt_iv;
one_test(pl_filename => $testpl, nc=>1) if $opt_nc;
one_test(pl_filename => $testpl, vcs=>1) if $opt_vcs;
@ -261,6 +264,12 @@ sub new {
v_flags2 => [], # Overridden in some sim files
v_other_filenames => [], # After the filename so we can spec multiple files
all_run_flags => [],
# ATSIM
atsim => 0,
atsim_flags => [split(/\s+/,"-c +sv +define+atsim"),
"+sv_dir+$self->{obj_dir}/.athdl_compile"],
atsim_flags2 => [], # Overridden in some sim files
atsimrun_flags => [],
# IV
iv => 0,
iv_flags => [split(/\s+/,"+define+iverilog -o $self->{obj_dir}/simiv")],
@ -288,6 +297,7 @@ sub new {
%$self};
bless $self, $class;
$self->{mode} ||= "atsim" if $self->{atsim};
$self->{mode} ||= "vcs" if $self->{vcs};
$self->{mode} ||= "vlt" if $self->{vlt};
$self->{mode} ||= "nc" if $self->{nc};
@ -387,6 +397,20 @@ sub compile {
$self->{trace} = 1 if ($opt_trace || $checkflags =~ /-trace\b/);
$self->{coverage} = 1 if ($checkflags =~ /-coverage\b/);
if ($param{atsim}) {
$self->_make_top();
$self->_run(logfile=>"$self->{obj_dir}/atsim_compile.log",
fails=>$param{fails},
cmd=>[($ENV{VERILATOR_ATSIM}||"atsim"),
@{$param{atsim_flags}},
@{$param{atsim_flags2}},
@{$param{v_flags}},
@{$param{v_flags2}},
$param{top_filename},
$param{top_shell_filename},
@{$param{v_other_filenames}},
]);
}
if ($param{vcs}) {
$self->_make_top();
$self->_run(logfile=>"$self->{obj_dir}/vcs_compile.log",
@ -511,6 +535,14 @@ sub execute {
my $run_env = $param{run_env};
$run_env .= ' ' if $run_env;
if ($param{atsim}) {
$self->_run(logfile=>"$self->{obj_dir}/atsim_sim.log",
fails=>$param{fails},
cmd=>["echo q | ".$run_env."$self->{obj_dir}/athdl_sv",
@{$param{atsimrun_flags}},
@{$param{all_run_flags}},
]);
}
if ($param{iv}) {
$self->_run(logfile=>"$self->{obj_dir}/iv_sim.log",
fails=>$param{fails},
@ -522,7 +554,7 @@ sub execute {
if ($param{nc}) {
$self->_run(logfile=>"$self->{obj_dir}/nc_sim.log",
fails=>$param{fails},
cmd=>[$run_env.($ENV{VERILATOR_NCVERILOG}||"ncverilog"),
cmd=>["echo q | ".$run_env.($ENV{VERILATOR_NCVERILOG}||"ncverilog"),
@{$param{ncrun_flags}},
@{$param{all_run_flags}},
]);
@ -531,7 +563,7 @@ sub execute {
#my $fh = IO::File->new(">simv.key") or die "%Error: $! simv.key,";
#$fh->print("quit\n"); $fh->close;
$self->_run(logfile=>"$self->{obj_dir}/vcs_sim.log",
cmd=>[$run_env."./simv",
cmd=>["echo q | ".$run_env."./simv",
@{$param{all_run_flags}},
],
%param,
@ -1166,6 +1198,10 @@ driver.pl invokes Verilator or another simulator on each little test file.
=over 4
=item --atsim
Run using ATSIM.
=item --benchmark [<cycles>]
Show execution times of each step. If an optional number is given,

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--stats"],
verilator_flags2 => ["--stats"],
);
if ($Self->{v3}) {

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--stats"],
verilator_flags2 => ["--stats"],
);
if ($Self->{v3}) {

View File

@ -16,7 +16,7 @@ compile (
);
execute (
fails => 1,
fails => $Self->{vlt},
);
ok(1);

View File

@ -16,7 +16,7 @@ compile (
execute (
check_finished=>0,
fails=>1,
fails=> $Self->{vlt},
expect=>
'%Error: t_assert_synth.v:\d+: Assertion failed in top.v: synthesis full_case'
);

View File

@ -16,7 +16,7 @@ compile (
execute (
check_finished=>0,
fails=>1,
fails => $Self->{v3},
expect=>
'%Error: t_assert_synth.v:\d+: Assertion failed in top.v: synthesis parallel_case'
);

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
$Self->{golden_out} ||= "t/$Self->{name}.out";
compile (
v_flags2 => [$Self->{v3}?"--stats --O3 -x-assign fast":""],
verilator_flags2 => ["--stats --O3 -x-assign fast"],
);
execute (

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
$Self->{golden_out} ||= "t/$Self->{name}.out";
compile (
v_flags2 => [$Self->{v3}?"--stats --O3 -x-assign fast":""],
verilator_flags2 => ["--stats --O3 -x-assign fast"],
);
execute (

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--x-assign 0"],
verilator_flags2 => ["--x-assign 0"],
);
execute (

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--stats"],
verilator_flags2 => ["--stats"],
);
execute (

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
verilator_flags2 => [$Self->{v3}?'--sp --coverage-line':''],
verilator_flags2 => ['--sp --coverage-line'],
);
execute (

View File

@ -48,7 +48,11 @@ module t (/*AUTOARG*/
toggle <= '1;
end
else if (cyc==5) begin
`ifdef VERILATOR
$c("call_task();");
`else
call_task();
`endif
end
else if (cyc==10) begin
$write("*-* All Finished *-*\n");

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => [$Self->{v3}?'--assert --sp --coverage-user':''],
verilator_flags2 => ['--assert --sp --coverage-user'],
);
execute (
@ -20,7 +20,8 @@ execute (
# Allow old Perl format dump, or new binary dump
# Check that the hierarchy doesn't include __PVT__
# Otherwise our coverage reports would look really ugly
file_grep ($Self->{coverage_filename}, qr/(top\.v\.sub.*.cyc_eq_5)/);
file_grep ($Self->{coverage_filename}, qr/(top\.v\.sub.*.cyc_eq_5)/)
if $Self->{vlt};
ok(1);
1;

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
verilator_flags2 => [$Self->{v3}?'--sp --coverage-toggle --stats':''],
verilator_flags2 => ['--sp --coverage-toggle --stats'],
);
execute (
@ -18,7 +18,8 @@ execute (
# Read the input .v file and do any CHECK_COVER requests
inline_checks();
file_grep ($Self->{stats}, qr/Coverage, Toggle points joined\s+25/i);
file_grep ($Self->{stats}, qr/Coverage, Toggle points joined\s+25/i)
if $Self->{vlt};
ok(1);
1;

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
$Self->_run (cmd=>["cd $Self->{obj_dir}"
." && g++ -c ../../t/t_flag_ldflags_a.cpp"
." && ar r t_flag_ldflags_a.a t_flag_ldflags_a.o"

View File

@ -12,7 +12,7 @@ module t (
chk chk (.clk (clk),
.rst_l (1'b1),
.expr (|crc),
.expr (|crc)
);
always @ (posedge clk) begin

View File

@ -3,7 +3,7 @@
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t_task (/*AUTOARG*/
module t (/*AUTOARG*/
// Inputs
clk
);

View File

@ -37,10 +37,14 @@ module t (clk);
if ( cyc >= 4 ) begin
dindex = dindex + 2; //*** Error line
$display("%m: DIndex increment %d", cyc);
`ifdef VERILATOR
$c("VL_PRINTF(\"Hello1?\\n\");");
`endif
end
`ifdef VERILATOR
$c("VL_PRINTF(\"Hello2?\\n\");");
$c("VL_PRINTF(\"Hello3?\\n\");");
`endif
end
end
endtask

View File

@ -3,7 +3,7 @@
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t_func (/*AUTOARG*/
module t (/*AUTOARG*/
// Inputs
clk
);

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
compile (
);
# No execute

View File

@ -12,7 +12,7 @@ my $pubtask = ($Self->{v3} && verilator_version() =~ /\(public_tasks\)/); # TBD
top_filename("t/t_func_public.v");
compile (
v_flags2 => [($pubtask?'-DVERILATOR_PUBLIC_TASKS':''), "--trace"],
verilator_flags2 => [($pubtask?'-DVERILATOR_PUBLIC_TASKS':''), "--trace"],
fails => $fail,
);

View File

@ -7,12 +7,14 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
$Self->_run(fails=>1,
cmd=>["perl","../bin/verilator",
"--help"],
logfile=>"$Self->{obj_dir}/t_help.log",
tee=>0,
) if $Self->{v3};
);
file_grep ("$Self->{obj_dir}/t_help.log", qr/DISTRIBUTION/i);

View File

@ -3,7 +3,7 @@
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t_initial (/*AUTOARG*/
module t (/*AUTOARG*/
// Inputs
clk
);

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
top_filename("t/t_inst_tree.v");
compile (
v_flags2 => ['+define+NOUSE_INLINE', '+define+USE_PUBLIC', '--stats'],
verilator_flags2 => ['+define+NOUSE_INLINE', '+define+USE_PUBLIC', '--stats'],
);
if ($Self->{v3}) {

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ['-public'],
verilator_flags2 => ['-public'],
);
execute (

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
compile (
v_flags => ["-Wno-IMPLICIT"],
);

View File

@ -3,7 +3,7 @@
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t_arith(/*AUTOARG*/
module t (/*AUTOARG*/
// Inputs
clk
);

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->skip("Verilator only test") if !$Self->{vlt};
compile (
make_top_shell => 0,
make_main => 0,

View File

@ -90,7 +90,6 @@ module fifo (/*AUTOARG*/
// verilator lint_off VARHIDDEN
reg [65:0] fifo[0:fifoDepth-1];
// verilator lint_on VARHIDDEN
reg [`PTRBITSM1:0] wrPtr, rdPtr;
//reg [65:0] temp;

View File

@ -3,7 +3,7 @@
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t_mem (/*AUTOARG*/
module t (/*AUTOARG*/
// Inputs
clk
);

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--stats"],
verilator_flags2 => ["--stats"],
);
if ($Self->{v3}) {

View File

@ -7,15 +7,16 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->skip("Verilator only test") if !$Self->{vlt};
compile (
fails=>$Self->{v3},
nc=>0, # Need to get it not to give the prompt
fails=>1,
expect=>
'%Error-MODDUP: t/t_mod_dup_bad.v:\d+: Duplicate declaration of module: a
%Error-MODDUP: t/t_mod_dup_bad.v:\d+: ... Location of original declaration
.*
%Error: Exiting due to.*',
) if $Self->{v3};
);
ok(1);
1;

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->skip("Verilator only test") if !$Self->{vlt};
compile (
make_top_shell => 0,
make_main => 0,

View File

@ -9,25 +9,45 @@ module t (/*AUTOARG*/
);
input clk;
`begin_keywords "1364-1995"
integer signed; initial signed = 1;
`end_keywords
`begin_keywords "1364-2001"
integer bit; initial bit = 1;
`end_keywords
`begin_keywords "1364-2005"
integer final; initial final = 1;
`end_keywords
`begin_keywords "1800-2005"
integer global; initial global = 1;
`begin_keywords "1800-2009"
final begin
$write("*-* All Finished *-*\n");
end
`end_keywords
`end_keywords
s1 s1 ();
s2 s2 ();
s3 s3 ();
s4 s4 ();
s5 s5 ();
initial begin
$finish;
end
endmodule
`begin_keywords "1364-1995"
module s1;
integer signed; initial signed = 1;
endmodule
`end_keywords
`begin_keywords "1364-2001"
module s2;
integer bit; initial bit = 1;
endmodule
`end_keywords
`begin_keywords "1364-2005"
module s3;
integer final; initial final = 1;
endmodule
`end_keywords
`begin_keywords "1800-2005"
module s4;
integer global; initial global = 1;
endmodule
`end_keywords
`begin_keywords "1800-2009"
module s5;
final begin
$write("*-* All Finished *-*\n");
end
endmodule
`end_keywords

View File

@ -3,7 +3,7 @@
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t_rnd(/*AUTOARG*/
module t (/*AUTOARG*/
// Inputs
clk
);

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
top_filename("t/t_unopt_combo.v");
compile (
v_flags2 => ['+define+ISOLATE --stats'],
verilator_flags2 => ['+define+ISOLATE --stats'],
);
if ($Self->{v3}) {

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--stats"],
verilator_flags2 => ["--stats"],
);
if ($Self->{v3}) {

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
top_filename("t/t_var_pinsizes.v");
compile (

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
top_filename("t/t_var_pinsizes.v");
compile (

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
top_filename("t/t_var_pinsizes.v");
compile (

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
top_filename("t/t_var_pinsizes.v");
compile (

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
top_filename("t/t_var_pinsizes.v");
compile (

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt} or $Self->skip("Verilator only test");
top_filename("t/t_var_pinsizes.v");
compile (