Skip to content

Commit

Permalink
Fix ChiselEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
adkian-sifive committed Dec 18, 2024
1 parent bc6ff61 commit a6046d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions core/src/main/scala/chisel3/ChiselEnumImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
_wire := this.asUInt
_wire
}
_padded.asTypeOf(that)
case None => super.asTypeOf(that)
_padded._asTypeOfImpl(that)
case None => super._asTypeOfImpl(that)
}
}

Expand Down Expand Up @@ -222,15 +222,7 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
for ((name, value) <- allNamesPadded) {
when(this === value) {
for ((r, c) <- result.zip(name)) {
// todo: this doesn't work in scala3
// r := c.toChar.U
// ^^^^^^^^^^
// value U is not a member of Char.
// An extension method was tried,
// but could not be fully constructed:
//
// chisel3.fromLongToLiteral(c.toChar)
// r := c.toChar.U
r := asUInt(c)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/DataImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ private[chisel3] trait DataImpl extends HasId with NamedComponent { self: Data =
/** Returns Some(width) if the width is known, else None. */
final def widthOption: Option[Int] = if (isWidthKnown) Some(getWidth) else None

protected def _asTypeOfImpl[T <: Data](that: T)(implicit sourceInfo: SourceInfo): T = {
private[chisel3] def _asTypeOfImpl[T <: Data](that: T)(implicit sourceInfo: SourceInfo): T = {
that._fromUInt(this.asUInt).asInstanceOf[T].viewAsReadOnly { _ =>
"Return values of asTypeOf are now read-only"
}
Expand Down

0 comments on commit a6046d8

Please sign in to comment.