@@ -21,12 +21,13 @@ import chisel3.internal.sourceinfo.{SourceInfoTransform, SourceInfoWhiteboxTrans
21
21
22
22
import scala .collection .immutable .SeqMap
23
23
import scala .language .experimental .macros
24
+ import scala .math .BigDecimal .RoundingMode .RoundingMode
24
25
import chisel3 .util .Cat
25
26
26
27
object FixedPoint extends NumObject {
27
28
28
29
/** Create a FixedPoint type with inferred width. */
29
- def apply (): FixedPoint = apply(UnknownWidth () , BinaryPoint ())
30
+ def apply (): FixedPoint = apply(UnknownWidth , BinaryPoint ())
30
31
31
32
/** Create a FixedPoint type or port with fixed width. */
32
33
def apply (width : Width , binaryPoint : BinaryPoint ): FixedPoint = new FixedPoint (width, binaryPoint)
@@ -42,15 +43,15 @@ object FixedPoint extends NumObject {
42
43
* Use PrivateObject to force users to specify width and binaryPoint by name
43
44
*/
44
45
def fromBigInt (value : BigInt , binaryPoint : BinaryPoint = 0 .BP ): FixedPoint = {
45
- apply(value, UnknownWidth () , binaryPoint)
46
+ apply(value, UnknownWidth , binaryPoint)
46
47
}
47
48
48
49
/** Create a FixedPoint literal with inferred width from BigInt.
49
50
* Use PrivateObject to force users to specify width and binaryPoint by name
50
51
*/
51
52
def fromBigInt (value : BigInt , width : Int , binaryPoint : Int ): FixedPoint =
52
53
if (width == - 1 ) {
53
- apply(value, UnknownWidth () , BinaryPoint (binaryPoint))
54
+ apply(value, UnknownWidth , BinaryPoint (binaryPoint))
54
55
} else {
55
56
apply(value, KnownWidth (width), BinaryPoint (binaryPoint))
56
57
}
@@ -103,7 +104,7 @@ object FixedPoint extends NumObject {
103
104
}
104
105
105
106
private [fixedpoint] def recreateWidth [T <: Data ](d : T ): Width = {
106
- d.widthOption.fold[Width ](UnknownWidth () )(_.W )
107
+ d.widthOption.fold[Width ](UnknownWidth )(_.W )
107
108
}
108
109
109
110
/** Align all FixedPoints in a (possibly heterogeneous) sequence by width and binary point
@@ -145,7 +146,7 @@ object FixedPoint extends NumObject {
145
146
146
147
implicit class fromDoubleToLiteral (double : Double ) {
147
148
def F (binaryPoint : BinaryPoint ): FixedPoint = {
148
- FixedPoint .fromDouble(double, UnknownWidth () , binaryPoint)
149
+ FixedPoint .fromDouble(double, UnknownWidth , binaryPoint)
149
150
}
150
151
151
152
def F (width : Width , binaryPoint : BinaryPoint ): FixedPoint = {
@@ -155,7 +156,7 @@ object FixedPoint extends NumObject {
155
156
156
157
implicit class fromBigDecimalToLiteral (bigDecimal : BigDecimal ) {
157
158
def F (binaryPoint : BinaryPoint ): FixedPoint = {
158
- FixedPoint .fromBigDecimal(bigDecimal, UnknownWidth () , binaryPoint)
159
+ FixedPoint .fromBigDecimal(bigDecimal, UnknownWidth , binaryPoint)
159
160
}
160
161
161
162
def F (width : Width , binaryPoint : BinaryPoint ): FixedPoint = {
@@ -223,8 +224,6 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
223
224
224
225
def do_unary_- (implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, - data)
225
226
226
- def do_unary_-% (implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data.unary_-% )
227
-
228
227
override def do_* (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint =
229
228
FixedPoint .fromData(binaryPoint + that.binaryPoint, data * that.data)
230
229
@@ -325,8 +324,10 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
325
324
326
325
override def bulkConnect (that : Data )(implicit sourceInfo : SourceInfo ): Unit = connectOp(that, _ <> _)
327
326
328
- override def connectFromBits (that : Bits )(implicit sourceInfo : SourceInfo ): Unit = {
329
- this .data := that.asTypeOf(this .data)
327
+ override protected def _fromUInt (that : UInt )(implicit sourceInfo : SourceInfo ): Data = {
328
+ val _w = Wire (this .cloneType)
329
+ _w.data := that.asTypeOf(this .data)
330
+ _w
330
331
}
331
332
332
333
def apply (x : BigInt ): Bool = data.apply(x)
0 commit comments