Revert "Remove executeTop & make everything to execute"

This reverts commit 5af7f21648.
This commit is contained in:
joey0320
2022-12-28 13:09:27 -08:00
parent 5af7f21648
commit 723bab78b9
2 changed files with 32 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ import firrtl.ir._
import firrtl.options.{Dependency, InputAnnotationFileAnnotation, StageMain} import firrtl.options.{Dependency, InputAnnotationFileAnnotation, StageMain}
import firrtl.passes.memlib.ReplSeqMemAnnotation import firrtl.passes.memlib.ReplSeqMemAnnotation
import firrtl.stage.{FirrtlCircuitAnnotation, FirrtlStage, OutputFileAnnotation, RunFirrtlTransformAnnotation} import firrtl.stage.{FirrtlCircuitAnnotation, FirrtlStage, OutputFileAnnotation, RunFirrtlTransformAnnotation}
import firrtl.passes.{ConvertFixedToSInt}
import firrtl.transforms.BlackBoxResourceFileNameAnno import firrtl.transforms.BlackBoxResourceFileNameAnno
import logger.LazyLogging import logger.LazyLogging
@@ -22,8 +23,8 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
}.toList }.toList
// Dump firrtl and annotation files // Dump firrtl and annotation files
// Reads global params "outAnno" protected def dump(
protected def dumpAnnos( circuit: Circuit,
annotations: AnnotationSeq annotations: AnnotationSeq
): Unit = { ): Unit = {
outAnno.foreach { annoPath => outAnno.foreach { annoPath =>
@@ -42,8 +43,26 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
// TODO: Filter out blackbox dumping from this FIRRTL step, let CIRCT do it // TODO: Filter out blackbox dumping from this FIRRTL step, let CIRCT do it
// Top Generation
def executeTop(): Unit = {
val annos = new FirrtlStage().execute(Array.empty, annotations)
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
case Some(circuit) =>
dump(circuit, annos)
case _ =>
throw new Exception(s"executeTop failed while executing FIRRTL!\n")
}
}
// Top and harness generation // Top and harness generation
def execute(): Unit = { def executeTopAndHarness(): Unit = {
executeTop()
// For harness run, change some firrtlOptions (below) for harness phase
// customTransforms: setup harness transforms, add AvoidExtModuleCollisions
// outputFileNameOverride: change to harnessOutput
// conf file must change to harnessConf by mapping annotations
val generatorAnnotations = annotations val generatorAnnotations = annotations
.filterNot(_.isInstanceOf[OutputFileAnnotation]) .filterNot(_.isInstanceOf[OutputFileAnnotation])
.map { .map {
@@ -54,11 +73,12 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
val annos = new FirrtlStage().execute(Array.empty, generatorAnnotations) val annos = new FirrtlStage().execute(Array.empty, generatorAnnotations)
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match { annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
case Some(circuit) => case Some(circuit) =>
dumpAnnos(annos) dump(circuit, annos)
case _ => case _ =>
throw new Exception(s"executeTop failed while executing FIRRTL!\n") throw new Exception(s"executeTop failed while executing FIRRTL!\n")
} }
} }
} }
object GenerateTopAndHarness extends StageMain(new TapeoutStage()) object GenerateTop extends StageMain(new TapeoutStage(doHarness = false))
object GenerateTopAndHarness extends StageMain(new TapeoutStage(doHarness = true))

View File

@@ -50,13 +50,18 @@ trait TapeoutCli {
).foreach(_.addOptions(parser)) ).foreach(_.addOptions(parser))
} }
class TapeoutStage() extends Stage { class TapeoutStage(doHarness: Boolean) extends Stage {
override val shell: Shell = new Shell(applicationName = "tapeout") with TapeoutCli with ChiselCli with FirrtlCli override val shell: Shell = new Shell(applicationName = "tapeout") with TapeoutCli with ChiselCli with FirrtlCli
override def run(annotations: AnnotationSeq): AnnotationSeq = { override def run(annotations: AnnotationSeq): AnnotationSeq = {
Logger.makeScope(annotations) { Logger.makeScope(annotations) {
val generator = new GenerateTopAndHarness(annotations) val generator = new GenerateTopAndHarness(annotations)
generator.execute()
if (doHarness) {
generator.executeTopAndHarness()
} else {
generator.executeTop()
}
} }
annotations annotations
} }