summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Waterman2016-01-16 18:43:17 -0800
committerAndrew Waterman2016-01-16 18:43:17 -0800
commite6a712b255d94e1b4d8b1c10db523100db25c721 (patch)
treeb42bcc9056d9b5aa81a7418e145bf07ae994bad6 /src
parent2d7bf7a5fdb5ee722009d4816bb8aa355ead59fc (diff)
Allow Wire() to be called from parameterized functions
Accomplish this by avoiding default-null parameters on the apply methods.
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Chisel/Data.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/Data.scala b/src/main/scala/Chisel/Data.scala
index c72c7dfc..7927db86 100644
--- a/src/main/scala/Chisel/Data.scala
+++ b/src/main/scala/Chisel/Data.scala
@@ -104,7 +104,16 @@ abstract class Data(dirArg: Direction) extends HasId {
}
object Wire {
- def apply[T <: Data](t: T = null, init: T = null): T = {
+ def apply[T <: Data](t: T): T =
+ makeWire(t, null.asInstanceOf[T])
+
+ def apply[T <: Data](dummy: Int = 0, init: T): T =
+ makeWire(null.asInstanceOf[T], init)
+
+ def apply[T <: Data](t: T, init: T): T =
+ makeWire(t, init)
+
+ private def makeWire[T <: Data](t: T, init: T): T = {
val x = Reg.makeType(t, null.asInstanceOf[T], init)
pushCommand(DefWire(x))
if (init != null) {