Skip to content

Commit

Permalink
wip: Update Chisel from 6.5.0 to 7.0.0
Browse files Browse the repository at this point in the history
`UnknownWidth` became a `case object` in this Chisel PR:
chipsalliance/chisel#4242

The `connectFromBits` method was removed in this Chisel PR:
chipsalliance/chisel#4168
  • Loading branch information
tymcauley committed Jul 16, 2024
1 parent 2e4adda commit 218579f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ scalacOptions ++= Seq(
"-language:reflectiveCalls",
"-Ymacro-annotations"
)
val chiselVersion = "6.5.0"
val chiselVersion = "7.0.0-M2"
addCompilerPlugin("org.chipsalliance" %% "chisel-plugin" % chiselVersion cross CrossVersion.full)
libraryDependencies ++= Seq(
"org.chipsalliance" %% "chisel" % chiselVersion,
Expand Down
16 changes: 6 additions & 10 deletions src/main/scala/fixedpoint/FixedPoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import chisel3.util.Cat
object FixedPoint extends NumObject {

/** Create a FixedPoint type with inferred width. */
def apply(): FixedPoint = apply(UnknownWidth(), BinaryPoint())
def apply(): FixedPoint = apply(UnknownWidth, BinaryPoint())

/** Create a FixedPoint type or port with fixed width. */
def apply(width: Width, binaryPoint: BinaryPoint): FixedPoint = new FixedPoint(width, binaryPoint)
Expand All @@ -42,15 +42,15 @@ object FixedPoint extends NumObject {
* Use PrivateObject to force users to specify width and binaryPoint by name
*/
def fromBigInt(value: BigInt, binaryPoint: BinaryPoint = 0.BP): FixedPoint = {
apply(value, UnknownWidth(), binaryPoint)
apply(value, UnknownWidth, binaryPoint)
}

/** Create a FixedPoint literal with inferred width from BigInt.
* Use PrivateObject to force users to specify width and binaryPoint by name
*/
def fromBigInt(value: BigInt, width: Int, binaryPoint: Int): FixedPoint =
if (width == -1) {
apply(value, UnknownWidth(), BinaryPoint(binaryPoint))
apply(value, UnknownWidth, BinaryPoint(binaryPoint))
} else {
apply(value, KnownWidth(width), BinaryPoint(binaryPoint))
}
Expand Down Expand Up @@ -103,7 +103,7 @@ object FixedPoint extends NumObject {
}

private[fixedpoint] def recreateWidth[T <: Data](d: T): Width = {
d.widthOption.fold[Width](UnknownWidth())(_.W)
d.widthOption.fold[Width](UnknownWidth)(_.W)
}

/** Align all FixedPoints in a (possibly heterogeneous) sequence by width and binary point
Expand Down Expand Up @@ -145,7 +145,7 @@ object FixedPoint extends NumObject {

implicit class fromDoubleToLiteral(double: Double) {
def F(binaryPoint: BinaryPoint): FixedPoint = {
FixedPoint.fromDouble(double, UnknownWidth(), binaryPoint)
FixedPoint.fromDouble(double, UnknownWidth, binaryPoint)
}

def F(width: Width, binaryPoint: BinaryPoint): FixedPoint = {
Expand All @@ -155,7 +155,7 @@ object FixedPoint extends NumObject {

implicit class fromBigDecimalToLiteral(bigDecimal: BigDecimal) {
def F(binaryPoint: BinaryPoint): FixedPoint = {
FixedPoint.fromBigDecimal(bigDecimal, UnknownWidth(), binaryPoint)
FixedPoint.fromBigDecimal(bigDecimal, UnknownWidth, binaryPoint)
}

def F(width: Width, binaryPoint: BinaryPoint): FixedPoint = {
Expand Down Expand Up @@ -325,10 +325,6 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred

override def bulkConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit = connectOp(that, _ <> _)

override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo): Unit = {
this.data := that.asTypeOf(this.data)
}

def apply(x: BigInt): Bool = data.apply(x)

def apply(x: Int): Bool = data.apply(x)
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/FixedPointSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ class FixedPointFromBitsTester extends BasicTester {
val f6bp0 = 6.0.F(0.BP)
val f6bp2 = 6.0.F(2.BP)

val f1bp5shiftleft2 = Wire(FixedPoint(UnknownWidth(), BinaryPoint()))
val f6bp0shiftright2 = Wire(FixedPoint(UnknownWidth(), BinaryPoint()))
val f6bp2shiftright2 = Wire(FixedPoint(UnknownWidth(), BinaryPoint()))
val f1bp5shiftleft2 = Wire(FixedPoint(UnknownWidth, BinaryPoint()))
val f6bp0shiftright2 = Wire(FixedPoint(UnknownWidth, BinaryPoint()))
val f6bp2shiftright2 = Wire(FixedPoint(UnknownWidth, BinaryPoint()))

f1bp5shiftleft2 := f1bp5 << 2
f6bp0shiftright2 := f6bp0 >> 2
Expand Down

0 comments on commit 218579f

Please sign in to comment.