Skip to content

Commit fc81421

Browse files
committed
[EDIFPort] Refactor getBitBlastedIndices()
Signed-off-by: Chris Lavin <[email protected]>
1 parent 0213db4 commit fc81421

File tree

8 files changed

+30
-20
lines changed

8 files changed

+30
-20
lines changed

src/com/xilinx/rapidwright/debug/DotEdifDumper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected Stream<EDIFPortInst> getPorts(EDIFCellInst edifCellInst) {
6363
protected Stream<Pair<EDIFPort,Integer>> getPortTemplates(EDIFCellInst edifCellInst) {
6464
return edifCellInst.getCellType().getPorts().stream().flatMap(p-> {
6565
if (p.isBus()) {
66-
return Arrays.stream(p.getBitBlastedIndicies()).mapToObj(i -> new Pair<>(p, i));
66+
return Arrays.stream(p.getBitBlastedIndices()).mapToObj(i -> new Pair<>(p, i));
6767
}
6868
return Stream.of(new Pair<>(p, 0));
6969
});

src/com/xilinx/rapidwright/design/tools/InlineFlopTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static void createAndPlaceFlopsInlineOnTopPorts(Design design, String clk
9898
continue;
9999
}
100100
if (port.isBus()) {
101-
for (int i : port.getBitBlastedIndicies()) {
101+
for (int i : port.getBitBlastedIndices()) {
102102
EDIFPortInst inst = port.getInternalPortInstFromIndex(i);
103103
Pair<Site, BEL> loc = nextAvailPlacement(design, siteItr);
104104
Cell flop = createAndPlaceFlopInlineOnTopPortInst(design, inst, loc, clk);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,8 @@ public void renamePort(String currName, String newName) {
346346

347347
EDIFPort newPort = new EDIFPort(newName, port.getDirection(), port.getWidth());
348348
addPort(newPort);
349-
int[] indices = port.isBus() ? port.getBitBlastedIndicies() : new int[]{0};
350349

351-
for (int i : indices) {
350+
for (int i : port.getBitBlastedIndices()) {
352351
EDIFPortInst portInst = port.getInternalPortInstFromIndex(i);
353352
if (portInst == null) {
354353
continue;

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,31 @@ public boolean isBus() {
356356
return width > 1 || !getName().equals(busName);
357357
}
358358

359+
private static final int[] SINGLE_BIT_INDICES = new int[] { 0 };
360+
361+
/**
362+
* @see #getBitBlastedIndicies()
363+
* @deprecated Misspelling in name, to be removed in 2026.1.0
364+
*/
359365
public int[] getBitBlastedIndicies() {
366+
return getBitBlastedIndices();
367+
}
368+
369+
/**
370+
* Returns an array of all the integer indices of this port. If the port is a
371+
* single bit it returns an array with a single entry of '0'. This is useful
372+
* when needing to iterate over a port's PortInst objects.
373+
*
374+
* @return The integer list of indices of this port, or {0} for a single bit
375+
* port.
376+
*/
377+
public int[] getBitBlastedIndices() {
360378
int lastLeftBracket = getName().lastIndexOf('[');
361379
if (getName().contains(":"))
362380
return EDIFTools.bitBlastBus(getName().substring(lastLeftBracket));
363381
if (getName().contains("["))
364382
return new int[] {Integer.parseInt(getName().substring(lastLeftBracket,getName().length()-1))};
365-
return null;
383+
return SINGLE_BIT_INDICES;
366384
}
367385

368386
public boolean isBusRangeEqual(EDIFPort otherPort) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@ public static EDIFNetlist createFlatNetlist(EDIFNetlist netlist, String partName
17361736
for (EDIFPort topPort : netlist.getTopCell().getPorts()) {
17371737
EDIFPort flatPort = flatTop.createPort(topPort);
17381738
if (flatPort.isBus()) {
1739-
int[] indicies = flatPort.getBitBlastedIndicies();
1739+
int[] indicies = flatPort.getBitBlastedIndices();
17401740
int i = 0;
17411741
for (EDIFNet net : topPort.getInternalNets()) {
17421742
if (net == null) continue;

test/src/com/xilinx/rapidwright/design/TestPartitionPin.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,10 @@ public void testPartitionPins() {
8181
int wireIdx = 10;
8282
int count = 0;
8383
for (EDIFPort port : design.getTopEDIFCell().getPorts()) {
84-
if (port.isBus()) {
85-
for (int i : port.getBitBlastedIndicies()) {
86-
Node node = Node.getNode(t, wireIdx++);
87-
PartitionPin ppin = design.createPartitionPin(port, i, node);
88-
testPortPartitionPin(design, ppin, port, i, node);
89-
count++;
90-
}
91-
} else {
84+
for (int i : port.getBitBlastedIndices()) {
9285
Node node = Node.getNode(t, wireIdx++);
93-
PartitionPin ppin = design.createPartitionPin(port, node);
94-
testPortPartitionPin(design, ppin, port, -1, node);
86+
PartitionPin ppin = design.createPartitionPin(port, i, node);
87+
testPortPartitionPin(design, ppin, port, i, node);
9588
count++;
9689
}
9790
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void testRenamePort() {
149149
EDIFPort myNewSignal = topCell.getPort("my_new_signal[");
150150
Assertions.assertNotNull(myNewSignal);
151151

152-
for (int i : myNewSignal.getBitBlastedIndicies()) {
152+
for (int i : myNewSignal.getBitBlastedIndices()) {
153153
EDIFPortInst portInst = myNewSignal.getInternalPortInstFromIndex(i);
154154
Assertions.assertNotNull(portInst);
155155
}
@@ -164,7 +164,7 @@ public void testRenamePort() {
164164
EDIFPort newTestZero = topCell.getPort("new_test_zero[");
165165
Assertions.assertNotNull(newTestZero);
166166

167-
for (int i : newTestZero.getBitBlastedIndicies()) {
167+
for (int i : newTestZero.getBitBlastedIndices()) {
168168
EDIFPortInst portInst = newTestZero.getInternalPortInstFromIndex(i);
169169
Assertions.assertNotNull(portInst);
170170
}
@@ -179,7 +179,7 @@ public void testRenamePort() {
179179
EDIFPort newTestFive = topCell.getPort("new_test_five[");
180180
Assertions.assertNotNull(newTestFive);
181181

182-
for (int i : newTestFive.getBitBlastedIndicies()) {
182+
for (int i : newTestFive.getBitBlastedIndices()) {
183183
EDIFPortInst portInst = newTestFive.getInternalPortInstFromIndex(i);
184184
Assertions.assertNotNull(portInst);
185185
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testCreatePort() {
9696
EDIFPort copy = cell.getPort("bus_output[" + outer + "][");
9797
Assertions.assertEquals(busOutput, copy);
9898

99-
int[] portIndices = busOutput.getBitBlastedIndicies();
99+
int[] portIndices = busOutput.getBitBlastedIndices();
100100
Assertions.assertEquals(width, portIndices.length);
101101
Assertions.assertEquals(left, portIndices[0]);
102102
Assertions.assertEquals(right, portIndices[portIndices.length - 1]);

0 commit comments

Comments
 (0)