Skip to content

Commit

Permalink
DesignComparator to accept a Predicate<Net> for PIP comparisons (#935)
Browse files Browse the repository at this point in the history
* DesignComparator to accept a Predicate<Net> for PIP comparisons

Signed-off-by: Eddie Hung <[email protected]>

* Fix polarity

Signed-off-by: Eddie Hung <[email protected]>

---------

Signed-off-by: Eddie Hung <[email protected]>
  • Loading branch information
eddieh-xlnx authored Jan 8, 2024
1 parent e9dcad1 commit 9d20688
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/com/xilinx/rapidwright/design/compare/DesignComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.function.Predicate;

import com.xilinx.rapidwright.design.Cell;
import com.xilinx.rapidwright.design.Design;
Expand All @@ -55,8 +56,8 @@ public class DesignComparator {
private int diffCount;
/** Flag indicating if PIP flags should be compared (default: false) */
private boolean comparePIPFlags = false;
/** Flag indicating if routing (PIPs) should be compared (default: true) */
private boolean comparePIPs = true;
/** Predicate indicating if routing (PIPs) should be compared for given Net (default: true) */
private Predicate<Net> comparePIPs = (net) -> true;
/**
* Flag indicating if placement information should be compared (default: true)
*/
Expand Down Expand Up @@ -182,23 +183,21 @@ public void setComparePIPFlags(boolean comparePIPFlags) {
}

/**
* Gets the comparePIPs flag indicating if a design's PIPs should be compared by
* DesignComparator.
* Sets a flag to tell the design comparator if PIP should be compared.
*
* @return True if the flag is set, false otherwise (default: true).
* @param comparePIPs Desired flag value (default: true).
*/
public boolean comparePIPs() {
return comparePIPs;
public void setComparePIPs(boolean comparePIPs) {
this.comparePIPs = (net) -> comparePIPs;
}

/**
* Sets a flag to tell the design comparator if PIP flags should also be
* compared.
*
* @param comparePIPs Desired flag value (default: true).
* Set the predicate for the design comparator if PIPs should be compared for the given Net.
*
* @param predicate Predicate.
*/
public void setComparePIPs(boolean comparePIPs) {
this.comparePIPs = comparePIPs;
public void setComparePIPs(Predicate<Net> predicate) {
this.comparePIPs = predicate;
}

/**
Expand All @@ -207,7 +206,7 @@ public void setComparePIPs(boolean comparePIPs) {
*
* @return True if the flag is set, false otherwise (default: true).
*/
public boolean comparePlacement() {
public boolean getComparePlacement() {
return comparePlacement;
}

Expand Down Expand Up @@ -352,7 +351,7 @@ private Map<String, PIP> getPIPMap(Net net) {
public int compareNets(Net gold, Net test) {
int init = getDiffCount();

if (!comparePIPs) {
if (!comparePIPs.test(gold) && !comparePIPs.test(test)) {
return getDiffCount() - init;
}

Expand Down

0 comments on commit 9d20688

Please sign in to comment.