byucc.edif
Class EdifCell

java.lang.Object
  extended bybyucc.edif.NamedPropertyObject
      extended bybyucc.edif.EdifCell
All Implemented Interfaces:
EdifOut, Nameable, Properties, java.io.Serializable, Trimable

public class EdifCell
extends NamedPropertyObject
implements EdifOut, Trimable, java.io.Serializable

Represents an EDIF cell definition. This class is not tied to any target langauge or implementation (i.e. VHDL, JHDL, etc).

This implementation of EdifCell contains Lists of all EdifCellInstance, EdifNet, and EdifPort objects associated with this EdifCell object. Additionally, this class contains a reference to the EdifLibrary object which owns the EdifCell object.

This class may allocate a large amount of memory to represent a given cell. To help control the memory allocation, this class implements the Trimable interface for trimming unneeded memory.

Sample EDIF code for an EdifCell:

 (cell graycount (cellType GENERIC)
    (view netlist (viewType NETLIST)
      (interface
        (port G_5322 (direction INPUT))
        ...
      )
      (contents
       (instance (rename count_0 "count[0]") (viewRef PRIM (cellRef FDCE (libraryRef UNILIB)))
       ...
       (net (rename write_addrgray_pre_0 "WRITE_ADDRGRAY_PRE(0)") (joined
        (portRef (member write_addrgray_pre 3))
        (portRef Q (instanceRef count_gray_0))
       ))
       ...
       )
      )
    )
 )
 

Definitions

There are a number of terms that are used to describe the various components of an EdifCell. This list serves as the definition of these terms to insure consistent and understandable usage.

To Do:

Name Space:

Version:
$Id: EdifCell.java,v 1.118 2004/08/27 19:16:42 tsa6 Exp $
Author:
Welson Sun, Mike Wirthlin, Tyler Anderson
See Also:
EdifPort, EdifCellInstance, EdifNet, EdifLibrary, Serialized Form

Field Summary
private  HashMapNameSpaceResolver _cellInstanceList
          This List is used to hold all of the instanced children within the cell (EdifCellInstance).
private  EdifCellInterface _interface
          The port interface of this EdifCell.
private  boolean _isPrimitive
          This flag indicates that the given EdifCell is a library "primitive" and does not contain any internal heirarchy (i.e. cell instances or nets).
private  EdifLibrary _library
          The EdifCell is defined within an Edif_Libraryrary.
private  HashMapNameSpaceResolver _netList
          This List is used to hold all the internal nets in this cell (EdifNet).
 
Fields inherited from class byucc.edif.NamedPropertyObject
 
Constructor Summary
EdifCell(EdifCell cell)
          Constructs an identical copy of cell.
EdifCell(EdifNameable name)
          Constructs an empty, named EdifCell object.
EdifCell(EdifNameable name, boolean isPrimitive)
          Constructs an empty, named EdifCell object.
EdifCell(java.lang.String name)
          Constructs an empty, named EdifCell object.
EdifCell(java.lang.String name, boolean isPrimitive)
          Constructs an empty, named EdifCell object.
EdifCell(java.lang.String name, EdifCellInterface iface)
          Constructs an empty, named EdifCell object.
 
Method Summary
 boolean addNet(EdifNet net)
          Add an EdifNet object to the EdifCell.
 EdifPort addPort(EdifNameable name, int width, int direction)
          Adds a new port to the EdifCellInterface.
 EdifPort addPort(java.lang.String name, int width, int direction)
          Adds a new port to the EdifCellInterface.
 boolean addSubCell(EdifCellInstance cellInstance)
          Add an EdifCellInstance object to the EdifCell.
 boolean busMatch(EdifCell cell)
          Returns true if the interfaces match, allowing to compare for a possible bus.
 java.util.Iterator cellInstanceIterator()
          Returns an Iterator of this cell's cellInstances.
 boolean contains(EdifCellInstance contain)
          Checks to see if the passed-in EdifCellInstance is already contained within this EdifCell.
 boolean contains(EdifNet contain)
          Checks to see if the passed-in EdifNet is already contained within this EdifCell.
 boolean contains(EdifPort contain)
          Checks to see if the passed-in EdifPort is already contained within this EdifCell.
 EdifPort contractPorts(java.util.Collection ports)
          Contracts the EdifPorts in the passed-in Collection to a single EdifPort Object, if canContractPorts returns true, then it updates all references from the old EdifPort objects to the new one, and then deletes all the old EdifPort Objects.
 EdifCell copy()
          Returns a deep copy of this EdifCell Object, copying all sub-objects using the 'new' statement except String Objects, having all new objects using the new EdifCell as parent.
 boolean deleteNet(EdifNet delete)
          Deletes the given net from this EdifCell.
 void deletePort(EdifPort delete)
          Deletes the given port from this EdifCell.
 boolean deleteSubCell(EdifCellInstance cellInstance)
           
 boolean deleteSubCell(EdifCellInstance cellInstance, boolean removeRefsInNets)
          Removes an EdifCellInstance object from the current EdifCell object.
 void equalizeInterfaces(EdifCell cell)
          Overloaded method that defaults to contracting ports to busses.
 void equalizeInterfaces(EdifCell cell, boolean contract)
          Overloaded method that defaults to not making expanded port directions equal to the left alone port directions.
 void equalizeInterfaces(EdifCell cell, boolean contract, boolean makeExpandedDirectionsEqualOther)
          Overloaded method that defaults to making it ok to modify the given EdifCell Object's interface.
 void equalizeInterfaces(EdifCell cell, boolean contract, boolean makeExpandedDirectionsEqualOther, boolean dontModifyGivenCell)
          Equalizes the interface of this EdifCell to the interface of the passed-in EdifCell.
 boolean equals(EdifCell cell)
          Overloaded method that defaults to not comparing for structure, and not comparing by interface only.
 boolean equals(EdifCell cell, boolean equalsStructure, boolean equalsInterfaceOnly)
          Overloaded method that defaults to not comparing possible busses.
 boolean equals(EdifCell cell, boolean equalsStructure, boolean equalsInterfaceOnly, boolean comparePossibleBus)
          Overloaded method that defaults to not comparing the property list of each cell.
 boolean equals(EdifCell cell, boolean equalsStructure, boolean equalsInterfaceOnly, boolean comparePossibleBus, boolean equalsProperties)
          Overloaded method that defaults to ignoring individual port directions when comparing against a bus.
 boolean equals(EdifCell cell, boolean equalsStructure, boolean equalsInterfaceOnly, boolean comparePossibleBus, boolean equalsProperties, boolean ignoreBusDirection)
          Checks the equality of two EdifCell objects.
 boolean equalsInterface(EdifCell cell)
          Overloaded method that defaults to not comparing by possible bus.
 boolean equalsInterface(EdifCell cell, boolean comparePossibleBus)
          Overloaded method that defaults to ignoring individual port directions when comparing against a bus.
 boolean equalsInterface(EdifCell cell, boolean comparePossibleBus, boolean ignoreBusDirection)
          Determines whether the given EdifCell object matches the interface of the current EdifCell object.
