diff options
| author | Carlos Eduardo | 2021-04-01 18:55:03 -0300 |
|---|---|---|
| committer | GitHub | 2021-04-01 14:55:03 -0700 |
| commit | d0d3cd4ec4348eea381fe463ac9c96956fdd5eba (patch) | |
| tree | 3a035449ef49e5e7bca8f620339e18163285255e /src/test | |
| parent | ffe83fa43b9269f1e899122ba7825025df173b5a (diff) | |
Add memory initialization options for synthesis (#2166)
This PR adds options for memory initialization inside or outside the
`ifndef SYNTHESIS` block.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/MemoryInitSpec.scala | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/test/scala/firrtlTests/MemoryInitSpec.scala b/src/test/scala/firrtlTests/MemoryInitSpec.scala index a7c9966a..44f0162e 100644 --- a/src/test/scala/firrtlTests/MemoryInitSpec.scala +++ b/src/test/scala/firrtlTests/MemoryInitSpec.scala @@ -4,7 +4,7 @@ package firrtlTests import firrtl._ import firrtl.annotations._ -import firrtl.testutils.FirrtlCheckers.containLine +import firrtl.testutils.FirrtlCheckers.{containLine, containLines} import firrtl.testutils.FirrtlFlatSpec import firrtlTests.execution._ @@ -182,6 +182,44 @@ class MemInitSpec extends FirrtlFlatSpec { compile(Seq(MemoryFileInlineAnnotation(mRef, filename = ""))) } } + + "MemoryInitialization" should "emit readmem in `ifndef SYNTHESIS` block by default" in { + val annos = Seq( + MemoryFileInlineAnnotation(mRef, filename = "text.hex", hexOrBinary = MemoryLoadFileType.Hex) + ) + val result = compile(annos) + result should containLines( + """`endif // RANDOMIZE""", + """$readmemh("text.hex", """ + mRef.name + """);""", + """end // initial""" + ) + } + + "MemoryInitialization" should "emit readmem outside `ifndef SYNTHESIS` block with MemorySynthInit annotation" in { + val annos = Seq( + MemoryFileInlineAnnotation(mRef, filename = "text.hex", hexOrBinary = MemoryLoadFileType.Hex) + ) ++ Seq(MemorySynthInit) + val result = compile(annos) + result should containLines( + """`endif // SYNTHESIS""", + """initial begin""", + """$readmemh("text.hex", """ + mRef.name + """);""", + """end""" + ) + } + + "MemoryInitialization" should "emit readmem outside `ifndef SYNTHESIS` block with MemoryNoSynthInit annotation" in { + val annos = Seq( + MemoryFileInlineAnnotation(mRef, filename = "text.hex", hexOrBinary = MemoryLoadFileType.Hex) + ) ++ Seq(MemoryNoSynthInit) + + val result = compile(annos) + result should containLines( + """`endif // RANDOMIZE""", + """$readmemh("text.hex", """ + mRef.name + """);""", + """end // initial""" + ) + } } abstract class MemInitExecutionSpec(values: Seq[Int], init: ReferenceTarget => Annotation) |
