Skip to content

Commit a3b66f8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 2024.2.3
2 parents c1fb0da + 2563830 commit a3b66f8

File tree

4 files changed

+79
-8
lines changed

4 files changed

+79
-8
lines changed

src/com/xilinx/rapidwright/eco/ECOTools.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,9 +1209,9 @@ public static void createNet(Design design, List<String> paths) {
12091209
* @return The refactored cell instance.
12101210
*/
12111211
public static EDIFHierCellInst refactorCell(Design design, EDIFHierCellInst cell, EDIFHierCellInst newParent) {
1212-
// TODO - Support non-leaf cells
1213-
if (!cell.getCellType().isLeafCellOrBlackBox()) {
1214-
throw new RuntimeException("ERROR: cell refactor of a hierarchical cell not yet supported: " + cell);
1212+
// TODO - Support non-leaf cells in implemented contexts
1213+
if (!cell.getCellType().isLeafCellOrBlackBox() && design.getSiteInsts().size() > 0) {
1214+
throw new RuntimeException("ERROR: Refactor of a non-leaf cell in a placed/routed design not yet supported: " + cell);
12151215
}
12161216
EDIFHierCellInst currParent = cell.getParent();
12171217
if (currParent.equals(newParent)) {

src/com/xilinx/rapidwright/edif/EDIFHierPortInst.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public String getHierarchicalInstName() {
7171

7272
}
7373

74+
/**
75+
* Gets the full instance, including the instance of the EDIFPortInst.
76+
*
77+
* @return
78+
*/
79+
public EDIFHierCellInst getFullHierarchicalInst() {
80+
return hierarchicalInst.getChild(portInst.getCellInst());
81+
}
82+
7483
/**
7584
* Gets the net on the port inst
7685
* @return The net on the port inst

src/com/xilinx/rapidwright/edif/EDIFTools.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,41 @@ public static void connectPortInstsThruHier(EDIFHierPortInst src, EDIFHierPortIn
532532
EDIFHierCellInst hierParentInst = hierPortInst.getHierarchicalInst();
533533
EDIFNet currNet = hierPortInst.getNet();
534534
if (currNet == null && !(hierParentInst.equals(commonAncestor) && hierPortInst == snk)) {
535-
if (hierPortInst == src) createdSrcNet = true;
536-
currNet = createUniqueNet(hierParentInst.getCellType(), newName);
537-
currNet.addPortInst(hierPortInst.getPortInst());
535+
// When operating on the snk pin, we've found that it is not connected to a net. Instead of trying to
536+
// connect through the hierarchy starting at the snk, start from the common ancestor and leverage
537+
// as much existing connectivity as possible.
538+
List<EDIFCellInst> sinkHier = snk.getFullHierarchicalInst().getFullHierarchy();
539+
boolean foundPath = false;
540+
do {
541+
foundPath = false;
542+
EDIFCellInst nextTargetInst = sinkHier.get(commonAncestor.getDepth());
543+
EDIFNet evalNet = finalSrc.getPortInst().getNet();
544+
if (evalNet != null) {
545+
for (EDIFPortInst pi : evalNet.getEDIFPortInstList()) {
546+
// Does this net connect to the next instance in hierarchy?
547+
if (pi.getCellInst() == nextTargetInst) {
548+
EDIFNet internalNet = pi.getInternalNet();
549+
// Is there a net inside the cell we can follow?
550+
if (internalNet != null) {
551+
EDIFHierCellInst nextParent = finalSrc.getHierarchicalInst()
552+
.getChild(pi.getCellInst());
553+
EDIFPortInst internalPortInst = internalNet.getPortInst(null, pi.getName());
554+
finalSrc = new EDIFHierPortInst(nextParent, internalPortInst);
555+
commonAncestor = commonAncestor.getChild(pi.getCellInst());
556+
foundPath = true;
557+
break;
558+
}
559+
}
560+
}
561+
}
562+
} while (foundPath && snk.getHierarchicalInst().getInst() != finalSrc.getHierarchicalInst().getInst());
563+
if (!foundPath) {
564+
// We still need to create some ports to get us to the end
565+
if (hierPortInst == src)
566+
createdSrcNet = true;
567+
currNet = createUniqueNet(hierParentInst.getCellType(), newName);
568+
currNet.addPortInst(hierPortInst.getPortInst());
569+
}
538570
}
539571

540572
while (hierParentInst.getInst() != commonAncestor.getInst()) {

test/src/com/xilinx/rapidwright/edif/TestEDIFTools.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.junit.jupiter.params.provider.ValueSource;
3434

3535
import java.nio.charset.StandardCharsets;
36+
import java.util.ArrayList;
3637
import java.util.List;
3738
import java.util.Map;
3839
import java.util.Map.Entry;
@@ -45,8 +46,8 @@ public class TestEDIFTools {
4546
public static final String TEST_SRC = "base_mb_i/microblaze_0/U0/"
4647
+ "MicroBlaze_Core_I/Performance.Core/Data_Flow_I/Data_Flow_Logic_I/Gen_Bits[22]."
4748
+ "MEM_EX_Result_Inst/Using_FPGA.Native/Q";
48-
public static final String TEST_SNK = "u_ila_0/inst/PROBE_PIPE."
49-
+ "shift_probes_reg[0][7]/D";
49+
public static final String TEST_SNK = "u_ila_0/inst/PROBE_PIPE.shift_probes_reg[0][7]/D";
50+
public static final String TEST_SNK2 = "u_ila_0/inst/PROBE_PIPE.shift_probes_reg[0][8]/D";
5051

5152
@ParameterizedTest
5253
@ValueSource(booleans = {true, false})
@@ -89,6 +90,35 @@ public void testConnectPortInstsThruHier(boolean netToPin) {
8990
}
9091
}
9192
Assertions.assertTrue(containsSnk);
93+
94+
// Now check if it will reuse ports already created
95+
96+
// Disconnect sink in anticipation of connecting to another net
97+
EDIFHierPortInst snkPortInst2 = netlist.getHierPortInstFromName(TEST_SNK2);
98+
snkPortInst2.getNet().removePortInst(snkPortInst2.getPortInst());
99+
100+
// Count number of ports prior to connection to ensure no additional ports were
101+
// created
102+
List<Integer> portCounts = new ArrayList<>();
103+
List<EDIFCellInst> insts = snkPortInst2.getFullHierarchicalInst().getFullHierarchy();
104+
for (EDIFCellInst i : insts) {
105+
portCounts.add(i.getCellPorts().size());
106+
}
107+
108+
if (netToPin) {
109+
EDIFTools.connectPortInstsThruHier(srcPortInst.getHierarchicalNet(), snkPortInst2,
110+
UNIQUE_SUFFIX);
111+
} else {
112+
EDIFTools.connectPortInstsThruHier(srcPortInst, snkPortInst2, UNIQUE_SUFFIX);
113+
}
114+
115+
// Ensure no additional ports were created
116+
for (int i = 0; i < insts.size(); i++) {
117+
EDIFCellInst inst = insts.get(i);
118+
Assertions.assertEquals(portCounts.get(i), inst.getCellPorts().size());
119+
}
120+
121+
Assertions.assertEquals(snkPortInst.getNet(), snkPortInst2.getNet());
92122
}
93123

94124
@Test

0 commit comments

Comments
 (0)