-
Notifications
You must be signed in to change notification settings - Fork 298
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
[ImportVerilog] Add assign and pre/post increment/decrement expressions #6859
Conversation
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.
LGTM!
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.
LGTM, just some minor comments.
@@ -53,6 +53,13 @@ struct ExprVisitor { | |||
return {}; | |||
} | |||
|
|||
// Handle references to the left-hand side of a parent assignment. | |||
Value visit(const slang::ast::LValueReferenceExpression &expr) { |
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.
Do continuous assignments use a different system for lvalues or can they not be nested?
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.
They don't allow for the +=
syntax. +=
is always a blocking assignment within a procedural block.
Add support for pre and post increment and decrement expressions, like `x++` and `--x`, as well as assign expressions, like `a += 5`. Slang represents these assignments as `Assign(a, Add(LValueRef, 5))` in the AST. The `LValueRef` node contextually refers to the parent assignment's left-hand side. To deal with this, also add a corresponding lvalue stack to the conversion context. Assignments push and pop their lvalues onto and off of this stack. These expressions require a mechanism in the IR to express _when_ a variable is read. To capture this, add a new `moore.read_lvalue` op. It currently looks like an identity operation with a `MemRead` side effect. Further down the road, we may want to introduce a proper reference type for variables, ports, nets, and other things, and have `read_lvalue` and the various assigns operate on that type instead. This sets the foundation for that. Co-authored-by: Hailong Sun <hailong.sun@terapines.com> Co-authored-by: ShiZuoye <albertethon@163.com> Co-authored-by: hunterzju <hunter_ht@zju.edu.cn> Co-authored-by: Anqi Yu <anqi.yu@terapines.com>
d0d0389
to
d05d3c9
Compare
Add support for pre and post increment and decrement expressions, like
x++
and--x
, as well as assign expressions, likea += 5
. Slang represents these assignments asAssign(a, Add(LValueRef, 5))
in the AST. TheLValueRef
node contextually refers to the parent assignment's left-hand side. To deal with this, also add a corresponding lvalue stack to the conversion context. Assignments push and pop their lvalues onto and off of this stack.These expressions require a mechanism in the IR to express when a variable is read. To capture this, add a new
moore.read_lvalue
op. It currently looks like an identity operation with aMemRead
side effect. Further down the road, we may want to introduce a proper reference type for variables, ports, nets, and other things, and haveread_lvalue
and the various assigns operate on that type instead. This sets the foundation for that.