aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtl/transforms
diff options
context:
space:
mode:
authorKevin Laeufer2021-02-17 12:16:52 -0800
committerGitHub2021-02-17 20:16:52 +0000
commit5a89fca6090948d0a99c217a09c692e58a20d1df (patch)
tree7996829e3589205607862cbbf578a4e9a9d6e623 /src/test/scala/firrtl/transforms
parent856226416cfa2d770c7205efad5331297c2e3a32 (diff)
Allow Side Effecting Statement to have Names (#2057)
* firrtl: add optional statement labels for stop, printf, assert, assume and cover * test: parsing of statement labels * ir: ensure that name is properly retained * SymbolTable: add support for labled statements * test: parsing statement labels * test: lower types name collisions with named statements * ignore empty names * Inline: deal with named and unnamed statements * RemoveWires: treat stop, printf and verification statements as "others" * test: fix InlineInstance tests * DeadCodeEliminations: statements are now als declarations * CheckHighForm: ensure that statement names are not used as references * CheckSpec: throw error if statement name collides * add pass to automatically add missing statement names * check: make sure that two statements cannot have the same name * stmtLabel -> stmtName * scalafmt * add statement names to spec * spec: meta data -> metadata * EnsureStatementNames: explain naming algorithm * remove returns * better namespace use * ir: add CanBeReferenced trait * ir: add newline as jack requested
Diffstat (limited to 'src/test/scala/firrtl/transforms')
-rw-r--r--src/test/scala/firrtl/transforms/EnsureNamedStatementsSpec.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/scala/firrtl/transforms/EnsureNamedStatementsSpec.scala b/src/test/scala/firrtl/transforms/EnsureNamedStatementsSpec.scala
new file mode 100644
index 00000000..4c993994
--- /dev/null
+++ b/src/test/scala/firrtl/transforms/EnsureNamedStatementsSpec.scala
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: Apache-2.0
+
+package firrtl.transforms
+
+import firrtl.options.Dependency
+import firrtl.testutils.LeanTransformSpec
+
+class EnsureNamedStatementsSpec extends LeanTransformSpec(Seq(Dependency(EnsureNamedStatements))) {
+ behavior.of("EnsureNamedStatements")
+
+ it should "automatically name statements that do not have a name yet" in {
+ val src = """circuit test :
+ | module test :
+ | input clock : Clock
+ | input stop_ : UInt<1>
+ | assert(clock, UInt(1), not(UInt(0)), "")
+ | stop(clock, UInt(1), 1) : stop_123
+ | stop(clock, UInt(1), 1)
+ | assert(clock, UInt(0), UInt(0), "")
+ | assume(clock, UInt(0), UInt(0), "")
+ | cover(clock, UInt(0), UInt(0), "")
+ | cover(clock, UInt(0), UInt(0), "")
+ |
+ |""".stripMargin
+
+ val result = compile(src, List()).circuit.serialize.split('\n').map(_.trim)
+
+ val expected = List(
+ """assert(clock, UInt<1>("h1"), not(UInt<1>("h0")), "") : assert_0""",
+ """stop(clock, UInt<1>("h1"), 1) : stop_123""",
+ """stop(clock, UInt<1>("h1"), 1) : stop_0""",
+ """assert(clock, UInt<1>("h0"), UInt<1>("h0"), "") : assert_1""",
+ """assume(clock, UInt<1>("h0"), UInt<1>("h0"), "") : assume_0""",
+ """cover(clock, UInt<1>("h0"), UInt<1>("h0"), "") : cover_0""",
+ """cover(clock, UInt<1>("h0"), UInt<1>("h0"), "") : cover_1"""
+ )
+ expected.foreach(e => assert(result.contains(e)))
+ }
+}