private  boolean equalsStructure(EdifCell cell)
          This method will determine if the structure of the EdifCell parameter is the same as the structure of this EdifCell.
 java.util.Collection expandPort(EdifPort port)
          Expands the passed-in EdifPort, if canExpandPort returns true, then all references to it point to the new EdifPorts, and the old one is deleted.
 java.util.Collection findCellInstancesOf(EdifCell type)
          This function returns all EdifCellInstances within this EdifCell object that reference a given cell in this library (i.e. the same type as the given cell).
 java.util.Collection findSinglePortsWithMatchingBaseName(java.lang.String baseName)
          Returns all ports whose baseName matches the passed-in String.
static EdifCell flatten(EdifCell origCell)
          Create a flattened copy of the given EdifCell.
 EdifCellInstance getCellInstance(java.lang.String name)
          Returns the EdifCellInstance contained within this EdifCell Object that matches the passed-in name.
 java.util.Collection getDanglingNets()
          Dangling net is not connected to any outputs.
 java.util.Collection getDanglingNets(boolean inputNoOutput, boolean outputsOnly)
          Dangling net is not connected to any outputs.
 java.util.Collection getHierarchicalPrimitiveList()
          Returns a Collection of List objects for each primitive instance within the hierarchy of this cell.
 java.util.Collection getInnerCells()
          Returns a Collection of all EdifCells instanced by the EdifCellInstances contained within this EdifCell Object.
 java.util.Collection getInputPorts()
          Returns a Collection Object of the input ports
 EdifCellInstance getInstance(java.lang.String name)
          Returns the EdifCellInstance Object that matches the passed-in name, or null if not found.
 EdifNet getInstancePortNet(EdifCellInstance instance, EdifPort port)
          This method will return the EdifNet that is connected to the given port on the given instance.
 java.util.Map getInstanceToMapOfPortsToPortRefArrayMapping(EdifCellInstance thisInst)
          Instances to Mapping of Ports to portRef array
 EdifCellInterface getInterface()
          Returns the EdifCellInterface of this EdifCell.
 java.util.Collection getLeafInstancesRecursively()
          Returns all EdifCellInstances contained in the EdifCell hierarchy, starting at this EdifCell Object and below, that refer to leaf cells.
 EdifLibrary getLibrary()
          Returns the EdifLibrary object to which the current EdifCell object belongs.
 EdifPort getMatchingPort(EdifPort port)
          Returns the EdifPort object which defines a port on the current EdifCell object and corresponds to the given name.
 EdifNet getNet(java.lang.String name)
          Returns the net that maps to the given name.
 java.util.Collection getNetList()
          Returns a List containing all of the EdifNet objects which this EdifCell object currently owns.
 java.util.Collection getOutputPorts()
          Returns a Collection Object of the output ports
 EdifPort getPort(java.lang.String name)
          Returns the EdifPort object which defines a port on the current EdifCell object and corresponds to the given name.
 java.util.Collection getPortList()
          Returns a Collection containing all of the EdifPort objects currently associated with this EdifCell object.
 java.util.Collection getPortRefs()
          Returns a collection of all EdifPortRef objects owned by this cell.
 java.util.Collection getSortedNetList()
          Returns a sorted Collection containing all of the EdifNet objects currently by this EdifCell object.
 java.util.Collection getSortedPortList()
          Returns a sorted Collection containing all of the EdifPort objects currently associated with this EdifCell object.
 java.util.TreeMap getSortedPropertyList()
          Returns a TreeMap of all Property objects corresponding to properties of the current EdifCell object.
 java.util.Collection getSortedSubCellList()
          Returns a Collection of EdifCellInstance objects owned and instantiated by the current EdifCell object.
 java.util.Collection getSubCellList()
          Returns a Collection of EdifCellInstance objects owned and instantiated by the current EdifCell object.
 java.util.Collection getUnconnectedInstances()
          Returns a Collection of EdifCellInstance objects that are not connected to any EdifNet in the Cell.
 java.util.Map getUnconnectedPorts()
          Returns a map whose key is an EdifCellInstance (EdifCell key refers to this cell), and whose value is a Collection of unconnected ports.
 boolean isLeafCell()
          Returns true if the current EdifCell object has no children in its EdifCellInstance list; otherwise, returns false.
 boolean isPrimitive()
          Returns whether or not this is a known primitive cell.
