From d95cb262aefc06458652b227980a3cdc5471d3ba Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 19 Dec 2017 17:33:07 -0800 Subject: Add WireInit.apply that accepts DontCare (#731) Prevents DontCare from affecting type inference Fixes #728 --- chiselFrontend/src/main/scala/chisel3/core/Data.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'chiselFrontend/src') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index db99d6b3..19adf01b 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -451,13 +451,20 @@ object WireInit { apply(model, init) } - def apply[T <: Data](t: T, init: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { + private def applyImpl[T <: Data](t: T, init: Data)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { implicit val noSourceInfo = UnlocatableSourceInfo val x = Wire(t) requireIsHardware(init, "wire initializer") x := init x } + + def apply[T <: Data](t: T, init: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { + applyImpl(t, init) + } + def apply[T <: Data](t: T, init: DontCare.type)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { + applyImpl(t, init) + } } /** RHS (source) for Invalidate API. -- cgit v1.2.3