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
Preliminary support for if statements and ternary expressions #224
Conversation
Pull Request Test Coverage Report for Build 816
💛 - Coveralls |
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.
Cool! I actually think the syntax and covered cases are good as is. If its marked very clearly as an experimental feature then I think it's okay to merge as is. Also the what works vs what doesn't work you note in your comment should be provided somewhere in magma docs so users know what to expect.
A question: what is allowed in the test part of the if? From the code it didn't seem like you do any checks there.
Added some documentation in |
Cool! A couple of comments
|
Done |
Can you handle multiple assignments inside a block? |
It takes the last assignment, and prints out a warning saying that you've assigned multiple times within the same block (and that it's taking the last assignment). It's a simple change to make it an error if we want. |
This reverts commit 52ec960.
Add fully combinational syntax
Supports basic nesting. Includes tests that compile some
Mux
declarations to verilog.Things that aren't supported:
x
was assigned in the else block.These changes introduce a decorator
@m.circuit_def
, which is replaces@classmethod
by first doing a rewrite pass. This provides hooks for doing other syntactic rewrites.Right now it uses
=
syntax to bind the result of theMux
that is generated for the statements. We could explore binding directly as an alternative to wiring (or by using<=
syntax to bind to a port), but the existing mechanism required the least amount of changes (we bind a variable to a magma value, just like any other magma code, which is then wired up to a port).Thoughts/feedback? Should I continue to widen support for the varying cases mentioned above before we merge? Or should we get this in so people can start playing around with it.