-
Notifications
You must be signed in to change notification settings - Fork 650
Update width-inference.md #3809
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,22 +16,22 @@ The width of a conditionally valid expression is the width of its input expressi | |
|
|
||
| Hardware operators have output widths as defined by the following set of rules: | ||
|
|
||
| | operation | bit width | | ||
| | --------- | --------- | | ||
| | `z = x + y` *or* `z = x +% y` | `w(z) = max(w(x), w(y))` | | ||
| | `z = x +& y` | `w(z) = max(w(x), w(y)) + 1` | | ||
| | `z = x - y` *or* `z = x -% y` | `w(z) = max(w(x), w(y))` | | ||
| | `z = x -& y` | `w(z) = max(w(x), w(y)) + 1` | | ||
| | `z = x & y` | `w(z) = max(w(x), w(y))` | | ||
| | `z = Mux(c, x, y)` | `w(z) = max(w(x), w(y))` | | ||
| | `z = w * y` | `w(z) = w(x) + w(y)` | | ||
| | `z = x << n` | `w(z) = w(x) + maxNum(n)` | | ||
| | `z = x >> n` | `w(z) = w(x) - minNum(n)` | | ||
| | `z = Cat(x, y)` | `w(z) = w(x) + w(y)` | | ||
| | `z = Fill(n, x)` | `w(z) = w(x) * maxNum(n)` | | ||
|
|
||
| >where for instance `w(z)` is the bit width of wire `z`, and the `&` | ||
| rule applies to all bitwise logical operations. | ||
| | operation | bit width | | ||
| | --------- | --------- | | ||
| | `z = x + y` *or* `z = x +% y` | `w(z) = max(w(x), w(y))` | | ||
| | `z = x +& y` | `w(z) = max(w(x), w(y)) + 1` | | ||
| | `z = x - y` *or* `z = x -% y` | `w(z) = max(w(x), w(y))` | | ||
| | `z = x -& y` | `w(z) = max(w(x), w(y)) + 1` | | ||
| | `z = x & y` | `w(z) = max(w(x), w(y))` | | ||
| | `z = Mux(c, x, y)` | `w(z) = max(w(x), w(y))` | | ||
| | `z = w * y` | `w(z) = w(x) + w(y)` | | ||
| | `z = x << n` | `w(z) = w(x) + maxNum(n)` | | ||
| | `z = x >> n` | `w(z) = w(x) - minNum(n)` | | ||
| | `z = Cat(x, y)` | `w(z) = w(x) + w(y)` | | ||
| | `z = Fill(n, x)` | `w(z) = w(x) * n` | | ||
|
|
||
| >where for instance `w(z)` is the bit width of wire `z`, `maxNum(n)` is the maximum number representable | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we define
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is there a way to check this? Cause I think when using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per @dtzSiFive comment I think we should use a different thing for the last number in Fill, as there it's an Int n not a UInt-that-has-a-width n |
||
| >by `n`, and the `&` rule applies to all bitwise logical operations. | ||
|
|
||
| Given a path of connections that begins with an unspecified width element (most commonly a top-level input), then the compiler will throw an exception indicating a certain width was uninferrable. | ||
|
|
||
|
|
||
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.
PDF link above for firrtl spec is a 404, just noting since noticed 👍 .