chipsalliance / chipsalliance/chisel

Interval literal creation is inconsistent

Open
#1,507 3 comments 0 reactions 1 assignee Claimed by @chick View on GitHub
API Modification bug
Dominant language
Scala
Stars
4.8k
Forks
658
Avg merge
18h 59m
Merged PRs (30d)
14

Description

**Type of issue**: bug report | documentation

**Impact**: Possible API modification

**Other information**
Not the discrepancy with the following Interval literals. Decimal values are encode using the .I arguments
while BigInt and Int values are interpreted according to the .I arguments. I think this is likely to create confusion
though the cat may already be out of the bag on this one.

import chisel3._

| Statement | Value |
| ------------- | ------------- |
| val b = BigInt(-2) | b: scala.math.BigInt = -2 |
| val e = BigDecimal(-2.0) | e: scala.math.BigDecimal = -2.0 |
| val d = -2.0 | d: Double = -2.0 |
| val l = -2 | l: Int = -2 |
| | |
| val ib = b.I(2.BP) | ib: chisel3.experimental.Interval = Interval<2>(-2) |
| val ie = e.I(2.BP) | ie: chisel3.experimental.Interval = Interval<4>(-8) |
| val id = d.I(2.BP) | id: chisel3.experimental.Interval = Interval<4>(-8) |
| val il = l.I(2.BP) | il: chisel3.experimental.Interval = Interval<2>(-2) |
| | |
| ib.litToDouble | res0: Double = -0.5 |
| ie.litToDouble | res1: Double = -2.0 |
| id.litToDouble | res2: Double = -2.0 |
| il.litToDouble | res3: Double = -0.5 |
| | |
| ib.litValue() | res4: BigInt = -2 |
| ie.litValue() | res5: BigInt = -8 |
| id.litValue() | res6: BigInt = -8 |
| il.litValue() | res7: BigInt = -2 |

**What is the current behavior?**
When creating Interval literals the behavior is different for BigInts, Longs, and Ints, than it is for Double and BigDecimal.
In the former case the bits of the number are interpreted according to the paramters of the cap-I conversion while the latter the number is the supplied

**What is the expected behavior?**
Seems to me that the behavior should be the same as Double and BigDecimal

**Please tell us about your environment:**
Chisel3 3.3

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.