aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJack Koenig2019-01-04 16:49:59 -0800
committerGitHub2019-01-04 16:49:59 -0800
commit37567cc65d531b5d47d13c12e9c7ac80fc4d7b1f (patch)
treef130774f6b1b4fec295ddc9a6d987bc41d9a36ad /src/test
parent4253791132c5c550e1bc4a8070cb54e558f17809 (diff)
parent1931649a050619a711c066f669d93d436bd03296 (diff)
Merge pull request #987 from freechipsproject/fix-grouping
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/transforms/GroupComponentsSpec.scala73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/transforms/GroupComponentsSpec.scala b/src/test/scala/firrtlTests/transforms/GroupComponentsSpec.scala
index 3a32ec71..c54e02e3 100644
--- a/src/test/scala/firrtlTests/transforms/GroupComponentsSpec.scala
+++ b/src/test/scala/firrtlTests/transforms/GroupComponentsSpec.scala
@@ -3,6 +3,10 @@ package transforms
import firrtl.annotations.{CircuitName, ComponentName, ModuleName}
import firrtl.transforms.{GroupAnnotation, GroupComponents}
+import firrtl._
+import firrtl.ir._
+
+import FirrtlCheckers._
class GroupComponentsSpec extends LowTransformSpec {
def transform = new GroupComponents()
@@ -42,6 +46,43 @@ class GroupComponentsSpec extends LowTransformSpec {
""".stripMargin
execute(input, check, groups)
}
+ "Grouping" should "work even when there are unused nodes" in {
+ val input =
+ s"""circuit $top :
+ | module $top :
+ | input in: UInt<16>
+ | output out: UInt<16>
+ | node n = UInt<16>("h0")
+ | wire w : UInt<16>
+ | wire a : UInt<16>
+ | wire b : UInt<16>
+ | a <= UInt<16>("h0")
+ | b <= a
+ | w <= in
+ | out <= w
+ """.stripMargin
+ val groups = Seq(
+ GroupAnnotation(Seq(topComp("w")), "Child", "inst", Some("_OUT"), Some("_IN"))
+ )
+ val check =
+ s"""circuit Top :
+ | module $top :
+ | input in: UInt<16>
+ | output out: UInt<16>
+ | inst inst of Child
+ | node n = UInt<16>("h0")
+ | inst.in_IN <= in
+ | node a = UInt<16>("h0")
+ | node b = a
+ | out <= inst.w_OUT
+ | module Child :
+ | input in_IN : UInt<16>
+ | output w_OUT : UInt<16>
+ | node w = in_IN
+ | w_OUT <= w
+ """.stripMargin
+ execute(input, check, groups)
+ }
"The two sets of instances" should "be grouped" in {
val input =
@@ -288,3 +329,35 @@ class GroupComponentsSpec extends LowTransformSpec {
execute(input, check, groups)
}
}
+
+class GroupComponentsIntegrationSpec extends FirrtlFlatSpec {
+ def topComp(name: String): ComponentName = ComponentName(name, ModuleName("Top", CircuitName("Top")))
+ "Grouping" should "properly set kinds" in {
+ val input =
+ """circuit Top :
+ | module Top :
+ | input clk: Clock
+ | input data: UInt<16>
+ | output out: UInt<16>
+ | reg r: UInt<16>, clk
+ | r <= data
+ | out <= r
+ """.stripMargin
+ val groups = Seq(
+ GroupAnnotation(Seq(topComp("r")), "MyModule", "inst", Some("_OUT"), Some("_IN"))
+ )
+ val result = (new VerilogCompiler).compileAndEmit(
+ CircuitState(parse(input), ChirrtlForm, groups),
+ Seq(new GroupComponents)
+ )
+ result should containTree {
+ case Connect(_, WSubField(WRef("inst",_, InstanceKind,_), "data_IN", _,_), WRef("data",_,_,_)) => true
+ }
+ result should containTree {
+ case Connect(_, WSubField(WRef("inst",_, InstanceKind,_), "clk_IN", _,_), WRef("clk",_,_,_)) => true
+ }
+ result should containTree {
+ case Connect(_, WRef("out",_,_,_), WSubField(WRef("inst",_, InstanceKind,_), "r_OUT", _,_)) => true
+ }
+ }
+}