[firechip] Instantiate multiple TracerV bridges

This commit is contained in:
David Biancolin
2020-01-17 17:56:37 -08:00
parent 524299bd39
commit 3fbc074b01
3 changed files with 27 additions and 27 deletions

View File

@@ -61,9 +61,7 @@ class WithFASEDBridge extends RegisterBridgeBinder({
}).toSeq }).toSeq
}) })
class WithTracerVBridge extends RegisterBridgeBinder({ class WithTracerVBridge extends Config((_,_,_) => { case InstantiateTracerVBridges => true })
case target: HasTraceIOImp => TracerVBridge(target.traceIO)(target.p)
})
class WithTraceGenBridge extends RegisterBridgeBinder({ class WithTraceGenBridge extends RegisterBridgeBinder({
case target: HasTraceGenTilesModuleImp => case target: HasTraceGenTilesModuleImp =>

View File

@@ -12,7 +12,7 @@ import freechips.rocketchip.util._
import freechips.rocketchip.tile.RocketTile import freechips.rocketchip.tile.RocketTile
import freechips.rocketchip.subsystem._ import freechips.rocketchip.subsystem._
import freechips.rocketchip.rocket.TracedInstruction import freechips.rocketchip.rocket.TracedInstruction
import firesim.bridges.{TraceOutputTop, DeclockedTracedInstruction} import firesim.bridges.{TracerVBridge}
import firesim.util.{HasAdditionalClocks, FireSimClockKey} import firesim.util.{HasAdditionalClocks, FireSimClockKey}
import midas.targetutils.MemModelAnnotation import midas.targetutils.MemModelAnnotation
@@ -22,34 +22,33 @@ import boom.common.BoomTile
/* Wires out tile trace ports to the top; and wraps them in a Bundle that the /* Wires out tile trace ports to the top; and wraps them in a Bundle that the
* TracerV bridge can match on. * TracerV bridge can match on.
*/ */
object PrintTracePort extends Field[Boolean](false) case object PrintTracePort extends Field[Boolean](false)
case object InstantiateTracerVBridges extends Field[Boolean](false)
trait HasTraceIO { trait HasTraceIO {
this: HasTiles => this: HasTiles =>
val module: HasTraceIOImp val module: HasTraceIOImp
// Bind all the trace nodes to a BB; we'll use this to generate the IO in the imp // Bind all the trace nodes to a BB; we'll use this to generate the IO in the imp
val traceNexus = BundleBridgeNexus[Vec[TracedInstruction]] val tileTraceNodes = tiles.map({ tile =>
val tileTraceNodes = tiles.map(tile => tile.traceNode) val node = BundleBridgeSink[Vec[TracedInstruction]]
tileTraceNodes foreach { traceNexus := _ } node := tile.traceNode
node
})
} }
trait HasTraceIOImp extends LazyModuleImp { trait HasTraceIOImp extends LazyModuleImp {
val outer: HasTraceIO val outer: HasTraceIO
outer.tileTraceNodes.zipWithIndex.foreach({ case (node, idx) =>
val traceIO = IO(Output(new TraceOutputTop( if (p(InstantiateTracerVBridges)) {
DeclockedTracedInstruction.fromNode(outer.traceNexus.in)))) val b = TracerVBridge(node.bundle)
(traceIO.traces zip outer.traceNexus.in).foreach({ case (port, (tileTrace, _)) => if (p(PrintTracePort)) {
port := DeclockedTracedInstruction.fromVec(tileTrace) val traceprint = WireDefault(0.U(512.W))
traceprint := b.io.traces.asUInt
printf(s"TRACEPORT ${idx}: %x\n", traceprint)
}
}
}) })
traceIO.clock := clock
// Enabled to test TracerV trace capture
if (p(PrintTracePort)) {
val traceprint = Wire(UInt(512.W))
traceprint := Cat(traceIO.traces.map(_.asUInt))
printf("TRACEPORT: %x\n", traceprint)
}
} }
trait CanHaveMultiCycleRegfileImp { trait CanHaveMultiCycleRegfileImp {

View File

@@ -106,14 +106,17 @@ abstract class FireSimTestSuite(
def diffTracelog(verilatedLog: String) { def diffTracelog(verilatedLog: String) {
behavior of "captured instruction trace" behavior of "captured instruction trace"
it should s"match the chisel printf in ${verilatedLog}" in { it should s"match the chisel printf in ${verilatedLog}" in {
def getLines(file: File, dropLines: Int = 0): Seq[String] = { def getLines(file: File, dropLines: Int = 0, prefixFilter: String = ""): Seq[String] = {
val lines = Source.fromFile(file).getLines.toList val lines = Source.fromFile(file).getLines.toList
lines.filter(_.startsWith("TRACEPORT")).drop(dropLines) lines.filter(_.startsWith(prefixFilter))
.drop(dropLines)
.map(_.stripPrefix(prefixFilter))
} }
val resetLength = 51 val resetLength = 51
val verilatedOutput = getLines(new File(outDir, s"/${verilatedLog}")) val verilatedOutput = getLines(new File(outDir, s"/${verilatedLog}"), prefixFilter = "TRACEPORT 0: ")
val synthPrintOutput = getLines(new File(genDir, s"/TRACEFILE"), resetLength) val synthPrintOutput = getLines(new File(genDir, s"/TRACEFILE"), dropLines = resetLength)
assert(math.abs(verilatedOutput.size - synthPrintOutput.size) <= 1, "Outputs differ in length") assert(math.abs(verilatedOutput.size - synthPrintOutput.size) <= 1,
s"\nPrintf Length: ${verilatedOutput.size}, Trace Length: ${synthPrintOutput.size}")
assert(verilatedOutput.nonEmpty) assert(verilatedOutput.nonEmpty)
for ( (vPrint, sPrint) <- verilatedOutput.zip(synthPrintOutput) ) { for ( (vPrint, sPrint) <- verilatedOutput.zip(synthPrintOutput) ) {
assert(vPrint == sPrint) assert(vPrint == sPrint)
@@ -125,7 +128,7 @@ abstract class FireSimTestSuite(
mkdirs mkdirs
elaborate elaborate
generateTestSuiteMakefrags generateTestSuiteMakefrags
runTest("verilator", "rv64ui-p-simple", false, Seq(s"""EXTRA_SIM_ARGS=+trace-test-output0""")) runTest("verilator", "rv64ui-p-simple", false, Seq(s"""EXTRA_SIM_ARGS=+trace-humanreadable0"""))
diffTracelog("rv64ui-p-simple.out") diffTracelog("rv64ui-p-simple.out")
runSuite("verilator")(benchmarks) runSuite("verilator")(benchmarks)
runSuite("verilator")(FastBlockdevTests) runSuite("verilator")(FastBlockdevTests)