Remove executeTop & make everything to execute

This commit is contained in:
joey0320
2022-12-28 11:12:18 -08:00
parent 13e2bb92ab
commit 5af7f21648
2 changed files with 7 additions and 32 deletions

View File

@@ -7,7 +7,6 @@ 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
@@ -23,8 +22,8 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
}.toList }.toList
// Dump firrtl and annotation files // Dump firrtl and annotation files
protected def dump( // Reads global params "outAnno"
circuit: Circuit, protected def dumpAnnos(
annotations: AnnotationSeq annotations: AnnotationSeq
): Unit = { ): Unit = {
outAnno.foreach { annoPath => outAnno.foreach { annoPath =>
@@ -43,26 +42,8 @@ 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 executeTopAndHarness(): Unit = { def execute(): 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 {
@@ -73,12 +54,11 @@ 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) =>
dump(circuit, annos) dumpAnnos(annos)
case _ => case _ =>
throw new Exception(s"executeTop failed while executing FIRRTL!\n") throw new Exception(s"executeTop failed while executing FIRRTL!\n")
} }
} }
} }
object GenerateTop extends StageMain(new TapeoutStage(doHarness = false)) object GenerateTopAndHarness extends StageMain(new TapeoutStage())
object GenerateTopAndHarness extends StageMain(new TapeoutStage(doHarness = true))

View File

@@ -50,18 +50,13 @@ trait TapeoutCli {
).foreach(_.addOptions(parser)) ).foreach(_.addOptions(parser))
} }
class TapeoutStage(doHarness: Boolean) extends Stage { class TapeoutStage() 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
} }