Skip to content
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

Verilog Operator Docs #314

Merged
merged 5 commits into from Nov 8, 2018
Merged

Verilog Operator Docs #314

merged 5 commits into from Nov 8, 2018

Conversation

leonardt
Copy link
Collaborator

@leonardt leonardt commented Nov 3, 2018

These changes add a table to docs/operators.md which provides a reference for Verilog user. It lists all the operators detailed in the IEEE SystemVerilog specification and shows their verilog counterpart.

Naturally, magma's operators are not feature complete, so I've attempted to note with TODOs where we could add missing operators (or corresponding mantle functions for Python operators that we can't overload), and other operators which I don't think we should plan to support (e.g. dist for constraints which is a verification feature).

This is mainly a documentation change, but it would be good to get a review on the TODO items and discuss what our plans for that are. If we decide to add them, we can open a separate github issue to track and discuss design.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1214

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 71.955%

Totals Coverage Status
Change from base Build 1210: 0.0%
Covered Lines: 3474
Relevant Lines: 4828

💛 - Coveralls

1 similar comment
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1214

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 71.955%

Totals Coverage Status
Change from base Build 1210: 0.0%
Covered Lines: 3474
Relevant Lines: 4828

💛 - Coveralls

@phanrahan
Copy link
Owner

This looks good. I haven't had a chance to review all the TODOs. But here are some comments.

  • Might want to show the type hierarchy. That is, make it clear that all the operators for Bits apply to SInt and Uint, for example.

  • Array slicing with constants is allowed, but that corresponds to just bit selection.

  • Do we need to mention the conversion functions. And when if any type restrictions there are on operator. Magma is different than verilog here.

Copy link
Collaborator

@rsetaluri rsetaluri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Agree with Pat that type conversions would be good to include (somewhere, not nec. here).

Perhaps it would be good to have a note somewhere that we can use functions instead of operators wherever python's syntax doesn't allow overloading. And that is in fact a benefit of embedding in python. Just to verilog users understand that lack of certain operators is not a fundamental limitation.

| `=` | `m.wire`, **TODO (=)** | Any | All | Assignment cannot be overloaded for arbitrary Python variables, so in general we must use `m.wire`. There are plans to add support for assignment to attributes of magma types, such as `reg.I = io.I`. |
| `+=`, `-=`, `/=`, `*=` | `None` | None | All | Again, unsupported due to the lack of support for overloading assignment. May be added in the future for attributes of magma types |
| `%=` | `None` | None | All | See above |
| `&=`, `|=`, `^=` | `None` | None | All | See above |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting messed up here because of | being used as a table separator.

| Verilog Operator | Magma Operator | Types | Context | Comments |
|------------------|----------------| ----- | ------- | -------- |
| `!` | **TODO** | `m.Bit`, `m.Bits` | All | Logical operators like `not` cannot be overloaded in Python. Planned support for a mantle function `m.lnot` as an alternative |
| `~`, `&`, `~&`, `|`, `~|`, `^`, `~^`, `^~` | **TODO** | `m.Bits` | All | Python does not have built-in support for reduction operators. Use the python `reduce` function instead, e.g. `reduce(mantle.nand, value)`. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting, same as above.

| Verilog Operator | Magma Operator | Types | Context | Comments |
|------------------|----------------| ----- | ------- | -------- |
| `<<`, `>>` | `<<`, `>>` | `m.Bits` | All | **TODO: What does verilog expect for bit width of the shift value? What does magma expect?** |
| `&&`, `||` | **TODO** | `m.Bits` | All | Python doesn't support overloading logical and and or, we can provide mantle functions instead |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting, same as above

@leonardt leonardt merged commit b66bbbe into master Nov 8, 2018
@leonardt leonardt deleted the operator-docs branch November 8, 2018 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants