byucc.edif
Class EdifCellInterface

java.lang.Object
  extended bybyucc.edif.EdifCellInterface
All Implemented Interfaces:
EdifOut, java.io.Serializable, Trimable

public class EdifCellInterface
extends java.lang.Object
implements EdifOut, Trimable, java.io.Serializable

Represents the port interface of an EdifCell object.

Version:
$Id: EdifCellInterface.java,v 1.37 2004/08/27 19:16:42 tsa6 Exp $
Author:
Mike Wirthlin, Tyler Anderson
See Also:
Serialized Form

Field Summary
private  EdifCell _parent
          Parent EdifCell that owns this interface
private  ArrayListNameSpaceResolver _portList
          This List is used to hold all the EdifPort objects of the current Cell.
 
Constructor Summary
EdifCellInterface(EdifCell parent)
          Constructs an Empty EdifCellInterface Object with the passed-in EdifCell object as its parent.
 
Method Summary
 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 busMatch(EdifCellInterface cell)
          Compares the two cell interfaces, taking into account the fact that one may have no busses, and the other might.
 boolean canContractPorts(java.util.Collection ports)
          1. make sure ports isn't null 2. make sure ports has a length greater than 1 3. make sure each port is contained within the EdifCellInterface 4. check to see if they all have same base name 5. make sure all ports have a bit position 6. make sure all ports aren't busses 7. make sure that the number of ports equals number of ports that exist in the range 8. check to make sure continuous bits are present
 boolean canExpandPort(EdifPort port)
          make sure the port isn't null.
 boolean contains(EdifPort contain)
          Checks to see if the passed-in EdifPort is already contained within this EdifCellInterface.
 EdifPort contractPorts(java.util.Collection ports)
          Contracts a Collection of port objects, if canContractPorts returns true.
 EdifCellInterface copy(EdifCell parent)
          Returns a deep copy of this EdifCellInterface Object.
 void deletePort(EdifPort port)
          Removes a port from this EdifCellInterface.
 void equalizeInterfaces(EdifCellInterface cell)
          Overloaded method that defaults to contracting ports to busses.
 void equalizeInterfaces(EdifCellInterface cell, boolean contract)
          Overloaded method that defaults to not making expanded port directions equal to the left alone port directions.
 void equalizeInterfaces(EdifCellInterface cell, boolean contract, boolean makeExpandedDirectionsEqualOther)
          Overloaded method that defaults to making it ok to modify the given EdifCellInterface.
 void equalizeInterfaces(EdifCellInterface cell, boolean contract, boolean makeExpandedDirectionsEqualOther, boolean dontModifyGivenCell)
          Equalizes this interface to the passed-in interface.
 boolean equals(EdifCellInterface cell)
          Overloaded method that defaults to not comparing by possible bus.
 boolean equals(EdifCellInterface cell, boolean comparePossibleBus)
          Overloaded method that defaults to ignoring individual port directions when comparing against a bus.
 boolean equals(EdifCellInterface cell, boolean comparePossibleBus, boolean ignoreBusDirection)
          Determines whether the given EdifCell object matches the interface of the current EdifCell object.
 java.util.Collection expandPort(EdifPort port)
          Expands the passed-in port, if it exists in this EdifCellInterface into a bunch of EdifPorts.
 java.util.Collection findSinglePortsWithMatchingBaseName(java.lang.String baseName)
          Returns all ports whose baseName matches the passed-in String.
 EdifCell getEdifCell()
          Return the parent EdifCell that owns this object.
 java.util.Collection getInOutPorts()
          Returns a Collection of only inout ports.
 java.util.Collection getInputOnlyPorts()
          Returns a Collection of only input ports.
 java.util.Collection getInputPorts()
          Returns a Collection of input and inout ports.
 EdifPort getMatchingPort(EdifPort port)
          Returns a port contained within this EdifCellInterface that matches the passed-in port by base name, bit position, and by calling EdifPort.equals(EdifPort).
 java.util.Collection getOutputOnlyPorts()
          Returns a Collection of only output ports.
 java.util.Collection getOutputPorts()
          Returns a Collection of output and inout 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.List getPortList()
          Returns a Collection containing all of the EdifPort objects currently associated with this EdifCell object.
 java.util.Collection getSortedPortList()
          Returns a sorted Collection containing all of the EdifPort objects currently associated with this EdifCell object.
 boolean inOutPortCountEquals(EdifCellInterface cell)
          Returns true if the # of inout ports match in this and the passed-in interface.
 boolean inputOnlyPortCountEquals(EdifCellInterface cell)
          Returns true if the # of input ports match in this and the passed-in interface.
 boolean outputOnlyPortCountEquals(EdifCellInterface cell)
          Returns true if the # of output ports match in this and the passed-in interface.
 boolean portCountEquals(EdifCellInterface cell)
          Returns true if the # of output, input, and inout ports match for the current and passed-in cell interfaces.
 void toEdif(EdifPrintWriter epw)
          Writes the EDIF representation of this EdifCell object to the EdifPrintWriter passed as a parameter.
 java.lang.String toString()
           
 void trimToSize()
          Trims this object and all other contained Trimmable Objects down to size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_portList

private ArrayListNameSpaceResolver _portList
This List is used to hold all the EdifPort objects of the current Cell.


_parent

private EdifCell _parent
Parent EdifCell that owns this interface

Constructor Detail

EdifCellInterface

public EdifCellInterface(EdifCell parent)
Constructs an Empty EdifCellInterface Object with the passed-in EdifCell object as its parent.

Parameters:
parent - The parent EdifCell Object, or owner if this EdifCellInterface
Method Detail

addPort

public EdifPort addPort(EdifNameable name,
                        int width,
                        int direction)
Adds a new port to the EdifCellInterface. Returns null if the port wasn't added (most likely due to a name clash).

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
Returns:
The port that was added, if it wasn't, null

addPort

public EdifPort addPort(java.lang.String name,
                        int width,
                        int direction)
Adds a new port to the EdifCellInterface. Returns null if the port wasn't added (most likely due to a name clash).

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
Returns:
The port that was added, if it wasn't, null

busMatch

public boolean busMatch(EdifCellInterface cell)
Compares the two cell interfaces, taking into account the fact that one may have no busses, and the other might.

Parameters:
cell - The interface used for comparison
Returns:
True if the two interfaces match, taking into account that either might be a bus and the other not a bus
See Also:
EdifCell.busMatch(byucc.edif.EdifCell)

canContractPorts

public boolean canContractPorts(java.util.Collection ports)
1. make sure ports isn't null 2. make sure ports has a length greater than 1 3. make sure each port is contained within the EdifCellInterface 4. check to see if they all have same base name 5. make sure all ports have a bit position 6. make sure all ports aren't busses 7. make sure that the number of ports equals number of ports that exist in the range 8. check to make sure continuous bits are present

Parameters:
ports - The Collection of ports to contract to a single port
Returns:
True if the passed-in ports are contractable

canExpandPort

public boolean canExpandPort(EdifPort port)
make sure the port isn't null. make sure the port is a bus. make sure the port is contained within the EdifCellInterface.

Parameters:
port - The port to expand into multiple ports
Returns:
True if this port is expandable

contains

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

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

contractPorts

public EdifPort contractPorts(java.util.Collection ports)
Contracts a Collection of port objects, if canContractPorts returns true.

Parameters:
ports - The Collection of port objects to contract
Returns:
The new contract port (is a bus)

copy

public EdifCellInterface copy(EdifCell parent)
Returns a deep copy of this EdifCellInterface Object. All copies are done using the 'new' statement, except String Objects.

Parameters:
parent - The EdifCell that will be the parent to this copy
Returns:
The copied EdifCellInterface Object

deletePort

public void deletePort(EdifPort port)
Removes a port from this EdifCellInterface.

Parameters:
port - The port to remove

equalizeInterfaces

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

Parameters:
cell - The interface that 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(EdifCellInterface), equalizeInterfaces(EdifCellInterface,boolean)

equalizeInterfaces

public void equalizeInterfaces(EdifCellInterface cell,
                               boolean contract,
                               boolean makeExpandedDirectionsEqualOther)
Overloaded method that defaults to making it ok to modify the given EdifCellInterface.

