aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAlbert Magyar2017-05-03 17:25:29 -0700
committerGitHub2017-05-03 17:25:29 -0700
commitaf222c1737fa72fce964190876346bdb7ff220cd (patch)
treef64949eeff380f10cc8afd79ebc72bf2265f4d15 /src/test
parent61a82d2e4518ec97b852c4555ad4c7c0fe05140a (diff)
Add checks on register clock and reset types (#33) (#553)
Remove infix notation on calls with side effects.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/CheckSpec.scala57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/CheckSpec.scala b/src/test/scala/firrtlTests/CheckSpec.scala
index 2fe5baf5..0d0df020 100644
--- a/src/test/scala/firrtlTests/CheckSpec.scala
+++ b/src/test/scala/firrtlTests/CheckSpec.scala
@@ -185,4 +185,61 @@ class CheckSpec extends FlatSpec with Matchers {
}
}
+ "Clocks with types other than ClockType" should "throw an exception" in {
+ val passes = Seq(
+ ToWorkingIR,
+ CheckHighForm,
+ ResolveKinds,
+ InferTypes,
+ CheckTypes)
+ val input =
+ """
+ |circuit Top :
+ |
+ | module Top :
+ | input clk : UInt<1>
+ | input i : UInt<1>
+ | output o : UInt<1>
+ |
+ | reg r : UInt<1>, clk
+ | r <= i
+ | o <= r
+ |
+ |""".stripMargin
+ intercept[CheckTypes.RegReqClk] {
+ passes.foldLeft(Parser.parse(input.split("\n").toIterator)) {
+ (c: Circuit, p: Pass) => p.run(c)
+ }
+ }
+ }
+
+ "Illegal reset type" should "throw an exception" in {
+ val passes = Seq(
+ ToWorkingIR,
+ CheckHighForm,
+ ResolveKinds,
+ InferTypes,
+ CheckTypes)
+ val input =
+ """
+ |circuit Top :
+ |
+ | module Top :
+ | input clk : Clock
+ | input reset : UInt<2>
+ | input i : UInt<1>
+ | output o : UInt<1>
+ |
+ | reg r : UInt<1>, clk with : (reset => (reset, UInt<1>("h00")))
+ | r <= i
+ | o <= r
+ |
+ |""".stripMargin
+ intercept[CheckTypes.IllegalResetType] {
+ passes.foldLeft(Parser.parse(input.split("\n").toIterator)) {
+ (c: Circuit, p: Pass) => p.run(c)
+ }
+ }
+ }
+
}