Skip to content

Commit 7aa9235

Browse files
GG: emit a fileset-grouped manifest
1 parent fab0048 commit 7aa9235

File tree

14 files changed

+114
-21
lines changed

14 files changed

+114
-21
lines changed

sim/firesim-lib/src/main/scala/passes/EC2F1Artefacts.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package firesim.passes
55
import firesim.util.{BuildStrategy}
66
import midas.{DesiredHostFrequency}
77
import midas.stage.phases.ConfigParametersAnnotation
8-
import midas.stage.GoldenGateOutputFileAnnotation
8+
import midas.stage.{GoldenGateOutputFileAnnotation, DownstreamFlows}
99

1010
import freechips.rocketchip.config.Parameters
1111

@@ -31,7 +31,7 @@ object EC2F1Artefacts extends Transform {
3131
set desired_host_frequency ${requestedFrequency}
3232
${buildStrategy.emitTcl}
3333
"""
34-
GoldenGateOutputFileAnnotation(constraints, fileSuffix = ".env.tcl")
34+
GoldenGateOutputFileAnnotation(constraints, fileSuffix = ".env.tcl", downstreamDependencies = Set(DownstreamFlows.BitstreamCompile))
3535
}
3636

3737
def execute(state: CircuitState): CircuitState = {

sim/midas/src/main/scala/midas/passes/AutoILATransform.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package midas.passes
44

55
import midas.{EnableAutoILA, ILADepthKey, ILAProbeTriggersKey}
66
import midas.targetutils.FirrtlFpgaDebugAnnotation
7-
import midas.stage.GoldenGateOutputFileAnnotation
7+
import midas.stage.{GoldenGateOutputFileAnnotation, DownstreamFlows}
88
import midas.stage.phases.ConfigParametersAnnotation
99

1010
import firrtl._
@@ -181,6 +181,7 @@ object AutoILATransform extends Transform with DependencyAPIMigration {
181181
| CONFIG.ALL_PROBE_SAME_MU_CNT {$probeTriggers}] [get_ips ${ilaBlackBoxName}]
182182
|""".stripMargin,
183183
s".${ilaBlackBoxName}.ipgen.tcl",
184+
downstreamDependencies = Set(DownstreamFlows.BitstreamCompile)
184185
)
185186

186187
val ilaWrapperModuleName = circuitNamespace.newName("ila_wrapper")

sim/midas/src/main/scala/midas/passes/SimulationMapping.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import freechips.rocketchip.diplomacy.LazyModule
2424

2525
import midas.core._
2626
import midas.platform.PlatformShim
27-
import midas.stage.{OutputFileBuilder, GoldenGateOutputFileAnnotation}
27+
import midas.stage.{OutputFileBuilder, GoldenGateOutputFileAnnotation, DownstreamFlows}
2828

2929
private[passes] class SimulationMapping(targetName: String) extends firrtl.Transform {
3030
def inputForm = LowForm
@@ -39,7 +39,9 @@ private[passes] class SimulationMapping(targetName: String) extends firrtl.Trans
3939
|// This contains target-specific preprocessor macro definitions,
4040
|// and encodes all required bridge metadata to instantiate bridge drivers.
4141
|""".stripMargin,
42-
fileSuffix = ".const.h")
42+
fileSuffix = ".const.h",
43+
downstreamDependencies = Set(DownstreamFlows.MetasimulatorCompile, DownstreamFlows.DriverCompile)
44+
)
4345
csb append "#ifndef __%s_H\n".format(targetName.toUpperCase)
4446
csb append "#define __%s_H\n".format(targetName.toUpperCase)
4547
c.genHeader(csb.getBuilder, targetName)
@@ -50,7 +52,9 @@ private[passes] class SimulationMapping(targetName: String) extends firrtl.Trans
5052
|// This file encodes variable width fields used in MIDAS-level simulation
5153
|// and is not used in FPGA compilation flows.
5254
|""".stripMargin,
53-
fileSuffix = ".const.vh")
55+
fileSuffix = ".const.vh",
56+
downstreamDependencies = Set(DownstreamFlows.MetasimulatorCompile),
57+
)
5458

5559
vsb append "`ifndef __%s_H\n".format(targetName.toUpperCase)
5660
vsb append "`define __%s_H\n".format(targetName.toUpperCase)

sim/midas/src/main/scala/midas/passes/WriteXDCFile.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import firrtl.stage.Forms
77
import firrtl.annotations._
88
import firrtl.analyses.InstanceKeyGraph
99

