summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAndrew Waterman2015-07-29 00:22:33 -0700
committerAndrew Waterman2015-07-29 00:22:46 -0700
commitd034f40b02e40d8a919596c7554bc0662db62001 (patch)
treefcdf0c374bdc15738c317fb93f391b8b5cc001c5 /src/main
parent6035ab90f10057561c679156a09087d638bf6cc9 (diff)
Clean up Reg constructor
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/Chisel/Core.scala13
1 files changed, 6 insertions, 7 deletions
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))