Generate LowFirrtl for Retime tests
This commit is contained in:
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
package barstools.tapeout.transforms.retime.test
|
package barstools.tapeout.transforms.retime.test
|
||||||
|
|
||||||
import barstools.tapeout.transforms.retime._
|
|
||||||
import chisel3._
|
import chisel3._
|
||||||
import chisel3.stage.ChiselStage
|
import chisel3.stage.{ChiselStage, ChiselGeneratorAnnotation}
|
||||||
import firrtl._
|
import firrtl.{EmittedFirrtlCircuitAnnotation, EmittedFirrtlModuleAnnotation}
|
||||||
|
import barstools.tapeout.transforms.retime.RetimeLib
|
||||||
|
import firrtl.FileUtils
|
||||||
import logger.Logger
|
import logger.Logger
|
||||||
import org.scalatest.{FlatSpec, Matchers}
|
import org.scalatest.{FlatSpec, Matchers}
|
||||||
|
|
||||||
@@ -18,20 +19,33 @@ class RetimeSpec extends FlatSpec with Matchers {
|
|||||||
val genClassName = gen.getClass.getName
|
val genClassName = gen.getClass.getName
|
||||||
name + genClassName.hashCode.abs
|
name + genClassName.hashCode.abs
|
||||||
}
|
}
|
||||||
|
def getLowFirrtl[T <: RawModule](gen: () => T, extraArgs: Array[String] = Array.empty): String = {
|
||||||
|
// generate low firrtl
|
||||||
|
(new ChiselStage).execute(
|
||||||
|
Array("-X", "low") ++ extraArgs,
|
||||||
|
Seq(ChiselGeneratorAnnotation(gen))
|
||||||
|
).collect {
|
||||||
|
case EmittedFirrtlCircuitAnnotation(a) => a
|
||||||
|
case EmittedFirrtlModuleAnnotation(a) => a
|
||||||
|
}.map(_.value)
|
||||||
|
.mkString("")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
behavior of "retime library"
|
behavior of "retime library"
|
||||||
|
|
||||||
it should "pass simple retime module annotation" in {
|
it should "pass simple retime module annotation" in {
|
||||||
val gen = () => new RetimeModule()
|
val gen = () => new RetimeModule
|
||||||
val dir = uniqueDirName(gen, "RetimeModule")
|
val dir = uniqueDirName(gen, "RetimeModule")
|
||||||
|
|
||||||
Logger.makeScope(Seq.empty) {
|
Logger.makeScope(Seq.empty) {
|
||||||
val captor = new Logger.OutputCaptor
|
val captor = new Logger.OutputCaptor
|
||||||
Logger.setOutput(captor.printStream)
|
Logger.setOutput(captor.printStream)
|
||||||
val firrtl = (new ChiselStage).emitFirrtl(
|
|
||||||
new RetimeModule(),
|
// generate low firrtl
|
||||||
Array("-td", s"test_run_dir/$dir", "-foaf", s"test_run_dir/$dir/final", "--log-level", "info")
|
val firrtl = getLowFirrtl(gen,
|
||||||
)
|
Array("-td", s"test_run_dir/$dir", "-foaf", s"test_run_dir/$dir/final", "--log-level", "info"))
|
||||||
|
|
||||||
firrtl.nonEmpty should be(true)
|
firrtl.nonEmpty should be(true)
|
||||||
//Make sure we got the RetimeTransform scheduled
|
//Make sure we got the RetimeTransform scheduled
|
||||||
captor.getOutputAsString should include ("barstools.tapeout.transforms.retime.RetimeTransform")
|
captor.getOutputAsString should include ("barstools.tapeout.transforms.retime.RetimeTransform")
|
||||||
@@ -45,16 +59,17 @@ class RetimeSpec extends FlatSpec with Matchers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it should "pass simple retime instance annotation" in {
|
it should "pass simple retime instance annotation" in {
|
||||||
val gen = () => new RetimeInstance()
|
val gen = () => new RetimeInstance
|
||||||
val dir = uniqueDirName(gen, "RetimeInstance")
|
val dir = uniqueDirName(gen, "RetimeInstance")
|
||||||
|
|
||||||
Logger.makeScope(Seq.empty) {
|
Logger.makeScope(Seq.empty) {
|
||||||
val captor = new Logger.OutputCaptor
|
val captor = new Logger.OutputCaptor
|
||||||
Logger.setOutput(captor.printStream)
|
Logger.setOutput(captor.printStream)
|
||||||
val firrtl = (new ChiselStage).emitFirrtl(
|
|
||||||
new RetimeInstance(),
|
// generate low firrtl
|
||||||
Array("-td", s"test_run_dir/$dir", "-foaf", s"test_run_dir/$dir/final", "--log-level", "info")
|
val firrtl = getLowFirrtl(gen,
|
||||||
)
|
Array("-td", s"test_run_dir/$dir", "-foaf", s"test_run_dir/$dir/final", "--log-level", "info"))
|
||||||
|
|
||||||
firrtl.nonEmpty should be(true)
|
firrtl.nonEmpty should be(true)
|
||||||
//Make sure we got the RetimeTransform scheduled
|
//Make sure we got the RetimeTransform scheduled
|
||||||
captor.getOutputAsString should include ("barstools.tapeout.transforms.retime.RetimeTransform")
|
captor.getOutputAsString should include ("barstools.tapeout.transforms.retime.RetimeTransform")
|
||||||
|
|||||||
Reference in New Issue
Block a user