summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authormergify[bot]2022-07-06 00:28:02 +0000
committerGitHub2022-07-06 00:28:02 +0000
commit2b977a74293a49e9e2a5d960a6a9c07df22430ce (patch)
tree320e9ee49d336fa18e63a04bf79dfcf6dbb1856d /core/src/main
parenta931c5e218014c659bbff7d0dec74c882281d9a0 (diff)
Implement trait for Chisel compiler to name arbitrary non-Data types (#2610) (#2617)
Co-authored-by: Jack Koenig <koenig@sifive.com> Co-authored-by: Megan Wachs <megan@sifive.com> (cherry picked from commit 3ab34cddd8b87c22d5fc31020f10ddb2f1990d51) Co-authored-by: Jared Barocsi <82000041+jared-barocsi@users.noreply.github.com>
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/scala/chisel3/experimental/package.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/src/main/scala/chisel3/experimental/package.scala b/core/src/main/scala/chisel3/experimental/package.scala
index 9b9c83f4..47b79099 100644
--- a/core/src/main/scala/chisel3/experimental/package.scala
+++ b/core/src/main/scala/chisel3/experimental/package.scala
@@ -162,6 +162,36 @@ package object experimental {
*/
trait NoChiselNamePrefix
+ /** Generate prefixes from values of this type in the Chisel compiler plugin
+ *
+ * Users can mixin this trait to tell the Chisel compiler plugin to include the names of
+ * vals of this type when generating prefixes for naming `Data` and `Mem` instances.
+ * This is generally useful whenever creating a `class` that contains `Data`, `Mem`,
+ * or `Module` instances but does not itself extend `Data` or `Module`.
+ *
+ * @see See [[https://www.chisel-lang.org/chisel3/docs/explanations/naming.html the compiler plugin documentation]] for more information on this process.
+ *
+ * @example {{{
+ * import chisel3._
+ * import chisel3.experimental.AffectsChiselPrefix
+ *
+ * class MyModule extends Module {
+ * // Note: This contains a Data but is not a named component itself
+ * class NotAData extends AffectsChiselPrefix {
+ * val value = Wire(Bool())
+ * }
+ *
+ * // Name with AffectsChiselPrefix: "nonData_value"
+ * // Name without AffectsChiselPrefix: "value"
+ * val nonData = new NotAData
+ *
+ * // Name with AffectsChiselPrefix: "nonData2_value"
+ * // Name without AffectsChiselPrefix: "value_1"
+ * val nonData2 = new NotAData
+ * }
+ */
+ trait AffectsChiselPrefix
+
object BundleLiterals {
implicit class AddBundleLiteralConstructor[T <: Record](x: T) {
def Lit(elems: (T => (Data, Data))*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {