diff options
| author | Kevin Laeufer | 2020-07-30 16:56:54 -0700 |
|---|---|---|
| committer | GitHub | 2020-07-30 23:56:54 +0000 |
| commit | ba2be50f42c1ec760decc22cfda73fbd39113b53 (patch) | |
| tree | 489bd4decf0931855f870a55c014ad005663a818 /src/test | |
| parent | 564312c3a813498b3ba5b88c6984b9cbeb94dd12 (diff) | |
ir: use Serializer.serialize where possible (#1809)
* ir: use Serializer.serialize where possible
* ir.Serializer: serialize MultiInfo correctly
* ir.Serializer: empty body needs to result in a skip statement
The firrtl grammar requires at least one statement.
* ir.Serializer: correctly serialize fixed point types and literals
* Serializer: change Seq -> Iterable in order to be Scala 2.13 compatible
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/fixed/FixedSerializationSpec.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/fixed/FixedSerializationSpec.scala b/src/test/scala/firrtlTests/fixed/FixedSerializationSpec.scala new file mode 100644 index 00000000..db107cb3 --- /dev/null +++ b/src/test/scala/firrtlTests/fixed/FixedSerializationSpec.scala @@ -0,0 +1,27 @@ +// See LICENSE for license details. + +package firrtlTests +package fixed + +import firrtl.ir +import org.scalatest.flatspec.AnyFlatSpec + +class FixedSerializationSpec extends AnyFlatSpec { + behavior of "FixedType" + + it should "serialize correctly" in { + assert(ir.FixedType(ir.IntWidth(3), ir.IntWidth(2)).serialize == "Fixed<3><<2>>") + assert(ir.FixedType(ir.IntWidth(10), ir.UnknownWidth).serialize == "Fixed<10>") + assert(ir.FixedType(ir.UnknownWidth, ir.IntWidth(-4)).serialize == "Fixed<<-4>>") + assert(ir.FixedType(ir.UnknownWidth, ir.UnknownWidth).serialize == "Fixed") + } + + behavior of "FixedLiteral" + + it should "serialize correctly" in { + assert(ir.FixedLiteral(1, ir.IntWidth(3), ir.IntWidth(2)).serialize == "Fixed<3><<2>>(\"h1\")") + assert(ir.FixedLiteral(1, ir.IntWidth(10), ir.UnknownWidth).serialize == "Fixed<10>(\"h1\")") + assert(ir.FixedLiteral(1, ir.UnknownWidth, ir.IntWidth(-4)).serialize == "Fixed<<-4>>(\"h1\")") + assert(ir.FixedLiteral(1, ir.UnknownWidth, ir.UnknownWidth).serialize == "Fixed(\"h1\")") + } +} |