(package private)  void modifyBusToSinglePorts(EdifPort oldPort, java.util.Collection newPorts)
          Modifies any references from oldPort to the correct EdifPort in newPorts.
 void modifyCellType(EdifCell oldType, EdifCell newType)
          This method will search through the EdifCell and modify the "cell type" of each EdifCellInstance of type oldType and replace it with an EdifCell of type newType.
(package private)  void modifyCellType(EdifCell oldType, EdifCell newType, boolean check)
          This method will search through the EdifCell and modify the "cell type" of each EdifCellInstance of type oldType and replace it with an EdifCell of type newType.
(package private)  void modifyCellType(EdifCellInstance oldTypeInst, EdifCell newType, boolean check)
          This method will search through the EdifCell and modify the "cell type" of the given EdifCellInstance of type oldType and replace it with an EdifCell of type newType.
 void modifyCellType(java.util.Map modifyMap)
          This method will use the modifyMap parameter to replace all EdifCellInstance types.
(package private)  void modifySinglePortsToBus(java.util.Collection oldPorts, EdifPort newPort)
          Modifies any references from oldPorts to newPort.
 java.util.Iterator netListIterator()
          Returns an iterator of this cell's nets.
protected  void setLibrary(EdifLibrary library)
          Sets the library for this EdifCell object if this EdifCell object is contained within the passed-in library. lib.addCell calls this method after adding the cell to the library.
 void setPrimitive()
          Sets this cell to primitive.
 void tagAsPrimitive(EdifLibrary primitives)
          Tags this cell as primitive if it matches a cell in the passed-in library.
 void toEdif(EdifPrintWriter epw)
          Writes the EDIF representation of this EdifCell object to the EdifPrintWriter passed as a parameter.
 java.lang.String toString()
          Returns a String representation of this object.
 void trimToSize()
          This method will trim the size of all collections contained by this class.
 void uniqueify()
          Makes unique, every instance in this cell, meaning that a new EdifCell will be copied and added to the same library for each instanced cell that this EdifCell contains that doesn't refer to a leaf cell.
 void uniqueify(EdifCellInstance instance, boolean uniqueifyLeaves, boolean recurse)
          Makes a unique EdifCell object for the passed in EdifCellInstance.
 
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

_cellInstanceList

private HashMapNameSpaceResolver _cellInstanceList
This List is used to hold all of the instanced children within the cell (EdifCellInstance). No space is initially allocated for this list since primitive cells will not contain cell instances.


_isPrimitive

private boolean _isPrimitive
This flag indicates that the given EdifCell is a library "primitive" and does not contain any internal heirarchy (i.e. cell instances or nets). Note that a "primitive" EdifCell is different than an EdifCell that has no internal cell instances or nets. An "empty" EdifCell that is not a primitive corresponds to a "black box" or an EdifCell object whose contents have not been defined. It is called a "black box" because we do not know what is inside of it. A primitive, however, is known to be a leaf-cell.
This field is a atomic meaning that it can only be set in the constructor.

See Also:
isLeafCell(), isPrimitive()

_library

private EdifLibrary _library
The EdifCell is defined within an Edif_Libraryrary. This field member defines the Edif_Libraryrary that owns this cell.


_netList

private HashMapNameSpaceResolver _netList
This List is used to hold all the internal nets in this cell (EdifNet). No space is initially allocated for this list since primitive cells will not contain nets.


_interface

private EdifCellInterface _interface
The port interface of this EdifCell.

Constructor Detail

EdifCell

public EdifCell(java.lang.String name)
Constructs an empty, named EdifCell object.

Parameters:
name - The name of the EdifCell object

EdifCell

public EdifCell(EdifNameable name)
Constructs an empty, named EdifCell object.

Parameters:
name - The name of the EdifCell object

EdifCell

public EdifCell(java.lang.String name,
                EdifCellInterface iface)
Constructs an empty, named EdifCell object.

Parameters:
name - The name of the EdifCell object

EdifCell

public EdifCell(java.lang.String name,
                boolean isPrimitive)
Constructs an empty, named EdifCell object. This constructor allows the primitive flag to be set.

Parameters:
name - The name of the EdifCell object
isPrimitive - Specifies the value of the _isPrimitive field for this EdifCell Object

EdifCell

public EdifCell(EdifNameable name,
                boolean isPrimitive)
Constructs an empty, named EdifCell object. This constructor allows the primitive flag to be set.

Parameters:
name - The name of the EdifCell object
isPrimitive - Specifies the value of the _isPrimitive field for this EdifCell Object

EdifCell

public EdifCell(EdifCell cell)
Constructs an identical copy of cell. TODO: we need to unify the copy methods.

Method Detail

addNet

public boolean addNet(EdifNet net)
Add an EdifNet object to the EdifCell. This sets the parent of the EdifNet object to the current EdifCell object.

Parameters:
net - EdifNet object to add to the EdifCell

addPort

public EdifPort addPort(EdifNameable name,
                        int width,
                        int direction)
