Skip to content

Commit

Permalink
Rename localPrefixAppliesToSelf to localModulePrefixAppliesToSelf
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoenig committed Nov 26, 2024
1 parent 31d6768 commit 0269cd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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

0 comments on commit 0269cd1

Please sign in to comment.