summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
diff options
context:
space:
mode:
authorJim Lawson2016-08-18 12:35:34 -0700
committerJim Lawson2016-08-18 12:35:34 -0700
commitd18274e307271809db2c27676f1dca40a49c9627 (patch)
tree2632a0e409bea3f9069c5ebfb555cc1ec04caa4f /chiselFrontend/src/main/scala/chisel3/core/Mem.scala
parentddb7278760029be9d960ba8bf2b06ac8a8aac767 (diff)
parent7922f8d4998dd902ee18a6e85e4a404a1f29eb3f (diff)
Merge branch 'sdtwigg_connectwrap_renamechisel3' into gsdt_tests
Revive support for firrtl flip direction. Remove compileOptions.internalConnectionToInputOk
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Mem.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Mem.scala27
1 files changed, 20 insertions, 7 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
index 38f5ef14..931a0489 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
@@ -19,9 +19,11 @@ object Mem {
* @param t data type of memory element
*/
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.cloneType
+ val mt = t.chiselCloneType
+ Binding.bind(mt, NoDirectionBinder, "Error: fresh t")
+ // TODO(twigg): Remove need for this Binding
+
val mem = new Mem(mt, size)
pushCommand(DefMemory(sourceInfo, mem, mt, size)) // TODO multi-clock
mem
@@ -60,7 +62,7 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId wi
*
* @param idx memory element index to write into
* @param data new data to write
- * @param mask write mask as a Vec of Bool: a write to the Vec element in
+ * @param mask write mask as a Seq of Bool: a write to the Vec element in
* memory is only performed if the corresponding mask index is true.
*
* @note this is only allowed if the memory's element data type is a Vec
@@ -79,9 +81,17 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId wi
when (cond) { port := datum }
}
- private def makePort(sourceInfo: SourceInfo, idx: UInt, dir: MemPortDirection): T =
- pushCommand(DefMemPort(sourceInfo,
- t.cloneType, Node(this), dir, idx.ref, Node(idx._parent.get.clock))).id
+ private def makePort(sourceInfo: SourceInfo, idx: UInt, dir: MemPortDirection): T = {
+ Binding.checkSynthesizable(idx, s"'idx' ($idx)")
+
+ val port = pushCommand(
+ DefMemPort(sourceInfo,
+ t.chiselCloneType, 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")
+ port
+ }
}
/** A combinational-read, sequential-write memory.
@@ -107,7 +117,10 @@ 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.cloneType
+ val mt = t.chiselCloneType
+ Binding.bind(mt, NoDirectionBinder, "Error: fresh t")
+ // TODO(twigg): Remove need for this Binding
+
val mem = new SeqMem(mt, size)
pushCommand(DefSeqMemory(sourceInfo, mem, mt, size)) // TODO multi-clock
mem