Adds a new port to the EdifCellInterface.

Parameters:
name - The name of the new port to add
width - The width of the new port to add
direction - The direction of the new port to add

addPort

public EdifPort addPort(java.lang.String name,
                        int width,
                        int direction)
Adds a new port to the EdifCellInterface.

Parameters:
name - The name of the new port to add
width - The width of the new port to add
direction - The direction of the new port to add

addSubCell

public boolean addSubCell(EdifCellInstance cellInstance)
Add an EdifCellInstance object to the EdifCell. The parent of the EdifCellInstance is set to the current EdifCell object. TODO: we need to give the user the option of not allowing renaming. TODO: create a method addSubCell (EdifCell, name) that creates the edifcellinstance automatically for the user.

Parameters:
cellInstance - EdifCellInstance object to add to the EdifCell

busMatch

public boolean busMatch(EdifCell cell)
Returns true if the interfaces match, allowing to compare for a possible bus. Example, a set of ports from 0 to 31 are separate in one cell, but grouped as a bus in another cell. They will match using this method if their base name is the same as well as direction, etc.

Parameters:
cell - The cell used for comparison
Returns:
True if this EdifCell Object and the passed-in EdifCell Object's match, taking into account bus matching
See Also:
equals(EdifCell,boolean,boolean,boolean)

cellInstanceIterator

public java.util.Iterator cellInstanceIterator()
Returns an Iterator of this cell's cellInstances.

Returns:
An Iterator Object of all the EdifCellInstances contained within this EdifCell Object

contains

public boolean contains(EdifCellInstance contain)
Checks to see if the passed-in EdifCellInstance is already contained within this EdifCell. Equality is done using ==.

Parameters:
contain - The EdifCellInstance to compare against the EdifCellInstance Objects contained within this EdifCell Object to check to see if it already exists in this EdifCell
Returns:
True if the passed-in EdifCellInstance is already contained within this EdifCell Object

contains

public boolean contains(EdifPort contain)
Checks to see if the passed-in EdifPort is already contained within this EdifCell. Equality is done using ==.

Parameters:
contain - The EdifPort to compare against the EdifPort Objects contained within this EdifCell Object to check to see if it already exists in this EdifCell
Returns:
True if the passed-in EdifPort is already contained within this EdifCell Object

contains

public boolean contains(EdifNet contain)
Checks to see if the passed-in EdifNet is already contained within this EdifCell. Equality is done using ==.

Parameters:
contain - The EdifNet to compare against the EdifNet Objects contained within this EdifCell Object to check to see if it already exists in this EdifCell
Returns:
True if the passed-in EdifNet is already contained within this EdifCell Object

contractPorts

public EdifPort contractPorts(java.util.Collection ports)
Contracts the EdifPorts in the passed-in Collection to a single EdifPort Object, if canContractPorts returns true, then it updates all references from the old EdifPort objects to the new one, and then deletes all the old EdifPort Objects.

Parameters:
ports - The Collection of EdifPort Objects to contract to a single EdifPort Object
Returns:
The contracted EdifPort Object

copy

public EdifCell copy()
Returns a deep copy of this EdifCell Object, copying all sub-objects using the 'new' statement except String Objects, having all new objects using the new EdifCell as parent.

Returns:
An EdifCell that is a copy of this one, having all new objects pointing to this one as parent

getDanglingNets

public java.util.Collection getDanglingNets(boolean inputNoOutput,
                                            boolean outputsOnly)
Dangling net is not connected to any outputs. Outter ports labeled IN and inner ports labeled OUT are inputs. Outter ports labeled OUT and inner ports labeled IN are outputs. Each net must have at least one output and one input.

Note: By default (false and false gets passed to this method) this method will only return nets with only inputs or nets with only outputs. Also, if inputNoOutput is true then the value of outputsOnly gets over-ridden.

Parameters:
inputNoOutput - Only returns nets with input(s) and no outputs, if true
outputsOnly - If true, this method will only return nets with outputs and no inputs
Returns:
A Collection of EdifNet Objects that have no outputs (they are dangling)

getDanglingNets

public java.util.Collection getDanglingNets()
Dangling net is not connected to any outputs. Outter ports labeled IN and inner ports labeled OUT are inputs. Outter ports labeled OUT and inner ports labeled IN are outputs. Each net must have at least one output and one input.

Note: By default this method will only return nets with only inputs or nets with only outputs.

Returns:
A Collection of EdifNet Objects that have no outputs (they are dangling)
See Also:
getDanglingNets(boolean,boolean)

deleteNet

public boolean deleteNet(EdifNet delete)
Deletes the given net from this EdifCell.

Parameters:
delete - The EdifNet to delete
Returns:
True if it was deleted, false otherwise

deletePort

public void deletePort(EdifPort delete)
Deletes the given port from this EdifCell.

Parameters:
delete - The EdifPort to delete
Returns:
True if it was deleted, false otherwise

deleteSubCell

public boolean deleteSubCell(EdifCellInstance cellInstance,
                             boolean removeRefsInNets)
Removes an EdifCellInstance object from the current EdifCell object. Returns true if the instance was found and successfully removed, otherwise false.

Parameters:
cellInstance - EdifCellInstance object to remove from the current EdifCell object.
removeRefsInNets - Deletes all references to this instance in all the nets within this EdifCell, if true
Returns:
boolean indicating whether the EdifCellInstance object was successfully found and removed

deleteSubCell

public boolean deleteSubCell(EdifCellInstance cellInstance)

