byucc.edif
Class EdifNet

java.lang.Object
  extended bybyucc.edif.NamedPropertyObject
      extended bybyucc.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.53 2004/10/18 22:00:31 tsa6 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
 
Fields inherited from class byucc.edif.NamedPropertyObject
 
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
 void addPortConnection(EdifCellInstance eci, EdifPort p)
           
 void addPortConnection(EdifCellInstance eci, EdifPort p, int busMember)
          Add a port connection to the net.
 void addPortConnection(EdifCellInstance eci, java.lang.String portName)
          Add a port connection to the given port on the given instance onto this net.
 void addPortConnection(EdifCellInstance eci, java.lang.String portName, int busMember)
          Add a port connection to the net.
 void addPortConnection(EdifPortRef portref)
          Add a pre-defined EdifPortRef port connection to the net.
 void addTopLevelPortConnection(EdifPort port)
           
 void addTopLevelPortConnection(java.lang.String portName)
           
 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.
 java.util.Collection getNetDriven()
          This method will return all portrefs that can be driven on the current net.
 java.util.Collection getNetDrivers()
          This method will return all portrefs that can drive on the current net.
 java.util.Collection getOutputPortRefs()
          This method will return all portrefs in this EdifNet object that are outputs.
 java.util.Collection getOutputPorts()
          Returns all 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.
 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 isLeaf()
          Returns True if this net's port refs only refer to ports of leaf cells.
 boolean matchesWithin(java.util.Collection netList)
          Returns true if the current net matches within the passed-in collection of EdifNet Objects.
 boolean matchesWithin(java.util.Map netList)
          Returns true if the current net matches within the passed-in Map of EdifNet Objects.
(package private)  void modifyBusToSinglePorts(EdifPort oldPort, java.util.Collection newPorts)
          Modifies all EdifPortRefs in this object that matches the passed-in old EdifPort Object to point one of those in the Collection of newPorts.
(package private)  void modifyCellTypeInNets(EdifCell oldType, EdifCell newType)
          This method will iterate through all EdifPortRef objects contained in this net and modify the port connection for each EdifPortRef that points to an EdifCellInstance of type "oldType".
(package private)  void modifySinglePortsToBus(java.util.Collection oldPorts, EdifPort newPort)
          Modifies all EdifPortRefs in this object that match one of those in the Collection of oldPorts to point to the newPort.
 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, equals, equalsProperties, getEdifNameable, getName, 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 void 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 void 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

addPortConnection

public void addPortConnection(EdifCellInstance eci,
                              EdifPort p)

addTopLevelPortConnection

public void addTopLevelPortConnection(java.lang.String portName)

addTopLevelPortConnection

public void addTopLevelPortConnection(EdifPort port)

addPortConnection

public void 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

addPortConnection

public void 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

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

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

getOutputPortRefs

public java.util.Collection getOutputPortRefs()
This method will return all portrefs in this EdifNet object that are outputs.

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

getOutputPorts

public java.util.Collection getOutputPorts()
Returns all output Ports.

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

getNetDriven

public java.util.Collection getNetDriven()
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 TODO: What is difference between this method and getOutputPortRefs?

getNetDrivers

public java.util.Collection getNetDrivers()
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

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

matchesWithin

public boolean matchesWithin(java.util.Collection netList)
Returns true if the current net matches within the passed-in collection of EdifNet Objects. Equality done by doing a deep compare on the port refs.

Parameters:
netList - The collection of EdifNets to check if this EdifNet has a match within
Returns:
True if this EdifNet Object matches within the passed-in Collection

matchesWithin

public boolean matchesWithin(java.util.Map netList)
Returns true if the current net matches within the passed-in Map of EdifNet Objects. Equality done by doing a deep compare on the port refs.

Parameters:
netList - The Map of EdifNets to check if this EdifNet has a match within
Returns:
True if this EdifNet Object matches within the passed-in Collection

modifySinglePortsToBus

void modifySinglePortsToBus(java.util.Collection oldPorts,
                            EdifPort newPort)
Modifies all EdifPortRefs in this object that match one of those in the Collection of oldPorts to point to the newPort.

Parameters:
oldPorts - A Collection of EdifPort Objects to match up with those in this Object
newPort - The EdifPort Object to have the old EdifPortRef Objects point to

modifyBusToSinglePorts

void modifyBusToSinglePorts(EdifPort oldPort,
                            java.util.Collection newPorts)
Modifies all EdifPortRefs in this object that matches the passed-in old EdifPort Object to point one of those in the Collection of newPorts.

Parameters:
oldPort - The old EdifPort Object to match up with EdifPortRefs in this Object
newPorts - The Collection of EdifPort Objects to have the old EdifPortRef Objects point to

modifyCellTypeInNets

void modifyCellTypeInNets(EdifCell oldType,
                          EdifCell newType)
This method will iterate through all EdifPortRef objects contained in this net and modify the port connection for each EdifPortRef that points to an EdifCellInstance of type "oldType". This method is called by other methods that change the type of an EdifCell.

This method assumes that the EdifCellInstances refer to the old type and have not yet been modified.

Parameters:
oldType - The old Cell whose information needs to be updated to the information in the new cell
newType - The new cell that contains the information that the old cell needs to be updated to
See Also:
EdifCell.modifyCellType(byucc.edif.EdifCell, byucc.edif.EdifCell, boolean)

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.

Returns:
a String value representing this Object and its EdifPortRefs

trimToSize

public void trimToSize()
Trims to size this object and all contained Trimmable Objects.