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
67
68
69
70
71
72
73
74
75
|
// See LICENSE for license details.
package firrtlTests
import java.io._
import org.scalatest._
import org.scalatest.prop._
import firrtl.Parser
import firrtl.ir.Circuit
import firrtl.passes._
class ChirrtlSpec extends FirrtlFlatSpec {
def passes = Seq(
CheckChirrtl,
CInferTypes,
CInferMDir,
RemoveCHIRRTL,
ToWorkingIR,
CheckHighForm,
ResolveKinds,
InferTypes,
CheckTypes,
ResolveGenders,
CheckGenders,
InferWidths,
CheckWidths,
PullMuxes,
ExpandConnects,
RemoveAccesses,
ExpandWhens,
CheckInitialization
)
"Chirrtl memories" should "allow ports with clocks defined after the memory" in {
val input =
"""circuit Unit :
| module Unit :
| input clk : Clock
| smem ram : UInt<32>[128]
| node newClock = clk
| infer mport x = ram[UInt(2)], newClock
| x <= UInt(3)
| when UInt(1) :
| infer mport y = ram[UInt(4)], newClock
| y <= UInt(5)
""".stripMargin
passes.foldLeft(Parser.parse(input.split("\n").toIterator)) {
(c: Circuit, p: Pass) => p.run(c)
}
}
"Chirrtl" should "catch undeclared wires" in {
val input =
"""circuit Unit :
| module Unit :
| input clk : Clock
| smem ram : UInt<32>[128]
| node newClock = clk
| infer mport x = ram[UInt(2)], newClock
| x <= UInt(3)
| when UInt(1) :
| infer mport y = ram[UInt(4)], newClock
| y <= z
""".stripMargin
intercept[PassException] {
passes.foldLeft(Parser.parse(input.split("\n").toIterator)) {
(c: Circuit, p: Pass) => p.run(c)
}
}
}
}
class ChirrtlMemsExecutionTest extends ExecutionTest("ChirrtlMems", "/features")
class EmptyChirrtlMemCompilationTest extends CompilationTest("EmptyChirrtlMem", "/features")
class NodeTypeCompilationTest extends CompilationTest("NodeType", "/features")
|