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

Add optional group API #3541

Merged
merged 1 commit into from
Sep 29, 2023
Merged

Add optional group API #3541

merged 1 commit into from
Sep 29, 2023

Conversation

seldridge
Copy link
Member

@seldridge seldridge commented Sep 21, 2023

Add optional groups.

Example

Chisel:

object A extends group.Declaration(group.Convention.Bind) {
  object B extends group.Declaration(group.Convention.Bind)
}

class Foo extends RawModule {
  val a = IO(Input(Bool()))

  group(A) {
    val w = WireInit(a)
    dontTouch(w)
    group(A.B) {
      val x = WireInit(w)
      dontTouch(x)
    }
  }

}

Output FIRRTL:

FIRRTL version 3.2.0
circuit Foo :%[[
  {
    "class":"firrtl.transforms.DontTouchAnnotation",
    "target":"~Foo|Foo>w"
  },
  {
    "class":"firrtl.transforms.DontTouchAnnotation",
    "target":"~Foo|Foo>x"
  }
]]
  declgroup A, bind :
    declgroup B, bind :
  module Foo :
    input a : UInt<1>

    group A:
      wire w : UInt<1>
      connect w, a
      group B:
        wire x : UInt<1>
        connect x, w

Output Verilog:

// Generated by CIRCT firtool-1.56.1-32-g4da6a4d83
module Foo_A_B(
  input _w
);

  wire x = _w;
endmodule

module Foo_A(
  input _a
);

  wire w = _a;
  wire w_probe = w;
endmodule

module Foo(
  input a
);

endmodule


// ----- 8< ----- FILE "groups_Foo_A_B.sv" ----- 8< -----

// Generated by CIRCT firtool-1.56.1-32-g4da6a4d83
`include "groups_Foo_A.sv"
`ifndef groups_Foo_A_B
`define groups_Foo_A_B
bind Foo Foo_A_B foo_A_B (
  ._w (Foo.foo_A.w_probe)
);
`endif

// ----- 8< ----- FILE "groups_Foo_A.sv" ----- 8< -----

// Generated by CIRCT firtool-1.56.1-32-g4da6a4d83
`ifndef groups_Foo_A
`define groups_Foo_A
bind Foo Foo_A foo_A (
  ._a (a)
);
`endif

Release Notes

Add optional groups. This is a feature that can be used to add optional verification functionality, e.g., asserts or debug code, that does not affect the main design. These groups are lowered to FIRRTL Optional Groups (see: chipsalliance/firrtl-spec#108) with the "bind" convention.

@seldridge seldridge added the Feature New feature, will be included in release notes label Sep 27, 2023
@seldridge seldridge marked this pull request as ready for review September 27, 2023 17:46
@seldridge
Copy link
Member Author

The documentation will fail until firtool has the LowerGroups pass on by default. This is the case for firtool top-of-tree, but not on a published release, yet.

@lsteveol
Copy link

Hey Schuyler, thanks for working on this. Do you guys have an idea when this will make it into a Chisel v6 release (v6.0.0-M4 I assume)?

@seldridge
Copy link
Member Author

Hey Schuyler, thanks for working on this. Do you guys have an idea when this will make it into a Chisel v6 release (v6.0.0-M4 I assume)?

That's a @jackkoenig question. I think we're probably ready for a true 6.0 release and not a milestone at this point.

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.

This is awesome, nice work Schuyler! I've included some suggestions, but overall looks really good.

core/src/main/scala/chisel3/Util.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/internal/Builder.scala Outdated Show resolved Hide resolved
@jackkoenig jackkoenig added this to the 6.0 milestone Sep 29, 2023
@seldridge seldridge force-pushed the dev/seldridge/groups branch 3 times, most recently from b31aaa5 to cadb03f Compare September 29, 2023 22:31
@seldridge seldridge enabled auto-merge (squash) September 29, 2023 22:54
Add support for optional groups.  These are groups of statements with
optional functionality.  The primary use case is intended for verification
code to "extract" such code into bound modules.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge merged commit b3e3383 into main Sep 29, 2023
@seldridge seldridge deleted the dev/seldridge/groups branch September 29, 2023 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants