chipsalliance / chipsalliance/chisel

Operations returns an OpBinding value regardless of whether all operand is literal or not

Open
#1,007 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
4.8k
Forks
658
Avg merge
18h 59m
Merged PRs (30d)
14

Description

**Type 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?**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.