1010 */
1111
1212#include "circt-c/Dialect/Synth.h"
13+ #include "circt-c/Dialect/Comb.h"
1314#include "circt-c/Dialect/HW.h"
1415#include "circt-c/Dialect/Seq.h"
1516#include "mlir-c/BuiltinAttributes.h"
@@ -39,12 +40,17 @@ void testLongestPathAnalysis(void) {
3940 mlirDialectHandleLoadDialect (mlirGetDialectHandle__synth__ (), ctx );
4041 mlirDialectHandleLoadDialect (mlirGetDialectHandle__hw__ (), ctx );
4142 mlirDialectHandleLoadDialect (mlirGetDialectHandle__seq__ (), ctx );
43+ mlirDialectHandleLoadDialect (mlirGetDialectHandle__comb__ (), ctx );
4244
4345 // clang-format off
4446 const char * moduleStr =
4547 "hw.module private @ch(in %c : !seq.clock, in %a: i2, out x: i2) {\n"
4648 " %p = seq.compreg %q, %c : i2\n"
47- " %q = synth.aig.and_inv %p, %p {sv.namehint = \"q\"}: i2\n"
49+ " %p0 = comb.extract %p from 0 : (i2) -> i1\n"
50+ " %p1 = comb.extract %p from 1 : (i2) -> i1\n"
51+ " %q0 = synth.aig.and_inv %p0, %p1 : i1\n"
52+ " %q1 = synth.aig.and_inv %p0, not %p1 : i1\n"
53+ " %q = comb.concat %q0, %q1 {sv.namehint = \"q\"} : i1, i1\n"
4854 " hw.output %p: i2\n"
4955 "}\n"
5056 "hw.module private @top(in %c : !seq.clock, in %a: i2) {\n"
@@ -71,11 +77,11 @@ void testLongestPathAnalysis(void) {
7177
7278 size_t pathCount = synthLongestPathCollectionGetSize (collection1 );
7379 printf ("Path count with elaboration: %zu\n" , pathCount );
74- // CHECK: Path count with elaboration: 4
80+ // CHECK: Path count with elaboration: 8
7581
7682 pathCount = synthLongestPathCollectionGetSize (collection2 );
7783 printf ("Path count without elaboration: %zu\n" , pathCount );
78- // CHECK: Path count without elaboration: 2
84+ // CHECK: Path count without elaboration: 4
7985
8086 // Test DataflowPath API
8187 if (pathCount > 0 ) {
@@ -101,8 +107,8 @@ void testLongestPathAnalysis(void) {
101107 startPointName .data , startPointBitPos );
102108 printf ("EndPoint: %.*s[%zu]\n" , (int )endPointName .length ,
103109 endPointName .data , endPointBitPos );
104- // CHECK: StartPoint: p[[[BIT:[ 0-9]]] ]
105- // CHECK: EndPoint: p[[[BIT]] ]
110+ // CHECK: StartPoint: p[{{[ 0-9]}} ]
111+ // CHECK: EndPoint: p[{{[0-9]}} ]
106112
107113 // Test instance path
108114 IgraphInstancePath startPointPath =
@@ -162,6 +168,19 @@ void testLongestPathAnalysis(void) {
162168 // CHECK: Input-to-internal paths count: 0
163169 // CHECK-NEXT: Internal-to-output paths count: 2
164170
171+ printf ("Path count before drop: %zu\n" ,
172+ synthLongestPathCollectionGetSize (collection1 ));
173+ // CHECK: Path count before drop: 8
174+ synthLongestPathCollectionDropNonCriticalPaths (collection1 , true);
175+ size_t pathCountAfterDrop = synthLongestPathCollectionGetSize (collection1 );
176+ printf ("Path count after drop perEndPoint=true: %zu\n" , pathCountAfterDrop );
177+ // CHECK: Path count after drop perEndPoint=true: 4
178+ synthLongestPathCollectionDropNonCriticalPaths (collection1 , false);
179+ pathCountAfterDrop = synthLongestPathCollectionGetSize (collection1 );
180+ printf ("Path count after drop perEndPoint=false: %zu\n" ,
181+ pathCountAfterDrop );
182+ // CHECK: Path count after drop perEndPoint=false: 2
183+
165184 // Cleanup
166185 synthLongestPathCollectionDestroy (collection1 );
167186 synthLongestPathCollectionDestroy (collection2 );
0 commit comments