summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/Mem.scala
diff options
context:
space:
mode:
authorAndrew Waterman2018-03-06 20:55:08 -0600
committerGitHub2018-03-06 20:55:08 -0600
commita4aa3929eb04f21724ae61ff5e45158eed3d0e3b (patch)
treeae6e7fa8a763670fe82b54ee17faef28ee7c8d6b /src/test/scala/chiselTests/Mem.scala
parent916938144702e064d5265473a8a7114de9f5ddf1 (diff)
Fix SyncReadMem.read; add test (#796)
SyncReadMem.read with an enable signal currently only works in compatibility mode, where Wires are implicitly initialized to DontCare. Fix by explicitly assigning DontCare to the Wire. This might fix #775.
Diffstat (limited to 'src/test/scala/chiselTests/Mem.scala')
-rw-r--r--src/test/scala/chiselTests/Mem.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/Mem.scala b/src/test/scala/chiselTests/Mem.scala
index 81b5307c..56110d0f 100644
--- a/src/test/scala/chiselTests/Mem.scala
+++ b/src/test/scala/chiselTests/Mem.scala
@@ -19,8 +19,26 @@ class MemVecTester extends BasicTester {
}
}
+class SyncReadMemTester extends BasicTester {
+ val (cnt, _) = Counter(true.B, 5)
+ val mem = SyncReadMem(2, UInt(2.W))
+ val rdata = mem.read(cnt - 1.U, cnt =/= 0.U)
+
+ switch (cnt) {
+ is (0.U) { mem.write(cnt, 3.U) }
+ is (1.U) { mem.write(cnt, 2.U) }
+ is (2.U) { assert(rdata === 3.U) }
+ is (3.U) { assert(rdata === 2.U) }
+ is (4.U) { stop() }
+ }
+}
+
class MemorySpec extends ChiselPropSpec {
property("Mem of Vec should work") {
assertTesterPasses { new MemVecTester }
}
+
+ property("SyncReadMem should work") {
+ assertTesterPasses { new SyncReadMemTester }
+ }
}