Commit Graph

15 Commits

Author SHA1 Message Date
Mike Urbach 9775df2cb4
[FIRRTL] Support MarkDUTAnnotation on extmodules. (#8001)
In some cases, the "DUT" might be an extmodule from a separate
compilation unit, and we still want all the old legacy "is DUT" logic
to work. To support this, we need applyDUTAnno to allow the annotation
to be applied to an extmodule, and we need extractDUT and its users to
work with FModuleLikes instead of FModuleOp. The only other thing that
appears to be using this "is DUT" logic is the newer InstanceInfo
helper, which already works with igraph::ModuleOpInterfaces and seems
to work fine with extmodules as the "DUT".
2024-12-17 13:11:34 -07:00
Schuyler Eldridge fb2343d626
[FIRRTL] "lowerToBind" is layer for InstanceInfo
Fix a bug in the `InstanceInfo` analysis where the analysis would be
different after running the `LowerLayers` pass.  The problem here is that
`LowerLayers` converts a layer to a bound module.  This could then cause
the new bound module to be in the design when it is not.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-11-21 00:36:35 -05:00
Schuyler Eldridge dd6e69f6cd
[FIRRTL] Improve GC InstanceInfo tests, NFC
Add a test of the `InstanceInfo` for a circuit which contains a Grand
Central companion, but does not contain a design-under-test.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-11-20 23:10:12 -05:00
Schuyler Eldridge 4e1927441b
[FIRRTL] Add GC Companion to InstanceInfo Analysis
Change the InstanceInfo analysis to record Grand Central Companions as
being _not_ in the design.  These are functionally the same as layers
except that this is represented as a module as opposed to an operation
with a block.  This is done as part of updating passes to use the
`InstanceInfo` analysis as opposed to relying on their own, individual
computations of what modules are in or not in the "design".

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-11-20 21:23:02 -05:00
Schuyler Eldridge 478fd3e400
[FIRRTL] Test uninstantiated is eff. design, NFC
Add a test to check that the FIRRTL `InstanceInfo` analysis treates an
uninstantiated module as being part of the "effective" design.  This is
also tested in tests of the `CreateSiFiveMetadata` pass.  However, it is
better to test this directly.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-11-20 19:51:38 -05:00
Schuyler Eldridge dc6f39c07b
[FIRRTL] Fix incorrect test comment, NFC
Fix a typo in two InstanceInfo tests.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-11-19 19:49:53 -05:00
Schuyler Eldridge ad28fd2291
[FIRRTL] Add "effective" design to Instance Info
Expand the API of the InstanceInfo analysis to include queries for if
something is in the "effective" design.  This is equivalent to querying if
something is not under a layer.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-10-24 18:43:42 -04:00
Schuyler Eldridge 4d03e88ab6
[FIRRTL] Add "inDesign" to InstanceInfo Analysis
Extend the existing InstanceInfo analysis to track information about if a
module is in the "design".  The design is defined is everything that is or
is under the design-under-test, but is not in a layer.  I.e., this
excludes things that are in layers.

This is added because it is not possible to compute this using the
existing information about something being under the DUT or under a layer.
A module could have mixed instantiation under the DUT and mixed
instantiation under a layer, yet not be in the design.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-10-24 00:17:07 -04:00
Schuyler Eldridge bcee76272e
[FIRRTL] Fix InstanceInfo top-is-DUT bug
Fix a bug where the internal `underDut` member was not correctly asserted
if the top module is the DUT.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-10-21 18:35:42 -04:00
Schuyler Eldridge fa3de1e7d2
[FIRRTL] Simplify InstanceInfo function names
Change the functions for the `InstanceInfo` analysis to use "any" instead
of "atLeastOne".  The former is far simpler and better aligns with the
"all" member functions.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-09-24 19:28:14 -04:00
Schuyler Eldridge 52c9d4c388
[FIRRTL] Add "effective" functions to InstanceInfo
Add two new functions for computing if a module is under the "effective"
design-under-test (DUT):

  - atLeastOneInstanceUnderEffectiveDut
  - allInstancesUnderEffectiveDut

These functions are very simple.  However, their use comes up in a number
of passes and this makes _reading_ those passes more straightforward.
I.e., it's quicker to grok what is going on with these functions than with
`!hasDut() || atLeastOneInstanceUnderEffectiveDut()`.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-09-24 19:27:52 -04:00
Schuyler Eldridge bf7aad754e
[FIRRTL] Add features, cleanup InstanceInfo (again) (#7618)
[FIRRTL] Add features, cleanup InstanceInfo (again)

This fixes problems with a commit [[1]] that was reverted [[2]].  The commit
message below is unchanged.

Add a number of new features to FIRRTL's `InstanceInfo` analysis.  These
changes were made after downstream efforts (uncommitted work) to use this
in the `AddSeqMemPorts` pass.  These new features include:

  - `hasDut` to check if a circuit has a design-under-test
  - `getDut` to get the design-under-test if it exists
  - `getEffectiveDut` to get the "effective" design-under-test
  - `isEffectiveDut` to check if a module is the "effective"
     design-under-test

The "effective" design-under-test (DUT) is a weird artifact of how some
SFC-derived passes have historically worked.  If a circuit has no
DUT (indicated by a circuit which contains no module annotated with a
`MarkDUTAnnotation`), then some passes will treat the top module as if it
were the DUT.  This "effective" DUT concept shows up in `AddSeqMemPorts`,
`GrandCentral`, and other passes.  For now, enshrine the _computation_ of
this in the `InstanceInfo` analysis to avoid having to scatter logic for
computing this across serverl passes.

Widen the accepted type of parameters that can be passed to `InstanceInfo`
member functions from `FModuleOp` to `igraph::ModuleOpInterface`.  This
already works without modifications and makes these member functions much
more usable.

[1]: 7e9cedd07
[2]: 2683f6772

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-09-24 10:59:17 -04:00
Schuyler Eldridge 2683f6772a
Revert "[FIRRTL] Add features, cleanup InstanceInfo"
This reverts commit 7e9cedd07b.  This commit
is showing problems with short integration tests hanging.  I'm reverting
it temporarily to prevent any issues from leaking into main.
2024-09-24 00:13:56 -04:00
Schuyler Eldridge 7e9cedd07b
[FIRRTL] Add features, cleanup InstanceInfo
Add a number of new features to FIRRTL's `InstanceInfo` analysis.  These
changes were made after downstream efforts (uncommitted work) to use this
in the `AddSeqMemPorts` pass.  These new features include:

  - `hasDut` to check if a circuit has a design-under-test
  - `getDut` to get the design-under-test if it exists
  - `getEffectiveDut` to get the "effective" design-under-test
  - `isEffectiveDut` to check if a module is the "effective"
     design-under-test

The "effective" design-under-test (DUT) is a weird artifact of how some
SFC-derived passes have historically worked.  If a circuit has no
DUT (indicated by a circuit which contains no module annotated with a
`MarkDUTAnnotation`), then some passes will treat the top module as if it
were the DUT.  This "effective" DUT concept shows up in `AddSeqMemPorts`,
`GrandCentral`, and other passes.  For now, enshrine the _computation_ of
this in the `InstanceInfo` analysis to avoid having to scatter logic for
computing this across serverl passes.

Widen the accepted type of parameters that can be passed to `InstanceInfo`
member functions from `FModuleOp` to `igraph::ModuleOpInterface`.  This
already works without modifications and makes these member functions much
more usable.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-09-23 21:07:58 -04:00
Schuyler Eldridge fe34e15e41
[FIRRTL] Add InstanceInfo Analysis (#7612)
Add a new InstanceInfo analysis.  This analysis provides common
information which can be computed from a single walk of the InstanceGraph.
The idea behind this is that there are a large amount of common
information that different passes want to compute which all follows this
same walk (and therefore has the same algorithmic complexity to compute
it).  Move all this information into a single, common analysis.

This analysis currently enables O(1) queries of if something is the DUT,
is instantiated under the DUT, or is instantiated under a layer.  More
queries can be added as they are identified.

This new analysis naturally depends on the InstanceGraph analysis.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-09-23 12:50:46 -04:00