Skip to content

Commit 121c08e

Browse files
seldridgechiselbot
authored andcommitted
[core] Switch to FIRRTL 6.0.0 inline layer ABI (#4982)
The forthcoming FIRRTL 6.0.0 makes some changes to the ABI for inline layers [[1]]. Specifically, the module name was dropped and the delimiter _after_ "layer" was changed from '_' to '$'. E.g., what was previously: ``` layer_Foo$A ``` Is now: ``` layer$A ``` Propagate this change into Chisel by updating the way that inline layers self-report their ABI. This is needed to keep Chisel compatible with CIRCT 1.126.0. [1]: chipsalliance/firrtl-spec@b88817b Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent b4ce851 commit 121c08e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

core/src/main/scala/chisel3/Layer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object layer {
5252

5353
/** Return the macro identifier that should be defined. */
5454
def toMacroIdentifier(layer: Layer, circuitName: String): String = {
55-
(s"layer_$circuitName" +: layer.layerSeq.map(_.name)).mkString("$")
55+
("layer" +: layer.layerSeq.map(_.name)).mkString("$")
5656
}
5757

5858
}

docs/src/explanations/layers.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ only a child layer's file will automatically include its parent layer's file.
208208

209209
Inline layers have their layer blocks guarded with conditional compilation
210210
directives. To enable an inline layer, set a preprocessor define when compiling
211-
your design. The preprocessor define begins with `layer_` and then includes the
212-
circuit name and all layer names delimited with dollar signs (`$`). Parent
213-
extract layer names appear in the macro.
211+
your design. The preprocessor define begins with `layer$` and then includes the
212+
all layer names delimited with dollar signs (`$`). Parent extract layer names
213+
appear in the macro.
214214

215215
For example, for module `Foo` declared above, this will be sensitive to three
216216
macros, one for each inline layer:
217217

218218
```
219-
layer_Foo$B
220-
layer_Foo$C$E
221-
layer_Foo$C$E$F
219+
layer$B
220+
layer$C$E
221+
layer$C$E$F
222222
```
223223

224224
## User-defined Layers
@@ -487,7 +487,7 @@ the bind file, `layers-Foo-A.sv`.
487487

488488
The design below is the same as the previous example, but uses an inline layer.
489489
Based on the FIRRTL ABI, we can expect that the body of the layer block will be
490-
guarded by an `` `ifdef `` sensitive to the preprocessor macro `layer_Foo$A`.
490+
guarded by an `` `ifdef `` sensitive to the preprocessor macro `layer$A`.
491491

492492
```scala mdoc:reset:silent
493493
import chisel3._
@@ -593,7 +593,7 @@ following filenames. One file is created for each extract layer:
593593
1. `layers_Foo_Verification_Assert.sv`
594594

595595
Additionally, the resulting SystemVerilog will be sensitive to the preprocessor
596-
define `layer_Foo$Verification$Debug` due to the one inline layer we added.
596+
define `layer$Verification$Debug` due to the one inline layer we added.
597597

598598
A user can then include any combination of these files in their design to
599599
include the optional functionality described by the `Verification` or

src/test/scala-2/chiselTests/LayerSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ class LayerSpec extends AnyFlatSpec with Matchers with FileCheck {
572572
|CHECK: module Foo_A(
573573
|CHECK-NOT: `ifdef
574574
|CHECK: foo: assert property
575-
|CHECK: `ifdef layer_Foo$A$B
575+
|CHECK: `ifdef layer$A$B
576576
|CHECK-NEXT: bar: assert property
577-
|CHECK-NEXT: `ifdef layer_Foo$A$B$C
577+
|CHECK-NEXT: `ifdef layer$A$B$C
578578
|CHECK-NEXT: baz: assert property
579579
|CHECK-NEXT: `endif
580580
|CHECK-NEXT: `endif""".stripMargin

0 commit comments

Comments
 (0)