Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
"Scope" test resource (top.cpp). (#398)
Browse files Browse the repository at this point in the history
Jar resources (unlike classes) are typically not scoped. This can create collisions if we have similarly named resources in multiple jars, especially when merging multiple projects in an IDE. Give this resource a distinct name to avoid colliding with chisel3 top.cpp.
  • Loading branch information
ucbjrl committed May 8, 2017
1 parent b960be0 commit 245471a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
File renamed without changes.
6 changes: 4 additions & 2 deletions src/test/scala/firrtlTests/FirrtlSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import firrtl.annotations
import firrtl.util.BackendCompilationUtilities

trait FirrtlRunners extends BackendCompilationUtilities {
lazy val cppHarness = new File(s"/top.cpp")

val cppHarnessResourceName: String = "/firrtl/testTop.cpp"

/** Compiles input Firrtl to Verilog */
def compileToVerilog(input: String, annotations: AnnotationMap = AnnotationMap(Seq.empty)): String = {
val circuit = Parser.parse(input.split("\n").toIterator)
Expand Down Expand Up @@ -64,7 +66,7 @@ trait FirrtlRunners extends BackendCompilationUtilities {
annotations: AnnotationMap = new AnnotationMap(Seq.empty)) = {
val testDir = compileFirrtlTest(prefix, srcDir, customTransforms, annotations)
val harness = new File(testDir, s"top.cpp")
copyResourceToFile(cppHarness.toString, harness)
copyResourceToFile(cppHarnessResourceName, harness)

// Note file copying side effect
val verilogFiles = verilogPrefixes map { vprefix =>
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/firrtlTests/IntegrationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class GCDSplitEmissionExecutionTest extends FirrtlFlatSpec {
topFile should exist

// Copy harness over
val harness = new File(testDir, s"top.cpp")
copyResourceToFile(cppHarness.toString, harness)
val harness = new File(testDir, s"testTop.cpp")
copyResourceToFile(cppHarnessResourceName, harness)

// topFile will be compiled by Verilator command by default but we need to also include dutFile
verilogToCpp(top, testDir, Seq(dutFile), harness).!
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/firrtlTests/StringSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PrintfSpec extends FirrtlPropSpec {
val prefix = "Printf"
val testDir = compileFirrtlTest(prefix, "/features")
val harness = new File(testDir, s"top.cpp")
copyResourceToFile(cppHarness.toString, harness)
copyResourceToFile(cppHarnessResourceName, harness)

verilogToCpp(prefix, testDir, Seq(), harness).!
cppToExe(prefix, testDir).!
Expand Down

0 comments on commit 245471a

Please sign in to comment.