Verilog: bind directive - #2124
Open
kroening wants to merge 2 commits into
Open
Conversation
This adds support for the SystemVerilog bind directive, per 1800-2017 section 23.11. The directive specifies an instantiation of a module without modifying the source of the target module, which is used, e.g., to attach assertions to a design in a non-intrusive manner. The bind directives are collected from the parse trees and stored in the symbol table; they are applied when a design element instance is elaborated, by adding the instantiation given in the directive to the instance's copy of the module source, as if it was written there. Both target forms are supported: a module target applies to every instance of the target module, while an instance target applies to one particular instance without affecting other instances of the same module. Directives that bind a module to itself are rejected, and modules instantiated only through bind directives are found when scanning library directories. Fixes: diffblue#2102
kroening
force-pushed
the
kroening/bind-directive
branch
from
September 6, 2026 01:04
c24d40c to
5514f7b
Compare
Bind directives are now handled during module elaboration, instead of being collected from the parse trees up front. Directives at the compilation-unit level are registered when the compilation unit is elaborated; directives that are module items are registered when the enclosing design element instance is elaborated, which means that a directive inside a generate construct only takes effect if its generate branch is taken. Previously, such directives failed an invariant. A directive that targets the design element instance currently being elaborated is applied in place. Directives whose target has already been elaborated are rejected with an error, since the target's item list is fixed at that point.
tautschnig
approved these changes
Sep 6, 2026
Comment on lines
+31
to
+34
| id2string(binary.op1().get(ID_base_name)); | ||
| } | ||
| else | ||
| return id2string(target.get(ID_base_name)); |
Collaborator
There was a problem hiding this comment.
In both of these uses of .get(ID_base_name): how do we know that this irept entry exists (for what seemingly could be an arbitrary irept?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for the SystemVerilog
binddirective, per 1800-2017 section 23.11. The directive specifies an instantiation of a module without modifying the source of the target module, which is used, e.g., to attach assertions or other instrumentation to a design in a non-intrusive manner.Changes
bind_directive(1800-2017 A.1.4) is now parsed, both at the top level and as a module item, producing a newverilog_bind_directiveparse-tree node.bind mod ...) applies to every instance of the module, and an instance target (bind top.sub ...) applies to that one instance only. A directive that targets the design element instance currently being elaborated is applied in place.-y).Testing
regression/verilog/bind/: top-level bind (refuted bound assertion), bind as module item with a parameter assignment (proved), binds inside taken/untaken generate branches, an in-place bind targeting the enclosing module from a generate branch, an instance-target bind that verifies the sibling instance is unaffected, and error tests for unknown module targets, unknown instance targets, self-binds, and too-late binds.regression/verilog,regression/ebmc,regression/vlindexsuites and the unit tests pass.Fixes #2102