Skip to content

Commit

Permalink
Test for site routing from raw placed design (#1000)
Browse files Browse the repository at this point in the history
* Test for site routing from raw placed design

Signed-off-by: Chris Lavin <[email protected]>

* Update src/com/xilinx/rapidwright/util/VivadoTools.java

Co-authored-by: eddieh-xlnx <[email protected]>
Signed-off-by: Chris Lavin <[email protected]>

* Refactoring

Signed-off-by: Chris Lavin <[email protected]>

* Switching to HEAD

Signed-off-by: Chris Lavin <[email protected]>

---------

Signed-off-by: Chris Lavin <[email protected]>
Co-authored-by: eddieh-xlnx <[email protected]>
  • Loading branch information
clavin-xlnx and eddieh-xlnx authored Jul 11, 2024
1 parent 7b3fd0a commit 1979e17
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/check-git-submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Submodule refs on origin

on:
pull_request:
branches:
- master

jobs:
check:
Expand Down
47 changes: 43 additions & 4 deletions src/com/xilinx/rapidwright/util/VivadoTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class VivadoTools {

public static final String REPORT_ROUTE_STATUS = "report_route_status";
public static final String PLACE_DESIGN = "place_design";
public static final String ROUTE_DESIGN = "route_design";
public static final String WRITE_CHECKPOINT = "write_checkpoint";
public static final String WRITE_EDIF = "write_edif";

Expand Down Expand Up @@ -337,11 +338,49 @@ public static Design placeDesign(Path dcp, Path workdir, boolean encrypted) {
}

/**
* Run Vivado's `get_timing_paths -setup` command on the provided DCP path
* (to find its worst setup timing path) and return its SLACK property as a float.
*
* @param dcp Path to DCP to report on.
* Run Vivado's `route_design` command on the design provided and get the
* `report_route_status` results. Note: this method does not preserve the routed
* output from Vivado.
*
* @param design The design to route and report on.
* @param workdir Directory to work within.
* @return The results of `report_route_status`.
*/
public static ReportRouteStatusResult routeDesignAndGetStatus(Design design, Path workdir) {
boolean encrypted = !design.getNetlist().getEncryptedCells().isEmpty();
Path dcp = workdir.resolve("routeDesignAndGetStatus.dcp");
design.writeCheckpoint(dcp);
return routeDesignAndGetStatus(dcp, workdir, encrypted);
}

/**
* Run Vivado's `route_design` command on the provided DCP path and return the
* `report_route_status` results. Note: this method does not preserve the routed
* output from Vivado.
*
* @param dcp Path to DCP to route and report on.
* @param workdir Directory to work within.
* @param encrypted Indicates whether DCP contains encrypted EDIF cells.
* @return The results of `report_route_status`.
*/
public static ReportRouteStatusResult routeDesignAndGetStatus(Path dcp, Path workdir, boolean encrypted) {
final Path outputLog = workdir.resolve("outputLog.log");

StringBuilder sb = new StringBuilder();
sb.append(createTclDCPLoadCommand(dcp, encrypted));
sb.append(ROUTE_DESIGN + "; ");
sb.append(REPORT_ROUTE_STATUS + "; ");

List<String> log = VivadoTools.runTcl(outputLog, sb.toString(), true);
return new ReportRouteStatusResult(log);
}

/**
* Run Vivado's `get_timing_paths -setup` command on the provided DCP path (to
* find its worst setup timing path) and return its SLACK property as a float.
*
* @param dcp Path to DCP to report on.
* @param workdir Directory to work within.
* @param encrypted Indicates whether DCP contains encrypted EDIF cells.
* @return Worst slack of design as float.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/RapidWrightDCP
19 changes: 17 additions & 2 deletions test/shared/com/xilinx/rapidwright/util/VivadoToolsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

package com.xilinx.rapidwright.util;

import com.xilinx.rapidwright.design.Design;
import java.nio.file.Path;

import org.junit.jupiter.api.Assertions;

import java.nio.file.Path;
import com.xilinx.rapidwright.design.Design;

public class VivadoToolsHelper {
public static void assertFullyRouted(Design design) {
Expand All @@ -45,4 +46,18 @@ public static void assertFullyRouted(Path dcp) {
ReportRouteStatusResult rrs = VivadoTools.reportRouteStatus(dcp);
Assertions.assertTrue(rrs.isFullyRouted());
}

/**
* Ensures that the provided design can be routed successfully in Vivado.
*
* @param design The design to route.
* @param dir The directory to work within.
*/
public static void assertRoutedSuccessfullyByVivado(Design design, Path dir) {
if (!FileTools.isVivadoOnPath()) {
return;
}
ReportRouteStatusResult rrs = VivadoTools.routeDesignAndGetStatus(design, dir);
Assertions.assertTrue(rrs.isFullyRouted());
}
}
10 changes: 10 additions & 0 deletions test/src/com/xilinx/rapidwright/design/TestSiteInst.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
import com.xilinx.rapidwright.device.Device;
import com.xilinx.rapidwright.device.Series;
import com.xilinx.rapidwright.support.RapidWrightDCP;
import com.xilinx.rapidwright.util.VivadoToolsHelper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.nio.file.Path;
import java.util.Arrays;

public class TestSiteInst {
Expand Down Expand Up @@ -365,4 +368,11 @@ public void testUnrouteSiteUpdatesNetSiteInsts() {

Assertions.assertTrue(net.getSiteInsts().isEmpty());
}

@Test
public void testSiteRouting(@TempDir Path dir) {
Design design = RapidWrightDCP.loadDCP("gnl_2_4_3_1.3_gnl_3000_07_3_80_80_placed.dcp");
design.routeSites();
VivadoToolsHelper.assertRoutedSuccessfullyByVivado(design, dir);
}
}

0 comments on commit 1979e17

Please sign in to comment.