Operations returns an OpBinding value regardless of whether all operand is literal or not
See original GitHub issueType of issue: feature request
Impact: unknown
Development Phase: request
If the current behavior is a bug, please provide the steps to reproduce the problem:
What is the current behavior?
For now, operations always return OpBinding value regardless of whether all operands are literal or not.
Probably, this behavior sometimes causes inconvenient.
For example, is
in switch
statement only accepts literal, and this is why the following is illegal.
switch(x) {
is(Cat(1.U(2.W), 0.U(2.W))) { ... }
...
}
However, in C, this is legal(e.g. case 1 + 2: …), so users that expect switch behavior like C probably confuse by this illegalness.
What is the expected behavior? I think it is better that an operation of literals returns an ElementLitBinding value insted of OpBinding one. If the solution already exists, please teach me.
Please tell us about your environment:
- chiselVersion:
3.1.+ (chisel-template)
- scalaVersion:
2.11.12
- OS:
macOS HighSierra 10.13.6
What is the use case for changing the behavior?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
In order to keep the code more-or-less DRY while supporting more propagation in Chisel, we could construct FIRRTL nodes as we go* and leverage FIRRTL’s own constant propagation.
*Since names are not yet known, we’d have to do it in some name agnostic way, I don’t think it would be all that difficult though.
The above code causes the following error.
This error tell me the Cat result is exactly not literal.