-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some issues in the LayerBlockOp verifier
When checking the ops under a layerblock: - When checking if a child op refers to a value defined outside the layerblock, we need to check if the layerblock is an ancestor of the value's definition, not the more strict "direct parent of definition" check. This check better handles blocks (such as when ops) nested under a layerblock. - When checking if an child op's operand is valid, we shouldn't early-return, which would disables all remaining verification for the op. - Explicitly allow ref.define op to define destinations outside the layerblock op. It is the only connect-like op that is allowed to do so. - Use WalkResult::interrupt() to signal failure.
- Loading branch information
Showing
2 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// RUN: circt-opt %s | FileCheck %s | ||
|
||
firrtl.circuit "Test" { | ||
firrtl.module @Test() {} | ||
|
||
// CHECK-LABEL: firrtl.layer @A bind | ||
firrtl.layer @A bind {} | ||
|
||
// CHECK-LABEL: firrtl.module @WhenUnderLayer(in %test: !firrtl.uint<1>) { | ||
// CHECK-NEXT: %c0_ui1 = firrtl.constant 0 : !firrtl.uint<1> | ||
// CHECK-NEXT: firrtl.layerblock @A { | ||
// CHECK-NEXT: %w = firrtl.wire : !firrtl.uint<1> | ||
// CHECK-NEXT: firrtl.when %test : !firrtl.uint<1> { | ||
// CHECK-NEXT: firrtl.strictconnect %w, %c0_ui1 : !firrtl.uint<1> | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
firrtl.module @WhenUnderLayer(in %test: !firrtl.uint<1>) { | ||
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1> | ||
firrtl.layerblock @A { | ||
%w = firrtl.wire : !firrtl.uint<1> | ||
firrtl.when %test : !firrtl.uint<1> { | ||
firrtl.strictconnect %w, %c0_ui1 : !firrtl.uint<1> | ||
} | ||
} | ||
} | ||
|
||
// CHECK-LABEL: firrtl.module @ProbeEscapeLayer(out %p: !firrtl.probe<uint<1>, @A>) { | ||
// CHECK-NEXT: %c0_ui1 = firrtl.constant 0 : !firrtl.uint<1> | ||
// CHECK-NEXT: firrtl.layerblock @A { | ||
// CHECK-NEXT: %0 = firrtl.ref.send %c0_ui1 : !firrtl.uint<1> | ||
// CHECK-NEXT: %1 = firrtl.ref.cast %0 : (!firrtl.probe<uint<1>>) -> !firrtl.probe<uint<1>, @A> | ||
// CHECK-NEXT: firrtl.ref.define %p, %1 : !firrtl.probe<uint<1>, @A> | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
firrtl.module @ProbeEscapeLayer(out %p: !firrtl.probe<uint<1>, @A>) { | ||
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1> | ||
firrtl.layerblock @A { | ||
%0 = firrtl.ref.send %c0_ui1 : !firrtl.uint<1> | ||
%1 = firrtl.ref.cast %0 : (!firrtl.probe<uint<1>>) -> !firrtl.probe<uint<1>, @A> | ||
firrtl.ref.define %p, %1 : !firrtl.probe<uint<1>, @A> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: firrtl.module @Layers4(out %o: !firrtl.openbundle<p: probe<uint<1>, @A>>) { | ||
// CHECK-NEXT: firrtl.layerblock @A { | ||
// CHECK-NEXT: %0 = firrtl.opensubfield %o[p] : !firrtl.openbundle<p: probe<uint<1>, @A>> | ||
// CHECK-NEXT: %c0_ui1 = firrtl.constant 0 : !firrtl.uint<1> | ||
// CHECK-NEXT: %1 = firrtl.ref.send %c0_ui1 : !firrtl.uint<1> | ||
// CHECK-NEXT: %2 = firrtl.ref.cast %1 : (!firrtl.probe<uint<1>>) -> !firrtl.probe<uint<1>, @A> | ||
// CHECK-NEXT: firrtl.ref.define %0, %2 : !firrtl.probe<uint<1>, @A> | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
firrtl.module @Layers4(out %o: !firrtl.openbundle<p: probe<uint<1>, @A>>) { | ||
firrtl.layerblock @A { | ||
%0 = firrtl.opensubfield %o[p] : !firrtl.openbundle<p: probe<uint<1>, @A>> | ||
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1> | ||
%1 = firrtl.ref.send %c0_ui1 : !firrtl.uint<1> | ||
%2 = firrtl.ref.cast %1 : (!firrtl.probe<uint<1>>) -> !firrtl.probe<uint<1>, @A> | ||
firrtl.ref.define %0, %2 : !firrtl.probe<uint<1>, @A> | ||
} | ||
} | ||
} |