blob: 121a4e8132d81324277b95de91050acae40ba385 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// SPDX-License-Identifier: Apache-2.0
package firrtl.stage
import firrtl.options.Dependency
import firrtl.stage.transforms.Compiler
import firrtl.stage.TransformManager.TransformDependency
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class CurrentFirrtlStateAnnotationSpec extends AnyFlatSpec with Matchers {
def getTransforms(input: String): Seq[TransformDependency] = {
val currentState = CurrentFirrtlStateAnnotation
.options(0)
.toAnnotationSeq(input)
.collectFirst {
case CurrentFirrtlStateAnnotation(currentState) => currentState
}
.get
new Compiler(Forms.VerilogOptimized, currentState).flattenedTransformOrder.map(Dependency.fromTransform)
}
behavior.of("CurrentFirrtlStateAnnotation")
it should "produce an expected transform order for CHIRRTL -> Verilog" in {
getTransforms("chirrtl") should contain(Dependency(firrtl.passes.CheckChirrtl))
}
it should "produce an expected transform order for minimum high FIRRTL -> Verilog" in {
val transforms = getTransforms("mhigh")
transforms should not contain noneOf(Dependency(firrtl.passes.CheckChirrtl), Dependency(firrtl.passes.InferTypes))
transforms should contain(Dependency(firrtl.passes.CheckHighForm))
}
it should "produce an expected transform order for high FIRRTL -> Verilog" in {
val transforms = getTransforms("high")
transforms should not contain (Dependency[firrtl.transforms.DedupModules])
(transforms should contain).allOf(
Dependency(firrtl.passes.InferTypes),
Dependency[firrtl.passes.ExpandWhensAndCheck]
)
}
it should "produce an expected transform order for middle FIRRTL -> Verilog" in {
val transforms = getTransforms("middle")
transforms should not contain (Dependency[firrtl.passes.ExpandWhensAndCheck])
(transforms should contain).allOf(Dependency(firrtl.passes.InferTypes), Dependency(firrtl.passes.LowerTypes))
}
it should "produce an expected transform order for low FIRRTL -> Verilog" in {
val transforms = getTransforms("low")
transforms should not contain (Dependency(firrtl.passes.LowerTypes))
(transforms should contain).allOf(
Dependency(firrtl.passes.InferTypes),
Dependency(firrtl.passes.CommonSubexpressionElimination)
)
}
it should "produce an expected transform order for optimized low FIRRTL -> Verilog" in {
val transforms = getTransforms("low-opt")
transforms should not contain (Dependency(firrtl.passes.CommonSubexpressionElimination))
(transforms should contain).allOf(Dependency(firrtl.passes.InferTypes), Dependency[firrtl.transforms.VerilogRename])
}
}
|