forked from github/verilator
Add --public-params flag (#3990)
This commit is contained in:
parent
ff889fde18
commit
13c9877099
@ -404,6 +404,7 @@ detailed descriptions of these arguments.
|
||||
--protect-key <key> Key for symbol protection
|
||||
--protect-lib <name> Create a DPI protected library
|
||||
--public Debugging; see docs
|
||||
--public-params Mark all parameters as public_flat
|
||||
--public-flat-rw Mark all variables, etc as public_flat_rw
|
||||
-pvalue+<name>=<value> Overwrite toplevel parameter
|
||||
--quiet-exit Don't print the command on failure
|
||||
|
@ -1101,6 +1101,12 @@ Summary:
|
||||
marking only those signals that need public_flat_rw is typically
|
||||
significantly better performing.
|
||||
|
||||
.. option:: --public-params
|
||||
|
||||
Declares all parameters public as if they had
|
||||
:code:`/*verilator public_flat_rd*/`
|
||||
metacomments.
|
||||
|
||||
.. option:: -pvalue+<name>=<value>
|
||||
|
||||
Overwrites the given parameter(s) of the top-level module. See
|
||||
|
@ -259,6 +259,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if (v3Global.opt.publicParams() && nodep->isParam()) nodep->sigUserRWPublic(true);
|
||||
|
||||
// We used modTrace before leveling, and we may now
|
||||
// want to turn it off now that we know the levelizations
|
||||
if (v3Global.opt.traceDepth() && m_modp
|
||||
|
@ -1385,7 +1385,10 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
m_publicFlatRW = flag;
|
||||
v3Global.dpi(true);
|
||||
});
|
||||
|
||||
DECL_OPTION("-public-params", CbOnOff, [this](bool flag) {
|
||||
m_public_params = flag;
|
||||
v3Global.dpi(true);
|
||||
});
|
||||
DECL_OPTION("-quiet-exit", OnOff, &m_quietExit);
|
||||
|
||||
DECL_OPTION("-relative-includes", OnOff, &m_relativeIncludes);
|
||||
|
@ -262,6 +262,7 @@ private:
|
||||
bool m_protectIds = false; // main switch: --protect-ids
|
||||
bool m_public = false; // main switch: --public
|
||||
bool m_publicFlatRW = false; // main switch: --public-flat-rw
|
||||
bool m_public_params = false; // main switch: --public-params
|
||||
bool m_quietExit = false; // main switch: --quiet-exit
|
||||
bool m_relativeIncludes = false; // main switch: --relative-includes
|
||||
bool m_reportUnoptflat = false; // main switch: --report-unoptflat
|
||||
@ -492,6 +493,7 @@ public:
|
||||
bool usesProfiler() const { return profExec() || profPgo(); }
|
||||
bool protectIds() const VL_MT_SAFE { return m_protectIds; }
|
||||
bool allPublic() const { return m_public; }
|
||||
bool publicParams() const { return m_public_params; }
|
||||
bool publicFlatRW() const { return m_publicFlatRW; }
|
||||
bool lintOnly() const VL_MT_SAFE { return m_lintOnly; }
|
||||
bool ignc() const { return m_ignc; }
|
||||
|
@ -21,9 +21,16 @@
|
||||
#include "verilated_vcd_c.h"
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "svdpi.h"
|
||||
|
||||
#ifdef T_VPI_PARAM
|
||||
#include "Vt_vpi_param.h"
|
||||
#include "Vt_vpi_param__Dpi.h"
|
||||
#include "svdpi.h"
|
||||
#elif defined(T_VPI_PUBLIC_PARAMS)
|
||||
#include "Vt_vpi_public_params.h"
|
||||
#else
|
||||
#error "Bad test"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
34
test_regress/t/t_vpi_public_params.pl
Executable file
34
test_regress/t/t_vpi_public_params.pl
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2010 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
# same vpi script should work with --public-params instead of inline publics
|
||||
pli_filename("t_vpi_param.cpp");
|
||||
|
||||
skip("Known compiler limitation")
|
||||
if $Self->cxx_version =~ /\(GCC\) 4.4/;
|
||||
|
||||
compile(
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
make_pli => 1,
|
||||
iv_flags2 => ["-g2005-sv -D USE_VPI_NOT_DPI"],
|
||||
v_flags2 => ["+define+USE_VPI_NOT_DPI"],
|
||||
verilator_flags2 => ["--exe --vpi --no-l2name $Self->{t_dir}/t_vpi_param.cpp --public-params "],
|
||||
);
|
||||
|
||||
execute(
|
||||
use_libvpi => 1,
|
||||
check_finished => 1
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
58
test_regress/t/t_vpi_public_params.v
Normal file
58
test_regress/t/t_vpi_public_params.v
Normal file
@ -0,0 +1,58 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// Copyright 2010 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
`ifdef USE_VPI_NOT_DPI
|
||||
//We call it via $c so we can verify DPI isn't required - see bug572
|
||||
`else
|
||||
import "DPI-C" context function int mon_check();
|
||||
`endif
|
||||
|
||||
// Copy of t_vpi_public_params.v but with the inline public taken out
|
||||
module t #(
|
||||
parameter int WIDTH = 32
|
||||
) (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
|
||||
`ifdef VERILATOR
|
||||
`systemc_header
|
||||
extern "C" int mon_check();
|
||||
`verilog
|
||||
`endif
|
||||
|
||||
input clk;
|
||||
|
||||
localparam int DEPTH = 16;
|
||||
localparam longint PARAM_LONG = 64'hFEDCBA9876543210;
|
||||
localparam string PARAM_STR = "'some string value'";
|
||||
|
||||
reg [WIDTH-1:0] mem0 [DEPTH:1];
|
||||
integer i, status;
|
||||
|
||||
// Test loop
|
||||
initial begin
|
||||
`ifdef VERILATOR
|
||||
status = $c32("mon_check()");
|
||||
`endif
|
||||
`ifdef IVERILOG
|
||||
status = $mon_check();
|
||||
`endif
|
||||
`ifndef USE_VPI_NOT_DPI
|
||||
status = mon_check();
|
||||
`endif
|
||||
|
||||
if (status!=0) begin
|
||||
$write("%%Error: t_vpi_param.cpp:%0d: C Test failed\n", status);
|
||||
$stop;
|
||||
end
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule : t
|
Loading…
Reference in New Issue
Block a user