edu.byu.ece.edif.core
Class EdifCellInterface

java.lang.Object
  extended by edu.byu.ece.edif.core.EdifCellInterface
All Implemented Interfaces:
EdifOut, Trimable, java.io.Serializable

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

Represents the port interface of an EdifCell object. The port interface is a list of EdifPort objects.

Version:
$Id:EdifCellInterface.java 198 2008-04-16 21:14:21Z jamesfcarroll $
See Also:
Serialized Form

Field Summary
private  EdifCell _parent
          Parent EdifCell that owns this interface
private  EdifNameSpaceList<EdifPort> _portList
          This List is used to hold all the EdifPort objects of the interface
 
Constructor Summary
EdifCellInterface(EdifCell parent)
          Construct an Empty EdifCellInterface Object with the passed-in EdifCell object as its parent.
 
Method Summary
 EdifPort addPort(EdifNameable name, int width, int direction)
          Add a new port to the EdifCellInterface.
 EdifPort addPort(java.lang.String name, int width, int direction)
          Add a new port to the EdifCellInterface.
 EdifPort addPortUniqueName(EdifNameable name, int width, int direction)
           
 EdifPort addPortUniqueName(java.lang.String name, int width, int direction)
           
 boolean contains(EdifPort contain)
          Check to see if the passed-in EdifPort is already contained within this EdifCellInterface.
 boolean contains(EdifSingleBitPort esbp)
          Check to see if the EdifSingleBitPort is contained within the interface.
 EdifCellInterface copy(EdifCell parent)
          Return a deep copy of this EdifCellInterface Object.
 void deletePort(EdifPort port)
          Remove a port from this EdifCellInterface.
 boolean equals(EdifCellInterface cell)
          Determine whether the given EdifCell object matches the interface of the current EdifCell object.
static java.util.Collection<EdifPort> findMatchingSingleBitPorts(EdifPort busPort, EdifCellInterface cellIf)
          This method will search the passed in EdifCellInterface object for single-bit EdifPort objects that have a name that begins with the name provided by the passed in busPort.
 EdifCell getEdifCell()
          Return the parent EdifCell that owns this object.
 java.util.Collection<EdifPort> getInOutPorts()
          Return a Collection of only inout ports.
 java.util.Collection<EdifPort> getInputOnlyPorts()
          Return a Collection of only input ports.
 java.util.Collection<EdifPort> getInputPorts()
          Return a Collection of input and inout ports.
 EdifPort getMatchingPort(EdifPort port)
          Return a port contained within this EdifCellInterface that matches the passed-in port by calling EdifPort.equals(EdifPort).
 java.util.Collection<EdifPort> getOutputOnlyPorts()
          Return a Collection of only output ports.
 java.util.Collection<EdifPort> getOutputPorts()
          Return a Collection of output and inout ports.
 EdifPort getPort(java.lang.String name)
          Return the EdifPort object which defines a port on the current EdifCell object and corresponds to the given name.
 java.util.List<EdifPort> getPortList()
          Return a Collection containing all of the EdifPort objects currently associated with this EdifCell object.
 java.util.Collection<EdifSingleBitPort> getSingleBitPortCollection()
           
 java.util.Collection<EdifPort> getSortedPortList()
          Return a sorted Collection containing all of the EdifPort objects currently associated with this EdifCell object.
 int getTotalInoutBits()
           
 int getTotalInputOnlyBits()
           
 int getTotalInterfaceBits()
           
 int getTotalOutputOnlyBits()
           
 EdifNameable getUniquePortNameable(EdifNameable en)
           
 EdifNameable getUniquePortNameable(EdifPort port)
           
 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)
          Write the EDIF representation of this EdifCell object to the EdifPrintWriter passed as a parameter.
 java.lang.String toString()
           
 void trimToSize()
          Trim 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

_parent

private EdifCell _parent
Parent EdifCell that owns this interface


_portList

private EdifNameSpaceList<EdifPort> _portList
This List is used to hold all the EdifPort objects of the interface

Constructor Detail

EdifCellInterface

public EdifCellInterface(EdifCell parent)
Construct 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)
                 throws EdifNameConflictException
Add a new port to the EdifCellInterface. Return 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
Throws:
EdifNameConflictException

addPort

public EdifPort addPort(java.lang.String name,
                        int width,
                        int direction)
                 throws InvalidEdifNameException,
                        EdifNameConflictException
Add a new port to the EdifCellInterface. Return 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
Throws:
InvalidEdifNameException
EdifNameConflictException

addPortUniqueName

public EdifPort addPortUniqueName(EdifNameable name,
                                  int width,
                                  int direction)

addPortUniqueName

public EdifPort addPortUniqueName(java.lang.String name,
                                  int width,
                                  int direction)
                           throws InvalidEdifNameException
Throws:
InvalidEdifNameException

contains

public boolean contains(EdifPort contain)
Check 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

contains

public boolean contains(EdifSingleBitPort esbp)
Check to see if the EdifSingleBitPort is contained within the interface. This method operates by calling EdifCellInterface.contains on the parent of the single-bit port.

Parameters:
esbp -
Returns:
true if the passed-in EdifSingleBitPort is owned by a EdifPort object contained in this interface.

copy

public EdifCellInterface copy(EdifCell parent)
Return a deep copy of this EdifCellInterface Object. The parent cell of the interface is specified by the EdifCell parent parameter. Note that the parent cell will explicitly need to set the interface as the active interface after the copy has occurred. 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)
Remove a port from this EdifCellInterface. TODO: is this what we want to do?

Parameters:
port - The port to remove

equals

public boolean equals(EdifCellInterface cell)
Determine 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
Returns:
boolean indicating whether the two EdifCell objects have equivalent port interfaces

findMatchingSingleBitPorts

public static java.util.Collection<EdifPort> findMatchingSingleBitPorts(EdifPort busPort,
                                                                        EdifCellInterface cellIf)
This method will search the passed in EdifCellInterface object for single-bit EdifPort objects that have a name that begins with the name provided by the passed in busPort. If there is a match, a collection of the matching single bit EdifPort objects will be returned. A match will only occur when the following are true:
  1. The prefix of each single bit port is the same as the multi-bit port
  2. Each single bit port can be identified as a valid "bus signal"
  3. The number of single-bit ports is the same as the number of bits in the multi-bit port

Parameters:
busPort - A EdifPort object that is multiple bits (i.e. a bus). The full name of this Port will be used to find matching single-bit EdifPort objects.
cellIf - The EdifCellInterface object that will be searched.
Returns:
A Collection of single-bit EdifPort objects that correspond to the given multi-bit EdifPort. A null will be returned if a complete match did not occur.

getEdifCell

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

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

getInOutPorts

public java.util.Collection<EdifPort> getInOutPorts()
Return a Collection of only inout ports.

Returns:
A Collection of InOut ports

getInputOnlyPorts

public java.util.Collection<EdifPort> getInputOnlyPorts()
Return a Collection of only input ports.

Returns:
A Collection of Input ports only

getInputPorts

public java.util.Collection<EdifPort> getInputPorts()
Return a Collection of input and inout ports.

Returns:
A Collection of Input and InOut ports

getMatchingPort

public EdifPort getMatchingPort(EdifPort port)
Return a port contained within this EdifCellInterface that matches the passed-in port by calling EdifPort.equals(EdifPort).

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

getOutputOnlyPorts

public java.util.Collection<EdifPort> getOutputOnlyPorts()
Return a Collection of only output ports.

Returns:
A Collection of Output ports only.

getOutputPorts

public java.util.Collection<EdifPort> getOutputPorts()
Return a Collection of output and inout ports.

Returns:
A Collection of Output and InOut ports.

getPort

public EdifPort getPort(java.lang.String name)
Return 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

getPortList

public java.util.List<EdifPort> getPortList()
Return 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

getSingleBitPortCollection

public java.util.Collection<EdifSingleBitPort> getSingleBitPortCollection()

getSortedPortList

public java.util.Collection<EdifPort> getSortedPortList()
Return 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

getTotalInoutBits

public int getTotalInoutBits()

getTotalInputOnlyBits

public int getTotalInputOnlyBits()

getTotalInterfaceBits

public int getTotalInterfaceBits()
Returns:
The total number of bits in this interface. This is the sum of the port width of each port in the interface.

getTotalOutputOnlyBits

public int getTotalOutputOnlyBits()

getUniquePortNameable

public EdifNameable getUniquePortNameable(EdifNameable en)

getUniquePortNameable

public EdifNameable getUniquePortNameable(EdifPort port)

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)
Write 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()
Overrides:
toString in class java.lang.Object

trimToSize

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

Specified by:
trimToSize in interface Trimable