summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main
diff options
context:
space:
mode:
authorRichard Lin2017-12-19 16:17:22 -0800
committerGitHub2017-12-19 16:17:22 -0800
commitd67914ffd4b983903f777c5c033ce84fbdb561f1 (patch)
tree613b65aa76fd950058cf393a14edeaa16164de8e /chiselFrontend/src/main
parent9f504b9926d38d11fb8003c72360ff11d24b5ef6 (diff)
Add source info / compile options transforms to Mem accessors (#744)
Fixes #708
Diffstat (limited to 'chiselFrontend/src/main')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Mem.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
index 72d91c3c..2c8e1a1e 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala
@@ -46,12 +46,18 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId {
/** Creates a read/write accessor into the memory with dynamic addressing.
* See the class documentation of the memory for more detailed information.
*/
- def apply(idx: UInt)(implicit compileOptions: CompileOptions): T = makePort(UnlocatableSourceInfo, idx, MemPortDirection.INFER)
+ def apply(x: UInt): T = macro SourceInfoTransform.xArg
+
+ def do_apply(idx: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T =
+ makePort(sourceInfo, idx, MemPortDirection.INFER)
/** Creates a read accessor into the memory with dynamic addressing. See the
* class documentation of the memory for more detailed information.
*/
- def read(idx: UInt)(implicit compileOptions: CompileOptions): T = makePort(UnlocatableSourceInfo, idx, MemPortDirection.READ)
+ def read(x: UInt): T = macro SourceInfoTransform.xArg
+
+ def do_read(idx: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T =
+ makePort(sourceInfo, idx, MemPortDirection.READ)
/** Creates a write accessor into the memory.
*
@@ -144,7 +150,9 @@ object SyncReadMem {
* result is undefined (unlike Vec, where the last assignment wins)
*/
sealed class SyncReadMem[T <: Data](t: T, n: Int) extends MemBase[T](t, n) {
- def read(addr: UInt, enable: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
+ def read(x: UInt, en: Bool): T = macro SourceInfoTransform.xEnArg
+
+ def do_read(addr: UInt, enable: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
val a = Wire(UInt())
var port: Option[T] = None
when (enable) {