Skip to content

Commit 9a8b282

Browse files
committed
Fix ChiselEnum
1 parent bc6ff61 commit 9a8b282

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

core/src/main/scala/chisel3/ChiselEnumImpl.scala

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
7070
_wire := this.asUInt
7171
_wire
7272
}
73-
_padded.asTypeOf(that)
74-
case None => super.asTypeOf(that)
73+
_padded._asTypeOfImpl(that)
74+
case None => super._asTypeOfImpl(that)
7575
}
7676
}
7777

@@ -222,15 +222,7 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
222222
for ((name, value) <- allNamesPadded) {
223223
when(this === value) {
224224
for ((r, c) <- result.zip(name)) {
225-
// todo: this doesn't work in scala3
226-
// r := c.toChar.U
227-
// ^^^^^^^^^^
228-
// value U is not a member of Char.
229-
// An extension method was tried,
230-
// but could not be fully constructed:
231-
//
232-
// chisel3.fromLongToLiteral(c.toChar)
233-
// r := c.toChar.U
225+
r := UInt.Lit(BigInt(c.toChar), Width())
234226
}
235227
}
236228
}

core/src/main/scala/chisel3/DataImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ private[chisel3] trait DataImpl extends HasId with NamedComponent { self: Data =
861861
/** Returns Some(width) if the width is known, else None. */
862862
final def widthOption: Option[Int] = if (isWidthKnown) Some(getWidth) else None
863863

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

0 commit comments

Comments
 (0)