Remove all passes again | rename GenerateTopAndHarness to GenerateModelStageMain
This commit is contained in:
@@ -10,11 +10,8 @@ import firrtl.stage.{FirrtlCircuitAnnotation, FirrtlStage, OutputFileAnnotation,
|
|||||||
import firrtl.transforms.BlackBoxResourceFileNameAnno
|
import firrtl.transforms.BlackBoxResourceFileNameAnno
|
||||||
import logger.LazyLogging
|
import logger.LazyLogging
|
||||||
|
|
||||||
// Requires two phases, one to collect modules below synTop in the hierarchy
|
private class GenerateModelStageMain(annotations: AnnotationSeq) extends LazyLogging {
|
||||||
// and a second to remove those modules to generate the test harness
|
|
||||||
private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogging {
|
|
||||||
val outAnno: Option[String] = annotations.collectFirst { case OutAnnoAnnotation(s) => s }
|
val outAnno: Option[String] = annotations.collectFirst { case OutAnnoAnnotation(s) => s }
|
||||||
val harnessConf: Option[String] = annotations.collectFirst { case HarnessConfAnnotation(h) => h }
|
|
||||||
|
|
||||||
val annoFiles: List[String] = annotations.flatMap {
|
val annoFiles: List[String] = annotations.flatMap {
|
||||||
case InputAnnotationFileAnnotation(f) => Some(f)
|
case InputAnnotationFileAnnotation(f) => Some(f)
|
||||||
@@ -40,10 +37,7 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Filter out blackbox dumping from this FIRRTL step, let CIRCT do it
|
def executeStageMain(): Unit = {
|
||||||
|
|
||||||
// Top Generation
|
|
||||||
def executeTop(): Unit = {
|
|
||||||
val annos = new FirrtlStage().execute(Array.empty, annotations)
|
val annos = new FirrtlStage().execute(Array.empty, annotations)
|
||||||
|
|
||||||
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
|
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
|
||||||
@@ -53,31 +47,6 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
|
|||||||
throw new Exception(s"executeTop failed while executing FIRRTL!\n")
|
throw new Exception(s"executeTop failed while executing FIRRTL!\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top and harness generation
|
|
||||||
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
|
|
||||||
.filterNot(_.isInstanceOf[OutputFileAnnotation])
|
|
||||||
.map {
|
|
||||||
case ReplSeqMemAnnotation(i, _) => ReplSeqMemAnnotation(i, harnessConf.get)
|
|
||||||
case anno => anno
|
|
||||||
}
|
|
||||||
|
|
||||||
val annos = new FirrtlStage().execute(Array.empty, generatorAnnotations)
|
|
||||||
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
|
|
||||||
case Some(circuit) =>
|
|
||||||
dumpAnnos(annos)
|
|
||||||
case _ =>
|
|
||||||
throw new Exception(s"executeTop failed while executing FIRRTL!\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object GenerateTop extends StageMain(new TapeoutStage(doHarness = false))
|
object GenerateModelStageMain extends StageMain(new TapeoutStage())
|
||||||
object GenerateTopAndHarness extends StageMain(new TapeoutStage(doHarness = true))
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package barstools.tapeout.transforms.stage
|
package barstools.tapeout.transforms.stage
|
||||||
|
|
||||||
import barstools.tapeout.transforms.GenerateTopAndHarness
|
import barstools.tapeout.transforms.GenerateModelStageMain
|
||||||
import chisel3.stage.ChiselCli
|
import chisel3.stage.ChiselCli
|
||||||
import firrtl.AnnotationSeq
|
import firrtl.AnnotationSeq
|
||||||
import firrtl.annotations.{Annotation, NoTargetAnnotation}
|
import firrtl.annotations.{Annotation, NoTargetAnnotation}
|
||||||
@@ -27,41 +27,22 @@ object OutAnnoAnnotation extends HasShellOptions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class HarnessConfAnnotation(harnessConf: String) extends NoTargetAnnotation with TapeoutOption
|
|
||||||
|
|
||||||
object HarnessConfAnnotation extends HasShellOptions {
|
|
||||||
val options: Seq[ShellOption[_]] = Seq(
|
|
||||||
new ShellOption[String](
|
|
||||||
longOption = "harness-conf",
|
|
||||||
shortOption = Some("thconf"),
|
|
||||||
toAnnotationSeq = (s: String) => Seq(HarnessConfAnnotation(s)),
|
|
||||||
helpText = "use this to set the harness conf file location"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
trait TapeoutCli {
|
trait TapeoutCli {
|
||||||
this: Shell =>
|
this: Shell =>
|
||||||
parser.note("Tapeout specific options")
|
parser.note("Tapeout specific options")
|
||||||
|
|
||||||
Seq(
|
Seq(
|
||||||
OutAnnoAnnotation,
|
OutAnnoAnnotation,
|
||||||
HarnessConfAnnotation
|
|
||||||
).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 stageMain = new GenerateModelStageMain(annotations)
|
||||||
|
stageMain.executeStageMain()
|
||||||
if (doHarness) {
|
|
||||||
generator.executeTopAndHarness()
|
|
||||||
} else {
|
|
||||||
generator.executeTop()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
annotations
|
annotations
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user