From 6169f2b1c2e7d4e2aee098a8d4dbff6c9bcda663 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Fri, 12 Apr 2019 13:00:00 -0700 Subject: Implement connectFromBits in ChiselEnum (#1052) This is necessary to use ChiselEnum in aggregates where things are casted using .asTypeOf--- chiselFrontend/src/main/scala/chisel3/core/StrongEnum.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'chiselFrontend/src/main/scala') diff --git a/chiselFrontend/src/main/scala/chisel3/core/StrongEnum.scala b/chiselFrontend/src/main/scala/chisel3/core/StrongEnum.scala index c359a119..1689e6ad 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/StrongEnum.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/StrongEnum.scala @@ -102,10 +102,10 @@ abstract class EnumType(private val factory: EnumFactory, selfAnnotating: Boolea this.factory == that.asInstanceOf[EnumType].factory } - // This isn't actually used anywhere (and it would throw an exception anyway). But it has to be defined since we - // inherit it from Data. private[core] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo, - compileOptions: CompileOptions): Unit = ??? + compileOptions: CompileOptions): Unit = { + this := factory.apply(that.asUInt) + } final def === (that: EnumType): Bool = macro SourceInfoTransform.thatArg final def =/= (that: EnumType): Bool = macro SourceInfoTransform.thatArg -- cgit v1.2.3