aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/ParserSpec.scala
diff options
context:
space:
mode:
authorKevin Laeufer2023-01-25 11:06:45 -0500
committerGitHub2023-01-25 16:06:45 +0000
commit82af22f300a6d47c63cd3304d5c9d0447b33091a (patch)
treec1eca36fdebed0ffa362a0d44295ab3352afcf27 /src/test/scala/firrtlTests/ParserSpec.scala
parent59f62d82f28947af472fc8ed030051be40f5bfbe (diff)
[smem] fix read-under-write serialization (#2595)
* [smem] fix read-under-write serialization Also adds some tests for the parser and the serializer. * Serializer: always serialize smem ruw behavior * test: simplify smem test circuit
Diffstat (limited to 'src/test/scala/firrtlTests/ParserSpec.scala')
-rw-r--r--src/test/scala/firrtlTests/ParserSpec.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/ParserSpec.scala b/src/test/scala/firrtlTests/ParserSpec.scala
index 5003871d..dea44844 100644
--- a/src/test/scala/firrtlTests/ParserSpec.scala
+++ b/src/test/scala/firrtlTests/ParserSpec.scala
@@ -405,6 +405,35 @@ class ParserSpec extends FirrtlFlatSpec {
firrtl.Parser.parse(input)
}
}
+
+ it should "parse smem read-under-write behavior" in {
+ val undefined = firrtl.Parser.parse(SMemTestCircuit.src(""))
+ assert(SMemTestCircuit.findRuw(undefined) == ReadUnderWrite.Undefined)
+
+ val undefined2 = firrtl.Parser.parse(SMemTestCircuit.src(" undefined"))
+ assert(SMemTestCircuit.findRuw(undefined2) == ReadUnderWrite.Undefined)
+
+ val old = firrtl.Parser.parse(SMemTestCircuit.src(" old"))
+ assert(SMemTestCircuit.findRuw(old) == ReadUnderWrite.Old)
+
+ val readNew = firrtl.Parser.parse(SMemTestCircuit.src(" new"))
+ assert(SMemTestCircuit.findRuw(readNew) == ReadUnderWrite.New)
+ }
+}
+
+/** used to test parsing and serialization of smems */
+object SMemTestCircuit {
+ def src(ruw: String): String =
+ s"""circuit Example :
+ | module Example :
+ | smem mem : UInt<8> [8] $ruw@[main.scala 10:25]
+ |""".stripMargin
+
+ def findRuw(c: Circuit): ReadUnderWrite.Value = {
+ val main = c.modules.head.asInstanceOf[ir.Module]
+ val mem = main.body.asInstanceOf[ir.Block].stmts.collectFirst { case m: CDefMemory => m }.get
+ mem.readUnderWrite
+ }
}
class ParserPropSpec extends FirrtlPropSpec {