aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala
diff options
context:
space:
mode:
authorAlbert Magyar2020-07-27 10:14:52 -0700
committerGitHub2020-07-27 10:14:52 -0700
commit3099fc1721514838f04fbf310c6a14616fc4e99a (patch)
tree57e37d731f7f89b3cb0605e3588737644f816c70 /src/test/scala
parent3fcfbf363e7e04c759f0523d8c4a43427ccdf4a9 (diff)
parent1220a23ac9dfc26dbf5475ef064b644cdd1d7983 (diff)
Merge pull request #1528 from freechipsproject/conditionally-scopes
Create new scopes for child statements of Conditionally
Diffstat (limited to 'src/test/scala')
-rw-r--r--src/test/scala/firrtlTests/CheckSpec.scala47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/CheckSpec.scala b/src/test/scala/firrtlTests/CheckSpec.scala
index c622bde5..b49054ad 100644
--- a/src/test/scala/firrtlTests/CheckSpec.scala
+++ b/src/test/scala/firrtlTests/CheckSpec.scala
@@ -352,6 +352,53 @@ class CheckSpec extends AnyFlatSpec with Matchers {
}
}
+ "Conditionally statements" should "create a new scope" in {
+ val input =
+ s"""|circuit scopes:
+ | module scopes:
+ | input i: UInt<1>
+ | output o: UInt<1>
+ | when i:
+ | node x = not(i)
+ | o <= and(x, i)
+ |""".stripMargin
+ assertThrows[CheckHighForm.UndeclaredReferenceException] {
+ checkHighInput(input)
+ }
+ }
+
+ "Attempting to shadow a component name" should "throw an error" in {
+ val input =
+ s"""|circuit scopes:
+ | module scopes:
+ | input i: UInt<1>
+ | output o: UInt<1>
+ | wire x: UInt<1>
+ | when i:
+ | node x = not(i)
+ | o <= and(x, i)
+ |""".stripMargin
+ assertThrows[CheckHighForm.NotUniqueException] {
+ checkHighInput(input)
+ }
+ }
+
+ "Conditionally statements" should "create separate consequent and alternate scopes" in {
+ val input =
+ s"""|circuit scopes:
+ | module scopes:
+ | input i: UInt<1>
+ | output o: UInt<1>
+ | o <= i
+ | when i:
+ | node x = not(i)
+ | else:
+ | o <= and(x, i)
+ |""".stripMargin
+ assertThrows[CheckHighForm.UndeclaredReferenceException] {
+ checkHighInput(input)
+ }
+ }
}
object CheckSpec {