aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/execution/VerilogExecution.scala
blob: 17eecc6588e9f4440d0cce0769d8ea1d73370005 (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
package firrtlTests.execution

import java.io.File

import firrtl._
import firrtl.ir._
import firrtlTests._

import firrtl.stage.{FirrtlCircuitAnnotation, FirrtlStage}
import firrtl.options.TargetDirAnnotation

/**
  * Mixing in this trait causes a SimpleExecutionTest to be run in Verilog simulation.
  */
trait VerilogExecution extends TestExecution {
  this: SimpleExecutionTest =>
  def runEmittedDUT(c: Circuit, testDir: File): Unit = {
    // Run FIRRTL, emit Verilog file
    val cAnno = FirrtlCircuitAnnotation(c)
    val tdAnno = TargetDirAnnotation(testDir.getAbsolutePath)
    (new FirrtlStage).run(AnnotationSeq(Seq(cAnno, tdAnno)))

    // Copy harness resource to test directory
    val harness = new File(testDir, s"top.cpp")
    copyResourceToFile(cppHarnessResourceName, harness)

    // Make and run Verilog simulation
    verilogToCpp(c.main, testDir, Nil, harness).!
    cppToExe(c.main, testDir).!
    assert(executeExpectingSuccess(c.main, testDir))
  }
}