Skip to content

Interval literal creation is inconsistent  #1507

@chick

Description

@chick

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions