Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from verilator:master #633

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fa1b112
Fix duplicate-named class variable equivalence (#5737).
wsnyder Jan 18, 2025
4954e76
Commentary: Changes update
wsnyder Jan 18, 2025
f4a01eb
Fix inlined expression with assignment under LHS of NBA (#5736) (#5740)
gezalore Jan 20, 2025
0507fb4
Improve hierarchical DPI wrapper scheduling performance (#2583) (#5734)
b-chmiel Jan 20, 2025
35fa0d0
Support integer atom type ports in `--hierarchical` (#5748)
b-chmiel Jan 24, 2025
bed9aa9
Internals: Cleanup std::string empty string constructors.
wsnyder Jan 22, 2025
d808000
Commentary
wsnyder Jan 22, 2025
d4f4fef
Fix `-j` ignored after `-f` (#5749).
wsnyder Jan 24, 2025
432d5f8
Internals: Cleanup some misnamed nodep's. No functional change.
wsnyder Jan 25, 2025
929e15f
Fix various round-trip Verilog output, including packed arrays
wsnyder Jan 25, 2025
7e6dd94
Commentary: Changes update
wsnyder Jan 25, 2025
6281385
Commentary/Internals: Sort option names. No functional change.
wsnyder Jan 25, 2025
694f2ff
Tests: renames
wsnyder Jan 25, 2025
05c7a3b
Optimize labels as final `if` block statements (#5744).
wsnyder Jan 25, 2025
98e40c8
Internals: Suppress vlSelf unused suppression when known used. No fun…
wsnyder Jan 25, 2025
001c098
Optimize empty function definition bodies (#5750).
wsnyder Jan 25, 2025
41bb54b
Add Makefile targets count to stats
wsnyder Jan 25, 2025
70c6651
Fix -Wno-subobject-linkage on GCC (#5754)
wsnyder Jan 25, 2025
bdcfc4e
Reduce verbosity under `--debug` default level
wsnyder Jan 25, 2025
61bfb6c
Remove `list`/`map` from keyword warnings.
wsnyder Jan 25, 2025
e2a6e19
Cleanup V3EmitMk report style
wsnyder Jan 25, 2025
a379382
Fix handling forced assigns in V3Life (#5757)
b-chmiel Jan 28, 2025
e0e164c
Internals: Optimize clearFired (#5753)
wsnyder Jan 30, 2025
6b41836
Support Unpacked Structures' Constrained Randomization (#5657) (#5759)
YilouWang Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ Verilator 5.033 devel
* Support generated classes (#5665). [Shou-Li Hsu]
* Support constraints on associative array user-defined keys (#5671) (#5729). [Yilou Wang]
* Support `+incdir` with multiple directories.
* Support integer atom type ports in `--hierarchical` (#5748). [Bartłomiej Chmiel, Antmicro Ltd.]
* Support side effects of form 'variable[index_function()]++'.
* Improve hierarchical DPI wrapper scheduling performance (#2583) (#5734). [Bartłomiej Chmiel, Antmicro Ltd.]
* Improve VPI write errors (#5712). [Andrew Nolte]
* Improve `resetall support (#5728) (#5730). [Ethan Sifferman]
* Optimize labels as final `if` block statements (#5744).
* Optimize empty function definition bodies (#5750).
* Fix error message when call task as a function (#3089). [Matthew Ballance]
* Fix VPI iteration over hierarchy (#5314) (#5731). [Natan Kreimer]
* Fix constrained random for > 64-bit associative arrays (#5670) (#5682). [Yilou Wang]
* Fix mis-optimizing away `$urandom` (#5703). [Parker Schless]
* Fix packages with `--public-depth 1` (#5708). [Andrew Nolte]
Expand All @@ -32,6 +38,10 @@ Verilator 5.033 devel
* Fix %p format output for real inside struct (#5713).
* Fix segfault when only enum value referenced in package (#5714). [Dan Katz]
* Fix `BLKSEQ` on suspendable processes (#5722). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix vpiDefName issues with non-inlined scopes and dpi conflicts (#5732). [Andrew Nolte]
* Fix inlined expression with assignment under LHS of NBA (#5736) (#5740). [Geza Lore]
* Fix duplicate-named class variable equivalence (#5737).
* Fix `-j` ignored after `-f` (#5749). [Luca Colagrande]
* Fix matching language extension options including dots.


Expand Down
12 changes: 6 additions & 6 deletions bin/verilator
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ detailed descriptions of these arguments.
--gdb Run Verilator under GDB interactively
--gdbbt Run Verilator under GDB for backtrace
--generate-key Create random key for --protect-key
--getenv <var> Get environment variable with defaults
--get-supported <feature> Get if feature is supported
--getenv <var> Get environment variable with defaults
--help Show this help
--hierarchical Enable hierarchical Verilation
--hierarchical-params-file <name> Internal option that specifies parameters file for hier blocks
Expand All @@ -385,6 +385,11 @@ detailed descriptions of these arguments.
--inline-mult <value> Tune module inlining
--instr-count-dpi <value> Assumed dynamic instruction count of DPI imports
-j <jobs> Parallelism for --build-jobs/--verilate-jobs
--no-json-edit-nums Don't dump editNum in .tree.json files
--no-json-ids Don't use short identifiers instead of adresses/paths in .tree.json
--json-only Create JSON parser output (.tree.json and .meta.json)
--json-only-output .tree.json output filename
--json-only-meta-output .tree.meta.json output filename
--l2-name <value> Verilog scope name of the top module
--language <lang> Default language standard to parse
-LDFLAGS <flags> Linker pre-object arguments for makefile
Expand Down Expand Up @@ -506,11 +511,6 @@ detailed descriptions of these arguments.
--x-assign <mode> Assign non-initial Xs to this value
--x-initial <mode> Assign initial Xs to this value
--x-initial-edge Enable initial X->0 and X->1 edge triggers
--no-json-edit-nums Don't dump editNum in .tree.json files
--no-json-ids Don't use short identifiers instead of adresses/paths in .tree.json
--json-only Create JSON parser output (.tree.json and .meta.json)
--json-only-output .tree.json output filename
--json-only-meta-output .tree.meta.json output filename
--xml-only Create XML parser output
--xml-output XML output filename
-y <dir> Directory to search for modules
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ m4_foreach([cflag],[
[-Wno-parentheses-equality],
[-Wno-shadow],
[-Wno-sign-compare],
[-Wno-subobject-linkage],
[-Wno-tautological-bitwise-compare],
[-Wno-tautological-compare],
[-Wno-uninitialized],
Expand Down Expand Up @@ -538,7 +539,7 @@ _MY_LDLIBS_CHECK_IFELSE(
[if test "$CFG_WITH_TCMALLOC" != "no"; then
CFG_LIBS="$LTCMALLOC $CFG_LIBS";
# If using tcmalloc, add some extra options to make the compiler not assume
# it is using it's own versions of the standard library functions
# it is using its own versions of the standard library functions
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-malloc)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-calloc)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-realloc)
Expand Down
71 changes: 39 additions & 32 deletions docs/guide/exe_verilator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,38 @@ Summary:
the number of threads in the current hardware. Otherwise, must be a
positive integer specifying the maximum number of parallel build jobs.

.. option:: --json-only

Create JSON output only, do not create any other output.

The JSON format is intended to be used to leverage Verilator's parser and
elaboration to feed to other downstream tools. For details on the format, see
the Verilator Internals manual. Be aware that the JSON
format is still evolving; there will be some changes in future versions.

This option disables some more aggressive transformations and dumps only
the final state of the AST. For more granular and unaltered dumps, meant
mainly for debugging see :vlopt:`--dump-tree-json`.

.. option:: --json-only-meta-output <filename>

Specifies the filename for the metadata output file (`.tree.meta.json`) of --json-only.
Using this option automatically sets :vlopt:`--json-only`.

.. option:: --json-only-output <filename>

Specifies the filename for the main output file (`.tree.json`) of --json-only.
Using this option automatically sets :vlopt:`--json-only`.

.. option:: --no-json-edit-nums

Don't dump edit number in .tree.json files. This may make the file more
run-to-run stable for easier comparison.

.. option:: --no-json-ids

Don't use short identifiers instead of addresses/paths in .tree.json.

.. option:: --l2-name <value>

Instead of using the module name when showing Verilog scope, use the
Expand Down Expand Up @@ -1893,38 +1925,6 @@ Summary:
iterations. This may be another indication of problems with the
modeled design that should be addressed.

.. option:: --json-only

Create JSON output only, do not create any other output.

The JSON format is intended to be used to leverage Verilator's parser and
elaboration to feed to other downstream tools. For details on the format, see
the Verilator Internals manual. Be aware that the JSON
format is still evolving; there will be some changes in future versions.

This option disables some more aggressive transformations and dumps only
the final state of the AST. For more granular and unaltered dumps, meant
mainly for debugging see :vlopt:`--dump-tree-json`.

.. option:: --json-only-meta-output <filename>

Specifies the filename for the metadata output file (`.tree.meta.json`) of --json-only.
Using this option automatically sets :vlopt:`--json-only`.

.. option:: --json-only-output <filename>

Specifies the filename for the main output file (`.tree.json`) of --json-only.
Using this option automatically sets :vlopt:`--json-only`.

.. option:: --no-json-edit-nums

Don't dump edit number in .tree.json files. This may make the file more
run-to-run stable for easier comparison.

.. option:: --no-json-ids

Don't use short identifiers instead of addresses/paths in .tree.json.

.. option:: --xml-only

Create XML output only, do not create any other output.
Expand Down Expand Up @@ -2154,6 +2154,13 @@ The grammar of configuration commands is as follows:
:option:`/*verilator&32;public_flat*/`, etc., metacomments. See
also :ref:`VPI Example`.

.. option:: profile_data -hier-dpi "<function_name>" -cost <cost_value>

Internal profiling data inserted during :vlopt:`--hierarchical`; specifies
execution cost of a hierarchical DPI wrappers for modules with
:option:`/*verilator&32;hier_block*/` metacomment. See
:ref:`Hierarchical Verilation`.

.. option:: profile_data -mtask "<mtask_hash>" -cost <cost_value>

Feeds profile-guided optimization data into the Verilator algorithms in
Expand Down
3 changes: 3 additions & 0 deletions include/verilated.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ enum class VerilatedAssertDirectiveType : uint8_t {
using VerilatedAssertType_t = std::underlying_type<VerilatedAssertType>::type;
using VerilatedAssertDirectiveType_t = std::underlying_type<VerilatedAssertDirectiveType>::type;

// Type trait for custom struct
template <typename>
struct VlIsCustomStruct : public std::false_type {};
//=============================================================================
// Utility functions

Expand Down
2 changes: 1 addition & 1 deletion include/verilated_random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void VlRandomizer::clear() { m_constraints.clear(); }
#ifdef VL_DEBUG
void VlRandomizer::dump() const {
for (const auto& var : m_vars) {
VL_PRINTF("Variable (%d): %s\n", var.second->width(), var.second->name());
VL_PRINTF("Variable (%d): %s\n", var.second->width(), var.second->name().c_str());
}
for (const std::string& c : m_constraints) VL_PRINTF("Constraint: %s\n", c.c_str());
}
Expand Down
35 changes: 27 additions & 8 deletions include/verilated_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ class ArrayInfo final {
using ArrayInfoMap = std::map<std::string, std::shared_ptr<const ArrayInfo>>;

class VlRandomVar VL_NOT_FINAL {
const char* const m_name; // Variable name
std::string m_name; // Variable name
void* const m_datap; // Reference to variable data
const int m_width; // Variable width in bits
const int m_dimension; //Variable dimension, default is 0
const std::uint32_t m_randModeIdx; // rand_mode index

public:
VlRandomVar(const char* name, int width, void* datap, int dimension, std::uint32_t randModeIdx)
VlRandomVar(const std::string& name, int width, void* datap, int dimension,
std::uint32_t randModeIdx)
: m_name{name}
, m_datap{datap}
, m_width{width}
, m_dimension{dimension}
, m_randModeIdx{randModeIdx} {}
virtual ~VlRandomVar() = default;
const char* name() const { return m_name; }
std::string name() const { return m_name; }
int width() const { return m_width; }
int dimension() const { return m_dimension; }
virtual void* datap(int idx) const { return m_datap; }
Expand Down Expand Up @@ -99,7 +100,7 @@ class VlRandomVar VL_NOT_FINAL {
template <typename T>
class VlRandomArrayVarTemplate final : public VlRandomVar {
public:
VlRandomArrayVarTemplate(const char* name, int width, void* datap, int dimension,
VlRandomArrayVarTemplate(const std::string& name, int width, void* datap, int dimension,
std::uint32_t randModeIdx)
: VlRandomVar{name, width, datap, dimension, randModeIdx} {}
void* datap(int idx) const override {
Expand Down Expand Up @@ -300,8 +301,9 @@ class VlRandomizer final {
}

template <typename T>
void write_var(T& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
typename std::enable_if<!VlIsCustomStruct<T>::value, void>::type
write_var(T& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
if (m_vars.find(name) != m_vars.end()) return;
// TODO: make_unique once VlRandomizer is per-instance not per-ref
m_vars[name]
Expand Down Expand Up @@ -341,6 +343,22 @@ class VlRandomizer final {
record_arr_table(var, name, dimension, {}, {});
}
}
template <typename T, std::size_t... I>
void modifyMembers(T& obj, std::index_sequence<I...>, std::string baseName) {
// Use the indices to access each member via std::get
(void)std::initializer_list<int>{
(write_var(std::get<I>(obj.getMembers(obj)),
sizeof(std::get<I>(obj.getMembers(obj))) * 8,
(baseName + "." + obj.memberNames()[I]).c_str(), 0),
0)...};
}

template <typename T>
typename std::enable_if<VlIsCustomStruct<T>::value, void>::type
write_var(T& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
modifyMembers(var, var.memberIndices(), name);
}

int idx;
std::string generateKey(const std::string& name, int idx) {
Expand All @@ -355,8 +373,9 @@ class VlRandomizer final {
}

template <typename T>
void record_arr_table(T& var, const std::string name, int dimension,
std::vector<IData> indices, std::vector<size_t> idxWidths) {
typename std::enable_if<!std::is_class<T>::value, void>::type
record_arr_table(T& var, const std::string name, int dimension, std::vector<IData> indices,
std::vector<size_t> idxWidths) {
const std::string key = generateKey(name, idx);
m_arr_vars[key] = std::make_shared<ArrayInfo>(name, &var, idx, indices, idxWidths);
++idx;
Expand Down
6 changes: 4 additions & 2 deletions src/V3AstInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,17 @@ bool AstVarRef::sameNode(const AstVarRef* samep) const {
if (varScopep()) {
return (varScopep() == samep->varScopep() && access() == samep->access());
} else {
return (selfPointer() == samep->selfPointer() && varp()->name() == samep->varp()->name()
&& access() == samep->access());
return (selfPointer() == samep->selfPointer()
&& classOrPackagep() == samep->classOrPackagep()
&& varp()->name() == samep->varp()->name() && access() == samep->access());
}
}
bool AstVarRef::sameNoLvalue(AstVarRef* samep) const {
if (varScopep()) {
return (varScopep() == samep->varScopep());
} else {
return (selfPointer() == samep->selfPointer()
&& classOrPackagep() == samep->classOrPackagep()
&& (!selfPointer().isEmpty() || !samep->selfPointer().isEmpty())
&& varp()->name() == samep->varp()->name());
}
Expand Down
17 changes: 14 additions & 3 deletions src/V3AstNodeDType.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class AstNodeUOrStructDType VL_NOT_FINAL : public AstNodeDType {
const int m_uniqueNum;
bool m_packed;
bool m_isFourstate = false; // V3Width computes
bool m_constrainedRand = false; // True if struct has constraint expression

protected:
AstNodeUOrStructDType(VNType t, FileLine* fl, VSigning numericUnpack)
Expand All @@ -244,7 +245,8 @@ class AstNodeUOrStructDType VL_NOT_FINAL : public AstNodeDType {
, m_name(other.m_name)
, m_uniqueNum(uniqueNumInc())
, m_packed(other.m_packed)
, m_isFourstate(other.m_isFourstate) {}
, m_isFourstate(other.m_isFourstate)
, m_constrainedRand(false) {}

public:
ASTGEN_MEMBERS_AstNodeUOrStructDType;
Expand Down Expand Up @@ -284,6 +286,8 @@ class AstNodeUOrStructDType VL_NOT_FINAL : public AstNodeDType {
VNumRange declRange() const VL_MT_STABLE { return VNumRange{hi(), lo()}; }
AstNodeModule* classOrPackagep() const { return m_classOrPackagep; }
void classOrPackagep(AstNodeModule* classpackagep) { m_classOrPackagep = classpackagep; }
bool isConstrainedRand() { return m_constrainedRand; }
void markConstrainedRand(bool flag) { m_constrainedRand = flag; }
};

// === Concrete node types =====================================================
Expand Down Expand Up @@ -905,26 +909,31 @@ class AstMemberDType final : public AstNodeDType {
string m_name; // Name of variable
string m_tag; // Holds the string of the verilator tag -- used in XML output.
int m_lsb = -1; // Within this level's packed struct, the LSB of the first bit of the member
bool m_constrainedRand = false;
// UNSUP: int m_randType; // Randomization type (IEEE)
public:
AstMemberDType(FileLine* fl, const string& name, VFlagChildDType, AstNodeDType* dtp,
AstNode* valuep)
: ASTGEN_SUPER_MemberDType(fl)
, m_name{name} {
, m_name{name}
, m_constrainedRand(false) {
childDTypep(dtp); // Only for parser
this->valuep(valuep);
dtypep(nullptr); // V3Width will resolve
refDTypep(nullptr);
}
AstMemberDType(FileLine* fl, const string& name, AstNodeDType* dtp)
: ASTGEN_SUPER_MemberDType(fl)
, m_name{name} {
, m_name{name}
, m_constrainedRand(false) {
UASSERT(dtp, "AstMember created with no dtype");
refDTypep(dtp);
dtypep(this);
widthFromSub(subDTypep());
}
ASTGEN_MEMBERS_AstMemberDType;
void dump(std::ostream& str = std::cout) const override;
void dumpJson(std::ostream& str = std::cout) const override;
void dumpSmall(std::ostream& str) const override;
string name() const override VL_MT_STABLE { return m_name; } // * = Var name
bool hasDType() const override VL_MT_SAFE { return true; }
Expand Down Expand Up @@ -958,6 +967,8 @@ class AstMemberDType final : public AstNodeDType {
v3fatalSrc("call isCompound on subdata type, not reference");
return false;
}
bool isConstrainedRand() const { return m_constrainedRand; }
void markConstrainedRand(bool flag) { m_constrainedRand = flag; }
};
class AstNBACommitQueueDType final : public AstNodeDType {
// @astgen ptr := m_subDTypep : AstNodeDType // Type of the corresponding variable
Expand Down
2 changes: 1 addition & 1 deletion src/V3AstNodeExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4151,7 +4151,7 @@ class AstArraySel final : public AstNodeSel {
return new AstArraySel{fileline(), lhsp, rhsp};
}
void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override {
V3ERROR_NA; /* How can from be a const? */
V3ERROR_NA; // How can from be a const?
}
string emitVerilog() override { return "%k(%l%f[%r])"; }
string emitC() override { return "%li%k[%ri]"; }
Expand Down
Loading
Loading