-
Notifications
You must be signed in to change notification settings - Fork 3
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
[WIP] Virtual interfaces support #17
Conversation
e8f1262
to
66fc6ca
Compare
c966e00
to
a4218ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good, I don't know enough about Verilator's scopes to suggest anything better. Just the one comment, also look through the source and constify all pointers that don't change.
src/V3Scope.cpp
Outdated
AstVarScope* const varscp = new AstVarScope{nodep->fileline(), scopep, nodep}; | ||
if (m_aboveCellp && m_aboveCellp->isVirtIface()) { | ||
// Prevent optimizations to this variable: may be cross-accessed | ||
nodep->sigPublic(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unavoidable? Which optimization is this needed for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be avoided if we added special handling for scope overlaps with virtual interfaces in V3Dead and V3Const.
Without this deoptimization the provided regression test (v8 = p8; v8.grant = 1; $display(v8.grant, p8.grant)
) shows the incorrect value for the actual interface (the value access to the virtual interface gets constified, and the assignment gets eliminated). The variables are reported as unused, because each variable is in a different scope.
7006b5f
to
624682c
Compare
624682c
to
faa21cb
Compare
This is more of a call for comments for now, aiming to discuss the difficulties and design of virtual interfaces support, with a proof-of-concept patchset to talk about.
A virtual interface is emitted to C++ as a variable holding a pointer to an interface scope (initialized to a null pointer), which is the most straightforward thing I came up with.
The main concern is the duality of scopes and variables in Verilator. In this patchset I decided that in the easiest case this can be worked out with minimal alteration, by simply using variables where variables are normally used (e.g.
viface = iface
assignments), and scopes where scopes are normally used (e.g.iface.signal
orviface.signal
), as opposed to MemberSel, to name one.This comes with several drawbacks:
vlSymsp->TOP_unique_absolute_path_to_interface
vssome_scope.some_var.path.to.viface_field
):