[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>
This commit is contained in:
Schuyler Eldridge 2024-10-24 18:09:09 -04:00
parent b173a2745b
commit ad28fd2291
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
4 changed files with 61 additions and 3 deletions

View File

@ -163,10 +163,18 @@ public:
/// within) the design.
bool anyInstanceInDesign(igraph::ModuleOpInterface op);
/// Return true if all instances of this module are within the design (or
/// transitively withiin) the design.
/// Return true if all instances of this module are within (or transitively
/// withiin) the design.
bool allInstancesInDesign(igraph::ModuleOpInterface op);
/// Return true if any instance of this module is within (or transitively
/// within) the effective design
bool anyInstanceInEffectiveDesign(igraph::ModuleOpInterface op);
/// Return true if all instances of this module are within (or transitively
/// withiin) the effective design.
bool allInstancesInEffectiveDesign(igraph::ModuleOpInterface op);
private:
/// Stores circuit-level attributes.
CircuitAttributes circuitAttributes = {/*dut=*/nullptr,

View File

@ -238,3 +238,11 @@ bool InstanceInfo::allInstancesInDesign(igraph::ModuleOpInterface op) {
auto inDesign = getModuleAttributes(op).inDesign;
return inDesign.isConstant() && inDesign.getConstant();
}
bool InstanceInfo::anyInstanceInEffectiveDesign(igraph::ModuleOpInterface op) {
return (!hasDut() && !allInstancesUnderLayer(op)) || anyInstanceInDesign(op);
}
bool InstanceInfo::allInstancesInEffectiveDesign(igraph::ModuleOpInterface op) {
return (!hasDut() && !anyInstanceUnderLayer(op)) || allInstancesInDesign(op);
}

View File

@ -247,7 +247,11 @@ static void printModuleInfo(igraph::ModuleOpInterface op,
<< " anyInstanceInDesign: " << iInfo.anyInstanceInDesign(op)
<< "\n"
<< " allInstancesInDesign: " << iInfo.allInstancesInDesign(op)
<< "\n";
<< "\n"
<< " anyInstanceInEffectiveDesign: "
<< iInfo.anyInstanceInEffectiveDesign(op) << "\n"
<< " allInstancesInEffectiveDesign: "
<< iInfo.allInstancesInEffectiveDesign(op) << "\n";
}
void FIRRTLInstanceInfoPass::runOnOperation() {

View File

@ -178,6 +178,8 @@ firrtl.circuit "Foo" {
// CHECK-NEXT: allInstancesUnderLayer: false
// CHECK-NEXT: anyInstanceInDesign: false
// CHECK-NEXT: allInstancesInDesign: false
// CHECK-NEXT: anyInstanceInEffectiveDesign: false
// CHECK-NEXT: allInstancesInEffectiveDesign: false
firrtl.module private @Baz() {}
// CHECK: @Bar
// CHECK-NEXT: isDut: true
@ -189,6 +191,8 @@ firrtl.circuit "Foo" {
// CHECK-NEXT: allInstancesUnderLayer: false
// CHECK-NEXT: anyInstanceInDesign: true
// CHECK-NEXT: allInstancesInDesign: true
// CHECK-NEXT: anyInstanceInEffectiveDesign: true
// CHECK-NEXT: allInstancesInEffectiveDesign: true
firrtl.module @Bar() attributes {
annotations = [
{
@ -210,6 +214,40 @@ firrtl.circuit "Foo" {
// CHECK-NEXT: allInstancesUnderLayer: false
// CHECK-NEXT: anyInstanceInDesign: false
// CHECK-NEXT: allInstancesInDesign: false
// CHECK-NEXT: anyInstanceInEffectiveDesign: false
// CHECK-NEXT: allInstancesInEffectiveDesign: false
firrtl.module @Foo() {
firrtl.instance dut interesting_name @Bar()
firrtl.instance foo interesting_name @Baz()
}
}
// -----
// Test that "inDesing" works properly for the effective DUT.
firrtl.circuit "Foo" {
firrtl.layer @A bind {}
// CHECK: @Baz
// CHECK: anyInstanceInDesign: false
// CHECK-NEXT: allInstancesInDesign: false
// CHECK-NEXT: anyInstanceInEffectiveDesign: true
// CHECK-NEXT: allInstancesInEffectiveDesign: false
firrtl.module private @Baz() {}
// CHECK: @Bar
// CHECK: anyInstanceInDesign: false
// CHECK-NEXT: allInstancesInDesign: false
// CHECK-NEXT: anyInstanceInEffectiveDesign: true
// CHECK-NEXT: allInstancesInEffectiveDesign: true
firrtl.module @Bar() {
firrtl.layerblock @A {
firrtl.instance baz @Baz()
}
}
// CHECK: @Foo
// CHECK: anyInstanceInDesign: false
// CHECK-NEXT: allInstancesInDesign: false
// CHECK-NEXT: anyInstanceInEffectiveDesign: true
// CHECK-NEXT: allInstancesInEffectiveDesign: true
firrtl.module @Foo() {
firrtl.instance dut interesting_name @Bar()
firrtl.instance foo interesting_name @Baz()