byucc.edif
Class EdifPort

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

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

Represents an Edif port, which belongs to a specific EdifCell. This class specifies a port direction (IN, OUT or INOUT), and a width for support of multi-bit ports.

Note that this object is immutable. Once this object has been created, it cannot be changed.

The purpose of an EdifPort object is to connect a net from the outer level of hierarchy to the inner level of heirarchy.

Sample EDIF code for an EdifPort:

    (cell RAMB4_S2 (cellType GENERIC)
       (view PRIM (viewType NETLIST)
         (interface
           (port (array (rename do "DO[1:0]") 2) (direction OUTPUT))
           (port (array (rename addr "ADDR[10:0]") 11) (direction INPUT))
           (port (array (rename di "DI[1:0]") 2) (direction INPUT))
           (port EN (direction INPUT))
           (port CLK (direction INPUT))
           (port WE (direction INPUT))
           (port RST (direction INPUT))
         )
       )
    )
 

To Do:

Version:
$Id: EdifPort.java,v 1.67 2005/11/10 18:14:39 wirthlin Exp $
Author:
Welson Sun, Mike Wirthlin, Tyler Anderson
See Also:
Serialized Form

Field Summary
(package private)  EdifNet[] _cachedInnerNets
          Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes
private  int _direction
          The direction of this EdifPort
private  EdifCellInterface _parentInterface
          The EdifCellInterface to which the EdifPort belongs
static int IN
          Constant value representing that the EdifPort direction is IN.
static int INOUT
          Constant value representing that the EdifPort direction is INOUT.
static int OUT
          Constant value representing that the EdifPort direction is OUT.
private  EdifSingleBitPort[] singleBitPorts
           
 
Constructor Summary
EdifPort(EdifCellInterface parent, EdifNameable name, int width, int direction)
          Constructs an EdifPort according to the passed in name, width and direction.
EdifPort(EdifCellInterface parent, java.lang.String name, int width, int direction)
          Constructs an EdifPort according to the passed in name, width and direction.
 
Method Summary
(package private)  int compareTo(EdifPort port)
          This method is needed to use a TreeSet of EdifPort objects.
 void createCachedInnerNets()
          Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes
 boolean equals(EdifPort port)
          This method determines whether the EdifPort object passed in is the same as this EdifPort object.
private static boolean equals(EdifPort port1, EdifPort port2)
          This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.
private static boolean equals(EdifPort port1, EdifPort port2, boolean ignoreDirection)
          This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.
 java.lang.String getBaseName()
           
 java.lang.String getBasePortName()
           
 EdifCellInterface getCellInterface()
          Returns the EdifCell which this EdifPort belongs to
 int getDirection()
          Returns the EdifPort's direction There are three kinds of directions in this package: IN OUT INOUT
 java.lang.String getDirectionString()
           
 EdifCell getEdifCell()
          Returns the EdifCell that contains this port.
 EdifNet getInnerNet()
          Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes
 EdifNet getInnerNet(int member)
          Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes
 EdifNet[] getInnerNets()
          This method will return an array of EdifNets, each EdifNet connects the corresponding bus member of this EdifPort( array index = bus member) inside the EdifCell which this EdifPort belongs to.
 EdifSingleBitPort getSingleBitPort(int i)
           
 java.util.Collection getSingleBitPortCollection()
           
 int getWidth()
          Returns the EdifPort's width
private  void init(EdifCellInterface parent, int width, int direction)
          Helper function for the constructor.
 void invalidateCachedInnerNets()
          Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes
 boolean isBus()
          Returns true if this port is a bus-port, false otherwise.
 boolean isInOut()
          Check if this port's direction is bidirectional
 boolean isInput()
          Check if this port's direction is input, meaning IN or INOUT
 boolean isInput(boolean tristate)
          Determine whether this port is an input.
 boolean isInputOnly()
          Check if this port's direction is input only, meaning IN but not INOUT
 boolean isOutput()
          Check if this port's direction is output, meaning OUT or INOUT
 boolean isOutput(boolean tristate)
          Determine whether this port is an output.
 boolean isOutputOnly()
          Check if this port's direction is output only, meaning OUT but not INOUT
 void toEdif(EdifPrintWriter epw)
          Writes the EDIF representation of this EdifPort object to the EdifPrintWriter passed as a parameter.
 java.lang.String toString()
          Returns the string representation of the EdifPort
 
