From d034f40b02e40d8a919596c7554bc0662db62001 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 29 Jul 2015 00:22:33 -0700 Subject: Clean up Reg constructor --- src/main/scala/Chisel/Core.scala | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/scala/Chisel/Core.scala b/src/main/scala/Chisel/Core.scala index eadba100..f2857f7c 100644 --- a/src/main/scala/Chisel/Core.scala +++ b/src/main/scala/Chisel/Core.scala @@ -372,13 +372,12 @@ object Wire { object Reg { def apply[T <: Data](t: T = null, next: T = null, init: T = null): T = { - var mType = t - if(mType == null) - mType = next - if(mType == null) - mType = init - if(mType == null) - throw new Exception("cannot infer type of Reg.") + val mType = + if (t ne null) t + else if (next ne null) next + else if (init ne null) init + else throwException("cannot infer type of Reg.") + val x = mType.cloneType x.isReg_ = true pushCommand(DefRegister(x.defd.cid, x.toType)) -- cgit v1.2.3