chipsalliance / chipsalliance/chisel
RFC: when should users expect `val foo = ...` to exist in output verilog?
- 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**: proposal
**Other information**
**If the current behavior is a bug, please provide the steps to reproduce the problem:**
Not a bug, just how things work today and should they change...
**What is the current behavior?**
Currently users cannot always expect a `val foo = ...` to result in a `foo` in the output Verilog. As a user, my general mental model is:
* [A] if `foo` results in any sort of hardware (IO, Wire, or Reg) that is not actually needed in the output circuit, it can be constant-propped or Dead-Code Eliminated away and it will not exist in the output verilog.
* [B] If I put `foo.dontTouch` then foo will exist without any logic optimization across it.
* [C] If `foo` is an IO or Reg that does exist in the output, its name should exist exactly as specified (Regs are not smushed together eve if they have the same functionality)
* [D] If `foo` is redundant with some other logic, it may or may not exist (`val bar = a + b; val foo = bar` -- I'm not sure which will exist in the output, `foo`, `bar`, or both)
* [E] If `foo` is redundant with some not-named other logic, `foo` should exist: `val bar = a + b + c; val foo = a + b`, I'd expect it to result in either `assign bar = foo + c` or `assign foo = a + b; assign bar = a + b + c`, I would NOT expect `assign BizzleBaz = a + b; assign bar = BizzleBaz+c; [logic that uses foo now uses BizzleBaz]`.
* [F] There is no way for me as a user to control the resolution of D or E.
I think `[A]` and `[B]` are roughly "specified" -- thats why we have dontTouch in the first place.
I think `[C]` is not really specified but not really controversial either.
I think [D] and [E] are completely unspecified behavior -- this is what today's combination of Chisel + SFC does (maybe?)
I *believe* `[F]` but I don't *like* it.
**What is the expected behavior?**
I would expect that if it's important to talk about expecting named variables in the output, we provide guarantees or an API that provides the guarantee we expect. `dontTouch` is too heavy a hammer for "this is an important, user-specified name that i want to have heavier value than made-up computer names or other names in this circuit".
**Please tell us about your environment:**
- version: 3.5.1
**What is the use case for changing the behavior?**
Enabling different compiler backends to not completely suprise users with different interpretations of undefined behavior
Contributor guide
Assessment
This issue has not been assessed yet.