📄 netlist.java
字号:
int netMapIndex = netCell.getNetMapOffset(global); if (netMapIndex < 0) return -1; return nm_net[netMapIndex]; } /** * Get net index of a global signal of nodable. * @param no nodable. * @param global global signal. * @return net index of a global signal of nodable. */ int getNetIndex(Nodable no, Global global) { checkForModification(); int netMapIndex = netCell.getNetMapOffset(no, global); if (netMapIndex < 0) return -1; return nm_net[netMapIndex]; } /** * Get net index of signal connected to specified external network of nodable. * Nodable must be subcell * @param no nodable (subcell) * @param subNetwork a network * @return network. */ int getNetIndex(Nodable no, Network subNetwork) { checkForModification(); Netlist subNetlist = subNetwork.getNetlist(); assert subNetlist.shortResistors == shortResistors; if (no.getParent() == netCell.cell && subNetlist.getCell() == no.getProto() && subNetwork.isExported()) { int equivPortIndex = subNetlist.getEquivPortIndexByNetIndex(subNetwork.getNetIndex()); assert equivPortIndex >= 0 && equivPortIndex < subNetlist.netCell.equivPortsN.length; int netMapIndex = netCell.getNetMapOffset(no, equivPortIndex); if (netMapIndex >= 0) return nm_net[netMapIndex]; } return -1; } /** * Get net index of signal in a port instance of nodable. * @param no nodable * @param portProto port of nodable * @param busIndex index of signal in a bus or zero. * @return net index */ int getNetIndex(Nodable no, PortProto portProto, int busIndex) { checkForModification(); if (no.getParent() != netCell.cell) return -1; if (portProto.getParent() != no.getProto()) { System.out.println("Netlist.getNetwork: invalid argument portProto"); return -1; } if (busIndex < 0 || busIndex >= netCell.getBusWidth(no, portProto)) {// System.out.println("Nodable.getNetwork: invalid arguments busIndex="+busIndex+" portProto="+portProto); return -1; } int netMapIndex = netCell.getNetMapOffset(no, portProto, busIndex); if (netMapIndex < 0) return -1; return nm_net[netMapIndex]; } /** * Get net index of signal in export. * @param export given Export. * @param busIndex index of signal in a bus or zero. * @return net index. */ int getNetIndex(Export export, int busIndex) { checkForModification(); if (export.getParent() != netCell.cell) return -1; if (busIndex < 0 || busIndex >= export.getNameKey().busWidth()) { System.out.println("Nodable.getNetwork: invalid arguments busIndex="+busIndex+" export="+export); return -1; } int netMapIndex = netCell.getNetMapOffset(export, busIndex); if (netMapIndex < 0) return -1; return nm_net[netMapIndex]; } /** * Get net index of signal on arc. * @param ai arc instance * @param busIndex index of signal in a bus or zero. * @return net index. */ int getNetIndex(ArcInst ai, int busIndex) { checkForModification(); if (ai.getParent() != netCell.cell) return -1; int netMapIndex = netCell.getNetMapOffset(ai, busIndex); if (netMapIndex < 0) return -1; return nm_net[netMapIndex]; } /** * Get network of a global signal. * @param global global signal. * @return net index of a gloabal signal. */ public Network getNetwork(Global global) { return getNetworkRaw(getNetIndex(global)); } /** * Get network of a global signal of nodable. * @param no nodable. * @param global global signal. * @return net index of a gloabal signal of nodable. */ public Network getNetwork(Nodable no, Global global) { return getNetworkRaw(getNetIndex(no, global)); } /** * Get network of signal connected to specified external network of nodable. * Nodable must be subcell * @param no nodable (subcell) * @param subNetwork a network * @return network. * @throws IllegalArgumentException if nodable is not subcell */ public Network getNetwork(Nodable no, Network subNetwork) { return getNetworkRaw(getNetIndex(no, subNetwork)); } /** * Get network of signal in a port instance of nodable. * @param no nodable * @param portProto port of nodable * @param busIndex index of signal in a bus or zero. * @return network. */ public Network getNetwork(Nodable no, PortProto portProto, int busIndex) { if (no == null || portProto == null) return null; if (no instanceof NodeInst && !((NodeInst)no).isLinked()) return null; if (portProto instanceof Export && !((Export)portProto).isLinked()) return null; return getNetworkRaw(getNetIndex(no, portProto, busIndex)); } /** * Method to tell whether two PortProtos are electrically connected. * @param no the Nodable on which the PortProtos reside. * @param port1 the first PortProto. * @param port2 the second PortProto. * @return true if the two PortProtos are electrically connected. */ public boolean portsConnected(Nodable no, PortProto port1, PortProto port2) { if (no == null || port1 == null || port2 == null) return false; if (no instanceof NodeInst && !((NodeInst)no).isLinked()) return false; if (port1 instanceof Export && !((Export)port1).isLinked()) return false; if (port2 instanceof Export && !((Export)port2).isLinked()) return false; int busWidth = netCell.getBusWidth(no, port1); if (netCell.getBusWidth(no, port2) != busWidth) return false; for (int i = 0; i < busWidth; i++) { if (getNetIndex(no, port1, i) != getNetIndex(no, port2, i)) return false; } return true; } /** * Get network of port instance. * @param pi port instance. * @return signal on port index or null. */ public Network getNetwork(PortInst pi) { if (!pi.isLinked()) return null; PortProto portProto = pi.getPortProto(); if (portProto.getNameKey().isBus()) { System.out.println("PortInst.getNetwork() was called for instance of bus port "+portProto.getName()); return null; } return getNetwork(pi.getNodeInst(), portProto, 0); } /** * Get network of signal in export. * @param export given Export. * @param busIndex index of signal in a bus or zero. * @return network. */ public Network getNetwork(Export export, int busIndex) { if (!export.isLinked()) return null; return getNetworkRaw(getNetIndex(export, busIndex)); } /** * Get network of signal on arc. * @param ai arc instance * @param busIndex index of signal in a bus or zero. * @return network. */ public Network getNetwork(ArcInst ai, int busIndex) { if (!ai.isLinked()) return null; return getNetworkRaw(getNetIndex(ai, busIndex)); } /** * Method to tell whether two ArcInsts are electrically equivalent. * This considers individual elements of busses. * @param ai1 the first ArcInst. * @param ai2 the second ArcInst. * @return true if the arcs are electrically connected. */ public boolean sameNetwork(ArcInst ai1, ArcInst ai2) { if (ai1 == null || ai2 == null) return false; if (!ai1.isLinked()) return false; if (!ai2.isLinked()) return false; int busWidth1 = netCell.getBusWidth(ai1); int busWidth2 = netCell.getBusWidth(ai2); if (busWidth1 != busWidth2) return false; for(int i=0; i<busWidth1; i++) { if (getNetIndex(ai1, i) != getNetIndex(ai2, i)) return false; } return true; } /** * Method to tell whether a PortProto on a Nodable is electrically equivalent to an ArcInst. * This considers individual elements of busses. * @param no the Nodable. * @param pp the PortProto on the Nodable. * @param ai the ArcInst. * @return true if they are electrically connected. */ public boolean sameNetwork(Nodable no, PortProto pp, ArcInst ai) { if (no == null || pp == null || ai == null) return false; if (no instanceof NodeInst && !((NodeInst)no).isLinked()) return false; if (pp instanceof Export && !((Export)pp).isLinked()) return false; if (!ai.isLinked()) return false; int busWidth1 = netCell.getBusWidth(no, pp); int busWidth2 = netCell.getBusWidth(ai); if (busWidth1 != busWidth2) return false; for(int i=0; i<busWidth1; i++) { if (getNetIndex(no, pp, i) != getNetIndex(ai, i)) return false; } return true; } /** * Method to tell whether two PortProto / Nodable pairs are electrically equivalent. * This considers individual elements of busses. * @param no1 the first Nodable. * @param pp1 the PortProto on the first Nodable. * @param no2 the second Nodable. * @param pp2 the PortProto on the second Nodable. * @return true if they are electrically connected. */ public boolean sameNetwork(Nodable no1, PortProto pp1, Nodable no2, PortProto pp2) { if (no1 == null || pp1 == null || no2 == null || pp2 == null) return false; if (no1 instanceof NodeInst && !((NodeInst)no1).isLinked()) return false; if (pp1 instanceof Export && !((Export)pp1).isLinked()) return false; if (no2 instanceof NodeInst && !((NodeInst)no2).isLinked()) return false; if (pp2 instanceof Export && !((Export)pp2).isLinked()) return false; int busWidth1 = netCell.getBusWidth(no1, pp1); int busWidth2 = netCell.getBusWidth(no2, pp2); if (busWidth1 != busWidth2) return false; for(int i=0; i<busWidth1; i++) { if (getNetIndex(no1, pp1, i) != getNetIndex(no2, pp2, i)) return false; } return true; } /** * Method to return either the network name or the bus name on this ArcInst. * @return the either the network name or the bus name on this ArcInst. */ public String getNetworkName(ArcInst ai) { if (ai == null || !ai.isLinked()) return null; checkForModification(); if (ai.getParent() != netCell.cell) return null; int busWidth = netCell.getBusWidth(ai); if (busWidth > 1) { return netCell.getBusName(ai).toString(); } Network network = getNetwork(ai, 0); if (network == null) return null; return network.describe(false); } /** * Method to return the name of the bus on this ArcInst. * @return the name of the bus on this ArcInst. */ public Name getBusName(ArcInst ai) { if (ai == null || !ai.isLinked()) return null; checkForModification(); if (ai.getParent() != netCell.cell) return null; int busWidth = netCell.getBusWidth(ai); if (busWidth <= 1) return null; return netCell.getBusName(ai); } /** * Method to return the bus width on an Export. * @param e the Export to examine. * @return the bus width of the Export. */ public int getBusWidth(Export e) { if (e == null || !e.isLinked()) return 0; return e.getNameKey().busWidth(); } /** * Method to return the bus width on this ArcInst. * @return the either the bus width on this ArcInst. */ public int getBusWidth(ArcInst ai) { if (ai == null || !ai.isLinked()) return 0; checkForModification(); if (ai.getParent() != netCell.cell) return 0; return netCell.getBusWidth(ai); } public ShortResistors getShortResistors() { return shortResistors; } /** * Returns a printable version of this Netlist. * @return a printable version of this Netlist. */ @Override public String toString() { return "Netlist of " + netCell.cell; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -