byucc.edif
Class EdifNet

java.lang.Object
  extended by byucc.edif.NamedPropertyObject
      extended by byucc.edif.EdifNet
All Implemented Interfaces:
EdifOut, Nameable, Properties, java.io.Serializable

public class EdifNet
extends NamedPropertyObject
implements EdifOut, java.io.Serializable

Represents an EDIF signal net. A net within EDIF is defined by a collection of edif port references. Specifically, the net is connected to each edif port reference in the collection.

This implementation of EdifNet contains contains a reference to the EdifCell that contains this net. This class also contains an array of EdifPortRef objects that attach to the net.

Sample EDIF code for an EdifNet:

(net sgn_exp (joined
  (portRef (member sgn_exp 0))
  (portRef DI (instanceRef L_3_U2))
  (portRef I1 (instanceRef L_3_l_4))
))
 

To Do:

Version:
$Id: EdifNet.java,v 1.67 2006/01/04 23:42:52 wirthlin Exp $
Author:
Welson Sun, Mike Wirthlin, Tyler Anderson
See Also:
EdifPortRef, Serialized Form

Field Summary
private  java.util.ArrayList _attachedPortRefs
          List of EdifPortRef objects that this net is connected to.
private  EdifCell _parent
          The reference to the parent EdifCell
 
Constructor Summary
EdifNet(EdifNameable name)
          Constructs an empty, parentless, named EdifNet Object.
EdifNet(EdifNameable name, EdifCell parent)
          Constructs an empty, named EdifNet Object with the specified parent.
EdifNet(java.lang.String name)
          Constructs an empty, parentless, named EdifNet Object.
EdifNet(java.lang.String name, EdifCell parent)
          Constructs an empty, named EdifNet Object with the specified parent.
 
Method Summary
 EdifPortRef addPortConnection(EdifCellInstance eci, EdifPort p)
           
 EdifPortRef addPortConnection(EdifCellInstance eci, EdifPort p, int busMember)
          Add a port connection to the net.
 EdifPortRef addPortConnection(EdifCellInstance eci, java.lang.String portName)
          Add a port connection to the given port on the given instance onto this net.
 EdifPortRef addPortConnection(EdifCellInstance eci, java.lang.String portName, int busMember)
          Add a port connection to the net.
 EdifPortRef addPortConnection(EdifPortRef portref)
          Add a pre-defined EdifPortRef port connection to the net.
 EdifPortRef addTopLevelPortConnection(EdifPort port)
          TODO Remove this method.
 EdifPortRef addTopLevelPortConnection(java.lang.String portName)
          TODO: We should remove this method.
 EdifNet copy(EdifCell parent)
          Returns a deep copy of this Object.
 boolean deletePortConnection(EdifPortRef delete)
          Detaches an EdifPortRef from this EdifNet.
 java.util.Collection getAttachedPortRefs(EdifCellInstance cell)
          This method will return a list of all EdifPortRef objects attached to the given EdifCellInstance.
 java.util.Collection getConnectedPortRefs()
          Returns a list of EdifPortRef objects which are attached to this net.
 EdifPortRef getEdifPortRef(EdifCellInstance inst, EdifSingleBitPort singlePort)
          Returns the EdifPortRef object attached to the given instance and single bit port.
 java.util.Collection getInOutPortRefs()
          This method will return all EdifPortRef in this EdifNet object that are outputs.
 java.util.Collection getInOutPorts()
          Provides a Colletion of EdifPortRef objects that are attached to this EdifNet and connected to tri-state ports (inout).
 java.util.Collection getInputPortRefs()
          This method will return all EdifPortRef in this EdifNet object that are connected to ports of type "input".
 java.util.Collection getNetDriven()
          Deprecated. Use getSinkPortRefs(boolean) in place of this method.
 java.util.Collection getNetDrivers()
          Deprecated. Use getSourcePortRefs(boolean) in place of this method.
 java.util.Collection getOutputPortRefs()
          This method will return all EdifPortRef in this EdifNet object that are connected to ports of type "output".
 java.util.Collection getOutputPorts()
          Provides a Colletion of EdifPortRef objects that are attached to this EdifNet and connected to true output ports.
 EdifCell getParent()
          Returns a reference to the parent EdifCell (owner of net).
 java.util.Iterator getPortRefIterator()
          Create an iterator for the EdifPortRef objects owned by this net.
 java.util.Collection getSinkPortRefs(boolean tristate, boolean includeTopPorts)
          This method will return all EdifPortRef objects in this EdifNet object that are "sinks".
 java.util.Collection getSourcePortRefs(boolean tristate, boolean includeTopPorts)
          This method will return all EdifPortRef objects in this EdifNet object that are "sources".
 boolean hasTopLevelPortConnection()
          This method will determine whether or not the given net connects to a top-level port.
 boolean isAttached(EdifCellInstance cell)
          This method will examine the EdifPortRef objects connected to this net and determine whether the given EdifCellInstance is connected or not to the given EdifNet.
 boolean isAttached(EdifCellInstance cell, EdifPort port)
          This method will return true if the given EdifPort/EdifCellInstance combination are attached to the given EdifNet.
 boolean isAttached(EdifCellInstance cell, EdifSingleBitPort singlePort)
          Determines if this EdifNet object is connected to the given instance and single-bit port.
 boolean isLeaf()
          Returns True if this net's port refs only refer to ports of leaf cells.
 boolean samePorts(EdifNet net)
          This method does a deep compare on the current net with the passed-in net.
(package private)  void setParent(EdifCell cell)
          Set the reference to the parent EdifCell.
 void toEdif(EdifPrintWriter epw)
          Converts this object to EDIF format and writes it to the passed-in EdifPrintWriter Object.
 java.lang.String toString()
          String representation of the EdifNet with detailed information.
 void trimToSize()
          Trims to size this object and all contained Trimmable Objects.
 
Methods inherited from class byucc.edif.NamedPropertyObject
addProperty, addProperty, copyProperties, equals, equalsProperties, getEdifNameable, getName, getOldName, getProperty, getPropertyList, rename, rename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_attachedPortRefs

private java.util.ArrayList _attachedPortRefs
List of EdifPortRef objects that this net is connected to. Limit the size initial List so that we don't waste memory on unused list elements.


_parent

private EdifCell _parent
The reference to the parent EdifCell

Constructor Detail

EdifNet

public EdifNet(java.lang.String name)
Constructs an empty, parentless, named EdifNet Object.

Parameters:
name - The name of this EdifNet Object

EdifNet

public EdifNet(EdifNameable name)
Constructs an empty, parentless, named EdifNet Object.

Parameters:
name - The Object that contains name information about this object

EdifNet

public EdifNet(java.lang.String name,
               EdifCell parent)
Constructs an empty, named EdifNet Object with the specified parent.

Parameters:
name - The name of this EdifNet Object
parent - The parent EdifCell Object of this EdifNet

EdifNet

public EdifNet(EdifNameable name,
               EdifCell parent)
Constructs an empty, named EdifNet Object with the specified parent.

Parameters:
name - The Object that contains name information about this object
parent - The parent EdifCell Object of this EdifNet
Method Detail

addPortConnection

public EdifPortRef addPortConnection(EdifPortRef portref)
Add a pre-defined EdifPortRef port connection to the net. The EdifPortRef object must be created before calling this method. This method makes the following assumptions (these assumptions are not checked): If any of these assumptions are violated, an incoherent data structure will result. TODO: Should we check these assumptions?

Parameters:
portref - The EdifPortRef to connect to the net.

addPortConnection

public EdifPortRef addPortConnection(EdifCellInstance eci,
                                     java.lang.String portName)
Add a port connection to the given port on the given instance onto this net.

Parameters:
eci - The EdifCellInstance whose parent contains the port referred to by the passed-in portName
portName - The name of the port contained by the parent to the passed-in EdifCellInstance Object TODO: We should remove this method. We shoudl force the caller to find the Port rather than doing this here. There is too much opportunity for run-time errors with this method. This is only referenced in halflatch and TMR -B

addPortConnection

public EdifPortRef addPortConnection(EdifCellInstance eci,
                                     EdifPort p)
Parameters:
eci -
p - TODO Remove this method and force the caller to create a new EdifPortRef() and then add that using addPortConnection(EdifPortRef epr) -B

addTopLevelPortConnection

public EdifPortRef addTopLevelPortConnection(java.lang.String portName)
TODO: We should remove this method. We should force the caller to find the Port rather than doing this here. There is too much opportunity for run-time errors with this method. This is only referenced in halflatch -B


addTopLevelPortConnection

public EdifPortRef addTopLevelPortConnection(EdifPort port)
TODO Remove this method. The caller should create a new EdifPortRef and use the constructor addPortConnection(EdifPortRef epr) This is never used -B

Parameters:
port -

addPortConnection

public EdifPortRef addPortConnection(EdifCellInstance eci,
                                     java.lang.String portName,
                                     int busMember)
Add a port connection to the net.

Parameters:
eci - The EdifCellInstance whose parent contains the port referred to by the passed-in portName
portName - The name of the port contained by the parent to the passed-in EdifCellInstance Object TOTO Remove this method. What happens if the string parameter for the port name fails to match in the method getPort? it is never used -B

addPortConnection

public EdifPortRef addPortConnection(EdifCellInstance eci,
                                     EdifPort p,
                                     int busMember)
Add a port connection to the net.

Parameters:
eci - The EdifCellInstance whose parent contains the port referred to by the passed-in portName
portName - The name of the port contained by the parent to the passed-in EdifCellInstance Object TODO Remove this method. Force the caller to create the EdifPortRef first and use the method addPortConnection(EdifPortRef epr)

copy

public EdifNet copy(EdifCell parent)
Returns a deep copy of this Object. No Object, except String, is copied over using '='. All are done using the 'new' statement, copying all the insides verbatim.

Parameters:
parent - The EdifCell Object that will become the parent of the copied EdifNet
Returns:
An EdifNet 'copy' of this Object, having the passed-in EdifCell as its parent

deletePortConnection

public boolean deletePortConnection(EdifPortRef delete)
Detaches an EdifPortRef from this EdifNet.

Parameters:
delete - The EdifPortRef to remove from this EdifNet Objects list of EdifPortRefs
Returns:
True if the EdifPortRef was found and deleted

getAttachedPortRefs

public java.util.Collection getAttachedPortRefs(EdifCellInstance cell)
This method will return a list of all EdifPortRef objects attached to the given EdifCellInstance.

Parameters:
cell - The instance to find port refs of this EdifNet that attach to this instance
Returns:
A Collection of EdifPortRef Objects that attach to the passed-in EdifCellInstance TODO: better name for method TODO: remove this method This method is only used by EdifCellInstance. Shouldn't EdifCellInstance then be responsible for the work of this method? EdifCellInstance could do the work by first getting the itterator using the getPortRefIterator() method. -B

getPortRefIterator

public java.util.Iterator getPortRefIterator()
Create an iterator for the EdifPortRef objects owned by this net.


getConnectedPortRefs

public java.util.Collection getConnectedPortRefs()
Returns a list of EdifPortRef objects which are attached to this net.

Returns:
A Collection of EdifPortRef objects TODO: Should this return a copy of the arraylist rather than the actual arraylist it self? The caller of the function could then modify the arraylist and cause changes to the EdifNet structure without going through the methods of EdifNet -B

getOutputPortRefs

public java.util.Collection getOutputPortRefs()
This method will return all EdifPortRef in this EdifNet object that are connected to ports of type "output". Note that this does NOT provide a list of "Source" EdifPortRefs as it returns the top-level output ports that are actually "sinks". @see getSourcePortRefs().

Returns:
A Collection of EdifPortRef objects that are connected to this EdifNet Object and attached to a port that is of type OUTPUT.

getInOutPortRefs

public java.util.Collection getInOutPortRefs()
This method will return all EdifPortRef in this EdifNet object that are outputs. Note that this does NOT provide a list of "Source" EdifPortRefs as it returns the top-level Output ports that are actually "sinks".

Returns:
A Collection of Output EdifPortRef Objects that are connected to this EdifNet Object

getSourcePortRefs

public java.util.Collection getSourcePortRefs(boolean tristate,
                                              boolean includeTopPorts)
This method will return all EdifPortRef objects in this EdifNet object that are "sources". This includes those EdifPortRef objects connected to output ports of EdifCellInstances and EdifPortRef objects connected to top-level input ports.

Parameters:
tristate - Indicates whether tristate ports should be included or not (true indicates that tri-state ports should be considered as "sources" and thus include corresponding port refs in the collection. False indicates that tri-state ports should not be considered as sources and thus ignore port refs to these connections).
includeTopPorts - Indicates whether connections to top-level ports should be included (true indicates that port refs to top-level ports should be included, false indicates that these port refs should be ignored).
Returns:
A Collection of EdifPortRef objects that are sources on the net.
See Also:
EdifPort.isOutput(boolean).

getSinkPortRefs

public java.util.Collection getSinkPortRefs(boolean tristate,
                                            boolean includeTopPorts)
This method will return all EdifPortRef objects in this EdifNet object that are "sinks". This includes those EdifPortRef objects connected to input ports of EdifCellInstances and EdifPortRef objects top-level output ports.

Parameters:
tristate - Indicates whether tristate ports should be ignored or not (true indicates that tri-state ports should not be ignored). @see EdifPort#isOutput(boolean).
Returns:
A Collection of EdifPortRef objects that are sinks on the net.

getInputPortRefs

public java.util.Collection getInputPortRefs()
This method will return all EdifPortRef in this EdifNet object that are connected to ports of type "input". Note that this does NOT provide a list of "sink" EdifPortRefs as it returns the top-level input ports that are actually "sources".

Returns:
A Collection of EdifPortRef objects that are connected to this EdifNet Object and attached to a port that is of type Input.
See Also:
getSinkPortRefs().

getOutputPorts

public java.util.Collection getOutputPorts()
Provides a Colletion of EdifPortRef objects that are attached to this EdifNet and connected to true output ports.

Returns:
A Collection of Output EdifPort Objects that are connected to this EdifNet Object

getInOutPorts

public java.util.Collection getInOutPorts()
Provides a Colletion of EdifPortRef objects that are attached to this EdifNet and connected to tri-state ports (inout).

Returns:
A Collection of EdifPort Objects that are connected to this EdifNet Object

getNetDriven

public java.util.Collection getNetDriven()
Deprecated. Use getSinkPortRefs(boolean) in place of this method.

This method will return all portrefs that can be driven on the current net. This will return all EdifPortRef objects that are associated with EdifCellInstances (i.e. EdifPortRef.getCellInstance() returns a non-null) and are inputs. This method will also return EdifPortRef objects that are associated with an EdifCell (i.e. EdifPortRef.getCellInstance() returns null) and is an output. These EdifPortRef objects refer to top-level output ports that can be driven by the given net.

Returns:
A Collection of EdifPortRefs that are driven by this EdifNet Object

getNetDrivers

public java.util.Collection getNetDrivers()
Deprecated. Use getSourcePortRefs(boolean) in place of this method.

This method will return all portrefs that can drive on the current net.

Returns:
A Collection of EdifPortRef Objects that can drive this EdifNet Object

getParent

public EdifCell getParent()
Returns a reference to the parent EdifCell (owner of net).

Returns:
The parent EdifCell object

isAttached

public boolean isAttached(EdifCellInstance cell)
This method will examine the EdifPortRef objects connected to this net and determine whether the given EdifCellInstance is connected or not to the given EdifNet.

Parameters:
cell - The EdifCellInstance Object that will be tested to see if it connects to this EdifNet Object
Returns:
True if this EdifNet Object is attached to the passed-in EdifCellInstance Object

isAttached

public boolean isAttached(EdifCellInstance cell,
                          EdifPort port)
This method will return true if the given EdifPort/EdifCellInstance combination are attached to the given EdifNet.

Parameters:
cell - An EdifCellInstance Object to check if one of the EdifPortRefs in this EdifNet Object connect to a port of that instance
port - An EdifPort Object to check if one of the EdifPortRefs in this EdifNet Object refer to that port
Returns:
True if this EdifNet is attached to the passed-in EdifPort/EdifCellInstance combination TODO: return the actual EdifPortRef

isAttached

public boolean isAttached(EdifCellInstance cell,
                          EdifSingleBitPort singlePort)
Determines if this EdifNet object is connected to the given instance and single-bit port.

Parameters:
cell - Instance object to search for
singlePort - The single-bit port to search for
See Also:
getEdifPortRef

getEdifPortRef

public EdifPortRef getEdifPortRef(EdifCellInstance inst,
                                  EdifSingleBitPort singlePort)
Returns the EdifPortRef object attached to the given instance and single bit port.

Parameters:
inst - The EdifCellInstance reference attached to this EdifNet
singlePort - The single-bit port within the instance type attached to the net.
Returns:
The EdifPortRef object that connects the net to the port of the instance.

hasTopLevelPortConnection

public boolean hasTopLevelPortConnection()
This method will determine whether or not the given net connects to a top-level port. This occurs when any owned EdifPortRef object has a "null" for its EdifCellInstance object.

Returns:

isLeaf

public boolean isLeaf()
Returns True if this net's port refs only refer to ports of leaf cells.

Returns:
True if an EdifPort in this EdifNet connects to the leaf or top cell TODO: Is this method reall useful? It is never used -B

samePorts

public boolean samePorts(EdifNet net)
This method does a deep compare on the current net with the passed-in net. The two nets must have the same name, same number of connected ports, and a port connected to one net must match the name of a port connected to the other net.

Parameters:
net - The net to compare to this net
Returns:
True if both nets have the same structure, false otherwise.

setParent

void setParent(EdifCell cell)
Set the reference to the parent EdifCell. Note: Adding this net to a cell will set the parent of this net to that cell.

Parameters:
cell - an EdifCell value that will become the new parent cell of this EdifNet

toEdif

public void toEdif(EdifPrintWriter epw)
Converts this object to EDIF format and writes it to the passed-in EdifPrintWriter Object.

Specified by:
toEdif in interface EdifOut
Parameters:
epw - The EdifPrintWriter Object that the EDIF data will be written to

toString

public java.lang.String toString()
String representation of the EdifNet with detailed information.

Overrides:
toString in class java.lang.Object
Returns:
a String value representing this Object and its EdifPortRefs

trimToSize

public void trimToSize()
Trims to size this object and all contained Trimmable Objects. TODO: Why do we frist test to see if the ArrayList is Trimmable? shoulden't this always be true? -B