equals

public boolean equals(EdifCell cell,
                      boolean equalsStructure,
                      boolean equalsInterfaceOnly,
                      boolean comparePossibleBus,
                      boolean equalsProperties,
                      boolean ignoreBusDirection)
Checks the equality of two EdifCell objects. Two EdifCell objects match if their names are the same and their interfaces are the same. If the equalsStructure flag is set, this method will also check the equality of the cell internal structure.

Parameters:
cell - EdifCell object to compare against the current EdifCell object
equalsStructure - If this parameter is true, check the structure of the two EdifCell objects as part of the equality condition.
equalsInterfaceOnly - If true, the equality comparison will be made by interface only, excluding name and structure
comparePossibleBus - If true, the equalsInterface will look for a possible bus match, meaning if one interface has 32 ports with the same base name that correspond to a bus and the interface has one port with 32 members that has the same name as the 32 port's base names and they all have the same direction, etc then this will count as a match
equalsProperties - If true, the two cells property lists will also be compared for equality
ignoreBusDirection - If true, the matching algorithm will ignore the direction of the passed-in ports
Returns:
True if this EdifCell object and the passed-in one are equal

equals

public boolean equals(EdifCell cell,
                      boolean equalsStructure,
                      boolean equalsInterfaceOnly,
                      boolean comparePossibleBus,
                      boolean equalsProperties)
Overloaded method that defaults to ignoring individual port directions when comparing against a bus.

Parameters:
cell - The cell used for comparison
equalsStructure - If true, the equality comparison will be made taking structure into account
equalsInterfaceOnly - If true, the equality comparison will be made by interface only, excluding name and structure
comparePossibleBus - If true, the equalsInterface will look for a possible bus match, meaning if one interface has 32 ports with the same base name that correspond to a bus and the interface has one port with 32 members that has the same name as the 32 port's base names and they all have the same direction, etc then this will count as a match
equalsProperties - If true, the two cells property lists will also be compared for equality
Returns:
True if this EdifCell object and the passed-in one are equal
See Also:
equals(EdifCell,boolean,boolean,boolean,boolean,boolean)

equals

public boolean equals(EdifCell cell,
                      boolean equalsStructure,
                      boolean equalsInterfaceOnly,
                      boolean comparePossibleBus)
Overloaded method that defaults to not comparing the property list of each cell.

Parameters:
cell - The cell used for comparison
equalsStructure - If true, the equality comparison will be made taking structure into account
equalsInterfaceOnly - If true, the equality comparison will be made by interface only, excluding name and structure
comparePossibleBus - If true, the equalsInterface will look for a possible bus match, meaning if one interface has 32 ports with the same base name that correspond to a bus and the interface has one port with 32 members that has the same name as the 32 port's base names and they all have the same direction, etc then this will count as a match
Returns:
True if this EdifCell object and the passed-in one are equal
See Also:
equals(EdifCell,boolean,boolean,boolean,boolean,boolean)

equals

public boolean equals(EdifCell cell,
                      boolean equalsStructure,
                      boolean equalsInterfaceOnly)
Overloaded method that defaults to not comparing possible busses.

Parameters:
cell - The cell used for comparison
equalsStructure - If true, the equality comparison will be made taking structure into account
equalsInterfaceOnly - If true, the equality comparison will be made by interface only, excluding name and structure
Returns:
True if this EdifCell object and the passed-in one are equal
See Also:
equals(EdifCell,boolean,boolean,boolean)

equals

public boolean equals(EdifCell cell)
Overloaded method that defaults to not comparing for structure, and not comparing by interface only.

Parameters:
cell - The cell used for comparison
Returns:
True if this EdifCell Object and the passed-in one are equal
See Also:
equals(EdifCell,boolean,boolean)

equalsInterface

public boolean equalsInterface(EdifCell cell,
                               boolean comparePossibleBus,
                               boolean ignoreBusDirection)
Determines whether the given EdifCell object matches the interface of the current EdifCell object. To make this test, each port is compared for equality. Two EdifCell port interfaces are the same if each of the following conditions are met:
The internal structure of the two EdifCell objects are not checked for equality.

Parameters:
cell - EdifCell object to compare against the current EdifCell object
comparePossibleBus - If true, the equalsInterface will look for a possible bus match, meaning if one interface has 32 ports with the same base name that correspond to a bus and the interface has one port with 32 members that has the same name as the 32 port's base names and they all have the same direction, etc then this will count as a match
ignoreBusDirection - If true, the matching algorithm will ignore the direction of the passed-in ports
Returns:
boolean indicating whether the two EdifCell objects have equivalent port interfaces
See Also:
equals(byucc.edif.EdifCell, boolean, boolean, boolean, boolean, boolean), EdifCellInterface.equals(EdifCellInterface,boolean)

equalsInterface

public boolean equalsInterface(EdifCell cell,
                               boolean comparePossibleBus)
Overloaded method that defaults to ignoring individual port directions when comparing against a bus.

Parameters:
cell - The cell used for the inteface comparison
Returns:
True if the interfaces are equal
See Also:
equalsInterface(EdifCell,boolean)

equalsInterface

public boolean equalsInterface(EdifCell cell)
Overloaded method that defaults to not comparing by possible bus.

Parameters:
cell - The cell used for the inteface comparison
Returns:
True if the interfaces are equal
See Also:
equalsInterface(EdifCell,boolean)

equalizeInterfaces

