Attempt at checking for Fixed types
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
// See LICENSE for license details.
|
||||||
|
|
||||||
|
package barstools.tapeout.transforms
|
||||||
|
|
||||||
|
import firrtl._
|
||||||
|
import firrtl.annotations.{ModuleTarget, ReferenceTarget, SingleTargetAnnotation}
|
||||||
|
import firrtl.ir._
|
||||||
|
import firrtl.options.Dependency
|
||||||
|
import firrtl.passes.memlib.ReplSeqMem
|
||||||
|
import firrtl.stage.Forms
|
||||||
|
import firrtl.stage.{RunFirrtlTransformAnnotation}
|
||||||
|
import firrtl.stage.TransformManager.TransformDependency
|
||||||
|
|
||||||
|
class CheckForUnsupportedFirtoolTypes extends Transform with DependencyAPIMigration {
|
||||||
|
override def prerequisites: Seq[TransformDependency] = Forms.ChirrtlForm
|
||||||
|
override def optionalPrerequisites: Seq[TransformDependency] = Seq.empty
|
||||||
|
override def optionalPrerequisiteOf: Seq[TransformDependency] = Seq.empty
|
||||||
|
override def invalidates(a: Transform): Boolean = false
|
||||||
|
|
||||||
|
def run(state: CircuitState): Boolean = {
|
||||||
|
val c = state.circuit
|
||||||
|
|
||||||
|
//def checkFixed(t: Type): Unit = {
|
||||||
|
// println(s"checkFixed -> $t")
|
||||||
|
// t match {
|
||||||
|
// case FixedType(_, _) => {
|
||||||
|
// runLowering = true
|
||||||
|
// println(s"runLowering is $runLowering")
|
||||||
|
// }
|
||||||
|
// case _ => Unit
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
def onStmtType(s: Statement): Boolean = {
|
||||||
|
var runLowering = false
|
||||||
|
println(s"Entering onStmtType")
|
||||||
|
|
||||||
|
def recursive(s: Statement): Unit = {
|
||||||
|
s match {
|
||||||
|
case x: DefRegister => x.foreachType(_ => println(s"It works!"))
|
||||||
|
case x: DefWire => x.foreachType(_ => println(s"1 It works!"))
|
||||||
|
case x: DefNode => x.foreachType(_ => println(s"2 It works!"))
|
||||||
|
case x: DefMemory => x.foreachType(_ => println(s"3 It works!"))
|
||||||
|
case x: WDefInstance => x.foreachType(_ => println(s"4 It works!"))
|
||||||
|
case x: Connect => x.foreachType(_ => println(s"5 It works!"))
|
||||||
|
case x: PartialConnect => x.foreachType(_ => println(s"6 It works!"))
|
||||||
|
case x: Block => x.foreachStmt(recursive)
|
||||||
|
case x => x.foreachType(_ => println(s"Uh oh"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//s.foreachType(checkFixed)
|
||||||
|
s.foreachType(_ => println("Reached"))
|
||||||
|
|
||||||
|
runLowering
|
||||||
|
}
|
||||||
|
|
||||||
|
val runLoweringOverall = c.modules.map {
|
||||||
|
case m: ExtModule => false
|
||||||
|
case m: Module => onStmtType(m.body)
|
||||||
|
}
|
||||||
|
|
||||||
|
runLoweringOverall.reduce(_ || _)
|
||||||
|
}
|
||||||
|
|
||||||
|
def execute(state: CircuitState): CircuitState = {
|
||||||
|
val runLoweringAnnos = Seq(RunFirrtlTransformAnnotation(new MiddleFirrtlEmitter))
|
||||||
|
val doLowering = run(state)
|
||||||
|
println(s"DEBUG: Final doLowering -> $doLowering")
|
||||||
|
state.copy(annotations = state.annotations)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,13 +7,13 @@ 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
|
||||||
|
|
||||||
// Requires two phases, one to collect modules below synTop in the hierarchy
|
// Requires two phases, one to collect modules below synTop in the hierarchy
|
||||||
// and a second to remove those modules to generate the test harness
|
// and a second to remove those modules to generate the test harness
|
||||||
private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogging {
|
private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogging {
|
||||||
val outFir: Option[String] = annotations.collectFirst { case OutFirAnnotation(s) => s }
|
|
||||||
val outAnno: Option[String] = annotations.collectFirst { case OutAnnoAnnotation(s) => s }
|
val outAnno: Option[String] = annotations.collectFirst { case OutAnnoAnnotation(s) => s }
|
||||||
|
|
||||||
// Dump firrtl and annotation files
|
// Dump firrtl and annotation files
|
||||||
@@ -21,11 +21,6 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
|
|||||||
circuit: Circuit,
|
circuit: Circuit,
|
||||||
annotations: AnnotationSeq,
|
annotations: AnnotationSeq,
|
||||||
): Unit = {
|
): Unit = {
|
||||||
outFir.foreach { firPath =>
|
|
||||||
val outputFile = new java.io.PrintWriter(firPath)
|
|
||||||
outputFile.write(circuit.serialize)
|
|
||||||
outputFile.close()
|
|
||||||
}
|
|
||||||
outAnno.foreach { annoPath =>
|
outAnno.foreach { annoPath =>
|
||||||
val outputFile = new java.io.PrintWriter(annoPath)
|
val outputFile = new java.io.PrintWriter(annoPath)
|
||||||
outputFile.write(JsonProtocol.serialize(annotations.filter(_ match {
|
outputFile.write(JsonProtocol.serialize(annotations.filter(_ match {
|
||||||
@@ -34,16 +29,19 @@ private class GenerateTopAndHarness(annotations: AnnotationSeq) extends LazyLogg
|
|||||||
case _: EmittedAnnotation[_] => false
|
case _: EmittedAnnotation[_] => false
|
||||||
case _: FirrtlCircuitAnnotation => false
|
case _: FirrtlCircuitAnnotation => false
|
||||||
case _: OutAnnoAnnotation => false
|
case _: OutAnnoAnnotation => false
|
||||||
case _: OutFirAnnotation => false
|
|
||||||
case _ => true
|
case _ => true
|
||||||
})))
|
})))
|
||||||
outputFile.close()
|
outputFile.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Filter out blackbox dumping from this FIRRTL step, let CIRCT do it
|
||||||
|
|
||||||
// Top Generation
|
// Top Generation
|
||||||
def executeTop(): Unit = {
|
def executeTop(): Unit = {
|
||||||
val annos = new FirrtlStage().execute(Array.empty, annotations)
|
val annos = new FirrtlStage().execute(Array.empty, annotations) //++ Seq(
|
||||||
|
// RunFirrtlTransformAnnotation(Dependency[CheckForUnsupportedFirtoolTypes]
|
||||||
|
//)))
|
||||||
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
|
annos.collectFirst { case FirrtlCircuitAnnotation(circuit) => circuit } match {
|
||||||
case Some(circuit) =>
|
case Some(circuit) =>
|
||||||
dump(circuit, annos)
|
dump(circuit, annos)
|
||||||
|
|||||||
@@ -14,19 +14,6 @@ sealed trait TapeoutOption extends Unserializable {
|
|||||||
this: Annotation =>
|
this: Annotation =>
|
||||||
}
|
}
|
||||||
|
|
||||||
case class OutFirAnnotation(outFir: String) extends NoTargetAnnotation with TapeoutOption
|
|
||||||
|
|
||||||
object OutFirAnnotation extends HasShellOptions {
|
|
||||||
val options: Seq[ShellOption[_]] = Seq(
|
|
||||||
new ShellOption[String](
|
|
||||||
longOption = "out-fir-file",
|
|
||||||
shortOption = Some("off"),
|
|
||||||
toAnnotationSeq = (s: String) => Seq(OutFirAnnotation(s)),
|
|
||||||
helpText = "out-fir-file"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
case class OutAnnoAnnotation(outAnno: String) extends NoTargetAnnotation with TapeoutOption
|
case class OutAnnoAnnotation(outAnno: String) extends NoTargetAnnotation with TapeoutOption
|
||||||
|
|
||||||
object OutAnnoAnnotation extends HasShellOptions {
|
object OutAnnoAnnotation extends HasShellOptions {
|
||||||
@@ -46,7 +33,6 @@ trait TapeoutCli {
|
|||||||
|
|
||||||
Seq(
|
Seq(
|
||||||
OutAnnoAnnotation,
|
OutAnnoAnnotation,
|
||||||
OutFirAnnotation,
|
|
||||||
).foreach(_.addOptions(parser))
|
).foreach(_.addOptions(parser))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user