Skip to content

Fail boring into module with endIOCreation set #4925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/src/main/scala/chisel3/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,12 @@ package experimental {
private[chisel3] def createSecretIO[A <: Data](data: => A)(implicit sourceInfo: SourceInfo): A = {
val iodef = data
requireIsChiselType(iodef, "io type")
require(!isFullyClosed, "Cannot create secret ports if module is fully closed")
if (isFullyClosed)
Builder.error(s"Cannot bore or tap into fully closed ${this.name} (from ${Builder.currentModule.get.name})")
if (!isIOCreationAllowed)
Builder.error(
s"Cannot bore or tap into ${this.name} (from ${Builder.currentModule.get.name}) if IO creation is not allowed"
)

Module.assignCompatDir(iodef)
iodef.bind(SecretPortBinding(this), iodef.specifiedDirection)
Expand Down
17 changes: 17 additions & 0 deletions src/test/scala-2/chiselTests/BoringUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -689,4 +689,21 @@ class BoringUtilsSpec extends AnyFlatSpec with Matchers with LogUtils with FileC
|""".stripMargin
)
}
it should "fail if endIOCreation is set" in {

class Bar extends RawModule {
val baz = Module(new Baz)
BoringUtils.bore(baz.c)
}

class Baz extends RawModule {
val c = Wire(Property[Int]())
endIOCreation()
}

val e = intercept[Exception] {
circt.stage.ChiselStage.emitCHIRRTL(new Bar, args)
}
e.getMessage should include("Cannot bore or tap into Baz (from Bar) if IO creation is not allowed")
}
}
Loading