Parameters:
cell - The interface to match 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(EdifCellInterface,boolean, boolean,boolean)

equalizeInterfaces

public void equalizeInterfaces(EdifCellInterface 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(EdifCellInterface,boolean, boolean)

equalizeInterfaces

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

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

equals

public boolean equals(EdifCellInterface 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 - Allows that the case when one port is a bus and the other port isn't or vice versa to be considered for interface equality
ignoreBusDirection - If true, the direction of the individual ports will be ignored
Returns:
boolean indicating whether the two EdifCell objects have equivalent port interfaces
See Also:
equals(EdifCellInterface), equals(EdifCellInterface,boolean)

equals

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

Parameters:
cell - The interface to match with this one
comparePossibleBus - Allows that the case when one port is a bus and the other port isn't or vice versa to be considered for interface equality
Returns:
boolean indicating whether the two EdifCell objects have equivalent port interfaces
See Also:
equals(EdifCellInterface,boolean,boolean)

equals

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

Parameters:
cell - The interface to match with this one
Returns:
boolean indicating whether the two EdifCell objects have equivalent port interfaces
See Also:
equals(EdifCellInterface,boolean,boolean)

expandPort

public java.util.Collection expandPort(EdifPort port)
Expands the passed-in port, if it exists in this EdifCellInterface into a bunch of EdifPorts. Purpose: Expand a multi-bit port into individual ports; create a whole bunch of new 1-bit ports, and leave old port around.

Parameters:
port - The port to expand into a bunch of EdifPorts
Returns:
The collection of expanded EdifPort Objects

findSinglePortsWithMatchingBaseName

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

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

getEdifCell

public EdifCell getEdifCell()
Return the parent EdifCell that owns this object.

Returns:
An EdifCell Object that is the parent to this EdifCellInterface

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 passed-in port

getMatchingPort

public EdifPort getMatchingPort(EdifPort port)
Returns a port contained within this EdifCellInterface that matches the passed-in port by base name, bit position, and by calling EdifPort.equals(EdifPort).

Parameters:
port - The EdifPort Object to match within this interface

getInputOnlyPorts

public java.util.Collection getInputOnlyPorts()
Returns a Collection of only input ports.

Returns:
A Collection of Input ports only

getInputPorts

public java.util.Collection getInputPorts()
Returns a Collection of input and inout ports.

Returns:
A Collection of Input and InOut ports

getOutputOnlyPorts

public java.util.Collection getOutputOnlyPorts()
Returns a Collection of only output ports.

Returns:
A Collection of Output ports only

getOutputPorts

public java.util.Collection getOutputPorts()
Returns a Collection of output and inout ports.

Returns:
A Collection of Output and InOut ports

getInOutPorts

public java.util.Collection getInOutPorts()
Returns a Collection of only inout ports.

Returns:
A Collection of InOut ports

getPortList

public java.util.List 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

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

inputOnlyPortCountEquals

public boolean inputOnlyPortCountEquals(EdifCellInterface cell)
Returns true if the # of input ports match in this and the passed-in interface. Note that this excludes inout ports.

Parameters:
cell - The interface used for comparison
Returns:
True if the # of ports that exist in each cell is the same

inOutPortCountEquals

public boolean inOutPortCountEquals(EdifCellInterface cell)
Returns true if the # of inout ports match in this and the passed-in interface. Note that this excludes in or out ports.

Parameters:
cell - The interface used for comparison
Returns:
True if the # of ports that exist in each cell is the same

outputOnlyPortCountEquals

public boolean outputOnlyPortCountEquals(EdifCellInterface cell)
Returns true if the # of output ports match in this and the passed-in interface. Note that this excludes inout ports.

Parameters:
cell - The interface used for comparison
Returns:
True if the # of ports that exist in each cell is the same

portCountEquals

public boolean portCountEquals(EdifCellInterface cell)
Returns true if the # of output, input, and inout ports match for the current and passed-in cell interfaces.

Parameters:
cell - The interface used for comparison
Returns:
True if the # of each type of port that exists in each cell is the same

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

toString

public java.lang.String toString()

trimToSize

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

Specified by:
trimToSize in interface Trimable