diff options
| author | Jim Lawson | 2016-07-19 16:52:27 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-07-19 16:52:27 -0700 |
| commit | f81202b896d30d90075be487895befa009b11733 (patch) | |
| tree | eba7bd56990788ecc6f68cca37a62e699ef57bf7 | |
| parent | 01e14c8c885527861152443f1233fa77b03cb8b5 (diff) | |
Fixes for only connectwrap version.
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Mem.scala | 10 | ||||
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Reg.scala | 15 |
2 files changed, 13 insertions, 12 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala index 5c1b5976..a9854362 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala @@ -20,7 +20,7 @@ object Mem { */ def apply[T <: Data](size: Int, t: T): Mem[T] = macro MemTransform.apply[T] def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo): Mem[T] = { - val mt = t.newType + val mt = t.cloneType Binding.bind(mt, NoDirectionBinder, "Error: fresh t") // TODO(twigg): Remove need for this Binding @@ -86,7 +86,7 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId wi val port = pushCommand( DefMemPort(sourceInfo, - t.newType, Node(this), dir, idx.ref, Node(idx._parent.get.clock)) + t.cloneType, Node(this), dir, idx.ref, Node(idx._parent.get.clock)) ).id // Bind each element of port to being a MemoryPort Binding.bind(port, MemoryPortBinder(Builder.forcedModule), "Error: Fresh t") @@ -103,7 +103,7 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId wi * @note when multiple conflicting writes are performed on a Mem element, the * result is undefined (unlike Vec, where the last assignment wins) */ -final class Mem[T <: Data] private (t: T, length: Int) extends MemBase(t, length) +sealed class Mem[T <: Data] private (t: T, length: Int) extends MemBase(t, length) object SeqMem { @deprecated("SeqMem argument order should be size, t; this will be removed by the official release", "chisel3") @@ -117,7 +117,7 @@ object SeqMem { def apply[T <: Data](size: Int, t: T): SeqMem[T] = macro MemTransform.apply[T] def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo): SeqMem[T] = { - val mt = t.newType + val mt = t.cloneType Binding.bind(mt, NoDirectionBinder, "Error: fresh t") // TODO(twigg): Remove need for this Binding @@ -137,7 +137,7 @@ object SeqMem { * @note when multiple conflicting writes are performed on a Mem element, the * result is undefined (unlike Vec, where the last assignment wins) */ -final class SeqMem[T <: Data] private (t: T, n: Int) extends MemBase[T](t, n) { +sealed class SeqMem[T <: Data] private (t: T, n: Int) extends MemBase[T](t, n) { def read(addr: UInt, enable: Bool): T = { implicit val sourceInfo = UnlocatableSourceInfo val a = Wire(UInt()) diff --git a/chiselFrontend/src/main/scala/chisel3/core/Reg.scala b/chiselFrontend/src/main/scala/chisel3/core/Reg.scala index df760b5c..b46b96ef 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Reg.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Reg.scala @@ -12,16 +12,18 @@ object Reg { init: T = null): T = { if (t ne null) { Binding.checkUnbound(t, s"t ($t) must be unbound Type. Try using newType?") - t.newType - } else if (next ne null) next.cloneTypeWidth(Width()) - else if (init ne null) { + t.cloneType + } else if (next ne null) { + next.cloneTypeWidth(Width()) + } else if (init ne null) { init.litArg match { - // For e.g. Reg(init=0.asUInt(k)), fix the Reg's width to k - case Some(lit) if lit.forcedWidth => init.newType + // For e.g. Reg(init=UInt(0, k)), fix the Reg's width to k + case Some(lit) if lit.forcedWidth => init.cloneType case _ => init.cloneTypeWidth(Width()) } + } else { + throwException("cannot infer type") } - else throw new Exception("cannot infer type") } /** Creates a register with optional next and initialization values. @@ -72,7 +74,6 @@ init: T = null): T = { Binding.checkSynthesizable(next, s"'next' ($next)") x := next } - x } } |
