Closed seldridge closed 5 months ago
Filelists are also not really lists of files. They are newline delimited command line arguments provided to tools (see verilator -F).
Is this true for other tools? It looks like it is true for VCS.
I'm not that thrilled about exposing an instance graph per-se.
With layers, though not instance choice, the file list can be inclusive (no name conflicts arise from including more files than you need).
I also don't think single-file emission is something we care about. I was inclined to hide it.
I discussed this with @darthscsi offline last week. The conclusion was that it would be better to not go the route of filelists or manifests. Instead, we should move in the direction of a flat output structure. Any movement of files into directories (which is still needed) can be handled by FIRRTL compilers in a post-pass. If this post-pass needs information that would be contained in a filelist/manifest, then it is the responsibility of the FIRRTL compiler to provide access to this. For CIRCT, this can be via an API that queries the MLIR instance graph. Other compilers may choose to implement a filelist or manifest if they choose.
With the recent addition of optionality to FIRRTL with layers and instance choices, a problem is brewing as it relates to knowing what files to include for a given compilation.
An example is helpful for the purposes of this discussion. Consider the following circuit which has one degree of optionality through
layer A
. The use ofDontTouchAnnotation
s exist to ensure that modules and optionality are not removed:Currently, there are three ways that such a circuit could be compiled:
Note that it is reasonable that there are other strategies that could be employed here that are not one of two extremes. I.e., private modules can be flexibly emitted anywhere and it is reasonable that they could be emitted in a way that minimizes the number of distinct files.
Using single-file output, we get the following. Comments with "FILE" indicate what file the following block of SystemVerilog code is placed:
When compiling with one-file-per-module output, you get the following files:
This creates problems for downstream consumers of this. Specifically:
Foo
, the ABI specifies that a fileFoo.sv
must exist. However, it does not say anything about where the other files are. The ABI is intentionally quiet about this for private modules and for layer enable files to allow for the compiler to place them anywhere it wants.Foo
with layerA
enabled, the ABI says how to enable the layer, but not that that will include all optional files. (Should it?)A partial solution to these problems exists in the FIRRTL spec today through filelists on public modules. The FIRRTL spec states that each public module must provide a filelist for all modules it instantiates. It follows that such filelists must be emitted for every degree of optionality in a circuit---each layer or instance choice becomes another filelist. This is viewed as not desirable (due to the duplication it creates). Filelists are also not really lists of files. They are newline delimited command line arguments provided to tools (see
verilator -F
). (This means they are actually lists of positional arguments.) It is natural that these may want to expand to include actual arguments in the filelists. However, this will run into problems where while filelists are closer to being universally accepted by tools, the arguments to them are not.As an alternative to this, and proposed by several others, it may be useful to add the notion of a FIRRTL manifest to the ABI. Such a manifest would provide information that would allow a user to answer the questions raised above and to, through lightweight tooling, create a directory structure that a user wants and generate command line arguments to drive downstream tools.
A manifest should include at least the following information:
As an example of this, for the single-file compilation, such a manifest could be:
For one-file-per-module emission, the manifest would be:
With one of these manifests, aforementioned lightweight tooling can generate a filelist based on arguments to the tool. E.g., a hypothetical tool invocation could be
manifest-tool filelist manifest_Foo.json --top-module Foo --layer A
and return one of the following filelists for the different manifests above:Related Efforts
This is very similar to existing non-standard files emitted by the SFC and the MFC. Cf.
dut_hier.json
andtb_hier.json
which are JSON representations of the instance hierarchy under, respectively, the design-under-test and the testbench.This is also likely similar to existing industry standard formats like IP-XACT or similar efforts like DuH.