10-
import midas.stage.{GoldenGateFileEmission}
10+
import midas.stage.{GoldenGateFileEmission, DownstreamFlows}
1111
import midas.targetutils.xdc._
12+
import midas.stage.DownstreamFlows
1213

1314
/**
1415
* We could reuse [[GoldenGateOutputFileAnnotation]] here, but this makes it
@@ -17,6 +18,7 @@ import midas.targetutils.xdc._
1718
private[midas] case class XDCOutputAnnotation(fileBody: String, suffix: Option[String])
1819
extends NoTargetAnnotation with GoldenGateFileEmission {
1920
def getBytes = fileBody.getBytes
21+
def downstreamDependencies = Set(DownstreamFlows.BitstreamCompile)
2022
}
2123

2224
private[midas] object WriteXDCFile extends Transform with DependencyAPIMigration with XDCAnnotationConstants {

sim/midas/src/main/scala/midas/platform/F1Shim.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import freechips.rocketchip.util.HeterogeneousBag
1010

1111
import midas.core.{DMANastiKey}
1212
import midas.widgets.{AXI4Printf, CtrlNastiKey}
13-
import midas.stage.GoldenGateOutputFileAnnotation
13+
import midas.stage.{GoldenGateOutputFileAnnotation, DownstreamFlows}
1414
import midas.targetutils.xdc._
1515

1616
case object AXIDebugPrint extends Field[Boolean]
@@ -52,7 +52,8 @@ class F1Shim(implicit p: Parameters) extends PlatformShim {
5252
|`define USE_DDR_CHANNEL_B ${channelInUse(2)}
5353
|`define USE_DDR_CHANNEL_D ${channelInUse(3)}
5454
|""".stripMargin,
55-
fileSuffix = ".defines.vh")
55+
fileSuffix = ".defines.vh",
56+
downstreamDependencies = Set(DownstreamFlows.BitstreamCompile))
5657

5758
SpecifyXDCCircuitPaths(Some("firesim_top"), Some("WRAPPER_INST/CL/firesim_top"))
5859
}

sim/midas/src/main/scala/midas/platform/VitisShim.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import freechips.rocketchip.util.HeterogeneousBag
1111

1212
import midas.core.{DMANastiKey, HostMemChannelKey}
1313
import midas.widgets.{AXI4Printf, CtrlNastiKey}
14-
import midas.stage.GoldenGateOutputFileAnnotation
14+
import midas.stage.{GoldenGateOutputFileAnnotation, DownstreamFlows}
1515
import midas.platform.xilinx._
1616
import midas.targetutils.xdc._
1717

@@ -95,8 +95,13 @@ class VitisShim(implicit p: Parameters) extends PlatformShim {
9595
GoldenGateOutputFileAnnotation.annotateFromChisel(
9696
s"// Vitis Shim requires no dynamically generated macros \n",
9797
fileSuffix = ".defines.vh",
98+
downstreamDependencies = Set(DownstreamFlows.BitstreamCompile)
99+
)
100+
GoldenGateOutputFileAnnotation.annotateFromChisel(
101+
s"# Currently unused",
102+
".env.tcl",
103+
downstreamDependencies = Set(DownstreamFlows.BitstreamCompile)
98104
)
99-
GoldenGateOutputFileAnnotation.annotateFromChisel(s"# Currenty unused", ".env.tcl")
100105
// We don't need to provide paths because
101106
// 1) The Shim module is the top-level of the kernel
102107
// 2) Implementation constraints are scoped to the kernel level in our vitis flow

sim/midas/src/main/scala/midas/platform/xilinx/AXI4Crossing.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import chisel3._
44
import chisel3.util._
55
import freechips.rocketchip.amba.axi4._
66
import midas.stage.GoldenGateOutputFileAnnotation
7+
import midas.stage.DownstreamFlows
78

89
/** An AXI4 bundle definition whose names should match the interfaces exposed on Xilinx IP blocks. aresetn and clock are
910
* omitted, and no user fields are provided.
@@ -209,5 +210,6 @@ class AXI4ClockConverter(
209210
| [get_ips ${desiredName}]
210211
|""".stripMargin,
211212
s".${desiredName}.ipgen.tcl",
213+
Set(DownstreamFlows.BitstreamCompile)
212214
)
213215
}

sim/midas/src/main/scala/midas/platform/xilinx/Clocking.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package midas.platform.xilinx
22

33
import chisel3._
4-
import midas.stage.GoldenGateOutputFileAnnotation
4+
import midas.stage.{DownstreamFlows, GoldenGateOutputFileAnnotation}
55

66
class MMCM(inputFreqMHz: Double, outputFreqMHz: Double, override val desiredName: String) extends BlackBox {
77
val io = IO(new Bundle {
@@ -27,5 +27,6 @@ class MMCM(inputFreqMHz: Double, outputFreqMHz: Double, override val desiredName
2727
| [get_ips ${desiredName}]
2828
|""".stripMargin,
2929
s".${desiredName}.ipgen.tcl",
30+
Set(DownstreamFlows.BitstreamCompile),
3031
)
3132
}

sim/midas/src/main/scala/midas/stage/GoldenGateFileEmission.scala

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,31 @@
22

33
package midas.stage
44

5+
import firrtl.AnnotationSeq
56
import firrtl.annotations.{NoTargetAnnotation, Annotation}
67
import firrtl.options.{CustomFileEmission}
78

89
import chisel3.experimental.{annotate, ChiselAnnotation}
910

11+
object DownstreamFlows {
12+
sealed trait FlowType
13+
case object BitstreamCompile extends FlowType
14+
case object MetasimulatorCompile extends FlowType
15+
case object DriverCompile extends FlowType
16+
case object RuntimeDeployment extends FlowType
17+
val allFlows = Seq(BitstreamCompile, MetasimulatorCompile, RuntimeDeployment, DriverCompile)
18+
19+
val fileManifestSuffix = ".file-manifest.json"
20+
val emittedVerilogKey = "EmittedVerilogFiles"
21+
val unclassifiedKey = "UnclassifiedFiles"
22+
}
23+
1024
trait GoldenGateFileEmission extends CustomFileEmission { this: Annotation =>
1125
override def baseFileName(annotations: firrtl.AnnotationSeq) = {
1226
annotations.collectFirst{ case OutputBaseFilenameAnnotation(name) => name }.get
1327
}
28+
/** Used to build a manifest that organizes output files based on what downstream flows consume it. **/
29+
def downstreamDependencies: Set[DownstreamFlows.FlowType]
1430
}
1531