public void equalizeInterfaces(EdifCell cell,
                               boolean contract,
                               boolean makeExpandedDirectionsEqualOther,
                               boolean dontModifyGivenCell)
Equalizes the interface of this EdifCell to the interface of the passed-in EdifCell. All ports that match on bus will be contracted or expanded so that merging can take place.

Parameters:
cell - The cell whose interface will be equalized with this one
contract - Specifies whether to contract ports or to expand busses
makeExpandedDirectionsEqualOther - If true, and if contract is false by inference, when the port is expanded, the ports of one interface will be set to the same direction as the corresponding port in the other interface
dontModifyGivenCell - If true, the passed-in EdifCellInterface will not be modified, and the passed-in contract flag will be ignored
See Also:
equalizeInterfaces(EdifCell), equalizeInterfaces(EdifCell,boolean), equalizeInterfaces(EdifCell,boolean,boolean)

equalizeInterfaces

public void equalizeInterfaces(EdifCell cell,
                               boolean contract,
                               boolean makeExpandedDirectionsEqualOther)
Overloaded method that defaults to making it ok to modify the given EdifCell Object's interface.

Parameters:
cell - The cell whose interface will be equalized with this one
contract - Specifies whether to contract ports or to expand busses
makeExpandedDirectionsEqualOther - If true, and if contract is false by inference, when the port is expanded, the ports of one interface will be set to the same direction as the corresponding port in the other interface
See Also:
equalizeInterfaces(EdifCell,boolean,boolean,boolean)

equalizeInterfaces

public void equalizeInterfaces(EdifCell cell,
                               boolean contract)
Overloaded method that defaults to not making expanded port directions equal to the left alone port directions.

Parameters:
cell - The interface to match with this one
contract - Specifies whether to contract ports or to expand busses
See Also:
equalizeInterfaces(EdifCell,boolean, boolean)

equalizeInterfaces

public void equalizeInterfaces(EdifCell cell)
Overloaded method that defaults to contracting ports to busses.

Parameters:
cell - The interface to match with this one
See Also:
equalizeInterfaces(EdifCell,boolean)

equalsStructure

private boolean equalsStructure(EdifCell cell)
This method will determine if the structure of the EdifCell parameter is the same as the structure of this EdifCell. The algorithm is as follows:

Parameters:
cell - The cell to check equality with this cell
Returns:
True if both cells have the same structure
See Also:
equals(byucc.edif.EdifCell, boolean, boolean, boolean, boolean, boolean)

expandPort

public java.util.Collection expandPort(EdifPort port)
Expands the passed-in EdifPort, if canExpandPort returns true, then all references to it point to the new EdifPorts, and the old one is deleted.

Parameters:
port - The EdifPort Object to be expanded
Returns:
A Collection of the expanded EdifPort Objects

findCellInstancesOf

public java.util.Collection findCellInstancesOf(EdifCell type)
This function returns all EdifCellInstances within this EdifCell object that reference a given cell in this library (i.e. the same type as the given cell). If no EdifCellInstances of this type are found, this method will return null.

Parameters:
type - The EdifCell Object to find references to within this EdifCell
Returns:
A Collection of EdifCellInstances contained within this EdifCell that reference the passed-in EdifCell

findSinglePortsWithMatchingBaseName

public java.util.Collection findSinglePortsWithMatchingBaseName(java.lang.String baseName)
Returns all ports whose baseName matches the passed-in String.

Parameters:
baseName - The base name of the ports to return
Returns:
A Collection of non-bus ports that match the passed-in String
See Also:
EdifCellInterface.findSinglePortsWithMatchingBaseName(java.lang.String)

getCellInstance

public EdifCellInstance getCellInstance(java.lang.String name)
Returns the EdifCellInstance contained within this EdifCell Object that matches the passed-in name.

Parameters:
name - The String used to match the returned EdifCellInstance
Returns:
The EdifCellInstance Object whose name matches the passed-in name

getInstancePortNet

public EdifNet getInstancePortNet(EdifCellInstance instance,
                                  EdifPort port)
This method will return the EdifNet that is connected to the given port on the given instance.

Parameters:
instance - The EdifCellInstance Object that one of the returned EdifNet Object's EdifPortRef Objects connects to
port - The EdifPort Object that one of the returned EdifNet Object's EdifPortRef Objects refers to
Returns:
An EdifNet Object that has an EdifPortRef Object that referse to the passed-in EdifPort Object, and connects to the passed-in EdifCellInstance Object

getInterface

public EdifCellInterface getInterface()
Returns the EdifCellInterface of this EdifCell.

Returns:
An EdifCellInterface Object that defines the port interface of this EdifCell

getNet

public EdifNet getNet(java.lang.String name)
Returns the net that maps to the given name.

Parameters:
name - The key name of the EdifNet to retrieve
Returns:
An EdifNet Object mapped to the given name

getInstance

public EdifCellInstance getInstance(java.lang.String name)
Returns the EdifCellInstance Object that matches the passed-in name, or null if not found.

Parameters:
name - The name of the EdifCellInstance to return
Returns:
The EdifCellInstance Object that matches the passed-in name or null

getHierarchicalPrimitiveList

public java.util.Collection getHierarchicalPrimitiveList()
Returns a Collection of List objects for each primitive instance within the hierarchy of this cell. Leaf cells will return a null Collection.

Returns:
A Collection of List Objects of EdifCellInstance Objects that are in order of hierarchy down to primitives

getLibrary

public EdifLibrary getLibrary()
Returns the EdifLibrary object to which the current EdifCell object belongs.

