From 9911b3467de2ebe92827ddc3288bd6db477cc636 Mon Sep 17 00:00:00 2001 From: Jim Lawson Date: Mon, 18 Mar 2019 15:20:51 -0700 Subject: Add serialization support for LoadMemoryFileType in LoadMemoryAnnotation (#1056) * Add serialization support for LoadMemoryFileType in LoadMemoryAnnotation Add custom LoadMemoryFileTypeSerializer. Add test to verify LoadMemoryAnnotation can be correctly serialized/deserialized. * Simplify and focus LoadMemoryAnnotation serialization/deserialization. Respond to comments on earlier implementations. * Add type FileType definition for current chisel3 code. --- .../annotationTests/LoadMemoryAnnotationSpec.scala | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/annotationTests/LoadMemoryAnnotationSpec.scala b/src/test/scala/firrtlTests/annotationTests/LoadMemoryAnnotationSpec.scala index 15b12d52..c702df13 100644 --- a/src/test/scala/firrtlTests/annotationTests/LoadMemoryAnnotationSpec.scala +++ b/src/test/scala/firrtlTests/annotationTests/LoadMemoryAnnotationSpec.scala @@ -2,7 +2,7 @@ package firrtlTests.annotationTests -import firrtl.annotations.{CircuitName, ComponentName, LoadMemoryAnnotation, ModuleName} +import firrtl.annotations._ import org.scalatest.{FreeSpec, Matchers} class LoadMemoryAnnotationSpec extends FreeSpec with Matchers { @@ -26,4 +26,16 @@ class LoadMemoryAnnotationSpec extends FreeSpec with Matchers { lma.getFileName should be("./target/scala-2.12/test-classes/init_mem_subdata") } } + "LoadMemoryAnnotation should be correctly parsed from a string" in { + val lma = new LoadMemoryAnnotation( + ComponentName("ram", ModuleName("ModuleMem", CircuitName("CircuitMem"))), + "CircuitMem.ModuleMem.ram.dat", + hexOrBinary = MemoryLoadFileType.Binary, + originalMemoryNameOpt = Some("memory") + ) + + val annoString = JsonProtocol.serializeTry(Seq(lma)).get + val loadedAnnos = JsonProtocol.deserializeTry(annoString).get + lma should equal(loadedAnnos.head) + } } -- cgit v1.2.3