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

Relax legality of defines, align with FIRRTL spec #3857

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

seldridge
Copy link
Member

Change the checking logic for the legality of a probe define destination to align with FIRRTL specification language introduced recently 1. Specifically, this enforces the following sentence:

An operation that "writes" to a probe must be in a region whose layer color is enabled when the probe's layer color is enabled.

Previously, Chisel was more restrictive and would only allow writing to a probe whose color was the same as the layer block you are currently in. However, as has been worked out in CIRCT and elsewhere, it is fine to drive a probe from any region that is enabled when the probe is also enabled.

Practically, this gets some Chisel code passing that was legal by a FIRRTL compiler, but Chisel was refusing to generate it.

CC: @rwy7

Release Notes

Align Chisel's checks of define destinations with the FIRRTL specification. Previously, Chisel was too strict.

Change the checking logic for the legality of a probe define destination
to align with FIRRTL specification language introduced recently [1].
Specifically, this enforces the following sentence:

> An operation that "writes" to a probe must be in a region whose layer
> color is enabled when the probe's layer color is enabled.

Previously, Chisel was more restrictive and would only allow writing to a
probe whose color was the same as the layer block you are currently in.
However, as has been worked out in CIRCT and elsewhere, it is fine to
drive a probe from any region that is enabled when the probe is also
enabled.

Practically, this gets some Chisel code passing that was legal by a FIRRTL
compiler, but Chisel was refusing to generate it.

CC: @rwy7

[1]: chipsalliance/firrtl-spec@673aa08

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge added the Bugfix Fixes a bug, will be included in release notes label Feb 23, 2024
layer.block(A.B) {
define(b, ProbeValue(in))
define(y, ProbeValue(e))
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will produce illegal FIRRTL as the probes are defined more than once. However, it makes the test terser to write it this way.

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully grok some of the logic but the tests look good

core/src/main/scala/chisel3/internal/package.scala Outdated Show resolved Hide resolved
val a = Wire(Bool())
// Without this enable, this circuit is illegal because `C` is NOT enabled
// when `A` is enabled. Cf. tests checking errors of this later.
layer.enable(A)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is enable the global enable for this Module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's indicating that this module has layer A enabled. This will emit:

public module Foo enablelayer A :
  ; ...

If there is more than one enable, then those will get appended, e.g., layer.enable(A); layer.enable(B) will be:

public module Foo enablelayer A enablelayer B :
  ; ...

@seldridge seldridge enabled auto-merge (squash) February 23, 2024 05:31
@seldridge seldridge merged commit 3573d11 into main Feb 23, 2024
13 checks passed
@seldridge seldridge deleted the dev/seldridge/relax-define-checks branch February 23, 2024 05:41
sequencer pushed a commit that referenced this pull request Feb 28, 2024
Change the checking logic for the legality of a probe define destination
to align with FIRRTL specification language introduced recently [1].
Specifically, this enforces the following sentence:

> An operation that "writes" to a probe must be in a region whose layer
> color is enabled when the probe's layer color is enabled.

Previously, Chisel was more restrictive and would only allow writing to a
probe whose color was the same as the layer block you are currently in.
However, as has been worked out in CIRCT and elsewhere, it is fine to
drive a probe from any region that is enabled when the probe is also
enabled.

Practically, this gets some Chisel code passing that was legal by a FIRRTL
compiler, but Chisel was refusing to generate it.

CC: @rwy7

[1]: chipsalliance/firrtl-spec@673aa08

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Fixes a bug, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants