Add --threads option through to makefiles, unadvertised for now.

This commit is contained in:
Wilson Snyder 2017-10-21 16:41:43 -04:00
parent eb65984368
commit b90f383cfe
11 changed files with 107 additions and 4 deletions

View File

@ -190,6 +190,7 @@ AC_SUBST(CFG_CXXFLAGS_STD_OLDEST)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wextra)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wfloat-conversion)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wlogical-op)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wthread-safety)
AC_SUBST(CFG_CXXFLAGS_WEXTRA)
# Flags for compiling Verilator internals including parser always

View File

@ -109,6 +109,14 @@ ifeq ($(VM_SC),1)
endif
endif
#######################################################################
##### Threaded builds
ifneq ($(VM_THREADS),0)
# Need C++11 at least, so always default to newest
CPPFLAGS += -DVM_THREADED $(CFG_CXXFLAGS_STD_NEWEST)
endif
#######################################################################
##### Stub

View File

@ -62,6 +62,8 @@ public:
of.puts("\n### Switches...\n");
of.puts("# Coverage output mode? 0/1 (from --coverage)\n");
of.puts("VM_COVERAGE = "); of.puts(v3Global.opt.coverage()?"1":"0"); of.puts("\n");
of.puts("# Threaded output mode? 0/1/N threads (from --threads)\n");
of.puts("VM_THREADS = "); of.puts(cvtToStr(v3Global.opt.threads())); of.puts("\n");
of.puts("# Tracing output mode? 0/1 (from --trace)\n");
of.puts("VM_TRACE = "); of.puts(v3Global.opt.trace()?"1":"0"); of.puts("\n");

View File

@ -984,6 +984,11 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
shift; m_prefix = argv[i];
if (m_modPrefix=="") m_modPrefix = m_prefix;
}
else if ( !strcmp (sw, "-no-threads") ) { m_threads = 0; } // Undocumented until functional
else if ( !strcmp (sw, "-threads") && (i+1)<argc ) { // Undocumented until functional
shift; m_threads = atoi(argv[i]);
if (m_threads < 0) fl->v3fatal("--threads must be >= 0: "<<argv[i]);
}
else if ( !strcmp (sw, "-top-module") && (i+1)<argc ) {
shift; m_topModule = argv[i];
}
@ -1218,6 +1223,7 @@ V3Options::V3Options() {
m_stats = false;
m_statsVars = false;
m_systemC = false;
m_threads = 0;
m_trace = false;
m_traceDups = false;
m_traceParams = true;

View File

@ -113,6 +113,7 @@ class V3Options {
int m_outputSplitCFuncs;// main switch: --output-split-cfuncs
int m_outputSplitCTrace;// main switch: --output-split-ctrace
int m_pinsBv; // main switch: --pins-bv
int m_threads; // main switch: --threads (0 == --no-threads)
int m_traceDepth; // main switch: --trace-depth
int m_traceMaxArray;// main switch: --trace-max-array
int m_traceMaxWidth;// main switch: --trace-max-width
@ -258,6 +259,7 @@ class V3Options {
int outputSplitCFuncs() const { return m_outputSplitCFuncs; }
int outputSplitCTrace() const { return m_outputSplitCTrace; }
int pinsBv() const { return m_pinsBv; }
int threads() const { return m_threads; }
int traceDepth() const { return m_traceDepth; }
int traceMaxArray() const { return m_traceMaxArray; }
int traceMaxWidth() const { return m_traceMaxWidth; }

View File

@ -40,8 +40,6 @@ ifeq ($(CFG_WITH_LONGTESTS),yes)
CPPFLAGS += $(CFG_CXXFLAGS_STD_NEWEST)
else ifeq ($(DRIVER_STD),oldest)
CPPFLAGS += $(CFG_CXXFLAGS_STD_OLDEST)
else ifneq ($(findstring VL_THREADED,$(CPPFLAGS)),)
CPPFLAGS += $(CFG_CXXFLAGS_STD_NEWEST)
endif
endif

View File

@ -13,8 +13,7 @@ my $root = "..";
compile (
# Can't use --coverage and --savable together, so cheat and compile inline
verilator_flags2 => ['--cc --coverage-toggle --coverage-line --coverage-user --trace --vpi $root/include/verilated_save.cpp'],
make_flags => 'DRIVER_STD=newest CPPFLAGS_ADD=-DVL_THREADED=1',
verilator_flags2 => ['--cc --coverage-toggle --coverage-line --coverage-user --trace --threads 1 --vpi $root/include/verilated_save.cpp'],
);
execute (

View File

@ -0,0 +1,24 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2017 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc;
always @ (posedge clk) begin
cyc <= cyc + 1;
if (cyc!=0) begin
if (cyc==10) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
end
endmodule

View File

@ -0,0 +1,21 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003-2009 by Wilson Snyder. This program 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.
top_filename("t/t_threads_counter.v");
compile (
verilator_flags2 => ['--cc --no-threads'],
);
execute (
check_finished=>1,
);
ok(1);
1;

View File

@ -0,0 +1,21 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003-2009 by Wilson Snyder. This program 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.
top_filename("t/t_threads_counter.v");
compile (
verilator_flags2 => ['--cc --threads 1'],
);
execute (
check_finished=>1,
);
ok(1);
1;

View File

@ -0,0 +1,21 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003-2009 by Wilson Snyder. This program 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.
top_filename("t/t_threads_counter.v");
compile (
verilator_flags2 => ['--cc --threads 2'],
);
execute (
check_finished=>1,
);
ok(1);
1;