From 1f0c1d47a9d675c8ae40bbb6df3ae8114bb4a091 Mon Sep 17 00:00:00 2001 From: Christian Hecken Date: Wed, 12 Nov 2025 02:38:11 +0100 Subject: [PATCH] Internals: Add isForceable() to VerilatedVarProps Allows runtime checking whether a signal is forceable without needing to check the existence of the `__VforceEn` and `__VforceVal` signals. This will be useful for a later implementation of `vpiForceFlag` for `vpi_put_value`. --- include/verilated.h | 3 ++- include/verilated_sym_props.h | 1 + src/V3AstNodes.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/verilated.h b/include/verilated.h index 02c022176..acfab9cb0 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -154,7 +154,8 @@ enum VerilatedVarFlags { // Flags VLVF_PUB_RD = (1 << 8), // Public readable VLVF_PUB_RW = (1 << 9), // Public writable - VLVF_DPI_CLAY = (1 << 10) // DPI compatible C standard layout + VLVF_DPI_CLAY = (1 << 10), // DPI compatible C standard layout + VLVF_FORCEABLE = (1 << 11) // Forceable }; // IEEE 1800-2023 Table 20-6 diff --git a/include/verilated_sym_props.h b/include/verilated_sym_props.h index 53600e7a1..65988fccb 100644 --- a/include/verilated_sym_props.h +++ b/include/verilated_sym_props.h @@ -156,6 +156,7 @@ public: return bits; } bool isPublicRW() const { return ((m_vlflags & VLVF_PUB_RW) != 0); } + bool isForceable() const { return ((m_vlflags & VLVF_FORCEABLE) != 0); } // DPI compatible C standard layout bool isDpiCLayout() const { return ((m_vlflags & VLVF_DPI_CLAY) != 0); } int udims() const VL_MT_SAFE { return m_unpacked.size(); } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 6a5295ad1..58b30787d 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -630,6 +630,9 @@ string AstVar::vlEnumDir() const { } else if (isSigUserRdPublic()) { out += "|VLVF_PUB_RD"; } + if (isForceable()) { + out += "|VLVF_FORCEABLE"; + } // if (const AstBasicDType* const bdtypep = basicp()) { if (bdtypep->keyword().isDpiCLayout()) out += "|VLVF_DPI_CLAY";