From 7ad29c6329379e6050d181d8b468b4e3ee63c767 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 21 Nov 2008 14:38:12 -0500 Subject: [PATCH] Test driver: Add benchmark option --- src/V3Error.h | 2 +- test_regress/driver.pl | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/V3Error.h b/src/V3Error.h index 470aa7b13..70489e7ca 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -178,7 +178,7 @@ inline void v3errorEnd(ostringstream& sstr) { V3Error::v3errorEnd(sstr); } #define UDEBUGONLY(stmts) {stmts} #define UASSERT(condition,stmsg) { if (!(condition)) { v3fatalSrc(stmsg); }} // For use in V3Ast static functions only -#define UASSERT_STATIC(condition,stmsg) { if (!(condition)) { cerr<<"Internal Error: "<<__FILE__<<":"< \$opt_jobs, "v3!" => \$opt_v3, "nc!" => \$opt_nc, + "benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; }, "gdb!" => \$opt_gdb, - "stop!" => \$opt_stop, "optimize:s" => \$opt_optimize, + "stop!" => \$opt_stop, "verbose!" => \$opt_verbose, "<>" => \¶meter, )) { @@ -215,9 +217,11 @@ sub new { make_top_shell => 1, # Make a default __top.v file make_main => 1, # Make __main.cpp sim_time => 1000, + benchmark => $opt_benchmark, # All compilers v_flags => [split(/\s+/,(" -f input.vc --debug-check" .($opt_verbose ? " +define+TEST_VERBOSE=1":"") + .($opt_benchmark ? " +define+TEST_BENCHMARK=$opt_benchmark":"") ))], v_flags2 => [], # Overridden in some sim files v_other_filenames => [], # After the filename so we can spec multiple files @@ -227,8 +231,9 @@ sub new { vcs_flags2 => [], # Overridden in some sim files # NC nc => 0, - nc_flags => [split(/\s+/,"+licqueue +nowarn+LIBNOU +define+nc=1 -q +assert +sv")], + nc_flags => [split(/\s+/,"+licqueue +nowarn+LIBNOU +define+nc=1 -q +assert +sv -c")], nc_flags2 => [], # Overridden in some sim files + ncrun_flags => [split(/\s+/,"+licqueue -q +assert +sv -R")], # Verilator 'v3' => 0, verilator_flags => [split(/\s+/,"-cc")], @@ -420,6 +425,13 @@ sub execute { return 1 if $self->errors; my %param = (%{$self}, @_); # Default arguments are from $self $self->oprint("Run\n"); + if ($param{nc}) { + $self->_run(logfile=>"obj_dir/".$self->{name}."__simnc.log", + fails=>$param{fails}, + cmd=>[($ENV{VERILATOR_NCVERILOG}||"ncverilog"), + @{$param{ncrun_flags}}, + ]); + } if ($param{vcs}) { #my $fh = IO::File->new(">simv.key") or die "%Error: $! simv.key,"; #$fh->print("quit\n"); $fh->close; @@ -482,6 +494,7 @@ sub _run { my %param = (tee=>1, @_); my $command = join(' ',@{$param{cmd}}); + $command = "time $command" if $opt_benchmark; print "\t$command"; print " > $param{logfile}" if $param{logfile}; print "\n"; @@ -917,6 +930,11 @@ driver.pl invokes Verilator or another simulator on each little test file. =over 4 +=item --benchmark [] + +Show execution times of each step. If an optional number is given, +specifies the number of simulation cycles (for tests that support it). + =item --gdb Run verilator under the debugger.