aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/DriverSpec.scala
diff options
context:
space:
mode:
authorJack Koenig2017-03-06 14:51:20 -0600
committerGitHub2017-03-06 14:51:20 -0600
commit3d58123ae654a2101ba81304ca3863b3be12c4f3 (patch)
tree2e662485fef5327a2697dbd4a9b42a2cdc5bae5f /src/test/scala/firrtlTests/DriverSpec.scala
parentc89f74f19dd5162ee533a0a20825819bc52bc73e (diff)
Add ability to emit 1 file per module (#443)
Changes Emitters to also be Transforms and use Annotations for both telling an emitter to do emission as well as getting the emitted result. Helper functions ease the use of the new interface. Also adds a FirrtlExecutionOptions field as well as a command-line option. Use of Writers in Compilers and Emitters is now deprecated.
Diffstat (limited to 'src/test/scala/firrtlTests/DriverSpec.scala')
-rw-r--r--src/test/scala/firrtlTests/DriverSpec.scala68
1 files changed, 49 insertions, 19 deletions
diff --git a/src/test/scala/firrtlTests/DriverSpec.scala b/src/test/scala/firrtlTests/DriverSpec.scala
index 4e1add39..9cbeb6f9 100644
--- a/src/test/scala/firrtlTests/DriverSpec.scala
+++ b/src/test/scala/firrtlTests/DriverSpec.scala
@@ -66,7 +66,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities
val firrtlOptions = optionsManager.firrtlOptions
val inputFileName = optionsManager.getBuildFileName("fir", firrtlOptions.inputFileNameOverride)
inputFileName should be ("./cat.fir")
- val outputFileName = optionsManager.getBuildFileName("v", firrtlOptions.outputFileNameOverride)
+ val outputFileName = firrtlOptions.getTargetFile(optionsManager)
outputFileName should be ("./cat.v")
}
"input and output file names can be overridden, overrides do not use targetDir" in {
@@ -79,7 +79,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities
val firrtlOptions = optionsManager.firrtlOptions
val inputFileName = optionsManager.getBuildFileName("fir", firrtlOptions.inputFileNameOverride)
inputFileName should be ("./bob.fir")
- val outputFileName = optionsManager.getBuildFileName("v", firrtlOptions.outputFileNameOverride)
+ val outputFileName = firrtlOptions.getTargetFile(optionsManager)
outputFileName should be ("carol.v")
}
"various annotations can be created from command line, currently:" - {
@@ -142,26 +142,31 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities
annotationsTestFile.delete()
}
- val input =
- """
- |circuit Dummy :
- | module Dummy :
- | input x : UInt<1>
- | output y : UInt<1>
- | y <= x
- """.stripMargin
-
- "Driver produces files with different names depending on the compiler" - {
- "compiler changes the default name of the output file" in {
-
+ "Circuits are emitted on properly" - {
+ val input =
+ """|circuit Top :
+ | module Top :
+ | output foo : UInt<32>
+ | inst c of Child
+ | inst e of External
+ | foo <= tail(add(c.foo, e.foo), 1)
+ | module Child :
+ | output foo : UInt<32>
+ | inst e of External
+ | foo <= e.foo
+ | extmodule External :
+ | output foo : UInt<32>
+ """.stripMargin
+
+ "To a single file with file extension depending on the compiler by default" in {
Seq(
- "low" -> "./Dummy.lo.fir",
- "high" -> "./Dummy.hi.fir",
- "middle" -> "./Dummy.mid.fir",
- "verilog" -> "./Dummy.v"
+ "low" -> "./Top.lo.fir",
+ "high" -> "./Top.hi.fir",
+ "middle" -> "./Top.mid.fir",
+ "verilog" -> "./Top.v"
).foreach { case (compilerName, expectedOutputFileName) =>
val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
- commonOptions = CommonOptions(topName = "Dummy")
+ commonOptions = CommonOptions(topName = "Top")
firrtlOptions = FirrtlExecutionOptions(firrtlSource = Some(input), compilerName = compilerName)
}
@@ -172,8 +177,33 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities
file.delete()
}
}
+ "To a single file per module if OneFilePerModule is specified" in {
+ Seq(
+ "low" -> Seq("./Top.lo.fir", "./Child.lo.fir"),
+ "high" -> Seq("./Top.hi.fir", "./Child.hi.fir"),
+ "middle" -> Seq("./Top.mid.fir", "./Child.mid.fir"),
+ "verilog" -> Seq("./Top.v", "./Child.v")
+ ).foreach { case (compilerName, expectedOutputFileNames) =>
+ println(s"$compilerName -> $expectedOutputFileNames")
+ val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
+ commonOptions = CommonOptions(topName = "Top")
+ firrtlOptions = FirrtlExecutionOptions(firrtlSource = Some(input),
+ compilerName = compilerName,
+ emitOneFilePerModule = true)
+ }
+
+ firrtl.Driver.execute(manager)
+
+ for (name <- expectedOutputFileNames) {
+ val file = new File(name)
+ file.exists() should be (true)
+ file.delete()
+ }
+ }
+ }
}
+
"Directory deleter is handy for cleaning up after tests" - {
"for example making a directory tree, and deleting it looks like" in {
FileUtils.makeDirectory("dog/fox/wolf")