summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel/Data.scala
diff options
context:
space:
mode:
authorAndrew Waterman2016-01-28 12:15:53 -0800
committerAndrew Waterman2016-01-28 12:15:53 -0800
commit7eff2b0a16e1ca982c227bd498720981c883686b (patch)
tree767a04718b16750b33dd4e2d629d3e836bb7f637 /src/main/scala/Chisel/Data.scala
parent6d37cc8b9d731fa4c844f097b11057c46771961b (diff)
parent41674d5e130f64d7489fdb8583b8f4ad88b64aeb (diff)
Merge branch 'master' into scalastyle
Diffstat (limited to 'src/main/scala/Chisel/Data.scala')
-rw-r--r--src/main/scala/Chisel/Data.scala25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/main/scala/Chisel/Data.scala b/src/main/scala/Chisel/Data.scala
index f9b277e1..0ac3ee32 100644
--- a/src/main/scala/Chisel/Data.scala
+++ b/src/main/scala/Chisel/Data.scala
@@ -4,7 +4,7 @@ package Chisel
import internal._
import internal.Builder.pushCommand
-import firrtl._
+import internal.firrtl._
sealed abstract class Direction(name: String) {
override def toString: String = name
@@ -104,13 +104,22 @@ 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) {
x := init
} else {
- x.flatten.foreach(e => e := e.fromInt(0))
+ pushCommand(DefInvalid(x.ref))
}
x
}
@@ -123,7 +132,7 @@ object Clock {
// TODO: Document this.
sealed class Clock(dirArg: Direction) extends Element(dirArg, Width(1)) {
def cloneType: this.type = Clock(dirArg).asInstanceOf[this.type]
- private[Chisel] override def flatten: IndexedSeq[UInt] = IndexedSeq()
+ private[Chisel] override def flatten: IndexedSeq[Bits] = IndexedSeq()
private[Chisel] def cloneTypeWidth(width: Width): this.type = cloneType
private[Chisel] def toType = "Clock"
@@ -132,11 +141,3 @@ sealed class Clock(dirArg: Direction) extends Element(dirArg, Width(1)) {
case _ => this badConnect that
}
}
-
-// TODO: check with FIRRTL specs, how much official implementation flexibility
-// is there?
-/** A source of garbage data, used to initialize Wires to a don't-care value. */
-private object Poison extends Command {
- def apply[T <: Data](t: T): T =
- pushCommand(DefPoison(t.cloneType)).id
-}