Skip to content

Commit

Permalink
Fix TestPolynomialGenerator tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Hung <[email protected]>
  • Loading branch information
eddieh-xlnx committed Oct 16, 2023
1 parent ff22fbb commit 9ce85d2
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.nio.file.Path;
import java.util.stream.Stream;

import com.xilinx.rapidwright.util.FileTools;
import com.xilinx.rapidwright.util.ReportRouteStatusResult;
import com.xilinx.rapidwright.util.VivadoTools;
import org.junit.jupiter.api.Assertions;
Expand All @@ -43,7 +44,7 @@ public class TestPolynomialGenerator {

@ParameterizedTest
@MethodSource
public void testPolynomialGenerator(String polynomial, int bitWidth, boolean route, @TempDir Path dir) {
public void testPolynomialGenerator(String polynomial, int bitWidth, boolean route, int expectedUnroutedPins, @TempDir Path dir) {
Path dcp = dir.resolve("polynomial.dcp");

PolynomialGenerator.generatePolynomial(polynomial, "test", bitWidth, route, dcp.toString(), null, false);
Expand All @@ -56,25 +57,28 @@ public void testPolynomialGenerator(String polynomial, int bitWidth, boolean rou
Assertions.assertTrue(c.isPlaced());
}

ReportRouteStatusResult rrs = VivadoTools.reportRouteStatus(d);
if (route) {
Assertions.assertTrue(rrs.isFullyRouted());
} else {
Assertions.assertTrue(rrs.unroutedNets > 0);
Assertions.assertEquals(0, rrs.netsWithRoutingErrors);
if (FileTools.isVivadoOnPath()) {
ReportRouteStatusResult rrs = VivadoTools.reportRouteStatus(d);
if (route) {
Assertions.assertTrue(rrs.isFullyRouted());
} else {
Assertions.assertTrue(rrs.unroutedNets > 0);
Assertions.assertEquals(expectedUnroutedPins, rrs.netsWithRoutingErrors);
Assertions.assertEquals(expectedUnroutedPins, rrs.netsWithSomeUnroutedPins);
}
}
}

public static Stream<Arguments> testPolynomialGenerator() {
return Stream.of(
Arguments.of("x^2+3*x+5", 16, true),
Arguments.of("x^2+3*x+5", 16, false),
Arguments.of("8*x^4+43*x^3+7*x^2-14", 18, true),
Arguments.of("8*x^4+43*x^3+7*x^2-14", 18, false),
Arguments.of("8*y^4+43*y*x^3+7*x^2-14", 18, true), // Section 3: "More Complex Polynomial"
Arguments.of("8*y^4+43*y*x^3+7*x^2-14", 18, false),
Arguments.of("3*x^2+x-2 16", 16, true), // Section 2: "Simple Polynomial Circuit"
Arguments.of("3*x^2+x-2 16", 16, false)
Arguments.of("x^2+3*x+5", 16, true, 0),
Arguments.of("x^2+3*x+5", 16, false, 0),
Arguments.of("8*x^4+43*x^3+7*x^2-14", 18, true, 0),
Arguments.of("8*x^4+43*x^3+7*x^2-14", 18, false, 1),
Arguments.of("8*y^4+43*y*x^3+7*x^2-14", 18, true, 0), // Section 3: "More Complex Polynomial"
Arguments.of("8*y^4+43*y*x^3+7*x^2-14", 18, false, 1),
Arguments.of("3*x^2+x-2 16", 16, true, 0), // Section 2: "Simple Polynomial Circuit"
Arguments.of("3*x^2+x-2 16", 16, false, 0)
);
}
}

0 comments on commit 9ce85d2

Please sign in to comment.