Skip to content

Commit

Permalink
Allow LogPerfControl to be reused if necessary (OpenXiangShan#261)
Browse files Browse the repository at this point in the history
Since chipsalliance/chisel#3753, the users
are able to check whether a Data is visible in the current context.
To avoid a large number of duplicated LogPerfControl modules, we
allow it to be reused when some previous instance is still visible
to the current context.

Call `LogPerfControl.reuse(DataMirror.isVisible)` instead of pure
`apply()` to allow the reuse.

However, this is still a temporary workaround. In the future, we
need some clean methods to extract the simulation environment and
access these signals during simulation, possibly via XMR.
  • Loading branch information
poemonsense authored Jan 20, 2024
1 parent ab7820f commit 08260b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/scala/common/LogPerfControl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LogPerfControl extends Bundle {
val dump = Bool()
}

class LogPerfHelper extends BlackBox with HasBlackBoxInline {
private class LogPerfHelper extends BlackBox with HasBlackBoxInline {
val io = IO(Output(new LogPerfControl))

val verilog =
Expand Down Expand Up @@ -57,4 +57,9 @@ object LogPerfControl {
def apply(): LogPerfControl = {
Module(new LogPerfHelper).io
}

private val instances = scala.collection.mutable.ListBuffer.empty[LogPerfControl]
def reuse(checker: LogPerfControl => Boolean): LogPerfControl = {
instances.find(checker).getOrElse(instances.addOne(apply()).last)
}
}

0 comments on commit 08260b4

Please sign in to comment.