Methods inherited from class byucc.edif.NamedPropertyObject
addProperty, addProperty, copyProperties, equals, equalsProperties, getEdifNameable, getName, getOldName, getProperty, getPropertyList, rename, rename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IN

public static final int IN
Constant value representing that the EdifPort direction is IN.

See Also:
Constant Field Values

OUT

public static final int OUT
Constant value representing that the EdifPort direction is OUT.

See Also:
Constant Field Values

INOUT

public static final int INOUT
Constant value representing that the EdifPort direction is INOUT.

See Also:
Constant Field Values

_direction

private int _direction
The direction of this EdifPort


singleBitPorts

private EdifSingleBitPort[] singleBitPorts

_parentInterface

private EdifCellInterface _parentInterface
The EdifCellInterface to which the EdifPort belongs


_cachedInnerNets

EdifNet[] _cachedInnerNets
Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes
Inner net: An inner net is the EdifNet array *within* the EdifCell object that are connected to this particular port. They are called inner nets because they are "inside" this edif cell (i.e. on the inside side of the port).

An array of EdifNet references, one for each bus member of this EdifPort. Each referenced EdifNet connects to the corresponding EdifPort bus member inside the EdifCell which this EdifPort belongs to.

Note that this information is cached and is a duplication of information already contained in this data structure. The "owner" of this information is the parent EdifCell. The EdifCell contains this information in the list of EdifNets that connect ports within the Cell.

Because this data structure is a duplication, it can potentially be inconsistent with "true" data structure. To account for this, this data structure is "cached" and created only when needed. Whenever the circuit changes, this cached data is invalidated.

TODO: When should this data structure be invalidated?

Who can change EdifPort?

See Also:
EdifCellInstance#_cachedOuterNets
Constructor Detail

EdifPort

public EdifPort(EdifCellInterface parent,
                java.lang.String name,
                int width,
                int direction)
Constructs an EdifPort according to the passed in name, width and direction.

Parameters:
parent - The parent of this new EdifPort
name - The name of this Object
width - The width of this EdifPort
direction - The direction of this EdifPort

EdifPort

public EdifPort(EdifCellInterface parent,
                EdifNameable name,
                int width,
                int direction)
Constructs an EdifPort according to the passed in name, width and direction.

Parameters:
parent - The parent of this new EdifPort
name - The Object holding name information for this EdifPort Object
width - The width of this EdifPort
direction - The direction of this EdifPort TODO: REmove this method and force the caller to pass in the String name rahter than the EdifNameable name and then clone the String before passing it along to the Parent. And then once the second constructor has been removed incorporate the init() emthod into the constructor.
Method Detail

init

private void init(EdifCellInterface parent,
                  int width,
                  int direction)
Helper function for the constructor.

Parameters:
parent - The parent of this new EdifPort
width - The width of this EdifPort
direction - The direction of this EdifPort

getSingleBitPort

public EdifSingleBitPort getSingleBitPort(int i)

getSingleBitPortCollection

public java.util.Collection getSingleBitPortCollection()

createCachedInnerNets

public void createCachedInnerNets()
Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes

This method will create the array of EdifNet objects. Each element of the array corresponds to one bit of the EdifPort. The EdifNet associated with each port corresponds to the Net that is connected from *within* the cell.


compareTo

int compareTo(EdifPort port)
This method is needed to use a TreeSet of EdifPort objects. In order to use a TreeSet, the Object must be "consistent with equals" meaning ... a class C is said to be "consistent with equals" if and only if (e1.compareTo((Object)e2) == 0) has the same boolean value as e1.equals((Object)e2) for every e1 and e2 of class C The comparison, or sorting for this object for now is going to just be based on the string represenation of its name. To enforce "consistent with equals", the method will return 0 if the two objects are equal according to the equals method.

Parameters:
port -
Returns:

equals

public boolean equals(EdifPort port)
This method determines whether the EdifPort object passed in is the same as this EdifPort object.

Parameters:
port - The EdifPort object to compare for equality with this EdifPort Object
Returns:
True if the passed-in EdifPort Object matches with this one

equals

private static boolean equals(EdifPort port1,
                              EdifPort port2,
                              boolean ignoreDirection)
This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.

This method determines whether the two EdifPort objects are the same. The following criteria are used to make this comparison:

Parameters:
port1 - The first port used for comparison
port2 - The second port used for comparison
ignoreDirection - Specifies whether the port directions during a compare will be ignored or not
Returns:
True if the two ports match each other
See Also:
equals(EdifPort)

