Update MacroCompiler for Chisel 3.4
This commit is contained in:
@@ -23,6 +23,14 @@ import Utils._
|
|||||||
|
|
||||||
case class MacroCompilerException(msg: String) extends Exception(msg)
|
case class MacroCompilerException(msg: String) extends Exception(msg)
|
||||||
|
|
||||||
|
// TODO The parameters could be unpacked here instead of keeping it in a serialized form
|
||||||
|
case class MacroCompilerAnnotation(content: String) extends NoTargetAnnotation {
|
||||||
|
import MacroCompilerAnnotation.Params
|
||||||
|
|
||||||
|
def params: Params = MacroCompilerUtil.objFromString(content).asInstanceOf[Params]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The MacroCompilerAnnotation to trigger the macro compiler.
|
* The MacroCompilerAnnotation to trigger the macro compiler.
|
||||||
* Note that this annotation does NOT actually target any modules for
|
* Note that this annotation does NOT actually target any modules for
|
||||||
@@ -32,7 +40,6 @@ case class MacroCompilerException(msg: String) extends Exception(msg)
|
|||||||
* To use, simply annotate the entire circuit itself with this annotation and
|
* To use, simply annotate the entire circuit itself with this annotation and
|
||||||
* include [[MacroCompilerTransform]].
|
* include [[MacroCompilerTransform]].
|
||||||
*
|
*
|
||||||
* TODO: make this into a "true" annotation?
|
|
||||||
*/
|
*/
|
||||||
object MacroCompilerAnnotation {
|
object MacroCompilerAnnotation {
|
||||||
/** Macro compiler mode. */
|
/** Macro compiler mode. */
|
||||||
@@ -92,16 +99,9 @@ object MacroCompilerAnnotation {
|
|||||||
* @param c Top-level circuit name (see class description)
|
* @param c Top-level circuit name (see class description)
|
||||||
* @param p Parameters (see above).
|
* @param p Parameters (see above).
|
||||||
*/
|
*/
|
||||||
def apply(c: String, p: Params): Annotation =
|
def apply(c: String, p: Params): MacroCompilerAnnotation =
|
||||||
Annotation(CircuitName(c), classOf[MacroCompilerTransform], MacroCompilerUtil.objToString(p))
|
MacroCompilerAnnotation(MacroCompilerUtil.objToString(p))
|
||||||
|
|
||||||
def unapply(a: Annotation) = a match {
|
|
||||||
case Annotation(CircuitName(c), t, serialized) if t == classOf[MacroCompilerTransform] => {
|
|
||||||
val p: Params = MacroCompilerUtil.objFromString(serialized).asInstanceOf[Params]
|
|
||||||
Some(c, p)
|
|
||||||
}
|
|
||||||
case _ => None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MacroCompilerPass(mems: Option[Seq[Macro]],
|
class MacroCompilerPass(mems: Option[Seq[Macro]],
|
||||||
@@ -656,9 +656,9 @@ class MacroCompilerTransform extends Transform {
|
|||||||
def inputForm = MidForm
|
def inputForm = MidForm
|
||||||
def outputForm = MidForm
|
def outputForm = MidForm
|
||||||
|
|
||||||
def execute(state: CircuitState) = getMyAnnotations(state) match {
|
def execute(state: CircuitState) = state.annotations match {
|
||||||
case Seq(MacroCompilerAnnotation(state.circuit.main,
|
case Seq(anno: MacroCompilerAnnotation) =>
|
||||||
MacroCompilerAnnotation.Params(memFile, memFileFormat, libFile, hammerIR, costMetric, mode, useCompiler, forceCompile, forceSynflops))) =>
|
val MacroCompilerAnnotation.Params(memFile, memFileFormat, libFile, hammerIR, costMetric, mode, useCompiler, forceCompile, forceSynflops) = anno.params
|
||||||
if (mode == MacroCompilerAnnotation.FallbackSynflops) {
|
if (mode == MacroCompilerAnnotation.FallbackSynflops) {
|
||||||
throw new UnsupportedOperationException("Not implemented yet")
|
throw new UnsupportedOperationException("Not implemented yet")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user