llvm / circt

Circuit IR Compilers and Tools

Home Page:https://circt.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FIRRTL] Generate Layer Collateral For All Public Modules

seldridge opened this issue · comments

Currently, firtool is not compliant with the FIRRTL specification around how public modules and layers work. Every layer module is supposed to generate a bind file. However, currently only one bind file is generated.

Consider the following:

FIRRTL version 4.0.0
circuit Foo: %[[
  {"class": "firrtl.transforms.DontTouchAnnotation", "target": "~Foo|Foo>a"},
  {"class": "firrtl.transforms.DontTouchAnnotation", "target": "~Foo|Bar>a"}
]]

  layer A, bind:

  public module Bar:

    layerblock A:
      node a = UInt<1>(0)

  public module Foo:

    layerblock A:
      node a = UInt<1>(0)

This compiles to:

// Generated by CIRCT firtool-1.66.0-7-g902ad4e1b-dirty
module Bar_A();
  wire a = 1'h0;
endmodule

module Bar();
endmodule

module Foo_A();
  wire a = 1'h0;
endmodule

module Foo();
endmodule


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

// Generated by CIRCT firtool-1.66.0-7-g902ad4e1b-dirty
`ifndef layers_Foo_A
`define layers_Foo_A
bind Bar Bar_A bar_A ();
bind Foo Foo_A foo_A ();
`endif // layers_Foo_A

The second bind file, layers_Bar_A.sv, is missing.