Skip to content

Commit

Permalink
[test] Add experimental ChiselStage extensions
Browse files Browse the repository at this point in the history
Add a utility that can be used to replace
`ChiselRunners.elaborateAndGetModule`.  This is intentionally private to
the `chiselTests.experimental` package as I don't want this method to be
used outside of some of the more exotic D/I or DataView APIs which want to
use this.  This also is not something that makes sense (right now) to
expose on `ChiselStage` publicly.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
  • Loading branch information
seldridge committed Feb 26, 2025
1 parent a946470 commit b6cd32e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/scala-2/chiselTests/experimental/ExtensionMethods.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: Apache-2.0

package chiselTests.experimental

import chisel3.RawModule
import circt.stage.ChiselStage

/** Object that contains various extension methods for all the [[experimental]] package. */
private[experimental] object ExtensionMethods {

/** Extension methods for [[ChiselStage]]. */
implicit class ChiselStageHelpers(obj: ChiselStage.type) {

/** Construct a module and return it. This has a _very_ narrow use case and
* should not be generally used for writing tests of Chisel.
*/
def getModule[A <: RawModule](gen: => A): A = {
var res: Any = null
obj.convert {
res = gen
res.asInstanceOf[A]
}
res.asInstanceOf[A]
}

}

}

0 comments on commit b6cd32e

Please sign in to comment.