chipsalliance / chipsalliance/chisel
Get width of value using the size of string for UInt, SInt, ...
- Dominant language
- Scala
- Stars
- 4.8k
- Forks
- 658
- Avg merge
- 18h 59m
- Merged PRs (30d)
- 14
Description
**Type of issue**: feature request
**Impact**: API addition (no impact on existing code)
**Development Phase**: request
**What is the current behavior?**
If we initialize a value with a string like it :
```scala
val testDebug = "b000010".U
```
The size of `testDebug` will be the tinyiest size, here it will be size of 2:
```scala
assert(testDebug.getWidth == 6, "Error, length of testDebug is " +
testDebug.getWidth +
" instead of 6")
```
Error :
```
[info] java.lang.AssertionError: assertion failed: Error, length of testDebug is 2 instead of 6
```
To ensure the size we have to set it in `U()` arguments :
```scala
val testDebug = "b000010".U(6.W)
```
**What is the use case for changing the behavior?**
It can be interesting that size of value match the size of string no ?
**Please tell us about your environment:**
- version: `3.1.8`
- OS: `Linux Debian Linux fabien 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u5 (2019-08-11) x86_64 GNU/Linux`
-->
Contributor guide
Assessment
This issue has not been assessed yet.