Returns:
EdifLibrary object to which the current EdifCell object belongs

getNetList

public java.util.Collection getNetList()
Returns a List containing all of the EdifNet objects which this EdifCell object currently owns.

Returns:
A Collection containing the EdifNet objects owned by the current EdifCell object

getMatchingPort

public EdifPort getMatchingPort(EdifPort port)
Returns the EdifPort object which defines a port on the current EdifCell object and corresponds to the given name. If no such EdifPort is found, a null object is returned.

Parameters:
port - The EdifPort to find a match for within this EdifCellInterface
Returns:
The EdifPort corresponding to the passed-in port

getPort

public EdifPort getPort(java.lang.String name)
Returns the EdifPort object which defines a port on the current EdifCell object and corresponds to the given name. If no such EdifPort is found, a null object is returned.

Parameters:
name - A string indicating the name of the EdifPort object desired to be found
Returns:
The EdifPort corresponding to the given name

getInstanceToMapOfPortsToPortRefArrayMapping

public java.util.Map getInstanceToMapOfPortsToPortRefArrayMapping(EdifCellInstance thisInst)
Instances to Mapping of Ports to portRef array


getInputPorts

public java.util.Collection getInputPorts()
Returns a Collection Object of the input ports


getOutputPorts

public java.util.Collection getOutputPorts()
Returns a Collection Object of the output ports


getPortList

public java.util.Collection getPortList()
Returns a Collection containing all of the EdifPort objects currently associated with this EdifCell object.

Returns:
Collection containing the EdifPort objects associated with the current EdifCell object

getSortedNetList

public java.util.Collection getSortedNetList()
Returns a sorted Collection containing all of the EdifNet objects currently by this EdifCell object. The objects in the Collection are sorted by their names.

Returns:
Sorted Collection containing the EdifNet objects owned by the current EdifCell object

getSortedPortList

public java.util.Collection getSortedPortList()
Returns a sorted Collection containing all of the EdifPort objects currently associated with this EdifCell object. The objects in the Collection are sorted by their names.

Returns:
Sorted Collection containing the EdifPort objects associated with the current EdifCell object

getSortedPropertyList

public java.util.TreeMap getSortedPropertyList()
Returns a TreeMap of all Property objects corresponding to properties of the current EdifCell object.

Returns:
TreeMap containing all properties of the EdifCell object in the form of Property objects

getSortedSubCellList

public java.util.Collection getSortedSubCellList()
Returns a Collection of EdifCellInstance objects owned and instantiated by the current EdifCell object. The EdifCellInstance objects are sorted based on their names.

Returns:
sorted Collection containing all EdifCellInstance objects owned by this EdifCell

getSubCellList

public java.util.Collection getSubCellList()
Returns a Collection of EdifCellInstance objects owned and instantiated by the current EdifCell object.

Returns:
A Collection containing all EdifCellInstance objects owned by this EdifCell

getLeafInstancesRecursively

public java.util.Collection getLeafInstancesRecursively()
Returns all EdifCellInstances contained in the EdifCell hierarchy, starting at this EdifCell Object and below, that refer to leaf cells.

Returns:
A Collection of EdifCellInstance Objects that refer to leaf cells starting from this EdifCell, and recursively searching down the hierarchy

getInnerCells

public java.util.Collection getInnerCells()
Returns a Collection of all EdifCells instanced by the EdifCellInstances contained within this EdifCell Object.

Returns:
A Collection of all the different EdifCell "types" instanced as sub-cells within the current EdifCell

getUnconnectedInstances

public java.util.Collection getUnconnectedInstances()
Returns a Collection of EdifCellInstance objects that are not connected to any EdifNet in the Cell.


getPortRefs

public java.util.Collection getPortRefs()
Returns a collection of all EdifPortRef objects owned by this cell. This method will iterate over each Net in the Cell and include all EdifPortRef objects owned by each Net.


isLeafCell

public boolean isLeafCell()
Returns true if the current EdifCell object has no children in its EdifCellInstance list; otherwise, returns false.

Returns:
boolean indicating if this EdifCell is a leaf cell

isPrimitive

public boolean isPrimitive()
Returns whether or not this is a known primitive cell. Note that this is different than a "black box". A black box is a an empty EdifCell whose contents have not been defined.

Returns:
True if this cell is a primitive

modifySinglePortsToBus

void modifySinglePortsToBus(java.util.Collection oldPorts,
                            EdifPort newPort)
Modifies any references from oldPorts to newPort.

Parameters:
oldPorts - A Collection of EdifPort Objects to update
newPort - The EdifPort Object to have the old ones point to
See Also:
modifySinglePortsToBus(java.util.Collection, byucc.edif.EdifPort)

modifyBusToSinglePorts

void modifyBusToSinglePorts(EdifPort oldPort,
                            java.util.Collection newPorts)
Modifies any references from oldPort to the correct EdifPort in newPorts.

Parameters:
oldPort - The old EdifPort to update
newPorts - The Collection of EdifPort Objects to have the old ones point to
See Also:
modifyBusToSinglePorts(byucc.edif.EdifPort, java.util.Collection)

modifyCellType

void modifyCellType(EdifCell oldType,
                    EdifCell newType,
                    boolean check)
This method will search through the EdifCell and modify the "cell type" of each EdifCellInstance of type oldType and replace it with an EdifCell of type newType. The cell interface of these two types must be the same or this method will throw a EdifRuntimeException. This method will also modify all of the EdifPortRefs among the nets in the current cell to reflect this change in type.

