Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to filter static sources #771

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/com/xilinx/rapidwright/edif/EDIFCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ public boolean isLeafCellOrBlackBox() {
return (instances == null || instances.size() == 0) && (nets == null || nets.size() == 0);
}

public boolean isStaticSource() {
return getName().equals("VCC") || getName().equals("GND");
}

/**
* Checks if all the port on the provided cell match and are equal to the ports on this cell.
* @param cell The other cell to check against.
Expand Down
51 changes: 46 additions & 5 deletions src/com/xilinx/rapidwright/edif/EDIFNetlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -1043,22 +1043,38 @@ public List<EDIFHierCellInst> findCellInsts(String wildcardPattern) {
public List<EDIFHierCellInst> getAllLeafDescendants(String instanceName) {
return getAllLeafDescendants(getHierCellInstFromName(instanceName));
}

/**
* Searches all lower levels of hierarchy to find all leaf descendants. It returns a
* list of all leaf cells that fall under the hierarchy of the provided instance name.
* @param instance The instance to start searching from.
* @return A list of all leaf cell instances or null if the instanceName was not found.
*/
public List<EDIFHierCellInst> getAllLeafDescendants(EDIFHierCellInst instance) {
List<EDIFHierCellInst> leafCells = new ArrayList<>();
return getAllLeafDescendants(instance, false);
}

/**
* Searches all lower levels of hierarchy to find all leaf descendants. It
* returns a list of all leaf cells that fall under the hierarchy of the
* provided instance name.
*
* @param instance The instance to start searching from.
* @param includeStaticSources If true, results returned will include all cell
* instances that instantiated the VCC and GND
* primitives
* @return A list of all leaf cell instances or null if the instanceName was not
* found.
*/
public List<EDIFHierCellInst> getAllLeafDescendants(EDIFHierCellInst instance, boolean includeStaticSources) {
List<EDIFHierCellInst> leafCells = new ArrayList<>();

Queue<EDIFHierCellInst> toProcess = new LinkedList<EDIFHierCellInst>();
toProcess.add(instance);

while (!toProcess.isEmpty()) {
EDIFHierCellInst curr = toProcess.poll();
if (curr.getCellType().isPrimitive()) {
if (curr.getCellType().isPrimitive() && (includeStaticSources || !curr.getCellType().isStaticSource())) {
leafCells.add(curr);
} else {
curr.addChildren(toProcess);
Expand Down Expand Up @@ -1387,10 +1403,35 @@ public List<EDIFCellInst> getAllLeafCellInstances() {
}

/**
* Get the physical pins all parent nets (as returned by {@link #getParentNet(EDIFHierNet)}).
* Traverses the netlist and produces a list of all primitive leaf cell
* instances.
*
* @return A list of all primitive leaf cell instances.
*/
public List<EDIFCellInst> getAllLeafCellInstances(boolean includeStaticSources) {
List<EDIFCellInst> insts = new ArrayList<>();
Queue<EDIFCellInst> q = new LinkedList<>();
q.add(getTopCellInst());
while (!q.isEmpty()) {
EDIFCellInst curr = q.poll();
for (EDIFCellInst eci : curr.getCellType().getCellInsts()) {
if (eci.getCellType().isPrimitive() && (includeStaticSources || !eci.getCellType().isStaticSource()))
insts.add(eci);
else
q.add(eci);
}
}
return insts;
}

/**
* Get the physical pins all parent nets (as returned by
* {@link #getParentNet(EDIFHierNet)}).
*
* No special handling for static nets is performed. Therefore, only the local connectivity is visible. To see
* all globally connected static pins, use {@link #getPhysicalVccPins()} and {@link #getPhysicalGndPins()}.
* No special handling for static nets is performed. Therefore, only the local
* connectivity is visible. To see all globally connected static pins, use
* {@link #getPhysicalVccPins()} and {@link #getPhysicalGndPins()}.
*
* @return the physicalNetPinMap
*/
public Map<EDIFHierNet, List<EDIFHierPortInst>> getPhysicalNetPinMap() {
Expand Down