1632
/**
@@ -20,7 +36,10 @@ trait GoldenGateFileEmission extends CustomFileEmission { this: Annotation =>
2036
* @param fileSuffix The string to append to base output file name
2137
*
2238
*/
23-
case class GoldenGateOutputFileAnnotation(body: String, fileSuffix: String)
39+
case class GoldenGateOutputFileAnnotation(
40+
body: String,
41+
fileSuffix: String,
42+
downstreamDependencies: Set[DownstreamFlows.FlowType])
2443
extends NoTargetAnnotation with GoldenGateFileEmission {
2544
def suffix = Some(fileSuffix)
2645
def getBytes = body.getBytes
@@ -30,17 +49,17 @@ object GoldenGateOutputFileAnnotation {
3049
/**
3150
* Sugar to add a new output file from a chisel source (e.g., in a bridge, platform shim)
3251
*/
33-
def annotateFromChisel(body: String, fileSuffix: String): Unit = {
34-
annotate(new ChiselAnnotation { def toFirrtl = GoldenGateOutputFileAnnotation(body, fileSuffix) })
52+
def annotateFromChisel(body: String, fileSuffix: String, downstreamDependencies: Set[DownstreamFlows.FlowType]): Unit = {
53+
annotate(new ChiselAnnotation { def toFirrtl = GoldenGateOutputFileAnnotation(body, fileSuffix, downstreamDependencies) })
3554
}
3655
}
3756

3857
/**
3958
* Wraps a StringBuilder to incrementally build up an output file annotation.
4059
*/
41-
class OutputFileBuilder(header: String, fileSuffix: String) {
60+
class OutputFileBuilder(header: String, fileSuffix: String, downstreamDependencies: Set[DownstreamFlows.FlowType]) {
4261
private val sb = new StringBuilder(header)
4362
def getBuilder = sb
4463
def append(str: String) = sb.append(str)
45-
def toAnnotation = GoldenGateOutputFileAnnotation(sb.toString, fileSuffix)
64+
def toAnnotation = GoldenGateOutputFileAnnotation(sb.toString, fileSuffix, downstreamDependencies)
4665
}

sim/midas/src/main/scala/midas/stage/GoldenGateStage.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class GoldenGateStage extends Stage with PreservesAll[Phase] {
2121
new firrtl.stage.phases.AddDefaults,
2222
new firrtl.stage.phases.Checks,
2323
new firrtl.stage.phases.AddCircuit,
24-
new midas.stage.GoldenGateCompilerPhase)
24+
new midas.stage.GoldenGateCompilerPhase,
25+
midas.stage.phases.GenerateOutputFileManifest
26+
)
2527
.map(DeletedWrapper(_))
2628

2729

0 commit comments

Comments
 (0)