Note that this method does not check the structure of the two intput types. This method assumes that the replacement is valid (this method will double check the equality of the interface).

Parameters:
oldType - The old information to be replaced
newType - The new information that will replace the old
check - If true, will check to see if the interfaces are equal, and if it's ok to make the switch. For speed, and if it's known that the match will succeed, use false
See Also:
EdifNet.modifyCellTypeInNets(byucc.edif.EdifCell, byucc.edif.EdifCell)

modifyCellType

void modifyCellType(EdifCellInstance oldTypeInst,
                    EdifCell newType,
                    boolean check)
This method will search through the EdifCell and modify the "cell type" of the given EdifCellInstance of type oldType and replace it with an EdifCell of type newType. The cell interface of these two types must be the same or this method will throw a EdifRuntimeException. This method will also modify all of the EdifPortRefs among the nets in the current cell to reflect this change in type.

Note that this method does not check the structure of the two intput types. This method assumes that the replacement is valid (this method will double check the equality of the interface).

Parameters:
oldTypeInst - The instance whose reference will be updated
newType - The new information that will replace the old
check - If true, will check to see if the interfaces are equal, and if it's ok to make the switch. For speed, and if it's known that the match will succeed, use false
See Also:
EdifNet.modifyCellTypeInNets(byucc.edif.EdifCell, byucc.edif.EdifCell)

modifyCellType

public void modifyCellType(EdifCell oldType,
                           EdifCell newType)
This method will search through the EdifCell and modify the "cell type" of each EdifCellInstance of type oldType and replace it with an EdifCell of type newType. The cell interface of these two types must be the same or this method will throw a EdifRuntimeException. This method will also modify all of the EdifPortRefs among the nets in the current cell to reflect this change in type.

Note that this method does not check the structure of the two intput types. This method assumes that the replacement is valid (this method will double check the equality of the interface).

Parameters:
oldType - The old information to be replaced
newType - The new information that will replace the old
See Also:
EdifNet.modifyCellTypeInNets(byucc.edif.EdifCell, byucc.edif.EdifCell)

modifyCellType

public void modifyCellType(java.util.Map modifyMap)
This method will use the modifyMap parameter to replace all EdifCellInstance types. The key of the map is the old cells, and the value is the new cell.

Parameters:
modifyMap - A mapping between cells that match
See Also:
modifyCellType(EdifCell,EdifCell)

netListIterator

public java.util.Iterator netListIterator()
Returns an iterator of this cell's nets.

Returns:
An Iterator Object of all the EdifNets contained in this EdifCell

setLibrary

protected void setLibrary(EdifLibrary library)
Sets the library for this EdifCell object if this EdifCell object is contained within the passed-in library. lib.addCell calls this method after adding the cell to the library.

Parameters:
library - EdifLibrary object to set as the library of the current EdifCell

setPrimitive

public void setPrimitive()
Sets this cell to primitive.


toEdif

public void toEdif(EdifPrintWriter epw)
Writes the EDIF representation of this EdifCell object to the EdifPrintWriter passed as a parameter.

Specified by:
toEdif in interface EdifOut
Parameters:
epw - EdifPrintWriter to which EDIF will be written

tagAsPrimitive

public void tagAsPrimitive(EdifLibrary primitives)
Tags this cell as primitive if it matches a cell in the passed-in library.

Parameters:
primitives - library of primitives that will be compared to this cell.

toString

public java.lang.String toString()
Returns a String representation of this object.

Returns:
A String representing this Object's name and port interface

trimToSize

public void trimToSize()
This method will trim the size of all collections contained by this class. Trimming each collection will reduce the memory consumed by this object by getting rid of all unused collection refernces. This method will also call trimToSize on each of the EdifNet objects in the _netList collection.

Specified by:
trimToSize in interface Trimable

getUnconnectedPorts

public java.util.Map getUnconnectedPorts()
Returns a map whose key is an EdifCellInstance (EdifCell key refers to this cell), and whose value is a Collection of unconnected ports. Every key will have a list of ports with size > 0. Otherwise it wouldn't appear in the map.

Returns:
A Map Object of EdifCellInstances to a Collection of EdifPorts, where each EdifPort is unconnected

uniqueify

public void uniqueify(EdifCellInstance instance,
                      boolean uniqueifyLeaves,
                      boolean recurse)
Makes a unique EdifCell object for the passed in EdifCellInstance. The new EdifCell object will be an exact copy of the original EdifCell object but will be a unique object. The new EdifCell objects created will be placed in the same library in which the oritional EdifCell library resides.

This method will uniqueify the new EdifCell object (i.e. perform a recursive uniqueify) only if the recurse parameter is set to true.

Parameters:
instance - The cell instance to uniqueify
recurse - Specifies whether or not the uniqueify should be applied recursively.

uniqueify

public void uniqueify()
Makes unique, every instance in this cell, meaning that a new EdifCell will be copied and added to the same library for each instanced cell that this EdifCell contains that doesn't refer to a leaf cell.


flatten

public static EdifCell flatten(EdifCell origCell)
Create a flattened copy of the given EdifCell. This will return a new EdifCell object with a flattened hierarchy. The resulting EdifCell will only contain primitive EdifCellInstances and no hierarchy. The passed in cell will not change during this process.

Note that this method does not add the cell to a library. The user will need to add this cell to a library before using it in a design.

Parameters:
origCell - The original Cell to be flattened
Returns:
A flat version of the given EdifCell