-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fab0048
commit 7aa9235
Showing
14 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
sim/midas/src/main/scala/midas/stage/phases/GenerateOutputFileManifest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// See LICENSE for license details. | ||
|
||
package midas.stage.phases | ||
|
||
import midas.stage.{GoldenGateFileEmission, GoldenGateOutputFileAnnotation, DownstreamFlows} | ||
import firrtl.{AnnotationSeq, EmittedVerilogCircuitAnnotation, EmittedVerilogModuleAnnotation} | ||
import firrtl.options.{TargetDirAnnotation, Phase, Dependency, CustomFileEmission} | ||
|
||
import org.json4s.native.Serialization | ||
|
||
import collection.immutable.ListMap | ||
|
||
/** | ||
* Extracts a TargetDir-relative path to an EmittedFile. | ||
*/ | ||
object TargetDirRelativePath { | ||
def apply(emittedAnno: CustomFileEmission, annotations: AnnotationSeq): String = { | ||
val targetDir = annotations.collectFirst { case TargetDirAnnotation(name) => name }.get | ||
emittedAnno.filename(annotations).getAbsolutePath.stripPrefix(s"${targetDir}/") | ||
} | ||
} | ||
|
||
/** Emits an manifest file that sorts all known output files into groups based on | ||
* where those files will be used. See [[midas.stage.DownstreamFlows]]. | ||
*/ | ||
object GenerateOutputFileManifest extends Phase { | ||
|
||
override val prerequisites = Seq(Dependency[midas.stage.GoldenGateCompilerPhase]) | ||
|
||
def transform(annotations: AnnotationSeq): AnnotationSeq = { | ||
val ggOutputFiles = annotations.collect { case anno: GoldenGateFileEmission => anno } | ||
|
||
// Group GG annotations based on the flows in which they are used. | ||
val unclassifiedFiles = "Unclassified" -> ggOutputFiles.filter(_.downstreamDependencies.isEmpty) | ||
val classifiedFiles = DownstreamFlows.allFlows.map { tpe => | ||
tpe.toString -> ggOutputFiles.filter(_.downstreamDependencies.contains(tpe)) | ||
} | ||
|
||
val ggFileTuples = for ((flowType, fileAnnos) <- (classifiedFiles :+ unclassifiedFiles)) yield { | ||
flowType -> fileAnnos.map { anno => TargetDirRelativePath(anno, annotations) } | ||
} | ||
|
||
// Capture all verilog files (GG does not control emission of these) and put them in a seperate field | ||
val verilogCircuitPath = annotations.collectFirst { case anno: EmittedVerilogCircuitAnnotation => TargetDirRelativePath(anno, annotations) } | ||
val verilogModulesPath = annotations.collect { case anno: EmittedVerilogModuleAnnotation => TargetDirRelativePath(anno, annotations) } | ||
val emittedVerilogTuple = (DownstreamFlows.emittedVerilogKey -> (verilogCircuitPath ++: verilogModulesPath).toSeq ) | ||
|
||
|
||
implicit val formats = org.json4s.DefaultFormats | ||
val body = Serialization.writePretty(ListMap((ggFileTuples :+ emittedVerilogTuple):_*)) | ||
GoldenGateOutputFileAnnotation(body, DownstreamFlows.fileManifestSuffix, Set()) +: annotations | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters