Skip to content
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

Rename localPrefixAppliesToSelf to localModulePrefixAppliesToSelf #4528

Merged
merged 1 commit into from
Nov 26, 2024
Merged
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
8 changes: 4 additions & 4 deletions core/src/main/scala/chisel3/ModuleImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -936,22 +936,22 @@ package experimental {
case Some(c) => getRef.fullName(c)
}

/** Additional module prefix, applies to this module if defined (unless localModulePrefix is false) and all children.
/** Additional module prefix, applies to this module if defined (unless localModulePrefixAppliesToSelf is false) and all children.
*/
def localModulePrefix: Option[String] = None

/** Should [[localModulePrefix]] apply to this module? Defaults to true.
*
* Users should override to false if [[localModulePrefix]] should apply only to children.
*/
def localPrefixAppliesToSelf: Boolean = true
def localModulePrefixAppliesToSelf: Boolean = true

/** The resolved module prefix used for this Module.
*
* Includes [[localModulePrefix]] if defined and if [[localPrefixAppliesToSelf]] is true.
* Includes [[localModulePrefix]] if defined and if [[localModulePrefixAppliesToSelf]] is true.
*/
final val modulePrefix: String =
withModulePrefix(localModulePrefix.filter(_ => localPrefixAppliesToSelf).getOrElse("")) {
withModulePrefix(localModulePrefix.filter(_ => localModulePrefixAppliesToSelf).getOrElse("")) {
Builder.getModulePrefix
}

Expand Down
6 changes: 3 additions & 3 deletions docs/src/explanations/moduleprefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ class Sub extends Module {

This results in two module definitions: `Foo_Top` and `Foo_Sub`.

You can also override `localPrefixAppliesToSelf` to `false` to only apply the prefix to the children.
You can also override `localModulePrefixAppliesToSelf` to `false` to only apply the prefix to the children.

```scala mdoc:silent:reset
import chisel3._

class Top extends Module {
override def localModulePrefix = Some("Foo")
override def localPrefixAppliesToSelf = false
override def localModulePrefixAppliesToSelf = false
val sub = Module(new Sub)
}

Expand Down Expand Up @@ -124,7 +124,7 @@ class Top extends Module {
class Mid extends Module {
// You can mix withModulePrefix and localModulePrefix.
override def localModulePrefix = Some("Bar")
override def localPrefixAppliesToSelf = false
override def localModulePrefixAppliesToSelf = false
val sub = Module(new Sub)
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/chiselTests/ModulePrefixSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ class ModulePrefixSpec extends ChiselFlatSpec with ChiselRunners with Utils with
matchesAndOmits(chirrtl)(lines: _*)()
}

it should "set the prefix for a Module's children but not the Module itself if localPrefixAppliesToSelf is false" in {
it should "set the prefix for a Module's children but not the Module itself if localModulePrefixAppliesToSelf is false" in {

class Foo extends RawModule
class Bar extends RawModule

class Top extends RawModule {
override def localModulePrefix = Some("Prefix")
override def localPrefixAppliesToSelf = false
override def localModulePrefixAppliesToSelf = false
val foo = Module(new Foo)
val bar = Module(new Bar)
}
Expand Down