equals

private static boolean equals(EdifPort port1,
                              EdifPort port2)
This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.

This method determines whether the two EdifPort objects are the same. The following criteria are used to make this comparison:

Parameters:
port1 - The first port used for comparison
port2 - The second port used for comparison
Returns:
True if the two ports match each other
See Also:
equals(EdifPort,EdifPort,boolean), equals(EdifPort)

getCellInterface

public EdifCellInterface getCellInterface()
Returns the EdifCell which this EdifPort belongs to

Returns:
an EdifCell value representing the EdifCellInterface of this EdifPort Object

getEdifCell

public EdifCell getEdifCell()
Returns the EdifCell that contains this port.

Returns:
An EdifCell that contains this EdifPort in its EdifCellInterface TODO: Is it proper for the EdifPort to be asked for the EdifCell or should the caller just get the interface and then ask the interface for the EdifCell?

getInnerNets

public EdifNet[] getInnerNets()
This method will return an array of EdifNets, each EdifNet connects the corresponding bus member of this EdifPort( array index = bus member) inside the EdifCell which this EdifPort belongs to. If this port is a single-bit port, this method will return an array of length one.

Returns:
An array of EdifNet objects representing all the EdifNets that connect to this EdifPort Object

getInnerNet

public EdifNet getInnerNet(int member)
Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes

This method will return the EdifNet which connects the designated bus member of this EdifPort. This is offset to zero for busses that begin at values higher than zero.

Parameters:
member - an int representing the index of the EdifNet of this bus
Returns:
an EdifNet representing the EdifNet at the specified index

getInnerNet

public EdifNet getInnerNet()
Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes

This method will return the EdifNet which connects this one bit wide EdifPort.

Returns:
an EdifNet value representing the EdifNet Object that this EdifPort is connected to on the inside

getDirection

public int getDirection()
Returns the EdifPort's direction There are three kinds of directions in this package: IN OUT INOUT

Returns:
The direction of the port

getDirectionString

public java.lang.String getDirectionString()

getWidth

public int getWidth()
Returns the EdifPort's width

Returns:
an int representing the width of this EdifPort

getBaseName

public java.lang.String getBaseName()
See Also:
Only used in HalfLatch -B

getBasePortName

public java.lang.String getBasePortName()

invalidateCachedInnerNets

public void invalidateCachedInnerNets()
Deprecated. All analysis of EdifNet connectivity should occur outside of the base edif classes

Invalidates cached inner nets.


isBus

public boolean isBus()
Returns true if this port is a bus-port, false otherwise. Equality is done by seeing if singleBitPorts.length > 1.

Returns:
True if this EdifPort Object has a width > 1, meaning that its a bus

isInOut

public boolean isInOut()
Check if this port's direction is bidirectional

Returns:
True if this EdifPort Object is InOut

isInput

public boolean isInput()
Check if this port's direction is input, meaning IN or INOUT

Returns:
True if this EdifPort Object is Input or InOut

isInput

public boolean isInput(boolean tristate)
Determine whether this port is an input. This method uses a tristate flag to indicate how to handle the tristate or INOUT condition.

Parameters:
tristate - Indicates that a tri-state port (INOUT) should be considered as an input. If false, this method will return false for ports that are tri-state (INOUT).
Returns:
true if the port is considered an input

isInputOnly

public boolean isInputOnly()
Check if this port's direction is input only, meaning IN but not INOUT

Returns:
True if this EdifPort Object is Input only

isOutput

public boolean isOutput()
Check if this port's direction is output, meaning OUT or INOUT

Returns:
True if this EdifPort Object is Output or InOut

isOutput

public boolean isOutput(boolean tristate)
Determine whether this port is an output. This method uses a tristate flag to indicate how to handle the tristate or INOUT condition.

Parameters:
tristate - Indicates that a tri-state port (INOUT) should be considered as an output. If false, this method will return false for ports that are tri-state (INOUT).
Returns:
true if the above

isOutputOnly

public boolean isOutputOnly()
Check if this port's direction is output only, meaning OUT but not INOUT

Returns:
True if this EdifPort Object is Output only

toEdif

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

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

toString

public java.lang.String toString()
Returns the string representation of the EdifPort

Overrides:
toString in class java.lang.Object
Returns:
a String value representing this Object, its direction and inner nets